
/* FROM CACHE */


/* FRONTEND MODE */


/* BEGIN OF INCLUDED FILE '/modules/backend/js/backend.js' */

/*
 * 
 * These backend functions may be used from frontend modules.
 * 
 */


/*
 * Popup Windows
 */

function backend_findElemPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

function backend_showPopup(clickedElem, elem) {
    elem = dojo.byId(elem);
    if(dojo.style(elem, 'display') == 'block') {
        dojo.style(elem, 'display', 'none');
    } else { 
        dojo.style(elem, 'display', 'block');
    }
    if (clickedElem && clickedElem.offsetLeft) {
        var clickedElemPos = backend_findElemPos(clickedElem);
        dojo.style(elem, 'left', (clickedElemPos[0] - elem.offsetWidth - 10) + 'px');
        dojo.style(elem, 'top', clickedElemPos[1] + 'px');
    }
}
/*
 * Ajax Refresh and Form Submit
 */

function backend_destroyWidgets(parentNode) {
    var nodes = dojo.query("*[widgetid]", parentNode);
    for(var ni=0; ni<nodes.length; ni++){
        var node = nodes[ni];
        var widgetid = dojo.attr(node, 'widgetid');
        if (widgetid && widgetid != '') {
            var widget = dijit.byId(widgetid);
            if (widget && widget.destroy) {
                widget.destroy();
            }
        }
    }    
}

function backend_ajaxSetRefreshUrl(url) {
    window.backend_ajaxRefreshUrl = url;
}

function backend_ajaxRefreshTabContent(tabname) {
    if (tabname == null) {
        tabname = window.backend_currentTab;
    }
    var divElem = dojo.byId('backend_tab_'+tabname);
    window.scrollTo(0,0);
    backend_showLoadingIcon(divElem);
    // destroy old htmleditors
    htmlcontent_destroyEditors(divElem);
    // destroy old widgets
    backend_destroyWidgets(divElem);
    // refresh tab content by ajax
    var ajaxUrl = window.backend_ajaxRefreshUrl;
    if (ajaxUrl.indexOf('#') != -1) {
        ajaxUrl = ajaxUrl.substr(0,ajaxUrl.indexOf('#'));
    }
    if (ajaxUrl.indexOf('?') == -1) {
        ajaxUrl = ajaxUrl + '?';
    } else {
        ajaxUrl = ajaxUrl + '&';
    }
    ajaxUrl = ajaxUrl + 'backaned_ajaxRefreshTabContent=' + escape(tabname);
    console.log('Refreshing tab content by ajax: tabname=', tabname);
    dojo.xhrGet({
        url: ajaxUrl,
        load: function(response, ioArgs){
            console.log('Refreshing tab content by ajax, ajax request successful:', tabname);
            // set new content
            divElem.innerHTML = response;
            // apply dojo parser
            dojo.parser.parse(divElem);
            // initialize editors for this tab
            htmlcontent_activateEditors(divElem);
            // hide loading icon
            backend_hideLoadingIcon(divElem);
            // always return response object
            return response;
        },
        handleAs: "text"
    });
}

function backend_ajaxSubmitForm(formElem) {
    var tabname = window.backend_currentTab;
    var divElem = dojo.byId('backend_tab_'+tabname);
    window.scrollTo(0,0);
    backend_showLoadingIcon(divElem);
    // destroy old htmleditors (before sending post data!)
    htmlcontent_destroyEditors(divElem);
    // refresh tab content by ajax
    var form = dojo.byId(formElem);
    var ajaxUrl = dojo.attr(form, 'action');
    if (!ajaxUrl || ajaxUrl == '') {
        ajaxUrl = window.backend_ajaxRefreshUrl;
    }
    if (ajaxUrl.indexOf('#') != -1) {
        ajaxUrl = ajaxUrl.substr(0,ajaxUrl.indexOf('#'));
    }
    if (ajaxUrl.indexOf('?') == -1) {
        ajaxUrl = ajaxUrl + '?';
    } else {
        ajaxUrl = ajaxUrl + '&';
    }
    ajaxUrl = ajaxUrl + 'backaned_ajaxRefreshTabContent=' + escape(tabname);
    console.log('Refreshing tab content by ajax post: tabname=', tabname);
    dojo.xhrPost({
        url: ajaxUrl,
        form: form,
        load: function(response, ioArgs){
            console.log('Refreshing tab content by ajax post, ajax request successful:', tabname);
            // destroy old widgets (after sending post data!)
            var nodes = dojo.query("*[widgetid]", divElem);
            for(var ni=0; ni<nodes.length; ni++){
                var node = nodes[ni];
                var widgetid = dojo.attr(node, 'widgetid');
                console.log("Destroying widget: ", widgetid);
                if (widgetid && widgetid != '') {
                    var widget = dijit.byId(widgetid);
                    if (widget) {
                        widget.destroy();
                    }
                }
            }
            // set new content
            divElem.innerHTML = response;
            // apply dojo parser
            dojo.parser.parse(divElem);
            // initialize editors for this tab
            htmlcontent_activateEditors(divElem);
            // hide loading icon
            backend_hideLoadingIcon(divElem);
            // always return response object
            return response;
        },
        handleAs: "text"
    });
}


