// Optionally override the settings defined at the top
// of the highslide.js file. The parameter hs.graphicsDir is important!

if (typeof relative_root == 'undefined') {
    relative_root = '/';
}

hs.graphicsDir = relative_root + 'images/graphics/';
hs.align = 'center';
hs.transitions = ['expand'];
hs.fadeInOut = true;
hs.dimmingOpacity = 0.9;
hs.wrapperClassName = 'dark';
hs.outlineType = 'red';
hs.outlineWhileAnimating = false;
hs.preserveContent = false;
hs.cacheAjax = false;
hs.objectLoadTime = 'after';
hs.showCredits = false;
hs.lang.closeText = 'Schließen';
hs.skin.contentWrapper = '<div class="highslide-header"><ul>'+
                        '<li class="highslide-previous">'+
                                '<a href="#" title="{hs.lang.previousTitle}" onclick="return hs.previous(this)">'+
                                '<span>{hs.lang.previousText}</span></a>'+
                        '</li>'+
                        '<li class="highslide-next">'+
                                '<a href="#" title="{hs.lang.nextTitle}" onclick="return hs.next(this)">'+
                                '<span>{hs.lang.nextText}</span></a>'+
                        '</li>'+
/*                      '<li class="highslide-move">'+
                                '<a href="#" title="{hs.lang.moveTitle}" onclick="return false">'+
                                '<span>{hs.lang.moveText}</span></a>'+
                        '</li>'+*/
                        '<li class="highslide-close">'+
                                '<a href="#" title="{hs.lang.closeTitle}" onclick="return hs.close(this)">'+
                                '{hs.lang.closeText} <img src="' + relative_root + 'images/close_btn.png" alt="Close Box"></img></a>'+
                        '</li>'+
                '</ul></div>'+
                '<div class="highslide-body"></div>'+
                '<div class="highslide-footer"><div>'+
                        '<span class="highslide-resize" title="{hs.lang.resizeTitle}"><span></span></span>'+
                '</div></div>';

/* Rails bug with POST, changed to GET */
hs.Ajax.prototype.run = function () {
        if (!this.src) this.src = hs.getSrc(this.a);
        if (this.src.match('#')) {
                var arr = this.src.split('#');
                this.src = arr[0];
                this.id = arr[1];
        }
        if (hs.cachedGets[this.src]) {
                this.cachedGet = hs.cachedGets[this.src];
                if (this.id) this.getElementContent();
                else this.loadHTML();
                return;
        }
        try { this.xmlHttp = new XMLHttpRequest(); }
        catch (e) {
                try { this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
                catch (e) {
                        try { this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
                        catch (e) { this.onError(); }
                }
        }
        var pThis = this;
        this.xmlHttp.onreadystatechange = function() {
                if(pThis.xmlHttp.readyState == 4) {
                        if (pThis.id) pThis.getElementContent();
                        else pThis.loadHTML();
                }
        };
        this.xmlHttp.open('GET', this.src, true);
        this.xmlHttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
        this.xmlHttp.send('dummy=1');
};

hs.Expander.prototype.onShowLoading = function(sender) {
    //$('splash').show();
    document.body.style.cursor = "progress";

};

hs.Expander.prototype.onHideLoading = function(sender) {
    //$('splash').hide();
    document.body.style.cursor = "default";
};

hs.Expander.prototype.onBeforeExpand = function(sender) {
    if (PlayerUtils.videoPlayer) {
        PlayerUtils.shouldResumePlayback = PlayerUtils.videoPlayer.isPlaying();
        PlayerUtils.videoPlayer.pause();
    }
};

hs.Expander.prototype.onAfterClose = function(sender) {
    if (PlayerUtils.shouldResumePlayback && PlayerUtils.videoPlayer) {
        PlayerUtils.videoPlayer.play();
    }
};

// IE HACK: a.onclick was passed as a string instead of function
hs.getParam = function (a, param) {
    if (typeof a.onclick == "string") {
        a.onclick = new Function('', a.onclick);
    }
    a.getParams = a.onclick;
    var p = a.getParams ? a.getParams() : null;
    a.getParams = null;

    return (p && typeof p[param] != 'undefined') ? p[param] :
                (typeof hs[param] != 'undefined' ? hs[param] : null);
};


<!--
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
   var obj = document.layers ? document.layers[szDivID] :
   document.getElementById ?  document.getElementById(szDivID).style :
   document.all[szDivID].style;
   obj.visibility = document.layers ? (iState ? "show" : "hide") :
   (iState ? "visible" : "hidden");
}
// -->

hs.Expander.prototype.onAfterExpand = function() {
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") &&
            anchor.getAttribute("rel").indexOf("external") >= 0) {
            anchor.target = "_blank";
        }
    }
    $$('.highslide-body .highslide').each(function(link){
        link.onclick = function() {
            return hs.htmlExpand(this, { objectType: 'ajax' } );
        }
    });
}