
/* 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);
    // 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 get, ajax request successful:', tabname);
            // destroy old widgets (after sending post data!)
            console.log('Refreshing tab content by ajax get, destroying old widgets:', tabname);
            backend_destroyWidgets(divElem);
            // set new content
            console.log('Refreshing tab content by ajax get, setting new content:', tabname);
            divElem.innerHTML = response;
            // apply dojo parser
            console.log('Refreshing tab content by ajax get, parsing:', tabname);
            dojo.parser.parse(divElem);
            // initialize editors for this tab
            console.log('Refreshing tab content by ajax get, activating html editors:', tabname);
            htmlcontent_activateEditors(divElem);
            // hide loading icon
            console.log('Refreshing tab content by ajax get, done:', tabname);
            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!)
            console.log('Refreshing tab content by ajax post, destroying old widgets:', tabname);
            backend_destroyWidgets(divElem);
            // set new content
            console.log('Refreshing tab content by ajax post, setting new content:', tabname);
            divElem.innerHTML = response;
            // apply dojo parser
            console.log('Refreshing tab content by ajax post, parsing:', tabname);
            dojo.parser.parse(divElem);
            // initialize editors for this tab
            console.log('Refreshing tab content by ajax post, activating html editors:', tabname);
            htmlcontent_activateEditors(divElem);
            // hide loading icon
            console.log('Refreshing tab content by ajax post, done:', tabname);
            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");
                if (dojo.hasClass(e, "ebene0-1")) {
                    dojo.addClass(e, "ebene0-1_dropdownHover");
                }
                if (dojo.hasClass(e, "ebene0-1_angewaehlt")) {
                    dojo.addClass(e, "ebene0-1_angewaehlt_dropdownHover");
                }
            });
        }
    }
    // Den uebergeordneten DIVs fuer "Runde Ecken" eine Hover-Klasse zuordnen
    if (window.dojo) {
        if (dojo.hasClass(elem.parentNode, "navEntryRoundCorner")) {
            // query all divs
            var corners = ['mitte', 'om', 'um', 'lm', 'rm', 'lo', 'ro', 'lu', 'ru'];
            var topNode =  elem.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
            dojo.forEach(corners, function(cr){
                var divElements = dojo.query('div.ecke0-1_' + cr, topNode);
                if (divElements) {
                    dojo.forEach(divElements, function(e){
                        dojo.addClass(e, 'cornerDropdownHover');
                        dojo.addClass(e, 'ecke0-1_' + cr + '_cornerDropdownHover');
                    });
                }
            });
        }
    }
};

// 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(e){
                    dojo.removeClass(e, "dropdownHover");
                    if (dojo.hasClass(e, "ebene0-1")) {
                        dojo.removeClass(e, "ebene0-1_dropdownHover");
                    }
                    if (dojo.hasClass(e, "ebene0-1_angewaehlt")) {
                        dojo.removeClass(e, "ebene0-1_angewaehlt_dropdownHover");
                    }
                });
            }
        }
        // Den uebergeordneten DIVs fuer "Runde Ecken" eine Hover-Klasse zuordnen
        if (window.dojo) {
            if (dojo.hasClass(elem.parentNode, "navEntryRoundCorner")) {
                // query all divs
                var corners = ['mitte', 'om', 'um', 'lm', 'rm', 'lo', 'ro', 'lu', 'ru'];
                var topNode =  elem.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
                dojo.forEach(corners, function(cr){
                    var divElements = dojo.query('div.ecke0-1_' + cr, topNode);
                    if (divElements) {
                        dojo.forEach(divElements, function(e){
                            dojo.removeClass(e, 'cornerDropdownHover');
                            dojo.removeClass(e, 'ecke0-1_' + cr + '_cornerDropdownHover');
                        });
                    }
                });
            }
        }
        // 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/imageviewer.js' */


window.imageviewer_fadeInDuration = 500; // set to 0 in imageviewer_custom.js to disable fade effect
window.imageviewer_fadeOutDuration = 500; // set to 0 in imageviewer_custom.js to disable fade effect
window.imageviewer_connectedListeners = new Array();