/*
 * Helpers
 */

function backend_reloadPage() {
    if (dojo.isFF || dojo.isIE) {
        window.location.href = new String(window.location.href);
    } else {
        window.location.reload(false);
    }
}

function backend_showLoadingIcon(targetElem) {
    // remove existing loading icon
    backend_hideLoadingIcon(targetElem);
    // show loading icon
    console.log("backend_showLoadingIcon()");
    targetElem = dojo.byId(targetElem);
    if (!targetElem.id || targetElem.id == '') {
        alert("Cannot create loading icon for an element without id.");
    }
    var div = dojo.doc.createElement("div");
    var w = targetElem.offsetWidth + 2;
    var h = targetElem.offsetHeight + 2;
    var bgX = (Math.floor(w/2)-16);
    var bgY = (Math.floor(h/2)-16);
    if (bgY > 250) {
        bgY = 250;
    }
    dojo.style(div, "position", "absolute");
    dojo.style(div, "zIndex", "999999");
    dojo.style(div, "opacity", 0.85);
    dojo.style(div, "backgroundColor", "#777777");
    dojo.style(div, "backgroundImage", "url(/media/images/backend/loading.gif)");
    dojo.style(div, "backgroundRepeat", "no-repeat");
    dojo.style(div, "backgroundPosition", bgX+"px "+bgY+"px");
    dojo.style(div, "width", w+"px");
    dojo.style(div, "height", h+"px");
    dojo.place(div, targetElem, "before");
    // show waiting cursor
    dojo.style(dojo.body(), "cursor", "wait");
    // register loading icon
    if (!window.backend_activeLoadingIcons) {
       window.backend_activeLoadingIcons = new Object();
    }
    window.backend_activeLoadingIcons[targetElem.id] = div;
}

function backend_hideLoadingIcon(targetElem) {
    // hide loading icon
    console.log("backend_hideLoadingIcon()");
    targetElem = dojo.byId(targetElem);
    if (window.backend_activeLoadingIcons && window.backend_activeLoadingIcons[targetElem.id]) {
        var div = window.backend_activeLoadingIcons[targetElem.id];
        div.parentNode.removeChild(div);
        delete window.backend_activeLoadingIcons[targetElem.id];
    }
    // unset waiting cursor
    dojo.style(dojo.body(), "cursor", "");
}



/* END OF INCLUDED FILE '/modules/backend/js/backend.js' */



/* BEGIN OF INCLUDED FILE '/modules/navigation/navigation.js' */

var currentAufklappElem = new Array();
var currentAufklappTimer = new Array();

window.autoDropdownSelectedLevel = null;
window.autoDropdownSelectedElemId = null;

// Layer fuer ausgewaehlten Eintrag automatisch einblenden
window.showAufklappLayerAutoDropdownSelected = function(level, elemId) {
    window.autoDropdownSelectedLevel = level;
    window.autoDropdownSelectedElemId = elemId;
    window.showAufklappLayer(level, elemId);
};

// Layoer fuer ausgewaehlten Eintrag automatisch wiedereinblenden, nachdem ein anderer Layer eingeblendet war
window.restoreAufklappLayerAutoDropdownSelected = function() {
    if (currentAufklappElem[window.autoDropdownSelectedLevel] == null) { // nur, wenn kein layer mehr eingeblendet ist
        window.showAufklappLayer(window.autoDropdownSelectedLevel, window.autoDropdownSelectedElemId);
    }
};

// Layer einblenden
window.showAufklappLayer = function(level, elemId) {
    // Momentan angezeigten Layer ausblenden
    if (currentAufklappElem[level] != null){
        hideCurrentAufklappLayerNow(level);
    }
    // Neuen Layer einblenden
    var elem = document.getElementById(elemId);
    elem.style.display = 'block';
    currentAufklappElem[level] = elem;
    // Dem passenden Link eine Hover-Klasse zuweisen
    if (window.dojo) {
        var aElements = dojo.query('a', elem.parentNode);
        if (aElements) {
            dojo.forEach(aElements, function(e){
                dojo.addClass(e, "dropdownHover");
            });
        }
    }
};

// Layer ausblenden (verzoegert!)
window.hideAufklappLayer = function(level, elemId) {
    if (currentAufklappTimer[level] != null) {
        window.clearTimeout(currentAufklappTimer[level]);
        currentAufklappTimer[level] = null;
    }
    currentAufklappTimer[level] = window.setTimeout('hideCurrentAufklappLayerNow('+level+');', 500);
};

// Layer jetzt ausblenden
window.hideCurrentAufklappLayerNow = function(level) {
    if (currentAufklappTimer[level] != null) {
        window.clearTimeout(currentAufklappTimer[level]);
        currentAufklappTimer[level] = null;
    }
    if (currentAufklappElem[level] != null) {
        var elem = currentAufklappElem[level];
        elem.style.display = 'none';
        currentAufklappElem[level] = null;
        // Dem passenden Link die Hover-Klasse wieder wegnehmen
        if (window.dojo) {
            var aElements = dojo.query('a', elem.parentNode);
            if (aElements) {
                dojo.forEach(aElements, function(elem){
                    dojo.removeClass(elem, "dropdownHover");
                });
            }
        }
        // Layer fuer ausgewaehlten Eintrag wieder einblenden, falls autoDropdownSelected aktiv
        if (window.autoDropdownSelectedLevel != null && window.autoDropdownSelectedElemId != null && window.autoDropdownSelectedLevel == level) {
            window.setTimeout("restoreAufklappLayerAutoDropdownSelected();", 50);
        }
    }
};



