// Show/Hide menu top/left menu link dropdown
function showMenuItems(e)   {
    document.getElementById(e).style.display = "block";
}
function hideMenuItems(e)   {
    document.getElementById(e).style.display = "none";
}

// Add page to favorites:
function addToFavorites(url,title)
{
	if (window.sidebar)	{	//	Firefox
		window.sidebar.addPanel(title, url, "");
	}
	else if (window.opera && window.print)	{	//	Opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if (document.all)	{	//	Internet Explorer
		window.external.AddFavorite(url, title);
	}
}



function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}


function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    
    document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}


function DeleteCookie (name) {
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}


function checkResolution() {
    var res = GetCookie('resolution');
    var defaultRes = "1280";
    var minRes = "1024";
    
    w = screen.width; // -> gaat mis met 2 monitoren en 1tje op high en de andere op low 
    
    if (window.innerWidth)
    {
       w = window.innerWidth;
    }
    else
    {
       if (!(document.documentElement.clientWidth == 0))
       { //strict mode
          w = document.documentElement.clientWidth + 20;
          defaultRes = "1260";
          minRes = "1004";
       }
       else { //quirks mode
          w = document.body.clientWidth;
       }
    }
//       alert("Screen width: " + w + "/Width in cookie: " + res);

    if (res == null)
    {//    Geen cookie gezet: zet cookie
       SetCookie('resolution', ((w > 1024) ? 1280 : 1024));
       if (w < defaultRes)
       {//   Ververs de pagina wanneer schermbreedte kleiner is dan default breedte (1280)
          location.href = location.href; // dit kan mis gaan als de gebruiker geen cookies wil..
       }
    }
    else
    {//    Cookie gezet
       if (res != w)
       {
       //  Update cookie wanneer cookie-waarde ongelijk is aan schermbreedte
          SetCookie('resolution', ((w > 1024) ? 1280 : 1024));
          if (w >= 1024 && w <= 1280)
          {//  Ververs de pagina ALLEEN wanneer schermresolutie groter dan of gelijk aan 1024, en kleiner of gelijk aan 1280 is, om refresh-loop te vermijden
             location.href = location.href; // dit kan mis gaan als de gebruiker geen cookies wil..
          }
       }
    }
//        if (w <= 1024)
//            location.href = location.href; // dit kan mis gaan als de gebruiker geen cookies wil..
//    }
}



function ToggleActivityCalender(){
    var item = document.getElementById("activiteitenOverzicht");
    var label = document.getElementById("activiteitenLabel");
    item.style.display = item.style.display == "none" ? "block" : "none";
    label.style.display = item.style.display == "block" ? "none" : "block";   
}

// Open Pims pop-up (personal info)
var activePimsPopup = "";
function openPimsPopup(id) {
    var divToOpen = document.getElementById(id);
    var divToClose = document.getElementById(activePimsPopup);
    divToOpen.style.display = 'block';
    if (activePimsPopup != "")
    {
        divToClose.style.display = 'none';
    }    
    activePimsPopup = id;
}


function popupKlimaatwens() {
    var win = window.open('/popup_klimaatkaravaan.aspx', 'popupklimaat', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=460');
}


/*
// Onload:
if (window.addEventListener)
{
    window.addEventListener("load", checkResolution, false);
}
else if (window.attachEvent)
{
    window.attachEvent("onload", checkResolution);
}
*/