window.imageviewer_init = function(elemId) {
    var iv = eval('window.' + elemId + '_object');
    iv.currentIi = -1;
    // preload first image
    imageviewer_preloadImage(elemId, 0);
    // call for a second time (don't ask why)
    window.setTimeout(function() {
        imageviewer_gotoImage(elemId, 0);
    }, 1500);
    // disable marking of text
    imageviewer_disableSelection(dojo.byId(elemId));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerScreen'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImageContainer1'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImageContainer2'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImage1'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImage2'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImage2'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerPrevNextContainer'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerPrev'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerNext'));
    imageviewer_disableSelection(dojo.byId(elemId + '_imageviewerImageNr'));
    // connect listeners
    (function(elemIdConnect){
        // add onmouseover
        dojo.connect(dojo.byId(elemIdConnect), 'onmouseover', function(event){
            imageviewer_createKeyboardListeners(elemIdConnect);
        });
        // add onclick to prev next buttons
        dojo.connect(dojo.byId(elemIdConnect + '_imageviewerPrev'), 'onclick', function(event){
            imageviewer_gotoPrevImage(elemIdConnect);
            dojo.stopEvent(event);
        });
        dojo.connect(dojo.byId(elemIdConnect + '_imageviewerNext'), 'onclick', function(event){
            imageviewer_gotoNextImage(elemIdConnect);
            dojo.stopEvent(event);
        });
        // add onclick for skipping to next image
        dojo.connect(dojo.byId(elemIdConnect + '_imageviewerScreen'), 'onclick', function(event){
            imageviewer_gotoNextImage(elemIdConnect);
            dojo.stopEvent(event);
        });
    })(elemId);
};

window.imageviewer_disableSelection = function(target) {
    if (typeof target.onselectstart != "undefined") { // IE
        target.onselectstart = function() {return false};
    } else if (typeof target.style.MozUserSelect != "undefined") { // Firefox
        target.style.MozUserSelect = "none";
    } else { // Others (ie: Opera)
        target.onmousedown = function() {return false};
        target.style.cursor = "default";
    }
};

window.imageviewer_createKeyboardListeners = function(elemIdConnect) {
    var listener;
    // remove existing listeners
    imageviewer_removeKeyboardListeners();
    // add onclick listeners to elem
    listener = dojo.connect(dojo.byId(elemIdConnect), 'onclick', function(event){
        dojo.stopEvent(event);
    });
    window.imageviewer_connectedListeners.push(listener);
    // add onclick listener (required to kill keyboard listener when clicking outside of imageviewer)
    listener = dojo.connect(window.document, 'onclick', function(event){
        imageviewer_removeKeyboardListeners();
        dojo.stopEvent(event);
    });
    window.imageviewer_connectedListeners.push(listener);
    // add keyboard listener
    listener = dojo.connect(window.document, 'onkeypress', function(event){
        imageviewer_onKeyPress(event, elemIdConnect);
    });
    window.imageviewer_connectedListeners.push(listener);
};

window.imageviewer_removeKeyboardListeners = function() {
    while(window.imageviewer_connectedListeners.length > 0) {
        dojo.disconnect(window.imageviewer_connectedListeners.pop());
    }
};

window.imageviewer_onKeyPress = function(event, elemId) {
    var iv = eval('window.' + elemId + '_object');
    if (event.keyCode == dojo.keys.LEFT_ARROW) {
        imageviewer_gotoPrevImage(elemId);
        dojo.stopEvent(event);
        return;
    }
    if (event.keyCode == dojo.keys.RIGHT_ARROW || event.keyCode == dojo.keys.SPACE || event.keyCode == 0) {
        imageviewer_gotoNextImage(elemId);
        dojo.stopEvent(event);
        return;
    }
    if (iv.fullscreen && event.keyCode == dojo.keys.ESCAPE) {
        imageviewer_toggleFullscreen(elemId);
        dojo.stopEvent(event);
        return;
    }
};

window.imageviewer_gotoPrevImage = function(elemId) {
    var iv = eval('window.' + elemId + '_object');
    imageviewer_gotoImage(elemId, iv.currentIi - 1);
};