/* END OF INCLUDED FILE '/modules/navigation/navigation.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_Paging.js' */


////
//// Paging dijit, used by PagingViewElement
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.Paging");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit._Widget");
    dojo.require("dijit._Templated");
    dojo.declare(
	    "seitbox.dijit.Paging",
	    [dijit._Widget, dijit._Templated],
	    {	    
            // summary: A paging dijit
            //
            // description: A simple paging dijit for navigating between
            //       pages from 1 to n. 
            //
			text: '',
			rowsPerPage: 10,
			numPages: 0,
			numRows: 0,
			currentPageI: 0,
			onChangePage: '',
            templateString: '<div class="seitboxDijitPaging">${text}<div class="seitboxDijitPagingSummary">SUM</div><div class="seitboxDijitPagingLinks">LINKS</div></div>',
            templatePath: null,
            postCreate: function(){
	            this.inherited(arguments);
	            this.refreshPagingLinks();
	        },
            setRowsPerPage: function(rowsPerPage) {
                this.rowsPerPage = rowsPerPage;
                this.refreshPagingLinks();
            },
            setNumRows: function(numRows) {
                this.numRows = numRows;
                this.refreshPagingLinks();
            },            
            setCurrentPageI: function(currentPageI) {
                this.currentPageI = currentPageI;
                this.refreshPagingLinks();
                var offset = this.currentPageI * this.rowsPerPage;
                var currentPage = currentPageI + 1;
                if (this.onChangePage != null && this.onChangePage != '') {
                    var js = this.onChangePage;
                    js = js.replace(/\${offset}/, offset);
                    js = js.replace(/\${pageI}/, currentPageI);
                    js = js.replace(/\${page}/, currentPage);
                    eval(js);
                } 
            },
            setCurrentPage: function(currentPage) {
                var currentPageI = currentPage - 1;
                this.setCurrentPageI(currentPageI);
            },
            refreshPagingLinks: function() {
                var currentPageN = this.currentPageI + 1;
                var numPages = Math.ceil(this.numRows / this.rowsPerPage);
                this.numPages = numPages;
                // generate paging links
                var pagingLinks = '';
                for(var pageI=0; pageI<numPages; pageI++) {
                    var pageN = pageI + 1;
                    pagingLinks += '<a class="seitboxDijitPagingLink'+(this.currentPageI==pageI ? ' seitboxDijitPagingLinkSelected' : '')+'" href="#page'+pageN+'" onclick="'+this.id+'.setCurrentPageI('+pageI+'); return false;">'+pageN+'</a> ';
                }
                // update paging links
                var pagingLinksContainers = dojo.query('div.seitboxDijitPagingLinks', this.domNode);
                dojo.forEach(pagingLinksContainers, function(elem){
                    elem.innerHTML = pagingLinks;
                });
                // update summary
                var summaryContainers = dojo.query('div.seitboxDijitPagingSummary', this.domNode);
                dojo.forEach(summaryContainers, function(elem){
                    elem.innerHTML = 'Seite ' + currentPageN + '/' + numPages;
                });
            }
	    }  
    );
}

/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_Paging.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndImageMulti.js' */


