var isIE = (navigator.appName == "Microsoft Internet Explorer");
var isLoaded = 0;
var isNetscape = (navigator.appName == "Netscape");
var lastClickOrKeyup = -1;
var last_active_element = "";
var last_element = new Array(); //content in usp table
last_element[0] = "";
var prevHeight = 0;
var prevWidth = 0;
var usp_text0 = new Array(); //default text in usp table
usp_text0[0] = "";
var allcookies = ""; //debug only;
function $id(x){return document.getElementById(x)};
var cookiename = "";
var cookie = null;
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.load = function() {
    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(':');
    //alert("i:"+i+", value: "+a);
    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;
}
Cookie.prototype.debug = function() {
    //makes use of debug function which prints at the top of the page
    if (allcookies) {
        debug("cookie:");
        debug(allcookies);
    }
    else
        debug("no cookie set");
}
        
//var visitordata = new Cookie(document, "sitegen_jva",240,"/");
function setupbestellen(isbn) {
    cookiename = "sitegen_jva"+isbn;
    cookie = new Cookie(document, cookiename,240,"/");
    cookie.load();
    var bElt = $id("leftlinkbestel");
    clearElement(bElt);
    var p = document.createElement("p");
    // Now create a text node containing the message, and add it to the <p>
    //debug("all"+allcookies);
    //alert("setupbestellen"+cookie.aantal);
    if (cookie && cookie.aantal && cookie.aantal != "0") {
        //debug("cookie: "+ cookie);
        var msg = 'BESTEL: ';
        var input = document.createElement('input');
        input.name = "bestel";
        input.id = "bestel";
        input.type ="text";
        input.value = cookie.aantal;
        input.size = "1";
        input.maxlength = "1";
        input.setAttribute("onchange", 'javascript:onchangeaantal("'+isbn+'");');
        
        p.appendChild(document.createTextNode(msg));
        p.appendChild(input);
        var bedrag = parseFloat(bookPrice)*parseInt(cookie.aantal);
        p.appendChild(document.createTextNode(" ex."));
        //p.appendChild(document.createEntityReference("&nbseur"));
        //alert("bookPrice: " + bookPrice + ", aantal: " + cookie.aantal + ", bedrag: "+ bedrag);
        bedrag = formatDutchTwoDecimals(bedrag);
        //alert("bookPrice: " + bookPrice + ", aantal: " + cookie.aantal + ", bedrag: "+ bedrag);
        // euro: \u20AC, nbsp: \u00A0
        bElt.appendChild(p);
        p = document.createElement("p");
        p.appendChild(document.createTextNode("\u00A0(\u20AC\u00A0"+bedrag+" + verzendkosten)"))
        bElt.appendChild(p);
        var p = document.createElement("p");
        //msg = "BESTELLING ";
        //p.appendChild(document.createTextNode(msg));
        var lwissen = document.createElement("a");
        lwissen.appendChild(document.createTextNode("BESTELLING WISSEN"));
        lwissen.setAttribute("href", 'javascript:bestellingwissen("'+isbn+'");');
        p.appendChild(lwissen);
        bElt.appendChild(p);

        var p = document.createElement("p");
        var lafronden = document.createElement("a");
        lafronden.appendChild(document.createTextNode("BESTELLING AFRONDEN"));
        var tolink = bestellenPrefix + '/bestel/index.php';
        lafronden.setAttribute("href", 'javascript:bestellingafronden("'+isbn+'", "'+tolink+'");');
        p.appendChild(lafronden);
        bElt.appendChild(p);
        
    }
    else {
        var link = document.createElement("a");
        link.appendChild(document.createTextNode("BESTELLEN"));
        link.setAttribute("href", 'javascript:startbestellen("'+isbn+'");');
        p.appendChild(link);
        bElt.appendChild(p);
    }
}
function clearElement(elt){
    // clears previous contents of a node:
    var kids = elt.childNodes;
    while (kids.length) {
        elt.removeChild(kids[0]);
    }
}
function onchangeaantal(isbn) {
    //set new number of items
    var elt = $id("bestel");
    var n = parseInt(elt.value);
    //alert("elt: "+elt+"onchange: "+n);
    if (!cookie) {
        //alert("no cookie set...");
        return
    }
    if (n) {
        cookie.aantal = n + "";
        cookie.isbn = isbn;
        cookie.title = bookTitle;
        cookie.author = bookAuthor;
        cookie.price = bookPrice;
        //alert("aantal"+cookie.aantal);
    }else{
        cookie.aantal = "";
    }
    cookie.store();
    setupbestellen(isbn);
}
function debug_cookie() {
    cookiebestname = "sitegen_jva";
    cookiebest = new Cookie(document, cookiebestname,240,"/");
    cookiebest.load();
    cookiebest.debug();
}


