var prev_error_src = "";
var prev_linkobj;
var prev_backgr;
var highlight_obj = NullObject;
var fixed_yn = false;

function init_document(def_fixed) {
    var tfix = find_get(page_gets, 'fixed');
    if (tfix != null) {
        if (tfix == 'off') {
 	   fixed_yn = false;
        }
        else {
 	   fixed_yn = true;
        }
    }
    else {
        if (def_fixed && def_fixed == 'off') {
            fixed_yn = false;
        }
        else {
            fixed_yn = true;
        }
    }
    perform_dhtml_test();
    window_resized(get_window_info());
    init_resize_detection(false,false,true,false);

    var anchorid = find_get(page_gets, 'scroll');
    if (anchorid && anchorid != "") {
        var reg = /[^a-z0-9_]/;
        if (reg.test(anchorid)) {
            debug_msg("scroll target contains nonallowed characters");
        }
        else {
            go_anchor('inhoud', anchorid);
        }
    }
}

function clear_image_error() {
     prev_error_src = "";
}

function window_resized(winfo) {

    debug_msg('browser info : ' + browser_info.debug_str);

    var min_height = 250;

    // Can't use jan_top and jan_bottom because Konqueror returns
    // the height of the contents of de cell instead of the cell itself.
    var border_height = get_object_height('t_bheight') +
			get_object_height('b_bheight');
    var objref = get_object('inhoud');
    var i_height = get_object_height(objref);
    var c_height = get_object_height('i_center');
    if (winfo && objref && border_height) {
        var new_height = winfo.Hincl - border_height;
	if (c_height >= i_height) {
	    new_height -= (c_height - i_height);
	}
	else {
	    new_height -= 2; // default value, just a guess :-)
	}
	if (new_height <= min_height) {
	    new_height = min_height;
	}

        if (!fixed_yn) {
 	    new_height = c_height; // works in mozilla :-?
        }

  	debug_msg('Hincl = ' + winfo.Hincl + '\n' +
	          'border = ' + border_height + '\n' +
		  'c_height = ' + c_height + '\n' +
		  'i_height = ' + i_height + '\n' +
		  'new = ' + new_height);

	/* inhoud div has a 1 pixel top and bottom padding to prevent margins of
	   elements creeping out in IE */
	var corr_height = 0;
	if (!browser_info.style_incl_padding) {
	    corr_height = 2;
	}
	objref.style.height = (new_height - corr_height) + 'px';
	if (!browser_info.verified) {
	    var r_height = get_object_height(objref);
	    if (r_height != new_height) {
		debug_msg("real height = " + r_height + "\n" +
			  "should be   = " + new_height);
		if (new_height - r_height == corr_height) {
//		    browser_info.style_incl_padding = true;
		    objref.style.height = new_height + 'px';
		}		    
	    }
        }
    }

    // Mozilla 1.7 has a problem with floats in overflow=auto divs or something
    // It results in html element being too large.
    // Shrinking only works the first time, growing works even with window resize.
    if (document.getElementsByTagName && document.body.style) {
        var htmlobj = document.getElementsByTagName('html')[0];
        var body_height = get_object_height(document.body);
        var html_height = get_object_height(htmlobj);
        debug_msg("window height = " + winfo.Hincl + "\n" +
                  "body height = " + body_height + "\n" +
                  "html height = " + html_height);
        if (body_height != winfo.Hincl) {
            bodyobj.style.height = winfo.Hincl + 'px';
        }
        if (html_height != winfo.Hincl) {
            htmlobj.style.height = winfo.Hincl + 'px';
        }
    }
}


function write_start_layout() {

    write_dhtml_test();

    document.write('<table id="oudedelft" cellspacing="0"><tbody><tr><td id="t_left" class="t_block"> &nbsp; </td><td id="t_center" class="t_block">');
    write_logo('oude');
    document.write('</td><td id="t_right" class="t_block">&nbsp;</td></tr><tr><td id="i_left" class="i_block">&nbsp;</td><td id="i_center" class="i_block">\n');

    document.write('<div id="inhoud">\n');
}

function write_end_layout() {

    document.write('</div>\n');

    document.write('</td><td id="i_right" class="i_block">&nbsp;</td></tr><tr><td id="b_left" class="b_block"> &nbsp; </td><td id="b_center" class="b_block">\n');

    write_navigation(true);

    document.write('</td><td id="b_right" class="b_block"> &nbsp; </td></tr></tbody></table>\n');

}