////
//// DndImageMulti dijit
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.form.DndImageMulti");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit._Widget");
    dojo.require("dijit._Templated");
    dojo.declare(
	    "seitbox.dijit.form.DndImageMulti",
	    [dijit._Widget, dijit._Templated],
	    {	    
            // summary: A dnd image drop area for multiple images
            //
            // description: A dnd image drop area which can be used like a standard form field and supports multiple images.
            //
	    	name: '',
			value: '',
			content: '',
            templateString: '<div class="seitboxDijitDndImageMulti dijitInlineTable"><input type="hidden" id="${id}_input" name="${name}" value="${value}" /><div dojoType="dojo.dnd.Source" accept="dndimg" id="${id}_dnd" jsId="${id}_dnd" class="dndContainer backenddndtarget"></div><div dojoType="dojo.dnd.Source" accept="dndimg" id="${id}_trash" jsId="${id}_trash" class="dndContainer backenddndtrash"></div></div>',
            templatePath: null,
            postCreate: function(){
	    		this._initContent();
	    		dojo.parser.parse(this.id);
	    		dojo.connect(eval(this.id + '_dnd'), 'onDropInternal', dojo.hitch(this, function(evt){
	    			this._updateValue();
	    		}));
	    		dojo.connect(eval(this.id + '_dnd'), 'onDropExternal', dojo.hitch(this, function(evt){
	    			this._updateValue();
	    		}));
	    		dojo.connect(eval(this.id + '_trash'), 'onDropExternal', dojo.hitch(this, function(evt){
	    			this._updateValue();
	    		}));
                dojo.connect(dojo.byId(this.id+'_dnd'), 'ondblclick', dojo.hitch(this, function(evt){
                    this._openImageProperties(evt);
                }));	    		
                dojo.connect(dojo.byId(this.id+'_dnd'), 'oncontextmenu', dojo.hitch(this, function(evt){
                    this._openMenu(evt);
                }));
	    	},   	
	    	_initContent: function(){
	    		var newContent = '';
	    		var value = this.value;
	    		var images = value.split(",");
	    		for(var i=0; i<images.length; i++) {
	    			var imgSrc = images[i];
	    			if (imgSrc && imgSrc != '') {
	    				newContent += '<img src="' + imgSrc + '" class="dojoDndItem dndimg" dndType="dndimg" alt="Image" border="0" />';
	    			}
	    		}
	    		dojo.byId(this.id+'_dnd').innerHTML = newContent;
	    	},
	    	_updateValue: function() {
	    		var newValue = '';
	    		var inputElem = dojo.byId(this.id + '_input');
	            var containerElem = document.getElementById(this.id + '_dnd');
	            var containerImages = dojo.query("img", containerElem);
	            for(var i=0; i<containerImages.length; i++) {
	                var imgNode = containerImages[i];
	                if (imgNode.src && imgNode.src != '') {
	                    if (newValue != '') {
	                        newValue += ',';
	                    }
	                    var isDndimgThumb = dojo.hasClass(imgNode, 'dndimgThumb');
	                    newValue += this._filterValue(imgNode.src, isDndimgThumb);
	                }
	            }
	    		inputElem.value = newValue;
	    		this.value = newValue;
	    		// update dnd container innerHtml
	    		this._initContent();
	    		// call sync
	    		eval(this.id + '_dnd').sync();
	    	},
	    	_filterValue: function(val, isDndimgThumb) {
	    		val = new String(val);
	    		var beginIndex = val.indexOf('/media/');
	    		if (beginIndex != -1){
	    			val = val.substr(beginIndex);
	    		}
	    		if (isDndimgThumb) { // filter away _image_scaler_ if this is a thumbnail 
    	    		var endIndex = val.indexOf('_image_scaler_');
                    if (endIndex != -1){
                        val = val.substr(0, endIndex);
                    }
	    		}
	    		return val;
	    	},
	    	_openImageProperties: function(e) {
                if (!e.target || (!dojo.hasClass(e.target, 'dndimgThumb') && !dojo.hasClass(e.target, 'dndimg'))) {
                    return;
                } else {
                    var imgSrc = backend_media_normalizeImagePath(e.target.src);
                    backend_media_showImagesPopupProperties(imgSrc);
                }
	    	},
            _openMenu: function(evt) {
                var imgContextMenu = dijit.byId('imgContextMenuForDndImage');
                if (imgContextMenu) {
                    imgContextMenu._openMyself(evt);
                }
            }	    	
	    }  
    );
}

/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndImageMulti.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndFile.js' */


////
//// DndFile dijit
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.form.DndFile");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit._Widget");
    dojo.require("dijit._Templated");
    dojo.declare(
	    "seitbox.dijit.form.DndFile",
	    [dijit._Widget, dijit._Templated],
	    {	    
            // summary: A dnd file drop area
            //
            // description: A dnd file drop area which can be used like a standard form field.
            //
	    	name: '',
			value: '',
            templateString: '<div class="seitboxDijitDndFile dijitInlineTable"><input type="hidden" id="${id}_input" name="${name}" value="${value}" /><div dojoType="dojo.dnd.Source" accept="dndfile" id="${id}_dnd" jsId="${id}_dnd" class="dndContainer backenddndtarget"></div><div dojoType="dojo.dnd.Source" accept="dndfile" id="${id}_trash" jsId="${id}_trash" class="dndContainer backenddndtrash"></div></div>',
            templatePath: null,
            _content: null,
            postCreate: function(){
	    		dojo.parser.parse(this.id);
	    		this._initCreator();
	    		this._setValue(this.value);
	    		dojo.connect(eval(this.id + '_dnd'), 'onDropExternal', dojo.hitch(this, function(evt){
	    			var newValue = '';
	    			if (evt.getSelectedNodes) {
		    			var selectedNodes = evt.getSelectedNodes();
		    			if (selectedNodes && selectedNodes.length) {
			                if (selectedNodes.length > 0) {
			                	selectedNode = selectedNodes[0];
			                    if (selectedNode.href && selectedNode.href != ''){
			                    	newValue = selectedNode.href;
			                    } else {
			                        selectedNodeLinks = dojo.query('a', selectedNode);
			                        if (selectedNodeLinks[0] && selectedNodeLinks[0].href && selectedNodeLinks[0].href != '') {
			                            newValue = selectedNodeLinks[0].href;
			                        }
			                    }
			                }
		    			}
	    			}
	                this._setValue(newValue);
	    		}));
	    		dojo.connect(eval(this.id + '_trash'), 'onDropExternal', dojo.hitch(this, function(evt){
	    			var newValue = '';
	    			this._setValue(newValue);
	    		}));	
	    	},
	    	_initCreator: function() {
	    		var dndSource = eval(this.id + '_dnd');
	    		dndSource.creator = this._creator;
	    		var dndTrash = eval(this.id + '_trash');
	    		dndTrash.creator = this._creator;
	    	},
	    	_creator: function(item, hint) {
				var type = ["dndfile"];
				var val = item.href;
				var node = dojo.doc.createElement("a");
				//node.id = dojo.dnd.getUniqueId(); // DON'T SET AN ID, THIS WILL NOT WORK WHEN LATER DRAGGING THE DROPPED ITEM TO TRASH
				node.href = val;
				node.alt = val;
				node.title = val;
				node.innerHTML = val;
				dojo.addClass(node, "dojoDndItem");
				dojo.addClass(node, "dndfile");
				return {node: node, data: item, type: type};
	    	},
	    	_setValue: function(val) {
	    		var dndSource = eval(this.id + '_dnd');
	    		val = this._filterValue(val);
	    		// remove all nodes
	    		dndSource.selectAll();
	    		dndSource.deleteSelectedNodes();
	    		// insert new node
	    		if (val != '') {
		    		var newItem = {href:val};
		    		dndSource.insertNodes(false, [newItem]);
	    		}
	    		// set input value
	    		dojo.byId(this.id + '_input').value = val;
	    		this.value = val;
	    	},
	    	_filterValue: function(val) {
	    		val = new String(val);
	    		var beginIndex = val.indexOf('/media/');
	    		if (beginIndex != -1){
	    			val = val.substr(beginIndex);
	    		}
	    		return val;
	    	}
	    }  
    );
}

