var isIE = (navigator.appName == "Microsoft Internet Explorer");
var isLoaded = 0;
var isNetscape = (navigator.appName == "Netscape");
var prevHeight = 0;
var prevWidth = 0;
function afterLoad() {
//records isLoaded and does onResize()
isLoaded = 1;
onLoadFunctions();
onResize();
}
//test
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 decreaseCols(items, cols) {
//try if cols can be lowered
if (cols == 1)
    return 1;
var nRows = Math.floor(items/cols);
if (items%cols)
    nRows++;
do {
    cols--;
    var newRows = Math.floor(items/cols);
    if (items%cols)
        newRows++;
} while (newRows == nRows);
return cols+1;
}
function doReload() {
    //reloads if height or width changed more than 10 pixels
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;
document.location.href = document.location.href;
}
function getPosition(w) {
  var myX = 0, myY = 0;
  if( typeof( w.pageXOffset ) == 'number' ) {
    //Non-IE
    myX = w.pageXOffset;
    myY = w.pageYOffset;
  } else {
    myX = document.body.scrollLeft ;
    myY = document.body.scrollTop ;
  }
  return Array(myX, myY);
}
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 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);
    nCol = decreaseCols(L, nCol);
    var WidthMin = Math.floor(dw/nCol);
    var widthActual = 0
    e = '<table class="indexmenu" 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 (Link[i] != "")
            li = '<a href="'+ Link[i] + '">' + Text[i] + '</a><br>';
        else
            li = Text[i];
        if (Pic[i] != "") {
             widthActual = Math.max(WidthMin, Width[i]);
             im = '<img src="'+Pic[i]+'" width="' + Width[i] +
                      '" height="'+Height[i]+'" alt="' + Text[i] +
                    '">';
             if (Link[i] != "") {
                im = '<a href="'+ Link[i] + '">' + im + '</a>';
             }
        }
        else {
            widthActual = WidthMin;
            im = "";
        }
        if (Pic[i] == "" && Additional[i] != "")
            li = li + "<br><br>"+Additional[i];
        document.write('<td class="' + Cl[i] + '" align="center" width="' +
                widthActual + '">' + li + im + '</td>');
    }
    document.write('</tr><tr><td height="10"><td></tr></table>');
}
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" width="50%">' + Text[i]+'</td>');
            if (Pic[i] != "") {
                 document.write('<td class="ibpright" align="left">');
                 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) {
    //expect picmenuPrefixForLinkTitle and picmenuWithText and picmenuScale
    // picmenuPaddingFactor as javascript global variables (from HtmlDoc)
    // set in html file.
    var L = Pic.length;
    var mw = 0;
    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*picmenuScale*picmenuPaddingFactor;
    var nCol = Math.min(parseInt(dw/(mw+10)), L);
    e = '<table class="picmenu" border="0" cellpadding="0" cellspacing="0" width="100%">';
    var spacerRow = '<tr><td height="10"><td></tr>';
    w(e);
    w(spacerRow + '<tr>');
    var al = "center";
    var im = '';
    var li = '';
    var te = '';
    var nValid = 0;
    for (var i=0; i<L; i++) {
        var AltText = Text[i];
        if (picmenuPrefixForLinkTitle)
            AltText = picmenuPrefixForLinkTitle + AltText;
        if (Pic[i]) {
             im = '<img src="'+Pic[i]+'" width="' + Width[i]+
                      '" height="'+Height[i]+'" alt="' + AltText+
                      '" title="' + AltText+
                     '">';
        }
        else {
            im = Text[i];
        }
        if (i%nCol == 0 && i > 0)
            w('</tr>' + spacerRow + '<tr>');
        if (Link[i] != "") {
            li = '<a href="'+ Link[i] + '">' + im + '</a>';
            te = '<a href="'+ Link[i] + '">' + Text[i] + '</a>';
        }
        else {
            li = im;
            te = Text[i];
        }
        if (picmenuWithText && Pic[i])
           // if want texts:
           li = li + '<br>' + te;
        w('<td class="' + Cl[i] + '" align="' +
                        'center' + '" title="'+AltText+'">' + li + '</td>');
    }
    w('</tr>' + spacerRow + '</table>');
}
function resizeprint(doResize, language) {
//sizes to convenient format for printing
var toX = 800;
var toY = 600;
var posX = 100;
var posY = 100;
alert ('doResize: '+doResize);
if (doResize != 1) {
    window.print();
    return;
}
var oldSize = getSize(window);
var oldPosition = getPosition (window);
alert('position: ' + oldPosition);
window.resizeTo(toX, toY);
window.moveTo(posX, posY);
var newPosition = getPosition (window);
alert('position: ' + newPosition);
var newSize = getSize(window);
var oldX = oldSize[0];
var oldY = oldSize[1];
var newX = newSize[0];
var newY = newSize[1];
window.print();
if (language == "nl")
    var T = "terug naar het vorige venster formaat";
else
    var T = "back to the previous window size" ;
alert(T);
window.resizeTo(toX + oldX-newX, toY+oldY-newY);
newSize = getSize(window);
//alert('old: '+ oldSize +' new:' + newSize);
}
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 w(t) {
    // helper function
    document.write(t);
}
