window.onload = function () {
    // check for large image
    if (document.getElementById("large-img")) {
        if (location.href.indexOf('mode=full') < 0) {
            var o = document.getElementById("large-img");
            o.onmouseover = function () {
                addClass(o, "hover");
            }
            o.onmouseout = function () {
                remClass(o, "hover");
            }
        }
    }
    if (document.body.className == "level0") {
        initFrontpage();
    }
}
function videoPopup(path, text) {
    var firstwin = window.open("/video/mediaplayer/realdaniavideo.html?text=" + text + "&path=" + path, '', "top=" + ((screen.height / 2) - (390 / 2)) + ",left=" + ((screen.width / 2) - (435 / 2)) + ",channelmode=no, resizable=no,height=452,width=433,status=1,toolbar=0,menubar=0,location=0");
}

function addClass(o, str) {
    remClass(o, str);
    o.className += " " + str;
}
function remClass(o, str) {
    o.className = o.className.replace(str, "");
    o.className = o.className.replace(/' '{2,}/gi, " ");
}

function galleryMenu() {
    oMenu = document.getElementById("overlay-menu");
    oBn = document.getElementById("overlay-menu-bn");



    if (oMenu.style.visibility == "visible") {
        oMenu.style.left = "0px";
        oMenu.style.top = "0px";
        oMenu.style.visibility = "hidden";
        remClass(oBn, "period-desc-sel");
        addClass(oBn, "period-desc");
    } else {
        oMenu.style.left = "472px";
        oMenu.style.top = 430 - oMenu.offsetHeight + "px";
        oMenu.style.visibility = "visible";
        remClass(oBn, "period-desc");
        addClass(oBn, "period-desc-sel");
    }
}

var innerHeight = 0;
var contentHeight = 0;

function initFrontpage() {
    fixPos();
    document.getElementById("wrapper").style.visibility = "visible";
    window.onresize = fixPos;
}

function fixPos(pos) {
    innerHeight = document.documentElement.clientHeight;
    contentHeight = document.getElementById("wrapper").offsetHeight;
    yPos = (innerHeight - contentHeight) / 2;
    if (yPos < 20) {
        yPos = 20;
    }
    document.getElementById("wrapper").style.top = yPos + "px";
}

function flashObject(file, w, h) {
    out = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + w + '" height="' + h + '" id="flash" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + file + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent"><embed src="' + file + '" quality="high" bgcolor="#ffffff" width="' + w + '" height="' + h + '" name="flash" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
    document.write(out);
}

function getUrlForXml(name) {
    var arrHref = location.href.split(".");
    var remove = "." + location.href.split(".")[arrHref.length - 1];
    var address = location.href.replace(remove, "");
    return address + "/" + name;
}

function eventCheckboxes(obj) {
    var boxes = document.getElementById("checkboxes").getElementsByTagName("input");
    // 'all'  == ""
    if (obj.value == "") {
        for (var i = 1; i < boxes.length; i++) {
            boxes[i].checked = false;
        }
    } else {
        boxes[0].checked = false;
    }
}