/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndFile.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndImage.js' */


////
//// DndImage dijit
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.form.DndImage");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit._Widget");
    dojo.require("dijit._Templated");
    dojo.declare(
        "seitbox.dijit.form.DndImage",
        [dijit._Widget, dijit._Templated],
        {       
            // summary: A dnd image drop area for an image
            //
            // description: A dnd image drop area which can be used like a standard form field
            //
            name: '',
            value: '',
            content: '',
            templateString: '<div class="seitboxDijitDndImage dijitInlineTable"><input type="hidden" id="${id}_input" name="${name}" value="${value}" /><div dojoType="dojo.dnd.Source" accept="dndimg" id="${id}_dnd" jsId="${id}_dnd" class="dndContainer backenddndtarget"></div><div dojoType="dojo.dnd.Source" accept="dndimg" id="${id}_trash" jsId="${id}_trash" class="dndContainer backenddndtrash"></div></div>',
            templatePath: null,
            postCreate: function(){
                this._initContent();
                dojo.parser.parse(this.id);
                dojo.connect(eval(this.id + '_dnd'), 'onDropInternal', dojo.hitch(this, function(evt){
                    this._updateValue();
                }));
                dojo.connect(eval(this.id + '_dnd'), 'onDropExternal', dojo.hitch(this, function(evt){
                    this._updateValue();
                }));
                dojo.connect(eval(this.id + '_trash'), 'onDropExternal', dojo.hitch(this, function(evt){
                    this._updateValue();
                }));
                dojo.connect(dojo.byId(this.id+'_dnd'), 'ondblclick', dojo.hitch(this, function(evt){
                    this._openImageProperties(evt);
                }));
                dojo.connect(dojo.byId(this.id+'_dnd'), 'oncontextmenu', dojo.hitch(this, function(evt){
                    this._openMenu(evt);
                }));
            },      
            _initContent: function(){
                var newContent = '';
                var value = this.value;
                var imgSrc = value;
                if (imgSrc && imgSrc != '') {
                    newContent += '<img src="' + imgSrc + '" class="dojoDndItem dndimg" dndType="dndimg" alt="Image" border="0" />';
                }
                dojo.byId(this.id+'_dnd').innerHTML = newContent;
            },
            _updateValue: function() {
                var inputElem = dojo.byId(this.id + '_input');
                var containerElem = document.getElementById(this.id + '_dnd');
                var containerImages = dojo.query("img", containerElem);
                if (containerImages.length == 0) {
                    var newValue = '';
                    inputElem.value = newValue;
                    this.value = newValue;
                } else {
                    var oldValue = this.value;
                    for(var i=0; i<containerImages.length; i++) {
                        var imgNode = containerImages[i];
                        if (imgNode.src && imgNode.src != '') {
                            var isDndimgThumb = dojo.hasClass(imgNode, 'dndimgThumb');
                            var newValue = this._filterValue(imgNode.src, isDndimgThumb);
                            if (newValue != oldValue) { // only accept new values (this way it is possible to replace existing images, by dropping a new image before or after the existing image)
                                inputElem.value = newValue;
                                this.value = newValue;
                            }
                        }
                    }
                }
                // update dnd container innerHtml
                this._initContent();
                // call sync
                eval(this.id + '_dnd').sync();
            },
            _filterValue: function(val, isDndimgThumb) {
                val = new String(val);
                var beginIndex = val.indexOf('/media/');
                if (beginIndex != -1){
                    val = val.substr(beginIndex);
                }
                if (isDndimgThumb) { // filter away _image_scaler_ if this is a thumbnail 
                    var endIndex = val.indexOf('_image_scaler_');
                    if (endIndex != -1){
                        val = val.substr(0, endIndex);
                    }
                }
                return val;
            },
            _openImageProperties: function(e) {
                if (!e.target || (!dojo.hasClass(e.target, 'dndimgThumb') && !dojo.hasClass(e.target, 'dndimg'))) {
                    return;
                } else {
                    var imgSrc = backend_media_normalizeImagePath(e.target.src);
                    backend_media_showImagesPopupProperties(imgSrc);
                }
            },
            _openMenu: function(evt) {
                var imgContextMenu = dijit.byId('imgContextMenuForDndImage');
                if (imgContextMenu) {
                    imgContextMenu._openMyself(evt);
                }
            }           
        }  
    );
}