window.imageviewer_gotoNextImage = function(elemId) {
    var iv = eval('window.' + elemId + '_object');
    imageviewer_gotoImage(elemId, iv.currentIi + 1);
};

window.imageviewer_gotoImage = function(elemId, ii) {
    imageviewer_createKeyboardListeners(elemId);
    var iv = eval('window.' + elemId + '_object');
    if (ii > iv.images.length - 1) {
        ii = 0;
    }
    if (ii < 0) {
        ii = iv.images.length - 1;
    }
    if (!iv.useSecondContainer) {
        iv.useSecondContainer = true;
        dojo.style(elemId + '_imageviewerImageContainer1', 'opacity', 0.0);
        dojo.style(elemId + '_imageviewerImageContainer1', 'zIndex', 1198);
        dojo.style(elemId + '_imageviewerImageContainer2', 'zIndex', 1197);
        dojo.byId(elemId + '_imageviewerImage1').src = iv.images[ii];
        imageviewer_fitImage(elemId, elemId + '_imageviewerImageContainer1', elemId + '_imageviewerImage1', ii);
        var fadeOut = dojo.animateProperty(
            {
                node: elemId + '_imageviewerImageContainer2',
                duration: (window.imageviewer_fadeOutDuration == 0 ? 1 : window.imageviewer_fadeOutDuration),
                properties: {
                    opacity: 0.0
                }
            }
        );
        fadeOut.play();
        var fadeIn = dojo.animateProperty(
            {
                node: elemId + '_imageviewerImageContainer1',
                duration: (window.imageviewer_fadeInDuration == 0 ? 1 : window.imageviewer_fadeInDuration),
                properties: {
                    opacity: 1.0
                }
            }
        );
        fadeIn.play();
    } else {
        iv.useSecondContainer = false;
        dojo.style(elemId + '_imageviewerImageContainer2', 'opacity', 0.0);
        dojo.style(elemId + '_imageviewerImageContainer2', 'zIndex', 1198);
        dojo.style(elemId + '_imageviewerImageContainer1', 'zIndex', 1197);
        dojo.byId(elemId + '_imageviewerImage2').src = iv.images[ii];
        imageviewer_fitImage(elemId, elemId + '_imageviewerImageContainer2', elemId + '_imageviewerImage2', ii);
        var fadeOut = dojo.animateProperty(
            {
                node: elemId + '_imageviewerImageContainer1',
                duration: (window.imageviewer_fadeOutDuration == 0 ? 1 : window.imageviewer_fadeOutDuration),
                properties: {
                    opacity: 0.0
                }
            }
        );
        fadeOut.play();
        var fadeIn = dojo.animateProperty(
            {
                node: elemId + '_imageviewerImageContainer2',
                duration: (window.imageviewer_fadeInDuration == 0 ? 1 : window.imageviewer_fadeInDuration),
                properties: {
                    opacity: 1.0
                }
            }
        );
        fadeIn.play();
    }
    dojo.byId(elemId + '_imageviewerTitle').innerHTML = (iv.imageinfos[ii].title == null || iv.imageinfos[ii].title == '' ? '&nbsp;' : iv.imageinfos[ii].title);
    dojo.byId(elemId + '_imageviewerDescription').innerHTML = (iv.imageinfos[ii].description == null || iv.imageinfos[ii].description == '' ? '&nbsp;' : iv.imageinfos[ii].description);
    dojo.byId(elemId + '_imageviewerImageNr').innerHTML = (parseInt(ii) + 1) + ' / ' + iv.images.length;
    imageviewer_preloadImage(elemId, ii - 1);
    imageviewer_preloadImage(elemId, ii + 1);
    iv.currentIi = ii;
};