function startbestellen(isbn) {
    //alert("startbestellen"+isbn);
    document.location = bestellenPrefix + "/bestel/index.php";

    //
    //if (cookie.aantal) {
    //    //debug('bestellen:' + isbn + ', aantal: '+cookie.aantal);
    //    cookie.aantal = parseInt(cookie.aantal) + 1;
    //}
    //else {
    //    cookie.aantal = 1;
    //    //debug('zet cookie aantal op 1:'+ cookie);
    //}
    //cookie.store();
    //setupbestellen(isbn);
}
function bestellingwissen(isbn) {
    //alert("bestelling wissen"+isbn);
    // zet aantal op 0
    cookie.aantal = 0;
    //debug('zet cookie aantal op 0:'+ cookie);
    cookie.store();
    setupbestellen(isbn);
}
function bestellingafronden(isbn, linktobestel) {
    //alert("bestelling wissen"+isbn);
    // zet aantal op 0
    //debug("bestellen:"+isbn);
    onchangeaantal(isbn);
    //cookie.store();
    //setupbestellen(isbn);
    document.location.href = linktobestel;
}
function formatDutchTwoDecimals(b) {
    var bb = Math.round(b*100);
    var s = bb/100.0 + "";
    s = s.replace(".", ",");
    //alert("s:"+s+" komma op:"+ s.indexOf(",") + ", length: "+s.length);
    while (s.indexOf(',') > s.length-3)
        s = s + "0";

    return s
}