/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_DndImage.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_Chichiupload.js' */


////
//// Chichiupload dijit
////
if (window.dojo) {
    ////
    //// seitbox.dojox.embed.Flas
    ////
    dojo.provide("seitbox.dojox.embed.Flash");
    dojo.require("dojox.embed.Flash");
    dojo.declare(
        "seitbox.dojox.embed.Flash",
        [dojox.embed.Flash],
        {
            init: function(/* dojox.embed.__flashArgs */kwArgs, /* DOMNode? */node){
                //  summary
                //      Initialize (i.e. place and load) the movie based on kwArgs.
                this.destroy();     //  ensure we are clean first.
                node = node || this.domNode;
                if(!node){ throw new Error("dojox.embed.Flash: no domNode reference has been passed."); }
    
                this._poller = null;
                this._pollCount = 0, this._pollMax = 250;
                if(dojox.embed.Flash.initialized){
                    this.id = dojox.embed.Flash.place(kwArgs, node);
                    this.domNode = node;
                    setTimeout(dojo.hitch(this, function(){
                        this.movie = (dojo.isIE)?dojo.byId(this.id):document[this.id];
                        this.onReady(this.movie);
    
                        this._poller = setInterval(dojo.hitch(this, function(){
                            if(!this._percentLoadedWarningThrown && (!this.movie || !this.movie.PercentLoaded)) {
                                this._percentLoadedWarningThrown = true;
                                console.log("seitbox.dojox.embed.Flash: WARNING: this.movie.PercentLoaded is not a function: id=",this.id);
                            }
                            if((this.movie && this.movie.PercentLoaded && this.movie.PercentLoaded() == 100) || this._pollCount++ > this._pollMax){
                                clearInterval(this._poller);
                                delete this._poller;
                                delete this._pollCount;
                                delete this._pollMax;
                                console.log("seitbox.dojox.embed.Flash: calling this.onLoad(): id=",this.id," movie=",this.movie);
                                this.onLoad(this.movie);
                            }
                        }), 20);
                    }), 1);
                }
            }
        }
    );    
    
    ////
    //// seitbox.dijit.Chichiupload
    ////    
    dojo.provide("seitbox.dijit.Chichiupload");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit.form.Button");
    dojo.require("dijit.ProgressBar");
    dojo.require("seitbox.dojox.embed.Flash");
    dojo.declare(
        "seitbox.dijit.Chichiupload",
        [dijit.form.Button],
        {
            statusNode: null,
            flashNode: null,
            flashObject: null,
            flashMovie: null,
            url: '',
            onComplete: '',
            _chichiFiles: null,
            _chichiTotalBytes: null,
            _chichiLoadedBytes: null,
            _chichiLoadedBytesFromCompletedFiles: null,
            _chichiProgressPercent: null,
            _swfUri: '/media/js/fancyupload_2/Swiff.Uploader.swf',
            postCreate: function(){
                // create status node
                this.statusNode = document.createElement("div");
                this.statusNode.id = this.id + "_statusNode";
                this.statusNode.className = "seitboxDijitChichiuploadStatus";
                dojo.style(this.statusNode, "display", "none");
                var html = 'Upload läuft...<br /><div style="width:200px" annotate="true" maximum="100" id="' + this.id + '_progressBar" progress="0" dojoType="dijit.ProgressBar"></div>';
                this.statusNode.innerHTML = html;
                dojo.parser.parse(this.statusNode);
                dojo.place(this.statusNode, this.domNode, 'after');
                // create fallback form (if flash not available)
                //   '<form id="backend_media_imagesSubdirUploadForm_'.$subDir.'" name="backend_media_imagesSubdirUploadForm_'.$subDir.'" method="post" dojoType="dijit.form.Form" enctype="multipart/form-data">'
                //   --> TODO
                // init chichi (Chichi upload)
                this.initChichi();
                // connect click
                dojo.connect(this, 'onClick', function() {
                    this.browse();
                });        
                // call inherited
                this.inherited(arguments);
            },
            initChichi: function() {
                console.log(" ===== Chichi says: Flash version detected:", dojox.embed.Flash.available);
                // create flash node
                this.flashNode = dojo.doc.createElement("div");
                dojo.style(this.flashNode, "position", "absolute");
                dojo.style(this.flashNode, "width", "100px");
                dojo.style(this.flashNode, "height", "22px");
                dojo.place(this.flashNode, this.focusNode, "before");
                // create flash object
                var args = {
                    path:this._swfUri,
                    width:'100%',
                    height:'100%',
                    params:{
                        wMode:'transparent'
                    },
                    vars:{
                        id:this.id,
                        multiple: true,
                        queued: true,
                        typeFilter: null,
                        url: this.url,
                        method: 'post',
                        data: null,
                        fieldName: this.name,
                        target: null,
                        width: '100%',
                        height: '100%',
                        callBacks: null,
                        onSelect: "dijit.byId('"+this.id+"')._onSelect",
                        onAllSelect: "dijit.byId('"+this.id+"')._onAllSelect",
                        onComplete: "dijit.byId('"+this.id+"')._onComplete",
                        onAllComplete: "dijit.byId('"+this.id+"')._onAllComplete",
                        onProgress: "dijit.byId('"+this.id+"')._onProgress",
                        onError: "dijit.byId('"+this.id+"')._onError",
                        onCancel: "dijit.byId('"+this.id+"')._onCancel"
                    }
                };
                this.flashObject = null;
                if (dojo.isFF) {
                    this.flashObject = new seitbox.dojox.embed.Flash(args, this.flashNode);
                } else {
                    this.flashObject = new dojox.embed.Flash(args, this.flashNode);
                }
                this.flashObject.onLoad = dojo.hitch(this, function(mov){
                    console.log(" ===== Chichi says: flashObject.onLoad! Yippieh!!!");
                    this.flashMovie = mov;
                })
            },
            _onSelect: function(file, index, length) {
                console.log(" ===== Chichi says: _onSelect");
            },
            _onAllSelect: function(files, current, overall) {
                console.log(" ===== Chichi says: _onAllSelect");
                console.log(" ===== Chichi says: _onAllSelect files: ", files);
                console.log(" ===== Chichi says: _onAllSelect current: ", current);
                this._chichiFiles = files;
                var totalBytes = 0;
                for(var i=0; i<files.length; i++) {
                    totalBytes += files[i].size;
                }
                this._chichiTotalBytes = totalBytes;
                this._chichiLoadedBytes = 0;
                this._chichiLoadedBytesFromCompletedFiles = 0;
                this._chichiProgressPercent = 0;
                this.upload();
            },
            _onComplete: function(file, response) {
                console.log(" ===== Chichi says: _onComplete");
                console.log(" ===== Chichi says: _onComplete file: ", file);
                this._chichiLoadedBytesFromCompletedFiles += file.size;
                this._updateProgress();
            },
            _onAllComplete: function(current) {
                console.log(" ===== Chichi says: _onAllComplete");
                dojo.style(this.statusNode, "display", "none");
                if (this.onComplete) {
                    eval(this.onComplete);
                }
            },
            _onProgress: function(file, current, overall) {
                console.log(" ===== Chichi says: _onProgress");
                console.log(" ===== Chichi says: _onProgress file: ", file);
                console.log(" ===== Chichi says: _onProgress current: ", current);
                console.log(" ===== Chichi says: _onProgress overall: ", overall);
                var bytesLoaded = parseInt(overall.bytesLoaded);
                if (!bytesLoaded || bytesLoaded == "NaN") {
                    bytesLoaded = 0;
                }
                if (bytesLoaded > this._chichiLoadedBytes) {
                    this._chichiLoadedBytes = bytesLoaded;
                }
                this._updateProgress();
            },
            _onError: function(file, error, info) {
                console.log(" ===== Chichi says: _onError");
                console.log(" ===== Chichi says: _onError file: ", file);
                console.log(" ===== Chichi says: _onError error: ", error);
                console.log(" ===== Chichi says: _onError info: ", info);
                alert("Upload failed: file="+file.name+", error="+error+", info="+info);
            },
            _onCancel: function() {
                console.log(" ===== Chichi says: _onCancel");
            },
            _updateProgress: function() {
                console.log(" ===== Chichi says: _updateProgress");
                dojo.style(this.statusNode, "display", "block");
                var totalBytes = this._chichiTotalBytes;
                var loadedBytes = this._chichiLoadedBytes;
                if (this._chichiLoadedBytesFromCompletedFiles > loadedBytes) {
                    loadedBytes = this._chichiLoadedBytesFromCompletedFiles;
                }
                var progressPercent = Math.floor((loadedBytes / totalBytes) * 100);
                if (progressPercent < 0) {
                    progressPercent = 0;
                }
                if (progressPercent > 100) {
                    progressPercent = 100;
                }
                console.log(" ===== Chichi says: _onProgress progressPercent: ", progressPercent);
                this._chichiProgressPercent = progressPercent;
                dijit.byId(this.id + '_progressBar').update({progress: progressPercent});
            },
            browse: function() {
                console.log(" ===== Chichi says: browse");
                this.flashMovie.browse();
                console.log(" ===== Chichi says: browse has been called ...");
            },
            upload: function() {
                console.log(" ===== Chichi says: upload, name="+this.name+", url="+this.url);
                var options = new Object();
                options.data = null;
                options.fieldName = this.name;
                options.method = 'post';
                options.url = this.url;
                this.flashMovie.upload(options);
                console.log(" ===== Chichi says: upload called ...");
                dojo.style(this.statusNode, "display", "block");
            },
            reposition: function() {
                console.log(" ===== Chichi says: reposition");
            },
            setUrl: function(url) {
                this.url = url;
            },
            setOnComplete: function(onComplete) {
                this.onComplete = onComplete;
            }
        }  
    );
}