window.imageviewer_fitImage = function(elemId, containerId, imageId, ii) {
    var iv = eval('window.' + elemId + '_object');
    var imageWidth = null;
    var imageHeight = null;
    if (iv.fullscreen) {
        imageWidth = dojo.byId(elemId + '_imageviewerScreen').offsetWidth;
        imageHeight = dojo.byId(elemId + '_imageviewerScreen').offsetHeight;
    } else {
        imageWidth = iv.imagewidth;
        imageHeight = iv.imageheight;
    }
    var container = dojo.byId(containerId);
    var img = dojo.byId(imageId);
    var preloadedImage = iv.preloadedImages[ii];
    if (!preloadedImage) {
        return;
    }
    var origWidth = preloadedImage.width;
    var origHeight = preloadedImage.height;
    var xFactor = origWidth / imageWidth;
    var yFactor = origHeight / imageHeight;
    if (xFactor >= yFactor) {
        img.width = imageWidth;
        img.height = Math.floor(origHeight / xFactor);
    } else {
        img.height = imageHeight;
        img.width = Math.floor(origWidth / yFactor);
    }
    dojo.style(img, 'marginLeft', Math.floor((imageWidth - img.width) / 2) + 'px');
    dojo.style(img, 'marginTop', Math.floor((imageHeight - img.height) / 2) + 'px');
};

window.imageviewer_preloadImage = function(elemId, ii) {
    var iv = eval('window.' + elemId + '_object');
    if (ii > iv.images.length - 1) {
        ii = 0;
    }
    if (ii < 0) {
        ii = iv.images.length - 1;
    }
    if (!iv.preloadedImages) {
        iv.preloadedImages = new Object();
    }
    if (!iv.preloadedImages[ii]) {
        iv.preloadedImages[ii] = new Image();
        iv.preloadedImages[ii].src = iv.images[ii];
    }
};

window.imageviewer_toggleFullscreen = function(elemId) {
    var iv = eval('window.' + elemId + '_object');
    iv.fullscreen = !iv.fullscreen;
    if (iv.fullscreen) {
        // switch to fullscreen mode
        dojo.removeClass(dojo.byId(elemId), 'imageviewerNonFullscreen');
        dojo.addClass(dojo.byId(elemId), 'imageviewerFullscreen');
        dojo.style(dojo.body(), 'overflow', 'hidden');
        window.scrollTo(0, 0);
        var viewportWidth = dijit.getViewport().w;
        var viewportHeight = dijit.getViewport().h;
        var imageWidth = viewportWidth - iv.imagewidthOffset;
        var imageHeight = viewportHeight - iv.imageheightOffset;
        iv.nonFullscreenWidth = dojo.style(elemId, 'width');
        iv.nonFullscreenHeigh = dojo.style(elemId, 'height');
        iv.nonFullscreenParentNode = dojo.byId(elemId).parentNode;
        dojo.place(elemId, dojo.body(), 'first');
        dojo.style(elemId, 'position', 'absolute');
        dojo.style(elemId, 'zIndex', '1195');
        dojo.style(elemId, 'left', '0px');
        dojo.style(elemId, 'top', '0px');
        dojo.style(elemId, 'width', viewportWidth + 'px');
        dojo.style(elemId, 'height', viewportHeight + 'px');
        dojo.style(elemId + '_imageviewerScreen', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerScreen', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerImageContainer1', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerImageContainer1', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerImageContainer2', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerImageContainer2', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerPrevNextContainer', 'width', imageWidth + 'px')
    } else {
        // switch to non-fullscreen mode
        dojo.removeClass(dojo.byId(elemId), 'imageviewerFullscreen');
        dojo.addClass(dojo.byId(elemId), 'imageviewerNonFullscreen');
        dojo.style(dojo.body(), 'overflow', '');
        window.scrollTo(0, 0);
        var imageWidth = iv.imagewidth;
        var imageHeight = iv.imageheight;
        dojo.place(elemId, iv.nonFullscreenParentNode, 'first');
        dojo.style(elemId, 'position', '');
        dojo.style(elemId, 'zIndex', '');
        dojo.style(elemId, 'left', '');
        dojo.style(elemId, 'top', '');
        dojo.style(elemId, 'width', iv.nonFullscreenWidth + 'px');
        dojo.style(elemId, 'height', iv.nonFullscreenHeigh + 'px');
        dojo.style(elemId + '_imageviewerScreen', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerScreen', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerImageContainer1', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerImageContainer1', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerImageContainer2', 'width', imageWidth + 'px');
        dojo.style(elemId + '_imageviewerImageContainer2', 'height', imageHeight + 'px');
        dojo.style(elemId + '_imageviewerPrevNextContainer', 'width', imageWidth + 'px')
    }
    imageviewer_gotoImage(elemId, iv.currentIi);
    imageviewer_gotoImage(elemId, iv.currentIi);
};



