﻿
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');

    if (res == null) {
        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;
            } else { //quirks mode
                w = document.body.clientWidth;
            }
        }

        actual_res = 1024; //default
        if (w > 1024) actual_res = 1280;


        //alert(w);
        SetCookie('resolution', actual_res);

        if (w <= 1024)
            location.href = location.href; // dit kan mis gaan als de gebruiker geen cookies wil..
    }
}


if (window.addEventListener) {
    window.addEventListener("load", checkResolution, false);
} else if (window.attachEvent) {
    window.attachEvent("onload", checkResolution);
}


function popupTellAFriend(page, site) {
    var win = window.open('/Tellafriend.aspx?page=' + page + "&site=" + site, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=430');
}

function inputfield_onFocus(e) {
    e.style.background = "#ffffff";
    e.style.borderColor = "#C2C2C2"
}

function inputfield_onBlur(e) {
    e.style.background = "#F0F2F2";
    e.style.borderColor = "#C2C2C2"
}

function printPage() {
    var a = window.open('', '', 'width=700,height=700,scrollbars=1');
    a.document.open("text/html");
    a.document.write('<html><head>');
    a.document.write('<link rel="stylesheet" type="text/css" href="/assets/nmfoverijssel/includes/pgf_content.css" />');
    a.document.write('<link rel="stylesheet" type="text/css" href="/assets/nmfoverijssel/includes/client_mainstyle.css" />');
    a.document.write('<link rel="stylesheet" type="text/css" href="/assets/nmfoverijssel/sifr3/sifr-print.css" />');
    a.document.write('</head><body style=\"background: white !important;\">');
    a.document.write(document.getElementById('content').innerHTML);
    a.document.write('</body></html>');
    a.document.close();
    a.print();

}

/** Fotobalk in de header, slideshow **/
// PH_ = photoheader
var PH_interval = 6000;
var PH_effectspeed = 1000;
var PH_effectspeed_in = PH_effectspeed + 500;
var PH_photoCount = 0;
var PH_currentPhoto = 0;
var PH_timer;

function initFadePhotoHeader() {

    PH_photoCount = $(".foto").length;
    
    // Alle foto's naar opacity 0 & display block
    for (i = 1; i <= PH_photoCount; i++) {
        $("#header_foto_" + i).css({ "opacity": 0, "display": "block" });

    }
    // laatste foto zichtbaar, dus als currentphoto zetten
    PH_currentPhoto = PH_photoCount;

    PH_timer = setTimeout("fadePhotoHeader()", 0);
}
function fadePhotoHeader() {
    $("#header_foto_" + PH_currentPhoto).animate({ opacity: 0 }, PH_effectspeed, function () {
        PH_currentPhoto++;
        if (PH_currentPhoto > PH_photoCount)
            PH_currentPhoto = 1;

        $("#header_foto_" + PH_currentPhoto).animate({ opacity: 1 }, PH_effectspeed_in, function () {
            if (PH_photoCount > 1)
                PH_timer = setTimeout("fadePhotoHeader()", PH_interval);
        });
    });
}