/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_Chichiupload.js' */



/* BEGIN OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_SlickCheckBox.js' */


////
//// SlickCheckBox dijit
////
//// A checkbox which supports the parameters 'checkedValue' and 'uncheckedValue' and posts
//// one of this values to the server, depending on it's current state.
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.form.SlickCheckBox");
    dojo.require("dijit.form.CheckBox");
    dojo.declare(
        "seitbox.dijit.form.SlickCheckBox",
        [dijit.form.CheckBox],
        {
            checkedValue: '1',
            uncheckedValue: '0',
            _currentValue: null,
            _uncheckedHiddenField: null,
            postMixInProperties: function(){
                // store current value and set value to checked value
                this._currentValue = this.value;
                this.value = this.checkedValue;
                // set checked state from current value
                if (this._currentValue == this.checkedValue) {
                    this.checked = true;
                } else {
                    this.checked = false;
                    //this._createUncheckedHiddenField(); --> will be done in postCreate()! This is too early!!
                }
                // call inherited
                this.inherited(arguments);
            },
            postCreate: function(){
                this.inherited(arguments);
                if(!this.checked){
                    this._createUncheckedHiddenField();
                }
            },
            _setCheckedAttr: function(){
                this.inherited(arguments);
                if (!this.checked) {
                    this._createUncheckedHiddenField();
                } else {
                    this._removeUncheckedHiddenField();
                }
            },
            _createUncheckedHiddenField: function() {
                this._uncheckedHiddenField = dojo.doc.createElement("input");
                dojo.attr(this._uncheckedHiddenField, "type", "hidden");
                dojo.attr(this._uncheckedHiddenField, "name", this.name);
                dojo.attr(this._uncheckedHiddenField, "value", this.uncheckedValue);
                if (!this.domNode) {
                    alert("seitbox.dijit.form.SlickCheckBox: Could not place unchecked hidden field before domNode, domNode not found.");
                }
                dojo.place(this._uncheckedHiddenField, this.domNode, "before");
            },
            _removeUncheckedHiddenField: function() {
                if (this._uncheckedHiddenField != null) {
                    this._uncheckedHiddenField.parentNode.removeChild(this._uncheckedHiddenField);
                    this._uncheckedHiddenField = null;
                }
            }
        }  
    );
}