/* END OF INCLUDED FILE '/modules/usability/js/imageviewer.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.button.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_FileUploader.js' */

if (window.dojo) {
    dojo.provide("seitbox.dijit.form.FileUploader");
    dojo.require("dojox.form.FileUploader");
    dojo.require("dijit.ProgressBar");
    dojo.declare(
        "seitbox.dijit.form.FileUploader",
        [dojox.form.FileUploader],
        {
            
            postCreate: function(){
                // call parent method
                this.inherited(arguments);
                // update position
                this.updatePosition();
                // create status node
                this.statusNode = document.createElement("div");
                this.statusNode.id = this.id + "_statusNode";
                this.statusNode.className = "seitboxDijitChichiuploadStatus";
                dojo.style(this.statusNode, "display", "block");
                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);
                // add on complete for hiding progress bar
                (function(uploader) {
                    dojo.connect(uploader, "_complete", function() {
                        dojo.style(uploader.statusNode, "display", "none");
                    });
                })(this);
            },
            
            createFlashUploader: function(){
                // summary:
                //      Internal. Creates Flash Uploader
                this.uploadUrl = this.uploadUrl.toString();
                if(this.uploadUrl){
                    if(this.uploadUrl.toLowerCase().indexOf("http")<0 && this.uploadUrl.indexOf("/")!=0){
                        // Appears to be a relative path. Attempt to 
                        //  convert it to absolute, so it will better 
                        //target the SWF.
                        //
                        var loc = window.location.href.split("/");
                        loc.pop();
                        loc = loc.join("/")+"/";
                        this.uploadUrl = loc+this.uploadUrl;
                        this.log("SWF Fixed - Relative loc:", loc, " abs loc:", this.uploadUrl);
                    }
                }else{
                    //console.warn("Warning: no uploadUrl provided.");
                }
                var w = this.fhtml.nr.w;
                var h = this.fhtml.nr.h;
                
                var args = {
                    expressInstall:true,
                    path: this.swfPath.uri || this.swfPath,
                    width: w,
                    height: h,
                    allowScriptAccess:"always",
                    allowNetworking:"all",
                    vars: {
                        uploadDataFieldName: this.flashFieldName,
                        uploadUrl: this.uploadUrl,
                        uploadOnSelect: this.uploadOnChange,
                        deferredUploading:this.deferredUploading || "",
                        selectMultipleFiles: this.selectMultipleFiles,
                        id: this.id,
                        isDebug: this.isDebug,
                        devMode:this.devMode,
                        flashButton:dojox.embed.flashVars.serialize("fh", this.fhtml),
                        fileMask:dojox.embed.flashVars.serialize("fm", this.fileMask)
                    },
                    params: {
                        scale:"noscale",
                        wmode:"transparent"
                    }
                    
                };
                
                this.flashObject = new dojox.embed.Flash(args, this.insideNode);
                this.flashObject.onError = function(msg){
                    console.warn("Flash Error:", msg);
                };
                this.flashObject.onReady = dojo.hitch(this, function(){
                    //console.log("READY");
                });
                this.flashObject.onLoad = dojo.hitch(this, function(mov){
                    this.log("flashObject onload", mov)
                    this.flashMovie = mov;
                    this.flashReady = true;
                    this.onReady();
                });
                this._connectFlash();
            },            
            
            upload: function(data){
                console.log("UPLOAD STARTED");
                console.log("DOMNODE", this.domNode);
                // display progress bar
                dojo.place(this.statusNode, this.domNode, "before");
                dojo.style(this.statusNode, "display", "block");                
                // call parent method
                this.inherited(arguments);
            },
            
            onProgress: function(dataArray){
                // calculate total progress
                var allFilesProgressPercent = 0;
                for(var di=0; di<dataArray.length; di++) {
                    allFilesProgressPercent += dataArray[di].percent;
                }
                allFilesProgressPercent = Math.floor(allFilesProgressPercent / dataArray.length);
                // update progress bar
                dijit.byId(this.id + '_progressBar').update({progress: allFilesProgressPercent});
            },
            
            updatePosition: function(){
                //dojo.place(this.domNode, dojo.body(), 'first');
                //dojo.style(this.domNode, "width", "40px");
                //dojo.style(this.domNode, "height", "20px");
                //dojo.style(this.domNode, "border", "1px solid #ff0000");
                //console.log("POS", this);
                //setTimeout(dojo.hitch(this, function(){
                /*
                    if (this.button.focusNode.offsetWidth == 0) { // place flash somewhere in visible area, if button is currently invisible
                        dojo.place(this.domNode, dojo.body(), 'first');
                        dojo.style(this.domNode, "position", "absolute");
                        dojo.style(this.domNode, "width", "4px");
                        dojo.style(this.domNode, "height", "4px");
                    } else {
                        dojo.place(this.domNode, this.button.focusNode, "before");
                        dojo.style(this.domNode, "position", "absolute");
                        dojo.style(this.domNode, "width", this.button.focusNode.offsetWidth+"px");
                        dojo.style(this.domNode, "height", this.button.focusNode.offsetHeight+"px");
                    }
                */
                //}), 100);
            }
                 
        }
    );
}


