var isIE = (navigator.appName == "Microsoft Internet Explorer");
if (isIE)
     {var displayShow = 'inline';}
else
    {var displayShow = 'table-row';}
var isLoaded = 0;
var isNetscape = (navigator.appName == "Netscape");
var prevHeight = 0;
var prevWidth = 0;

function Cookie(document, name, hours, path, domain, secure)
{
    this.$document = document;
    this.$name = name;
    if (hours)
        this.$expiration = new Date((new Date()).getTime() + hours*3600000);
    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}
Cookie.prototype.showdebug = function() {
    var allcookies = this.$document.cookie;
    alert('allcookies:'+ allcookies);
}

Cookie.prototype.load = function() {
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;
    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false; // Cookie not defined for this page.
    start += this.$name.length + 1; // Skip name and equals sign.
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);
    var a = cookieval.split('&'); // Break it into array of name/value pairs.
    for(var i=0; i < a.length; i++) // Break each pair into an array.
        a[i] = a[i].split(':');
    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }
    return true;
}
Cookie.prototype.remove = function() {
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
    this.$document.cookie = cookie;
}
Cookie.prototype.store = function () {
    var cookieval = "";
    for(var prop in this) {
        // Ignore properties with names that begin with '$' and also methods.
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function'))
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }
    // Now that we have the value of the cookie, put together the
    // complete cookie string, which includes the name and the various
    // attributes specified when the Cookie object was created.
    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString();
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';
    this.$document.cookie = cookie;
}
var visitordata = new Cookie(document, "sitegen_nbja", 240, "/");
visitordata.load();
//visitordata.showdebug();