/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_SlickCheckBox.js' */



/* BEGIN OF INCLUDED FILE '/modules/headerimage/js/headerimage.js' */


// Init slideshow if first slide found
if (window.dojo) {
    dojo.addOnLoad(function(){
        if (dojo.byId('headerimageSlide0') && dojo.byId('headerimageSlide1')) { // we need at least two slides
            window.headerimage.startSlideshow();
        }
    });
}

// Create namespace
window.headerimage = new Object();

// Array containing all slide nodes
window.headerimage.DELAY = 6000;  
window.headerimage.DURATION = 750;
window.headerimage.currentOffset = 0;
window.headerimage.allSlides = new Array();

// Start slideshow
window.headerimage.startSlideshow = function() {
	var containerNode = dojo.byId("headerimageSlideshow");
    // find all slides
    window.headerimage.allSlides = dojo.query(".headerimageSlide", containerNode);
    // set the size of all slides to the size of the container, set the z-index
    for(var i=0; i<window.headerimage.allSlides.length; i++) {
    	dojo.style(window.headerimage.allSlides[i], "width", containerNode.offsetWidth+"px");
    	dojo.style(window.headerimage.allSlides[i], "height", containerNode.offsetHeight+"px");
    	dojo.style(window.headerimage.allSlides[i], "zIndex", 8);
    }
    // make all but the first slide transparent
    dojo.style(window.headerimage.allSlides[0], "opacity", 1.0);
    dojo.style(window.headerimage.allSlides[0], "visibility", "visible");
    for(var i=1; i<window.headerimage.allSlides.length; i++) {
        dojo.style(window.headerimage.allSlides[i], "opacity", 0.0);
        dojo.style(window.headerimage.allSlides[i], "visibility", "visible"); // slides are hidden when loading
    }
    // start the slideshow loop
    window.setTimeout(window.headerimage.nextSlide, window.headerimage.DELAY);
};

// Skip to next slide
window.headerimage.nextSlide = function() {
    var newOffset = window.headerimage.currentOffset + 1;
    if (newOffset >= window.headerimage.allSlides.length) {
        newOffset = 0;
    }
    window.headerimage.gotoSlide(newOffset);
    // repeat the slideshow loop forever
    window.setTimeout(window.headerimage.nextSlide, window.headerimage.DELAY);
};

// Goto given slide
window.headerimage.gotoSlide = function(newOffset) {
    var oldOffset = window.headerimage.currentOffset;
    // set z-indexes
    dojo.style("headerimageSlide"+oldOffset, "zIndex", 8);
    dojo.style("headerimageSlide"+newOffset, "zIndex", 9);
    // fade in new slide and make old slide invisible on end
    var fadeIn = dojo.animateProperty(
    	{
    		node: "headerimageSlide"+newOffset,
    		duration: window.headerimage.DURATION,
    		properties: {
    			opacity: 1.0
    		},
    		onEnd: function() {
    			dojo.style("headerimageSlide"+oldOffset, "opacity", 0.0);
    		}
    	}
    );
    fadeIn.play();
    // set current slide
    window.headerimage.currentOffset = newOffset;
};



/* END OF INCLUDED FILE '/modules/headerimage/js/headerimage.js' */