/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dijit_form_FileUploader.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/usability/js/seitbox_dijit_form_DndFileMulti.js' */


////
//// DndFile dijit
////
if (window.dojo) {
    dojo.provide("seitbox.dijit.form.DndFileMulti");
    dojo.require("dijit.Declaration");
    dojo.require("dojo.parser");
    dojo.require("dijit._Widget");
    dojo.require("dijit._Templated");
    dojo.declare(
	    "seitbox.dijit.form.DndFileMulti",
	    [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="seitboxDijitDndFileMulti 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(){
                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();
                }));
	    	},
            _initContent: function(){
                var newContent = '';
                var value = this.value;
                var files = value.split(",");
                for(var i=0; i<files.length; i++) {
                    var fileHref = files[i];
                    if (fileHref && fileHref != '') {
                        newContent += '<a href="' + fileHref + '" class="dojoDndItem dndfile" dndType="dndfile">' + fileHref + '</a>';
                    }
                }
                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 containerFiles = dojo.query("a", containerElem);
                for(var i=0; i<containerFiles.length; i++) {
                    var fileNode = containerFiles[i];
                    if (fileNode.href && fileNode.href != '') {
                        if (newValue != '') {
                            newValue += ',';
                        }
                        newValue += this._filterValue(fileNode.href);
                    }
                }
                inputElem.value = newValue;
                this.value = newValue;
                // update dnd container innerHtml
                this._initContent();
                // call sync
                eval(this.id + '_dnd').sync();
            },
            _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_DndFileMulti.js' */



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


