var currentCal = "";

function InitCal()
{	
    var s1 = getCookie('buttonid');	
    var s2 = getCookie('divcalid');
    var s3 = getCookie('index');	
    	
    if(s1 == null || s2 == null || s3==null)
        return;

    ToggleCalendar(s1, s2, s3);
    
    FolderDimensions();
}

function getCookie(sName) {
    var aCookie = document.cookie.split('; '), i = aCookie.length, aCrumb;
    while (i--) {
        aCrumb = aCookie[i].split('=');
        if (sName == aCrumb[0])
            return typeof aCrumb[1] != 'undefined' ? unescape(aCrumb[1]) : null;
    }

    return null;
}

function setCookie(sName, sValue) {
    var date = new Date();
    date.setTime(date.getTime() + (30 * 1000));
    document.cookie = sName + '=' + escape(sValue) + '; expires=' + date.toGMTString() + '; path=/';
}

if (window.attachEvent) {
    window.attachEvent("onload", InitCal);
}
else
{
    if(window.addEventListener)
    {
        window.addEventListener("load", InitCal, false);    		
    }
}

function generateClassNames() {
    if (document.bigimage.src == 'http://' + document.domain + '/images/layout/nophoto.gif') {
        document.getElementById('Photos').style.display = "none";
    }
    else {
        var inputs = document.getElementsByTagName('div');

        for (var i = 0; i < inputs.length; i++) {
            var x = inputs[i];

            if (x.className == "Photo") {
                x.onmouseover = MouseOver;
            }
        }
    }
}

function MouseOver() {
    var inputs = document.getElementsByTagName('div');

    for (var i = 0; i < inputs.length; i++) {
        var x = inputs[i];

        if (x.className == "PhotoHover") {
            x.className = "Photo";
        }
    }
    return this.className = "PhotoHover";
}

var nophoto = 1;
function checkPhoto(img) {
    if (nophoto == 1) {
        document.bigimage.src = img;
        nophoto = 0;
    }
}

function popUp2(img, width, height) {
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;

    day = new Date();
    id = day.getTime();
    eval("page" + " = window.open(img, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");
}

function popUp(img) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(img, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=100,top=150');");
}

function Print() {
    window.print();
    window.close();
}

function clickButton(e, buttonid) {
    var bt = document.getElementById(buttonid);
    if (typeof bt == 'object') {
        if (navigator.appName.indexOf("Netscape") > (-1)) {
            if (e.keyCode == 13) {
                bt.click();
                return false;
            }
        }
        if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1)) {
            if (event.keyCode == 13) {
                bt.click();
                return false;
            }
        }
    }
}

function toggleAll(o) {
    for (i = 0; i < document.forms[0].elements.length; i++) {
        if (document.forms[0].elements[i].type == "checkbox") {
            document.forms[0].elements[i].checked = o.checked;
        }
    }
}

function showGalleryPopup(url, width) {
    width = width + 20;
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;
    var height = screen.height - 40;
    day = new Date();
    id = day.getTime();
    eval("page" + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");
}



function CopyError(lang) {
    if (lang = "nl")
        alert("Kopieren niet toegelaten");
    else if (lang = "fr")
        alert("Copier non authorise");
    else
        alert("Copy Error");
}

function FolderDimensions()
{
    var KleineBreedte = document.getElementById("ctl00_MainContentPlaceholder_admCategoryEdit_tcContainer_tpFields_editform_cf_377");
    if (KleineBreedte != null)
    {
        alert("Gefonden");
    }
}