function adjustindexmenuright(subtract, totpics, numspaces) {
// do at changing size also on load (through onResizeFunctions)
// adjusts spacing between pic menu right pictures, like bodyHeight...
    var height = 0;
    var spacing = 5;
    var dh = document.body.clientHeight;
    var totalSubtract = subtract + totpics;
    if (totalSubtract > 0 && dh > totalSubtract ) {
        var height = dh - totalSubtract;
        if (isNetscape)
            height += 15;
        if (height > 20) {
             var spacing = parseInt(height/(numspaces+2));
        }
    }
 //alert("spacing: "+spacing);
    for (var i=0; i<=numspaces; i++) {
        var id = "indexmenuspacer" + i;
       var picEl = document.getElementById(id);
       picEl.style.height = spacing;
    }
}
function adjustpicmenuright(subtract, totpics, numspaces) {
// do at changing size also on load (through onResizeFunctions)
// adjusts spacing between pic menu right pictures, like bodyHeight...
    var height = 0;
    var spacing = 5;
    var dh = document.body.clientHeight;
    var totalSubtract = subtract + totpics;
    if (totalSubtract > 0 && dh > totalSubtract ) {
        var height = dh - totalSubtract;
        if (isNetscape)
            height += 15;
        if (height > 20) {
             var spacing = parseInt(height/(numspaces+2));
        }
    }
 //alert("spacing: "+spacing);
    for (var i=0; i<=numspaces; i++) {
        var id = "picmenuspacer" + i;
       var picEl = document.getElementById(id);
       picEl.style.height = spacing;
    }
}
function afterLoad() {
//records isLoaded and does onResize()
isLoaded = 1;
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 combo_onblur(e, typename, arrayname, wasselected) {
    var sel = getListIndex(typename);
    //debug("onblur clear lastClickOrKeyup");
    // the first click is the wasselected item, remember the lastClickOrKeyup!
    lastClickOrKeyup = -1;
}
function combo_onclick(e, typename, arrayname, wasselected) {
    var sel = getListIndex(typename);
    //debug("onclick "+e+", typename "+typename + +typename+ " new sel:" + sel+ ", was selected: "+wasselected);
    // the first click is the wasselected item, remember the lastClickOrKeyup!
    // if click on new item, this is a change...
    if (lastClickOrKeyup == sel || sel != wasselected)
        gotoitem(typename, arrayname, sel);
    else
        lastClickOrKeyup = sel;
}
function combo_onkeypress(e, typename, arrayname, wasselected) {
    var sel = getListIndex(typename);
    //debug("onkeypress: "+e+ ", typename "+typename + " new sel:" + sel+ ", was selected: "+wasselected);
    //debug("event: "+window.event);
    // with keys two keys must hit the same sel (first the arrow then the enter key)
    if (lastClickOrKeyup == sel)
        gotoitem(typename, arrayname, sel);
    else
        lastClickOrKeyup = sel;
}
function copyArrayToElement(fromArray, toElement) {
    //first empty element
    while (toElement.hasChildNodes()) {
        toElement.removeChild(toElement.lastChild);
    }
    for (var i = 0; i<fromArray.length; i++)
        if (fromArray[i] != "")
               toElement.appendChild(fromArray[i]);
}
function copyElementToArray(fromElement, toArray) {
    var kids = fromElement.childNodes;
    var numkids = kids.length;
    for (var i = 0; i<toArray.length; i++)
        toArray[i] = "";
    for (var i=0; i<numkids; i++) {
        var clone = kids[i].cloneNode(true);
    //alert("i:"+i+ " clone:"+clone);
        toArray[i] = clone;
        }
}
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
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 < 25)
    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 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 gotoitem(typename, arrayname, sel) {
    //change selection of one of the comboboxes
    var linkName = arrayname[sel]
    document.location.href = linkName;
}
function hideMore(id) {
    //at start of page, hide the Lees verder part
var d = $id(id);
if (d === null) {
    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);
    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] +
                    '" class="indexim">';
             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 < 25)
    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, 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);
    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 prelima(Name, Width, Height) {
    var L = Name.length;
    for (var i=0; i<L; i++) {
        (new Image(Width[i], Height[i])).src = Name[i];
    }
}
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.
var style_node = document.createElement("style");
style_node.setAttribute("type", "text/css");
style_node.setAttribute("media", "screen");
if (!isIE) { // firefox:
var text = selector + "{" + declaration + "}";
    style_node.appendChild(document.createTextNode(text));
    // append the style node
    document.getElementsByTagName("head")[0].appendChild(style_node);
}
else { //IE
   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 sgphotopage(Text, Pic, Width, Height, AltText, HeaderText, Link, 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">');
                if (Link[i] != "") {
                    document.write('<h3><a href="' + Link[i] + '" target="_blank">');
                    document.write(HeaderText[i]);
                    document.write('</a></h3><br><br>');
                }
                document.write(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">');
                 if (Link[i] == "")
                     document.write('<img src="'+Pic[i]+'" width="' + Width[i]+
                          '" height="'+Height[i]+'" alt="' + AltText[i]+
                         '">');
                 else
                     document.write('<a href="' + Link[i]+
                     '" target="_blank"><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%">');
            if (Link[i] != "") {
                document.write('<h3><a href="' + Link[i] + '" target="_blank">');
                document.write(HeaderText[i]);
                document.write('</a></h3><br><br>');
            }
            document.write(Text[i]+ '</td>');
            if (Pic[i] != "") {
                 document.write('<td class="ibpright" align="left">');
                 if (Link[i] == "")
                     document.write('<img src="'+Pic[i]+'" width="' + Width[i]+
                          '" height="'+Height[i]+'" alt="' + AltText[i]+
                         '">');
                 else
                     document.write('<a href="' + Link[i]+
                     '" target="_blank"><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 showMore(id) {
    //show Lees verder part hide id+"link"
var d = $id(id);
if (d === null) {
    alert("no such id: "+id);
    return;
}
d.style.display = "inline";
d = $id(id+"link");
if (d === null) {
    return;
}
d.style.display = "none";
}
function tdhide(idnum) {
//do a (closing) hide by leaving a table usp cell, for tableusp
var tfield = document.getElementById(idnum+'t');
tfield.className = "tduspsb";
var e=document.getElementById(idnum+'h');
var f=document.getElementById('tduspe');
copyArrayToElement(usp_text0, f);
}
function tdshow(idnum) {
//do show in usp table (from tableusp and tableusp2)
if (last_active_element)
    tdhide(last_active_element);
last_active_element = idnum;
var tfield = document.getElementById(idnum+"t");
tfield.className = "tduspsa";
var e=document.getElementById(idnum+'h');
var f=document.getElementById('tduspe');
var toChild = f.lastChild;
// first time copy contents to array:
if (usp_text0.length == 1 && usp_text0[0] == "" && f.hasChildNodes())
    copyElementToArray(f, usp_text0);
//copy contents to last_array:
copyElementToArray(e, last_element);
//put element in e cell:
copyArrayToElement(last_element, f);
}
function tdshowextra() {
//do show last content in extra cell
var efield = document.getElementById('tduspe');
//if first time quit:
if (last_active_element != "") {
    copyArrayToElement(last_element, efield);
    var lastfield = document.getElementById(last_active_element+"t");
    lastfield.className = "tduspsa";
    }
}
function w(t) {
    // helper function
    document.write(t);
}
function debug(msg) {
    if (!debug.box) {
        debug.box = document.createElement("div");
        // Specify what it looks like using CSS style attributes
        debug.box.setAttribute("style",
                               "background-color: white; " +
                               "font-family: monospace; " +
                               "border: solid black 3px; " +
                               "padding: 10px;");
        var bodyElt = $id("body0");
        var firstChild = bodyElt.firstChild;
        //alert("firstChild"+firstChild);
        bodyElt.insertBefore(debug.box, firstChild);
        debug.box.innerHTML = "<h1 style='text-align:center'>Debugging Output</h2>";
    }
    // When we get here, debug.box refers to a <div> element into which
    // we can insert our debugging message.
    // First create a <p> node to hold the message.
    var p = document.createElement("p");
    // Now create a text node containing the message, and add it to the <p>
    p.appendChild(document.createTextNode(msg));
    // And append the <p> node to the <div> that holds the debugging output
    debug.box.appendChild(p);
}