////
//// LightboxNanoMultiMedia
////
//// A modified version of LightboxNano which supports multiple media types, like .swf or .flv.
////
if (window.dojo) {
    
    if(!dojo._hasResource["seitbox.dojox.image.LightboxNanoMultiMedia"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
        dojo._hasResource["seitbox.dojox.image.LightboxNanoMultiMedia"] = true;
        dojo.provide("seitbox.dojox.image.LightboxNanoMultiMedia");
        dojo.require("dojo.fx");

        (function(d){

            var getViewport = function(){
                    //  summary: Returns the dimensions and scroll position of the viewable area of a browser window
                    var scrollRoot = (d.doc.compatMode == "BackCompat") ? d.body() : d.doc.documentElement,
                        scroll = dojo._docScroll();
                    return { w: scrollRoot.clientWidth, h: scrollRoot.clientHeight, l: scroll.x, t: scroll.y };
                };
                
            var abs = "absolute";
    
            d.declare("seitbox.dojox.image.LightboxNanoMultiMedia", null, {
                //  summary:
                //      A simple "nano" version of the lightbox. 
                //
                //  description:
                //      Very lightweight lightbox which only displays a larger image.  There is
                //      no support for a caption or description.  The lightbox can be closed by
                //      clicking any where or pressing any key.  This widget is intended to be
                //      used on <a> and <img> tags.  Upon creation, if the domNode is <img> tag,
                //      then it is wrapped in an <a> tag, then a <div class="enlarge"> is placed
                //      inside the <a> and can be styled to display an icon that the original
                //      can be enlarged.
                //
                //  example:
                //  |   <a dojoType="seitbox.dojox.image.LightboxNanoMultiMedia" href="/path/to/largeimage.jpg"><img src="/path/to/thumbnail.jpg"></a>
                //
                //  example:
                //  |   <img dojoType="seitbox.dojox.image.LightboxNanoMultiMedia" src="/path/to/thumbnail.jpg" href="/path/to/largeimage.jpg">
    
                //  href: string
                //      URL to the large image to show in the lightbox.
                href: "",
    
                //  duration: int
                //      The delay in milliseconds of the LightboxNano open and close animation.
                duration: 500,
    
                //  preloadDelay: int
                //      The delay in milliseconds after the LightboxNano is created before preloading the larger image.
                preloadDelay: 5000,
    
                constructor: function(p, n){
                    // summary: Initializes the DOM node and connect onload event
                    var _this = this;
    
                    d.mixin(_this, p);
                    n = dojo.byId(n);
    
                    if(!/a/i.test(n.tagName)){
                        var a = d.create("a", { href: _this.href, "class": n.className }, n, "after");
                        n.className = "";
                        a.appendChild(n);
                        n = a;
                    }
    
                    d.style(n, {
                        display: "block",
                        position: "relative"
                    });
                    _this._createDiv("dojoxEnlarge", n);
    
                    _this._node = n;
                    d.setSelectable(n, false);
                    _this._onClickEvt = d.connect(n, "onclick", _this, "_load");
    
                    setTimeout(function(){
                        (new Image()).src = _this.href;
                        _this._hideLoading();
                    }, _this.preloadDelay);
                },
    
                destroy: function(){
                    // summary: Destroys the LightboxNano and it's DOM node
                    var a = this._connects || [];
                    a.push(this._onClickEvt);
                    d.forEach(a, d.disconnect);
                    d.destroy(this._node);
                },
    
                _createDiv: function(/*String*/cssClass, /*DomNode*/refNode, /*boolean*/display){
                    // summary: Creates a div for the enlarge icon and loading indicator layers
                    return d.create("div", { "class": cssClass, style: { position: abs, display: display ? "" : "none" } }, refNode); // DomNode
                },
                
                _load: function(/*Event*/e){
                    // summary: Creates the large image and begins to show it
                    var _this = this;
    
                    d.stopEvent(e);
    
                    if(!_this._loading){
                        _this._loading = true;
                        _this._reset();
    
                        var n = d.query("img", _this._node)[0],
                            a = d._abs(n, true),
                            c = d.contentBox(n),
                            b = d._getBorderExtents(n),
                            m = _this._createMediaNode(),
                            ln = _this._loadingNode;
    
                        if(ln == null){
                            _this._loadingNode = ln = _this._createDiv("dojoxLoading", _this._node, true)
                            var l = d.marginBox(ln);
                            d.style(ln, {
                                left: parseInt((c.w - l.w) / 2) + "px",
                                top: parseInt((c.h - l.h) / 2) + "px"
                            });
                        }
    
                        c.x = a.x - 10 + b.l;
                        c.y = a.y - 10 + b.t;
                        _this._start = c;
    
                        _this._connects = [d.connect(m, "onload", _this, "_show")];
    
                        _this._loadMedia();
                    }
                },
                
                _createMediaNode: function() {
                    var _this = this;
                    _this._mediaNode = d.create("img", {
                        style: {
                            visibility: "hidden",
                            cursor: "pointer",
                            position: abs,
                            top: 0,
                            left: 0,
                            zIndex: 9999999
                        }
                    }, d.body());
                    return _this._mediaNode;
                },
                
                _loadMedia: function() {
                    var _this = this;
                    _this._mediaNode.src = _this.href;
                },
    
                _hideLoading: function(){
                    // summary: Hides the animated loading indicator
                    if(this._loadingNode){
                        d.style(this._loadingNode, "display", "none");
                    }
                    this._loadingNode = false;
                },
    
                _show: function(){
                    // summary: The image is now loaded, calculate size and display
                    var _this = this,
                        vp = getViewport(),
                        w = _this._mediaNode.width,
                        h = _this._mediaNode.height,
                        vpw = parseInt((vp.w - 20) * 0.9),
                        vph = parseInt((vp.h - 20) * 0.9),
                        dd = d.doc,
                        bg = _this._bg = d.create("div", {
                            style: {
                                backgroundColor: "#000",
                                opacity: 0.0,
                                position: abs,
                                zIndex: 9999998
                            }
                        }, d.body()),
                        ln = _this._loadingNode;
    
                    if(_this._loadingNode){
                        _this._hideLoading();
                    }
                    d.style(_this._mediaNode, {
                        border: "10px solid #fff",
                        visibility: "visible"
                    });
                    d.style(_this._node, "visibility", "hidden");
    
                    _this._loading = false;
    
                    _this._connects = _this._connects.concat([
                        d.connect(dd, "onmousedown", _this, "_hide"),
                        d.connect(dd, "onkeypress", _this, "_key"),
                        d.connect(window, "onresize", _this, "_sizeBg")
                    ]);
    
                    if(w > vpw){
                        h = h * vpw / w;
                        w = vpw;
                    }
                    if(h > vph){
                        w = w * vph / h;
                        h = vph;
                    }
    
                    _this._end = {
                        x: (vp.w - 20 - w) / 2 + vp.l,
                        y: (vp.h - 20 - h) / 2 + vp.t,
                        w: w,
                        h: h
                    };
    
                    _this._sizeBg();
    
                    d.fx.combine([
                        _this._anim(_this._mediaNode, _this._coords(_this._start, _this._end)),
                        _this._anim(bg, { opacity: 0.5 })
                    ]).play();
                },
    
                _sizeBg: function(){
                    // summary: Resize the background to fill the page
                    var dd = d.doc.documentElement;
                    d.style(this._bg, {
                        top: 0,
                        left: 0,
                        width: dd.scrollWidth + "px",
                        height: dd.scrollHeight + "px"
                    });
                },
    
                _key: function(/*Event*/e){
                    // summary: A key was pressed, so hide the lightbox
                    d.stopEvent(e);
                    this._hide();
                },
    
                _coords: function(/*Object*/s, /*Object*/e){
                    // summary: Returns animation parameters with the start and end coords
                    return {
                        left:   { start: s.x, end: e.x },
                        top:    { start: s.y, end: e.y },
                        width:  { start: s.w, end: e.w },
                        height: { start: s.h, end: e.h }
                    }; // object
                },
    
                _hide: function(){
                    // summary: Closes the lightbox
                    var _this = this;
                    d.forEach(_this._connects, d.disconnect);
                    _this._connects = [];
                    d.fx.combine([
                        _this._anim(_this._mediaNode, _this._coords(_this._end, _this._start), "_reset"),
                        _this._anim(_this._bg, {opacity:0})
                    ]).play();
                },
    
                _reset: function(){
                    // summary: Destroys the lightbox
                    d.style(this._node, "visibility", "visible");
                    d.forEach([this._mediaNode, this._bg], function(n){
                        d.destroy(n);
                        n = null;
                    });
                    this._node.focus();
                },
    
                _anim: function(node, args, onEnd){
                    // summary: Creates the lightbox open/close and background fadein/out animations
                    return d.animateProperty({
                        node: node,
                        duration: this.duration,
                        properties: args,
                        onEnd: onEnd ? d.hitch(this, onEnd) : null
                    }); // object
                }
            });
    
        })(dojo);

    }
    
}
    
    


/* END OF INCLUDED FILE '/modules/usability/js/seitbox_dojox_image_LightboxNanoMultiMedia.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' */