function afterLoad() {
//records isLoaded and does onResize()
isLoaded = 1;
//temp::::
    onLoadFunctions();
onResize();
}
function bodyHeight(subtract) {
// do at changing size also on load (through onResizeFunctions)
// expecting a div with id "body0" setting at height minus "subtract":
// or a "leftpart" (only IE); with Netscape 15 more
    var height = 0;
    var dh = document.body.clientHeight;
    if (subtract > 0 && dh > subtract) {
    var height = dh - subtract;
    if (isNetscape)
        height += 15;
    }
    else
    var d = null;
    if (isIE)
    var d = document.getElementById("leftpart");
    if (d == null)
    d = document.getElementById("body0");
    if (d == null) {
    alert("no such id: leftpart or body0");
    return;
    }
    d.style.height = height;
}
function changeSize(frameName, Width, Height, minWPadding, minHPadding, scale) {
// do at changing size also on load
// expecting a div with id "frameName":
var dw = parseInt(document.body.clientWidth*scale);
var d = document.getElementById(frameName);
if (d == undefined) {
    alert("no such id: frame");
    return;
}
var p = String(minWPadding);
var q = String(minHPadding);
if (Width > 0 && dw > Width)
   var p = String(Math.max(minWPadding, parseInt((dw-Width)/2)));
var dh = document.body.clientHeight;
if (Height > 0 && dh > Height)
   var q= String(Math.max(minHPadding, parseInt((dh-Height)/2)));
//style_node.appendChild(document.createTextNode(
var selector = "#" + frameName;
var declaration = "padding: " + q + " " + p;
setCssStyleScreenOnly(selector, declaration);
}
function changeselection() {
    //change visible state of left menu from
    //lists cattype, catlength
    var selontw = Array();
    var nosel = Array();
    //type:
    var ltype = getListSelection('choicetype', tottypes);
    var indextype = getListIndex('choicetype');
    visitordata.indextype = indextype;
    //length:
    var llength = getListSelection('choicelength', totlengths);
    var indexlength = getListIndex('choicelength');
    visitordata.indexlength = indexlength;
    //options:
    var loptions = getListSelection('choiceoptions', totoptions);
    var indexoptions= getListIndex('choiceoptions');
    visitordata.indexoptions= indexoptions;
    visitordata.store();
    //visitordata.showdebug();
    for (i=0; i<ontwlist.length; i++) {
        var yes = 1;
        var ontw = ontwlist[i];
        if (ltype.length > 0) {
            if (isinlist(ltype, ontw) == 0)
                yes = 0;
            }
        if (llength.length > 0) {
            if (isinlist(llength, ontw) == 0)
                yes = 0;
            }
        if (loptions.length > 0) {
            if (isinlist(loptions, ontw) == 0)
                yes = 0;
            }
        if (yes == 1)
            selontw.push(ontw);
        else
            nosel.push(ontw);
    }
     // alert('selontw:'+selontw);
     // alert('nosel:'+nosel);
    for (var i=0; i<selontw.length; i++) {
        var eltName = selontw[i];
        var elt = document.getElementById(eltName);
        if (elt != null) {
            elt.style.display = displayShow;
        }
    }
    for (var i=0; i<nosel.length; i++) {
        var eltName = nosel[i];
        var elt = document.getElementById(eltName);
        if (elt != null) {
            elt.style.display = 'none';
            }
    }
}
function doReload() {
//reloads if height or width changed more than 10 pixels
if (!isLoaded) return;
var dw = document.body.clientWidth;
var dh = document.body.clientHeight;
var deltax = Math.abs(prevWidth-dw);
var deltay = Math.abs(prevHeight-dh);
if (deltax < 10 && deltay < 50)
    return;
isLoaded = 0;
document.location.href = document.location.href;
}
function getListIndex(typename) {
    //get the index of the selectbox, -1 if not found
    var els = document.getElementsByName(typename);
    if (els.length != 1) {
        alert('invalid selectboxtype:'+typename);
        return -1
    }
    var selectel = els[0];
    var indexof = selectel.selectedIndex;
    return indexof;
}
function getListSelection(typename, indexlist) {
    //get the name from the index of the selecbox
    var indexof = getListIndex(typename); // extract index of selectbox
    if (indexof <= 0)
        return [];
    indexof -= 1;
    return indexlist[indexof];
}
function getSize(w) {
  var myWidth = 0, myHeight = 0;
  if( typeof( w.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = w.innerWidth;
    myHeight = w.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return Array(myWidth, myHeight);
}
function getselectboxdata() {
// lees cookiedata in.
//visitordata.load();
//type:
if (visitordata.indextype)
    indtype = parseInt(visitordata.indextype);
else
    indtype = 0;
setselectbox('choicetype', indtype);
//length:::
if (visitordata.indexlength)
    indtype = parseInt(visitordata.indexlength);
else
    indtype = 0;
setselectbox('choicelength', indtype);
//options:
if (visitordata.indexoptions)
    indtype = parseInt(visitordata.indexoptions);
else
    indtype = 0;
setselectbox('choiceoptions', indtype);
changeselection();
}
function hello() {
    var win = window._content.top;
    var doc = win.document;
    var Frames = win.frames;
    var t = "";
    alert("hello");
    if (Frames.length > 0) {
        alert("frames:" + Frames.length);
        t = 'Frames:'
        for (var f in Frames)
            t += "\n"+f.document.name;
        alert(t);
    }
    else {
        t = "location:"+win.location+"\ndocument:"+doc.title;
        alert(t);
    }
}
function hideMore(id) {
    //at start of page, hide the Lees verder part
var d = document.getElementById(id);
if (d == undefined) {
    alert("no such id: "+id);
    return;
}
d.style.display = "none";
}
function indexmenu(Pic, Width, Height, Cl, Link, Text, Additional, Scale) {
    var L = Pic.length;
    var mw = 0;
    var paddingFactor = 0.98;
    for (var i=0; i<L; i++) {
        mw = Math.max(mw, Width[i]);
    }
    //width times Scale, that accounts for leftMenuWidth times
    //paddingFactor (above) which accounts for padding.
    var dw = document.body.clientWidth*Scale*paddingFactor;
    var nCol = Math.min(parseInt(dw/(mw+10)), L);
    e = '<table class="picmenu" border="0" cellpadding="0" cellspacing="0" width="100%">';
    document.write(e);
    document.write('<tr><td height="10"><td></tr><tr>');
    var al = "center";
    var im = '';
    var li = '';
    for (var i=0; i<L; i++) {
        if (i%nCol == 0 && i > 0) {
        document.write('</tr><tr><td height="10"><td></tr><tr>');
        }
        if (Pic[i] != "") {
             im = '<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + Text[i] +
                     '">';
        }
        else {
            im = Text[i];
        }
        if (Link[i] != "") {
            li = '<a href="'+ Link[i] + '">' + im + '</a>';
        }
        else {
            li = im;
        }
        if (Pic[i] == "" && Additional[i] != "")
            li = li + "<br>"+Additional[i];
        document.write('<td class="' + Cl[i] + '" align="' +
                        'center' + '">' + li + '</td>');
    }
    document.write('</tr><tr><td height="10"><td></tr></table>');
}
function indexmenucount(Pic, Width, Height, Cl, Link, Text, Additional, Count, Scale) {
    var L = Pic.length;
    var mw = 0;
    var paddingFactor = 0.98;
    for (var i=0; i<L; i++) {
        mw = Math.max(mw, Width[i]);
    }
    //width times Scale, that accounts for leftMenuWidth times
    //paddingFactor (above) which accounts for padding.
    var dw = document.body.clientWidth*Scale*paddingFactor;
    var nCol = Math.min(parseInt(dw/(mw+10)), L);
    e = '<table class="picmenu" border="0" cellpadding="0" cellspacing="0" width="100%">';
    document.write(e);
    document.write('<tr><td height="10"><td></tr><tr>');
    var al = "center";
    var im = '';
    var li = '';
    for (var i=0; i<L; i++) {
        if (i%nCol == 0 && i > 0) {
        document.write('</tr><tr><td height="10"><td></tr><tr>');
        }
        if (Pic[i] != "") {
             im = '<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + Text[i] +
                     '">';
        }
        else {
            im = Text[i];
        }
        if (Link[i] != "") {
            li = '<a href="'+ Link[i] + '">' + im + '</a>';
        }
        else {
            li = im;
        }
        if (Pic[i] == "" && Additional[i] != "")
            li = li + "<br>"+Additional[i];
        if (Count[i] > 1)
            li = li + '&nbsp;('+Count[i]+')';
        document.write('<td class="' + Cl[i] + '" align="' +
                        'center' + '">' + li + '</td>');
    }
    document.write('</tr><tr><td height="10"><td></tr></table>');
}
function isinlist(List, zoek) {
    ///zoek of zoek in List zit
    for (var i=0; i<List.length; i++)
        if (List[i] == zoek)
            return 1;
    return 0;
}
function loadCookieNbja(){
var visitordata = new Cookie(document, "sitegen_nbja", 240, "/");
if (!visitordata.load() || !visitordata.name || !visitordata.color) {
    visitordata.name = prompt("What is your name:", "");
    visitordata.color = prompt("What is your favorite color:", "");
}
if (visitordata.visits == null) visitordata.visits = 0;
visitordata.visits++;
visitordata.store();
}
function m(a, b, s, t) {
var mm;mm='<a href="';mm=mm+'mailto';mm+=":"+b;mm+="@"+a;
if(s){mm+="?subj";mm+="ect="+s};mm+='">';
if(t)mm=mm+t;else mm=mm+b+"@"+a;mm+="</a>";w(mm);
}
function onResize() {
    //acts if height or width changed more than 10 pixels
    if (!isLoaded) return;
    var dw = document.body.clientWidth;
    var dh = document.body.clientHeight;
    var deltax = Math.abs(prevWidth-dw);
    var deltay = Math.abs(prevHeight-dh);
    if (deltax < 10 && deltay < 50)
    return;
    prevHeight=dh;
    prevWidth=dw;
    onResizeFunctions();
}
function onResizeReload() {
    //reloads if height or width changed more than 10 pixels
    if (!isLoaded) return;
    var dw = document.body.clientWidth;
    var dh = document.body.clientHeight;
    var deltax = Math.abs(prevWidth-dw);
    var deltay = Math.abs(prevHeight-dh);
    if (deltax < 25 && deltay < 50)
    return;
    document.location.href = document.location.href;
}
function photopage(Text, Pic, Width, Height, AltText, Scale, SplitAt) {
    var L = Pic.length;
    var mw = 0;
    var padding = 20;
    for (var i=0; i<L; i++) {
        mw = Math.max(mw, Width[i]);
    }
    //width times Scale, that accounts for leftMenuWidth times
    //paddingFactor (above) which accounts for padding.
    var available = document.body.clientWidth*Scale - 2*padding;
    var dw = available*(1.0-SplitAt);
    var wide = 0;
    var leftandright = 0;
    if (dw > mw) wide = 1;
    else {
        if (available > mw)
            leftandright = (available - mw)/2;
    }
    //comment = 'wide; ' + wide + ' available: '+available + ' mw: '+ mw + ' leftandright:' + leftandright;
    //document.write('<p>'+comment+'</p>');
    document.write('<table class="inbody" border="0" cellpadding="0" cellspacing="0" width="100%">');
    for (var i=0; i<L; i++) {
        document.write('<tr><td height=10></td></tr>')
        if (wide == 0) {
            // onder elkaar!!
            if (Text[i] != "") {
// document.write('<tr><td height=10></td></tr>');
                document.write('<tr>');
                if (leftandright > 0)
                     document.write('<td width="'+leftandright+'"></td>');
                document.write('<td class="ibtop" align="left">' + Text[i]+ '</td></tr>');
                if (leftandright > 0)
                     document.write('<td width="'+leftandright+'"></td>');
// document.write('<tr><td height=10></td></tr>')
            }
            if (Pic[i] != "") {
                document.write('<tr>');
                 if (leftandright > 0)
                     document.write('<td width="'+leftandright+'"></td>');
                document.write('<td class="ibpbottom" align="left">');
                document.write('<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + AltText[i]+
                     '">');
                document.write('</td>');
                 if (leftandright > 0)
                     document.write('<td width="'+leftandright+'"></td>');
                 document.write('</tr>');
            }
        }
        else {
            // naast elkaar!!
            // altijd (eventueel lege) tekst:
            // eventueel test:' dw:' + dw + ' mw: ' + mw + ' wide: ' + wide +
            document.write('<tr><td class="ibleft">' + Text[i]+'</td>');
            if (Pic[i] != "") {
                 document.write('<td class="ibpright" align="left" ')
                 document.write('width="'+Width[i]+'" height="'+Height[i]+'">');
                 document.write('<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + AltText[i]+
                     '">');
                 document.write('</td></tr>');
            }
            else {
                document.write('<td></td></tr>');
            }
        }
    }
    document.write('<tr><td height=10></td></tr>')
    document.write('</table>');
}
function picmenu(Pic, Width, Height, Cl, Link, Text, Scale) {
    var L = Pic.length;
    var mw = 0;
    var paddingFactor = 0.98;
    for (var i=0; i<L; i++) {
        mw = Math.max(mw, Width[i]);
    }
    //width times Scale, that accounts for leftMenuWidth times
    //paddingFactor (above) which accounts for padding.
    var dw = document.body.clientWidth*Scale*paddingFactor;
    var nCol = Math.min(parseInt(dw/(mw+10)), L);
    e = '<table class="picmenu" border="0" cellpadding="0" cellspacing="0" width="100%">';
    document.write(e);
    document.write('<tr><td height="10"><td></tr><tr>');
    var al = "center";
    var im = '';
    var li = '';
    for (var i=0; i<L; i++) {
        if (i%nCol == 0 && i > 0) {
        document.write('</tr><tr><td height="10"><td></tr><tr>');
        }
        if (Pic[i] != "") {
             im = '<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + Text[i]+
                     '">';
        }
        else {
            im = Text[i];
        }
        if (Link[i] != "") {
            li = '<a href="'+ Link[i] + '">' + im + '</a>';
        }
        else {
            li = im;
        }
        document.write('<td class="' + Cl[i] + '" align="' +
                        'center' + '">' + li + '</td>');
    }
    document.write('</tr><tr><td height="10"><td></tr></table>');
}
function resizeprint(doResize, language) {
//sizes to convenient format for printing
alert ('doResize: '+doResize);
if (doResize != 1) {
    window.print();
    return;
}
alert('href:'+window.location.href);
var w = window.open(window.location.href, 'Sample', 'width=800,height=600');
w.print();
alert('close againsize:');
w.close();
}
function setCssStyleScreenOnly(selector, declaration) {
// set style for element screen only. declaration WITHOUT braces!!
// example: see changeSize.
if (!isIE) { // firefox:
    var style_node = document.createElement("style");
    style_node.setAttribute("type", "text/css");
    style_node.setAttribute("media", "screen");
    var text = selector + "{" + declaration + "}";
    style_node.appendChild(document.createTextNode(text));
    // append the style node:
    document.getElementsByTagName("head")[0].appendChild(style_node);
}
else { //IE
   if (declaration.indexOf("url(../") >= 0){
    declaration = declaration.replace(/..\//g, "");
   }
   if (document.styleSheets && document.styleSheets.length > 0) {
         var last_style_node = document.styleSheets[document.styleSheets.length - 1];
         if (typeof(last_style_node.addRule) == "object") last_style_node.addRule(selector, declaration);
        }
}
}
function setselectbox(typename, newindex) {
//set box on specified index
    var els = document.getElementsByName(typename);
    if (els.length != 1) {
     // alert('invalid selectboxtype:'+typename);
     return;
    }
    var selectel = els[0];
    if (newindex >= selectel.length || newindex <= 0) {
        selectel.selectedIndex = 0;
    }
    else
        selectel.selectedIndex = newindex;
    }
function showMore(id) {
    //show Lees verder part hide id+"link"
var d = document.getElementById(id);
if (d == undefined) {
    alert("no such id: "+id);
    return;
}
d.style.display = "inline";
d = document.getElementById(id+"link");
if (d == undefined) {
    return;
}
d.style.display = "none";
}
function w(t) {
    // helper function
    document.write(t);
}
