/**
 * Include script for ThirdWave Website.
 * 
 * @author R.J.T. de Vries <rdevries@thirdwave.nl>
 * @version 1.00, 05/03/2007
 * @access public
 * @package THIRDWAVE
 */
 
//------------------------------------------------------------------------------
// PHASE I: INCLUDE ALL NECESSARY JAVASCRIPT FILES.
//------------------------------------------------------------------------------
document.write("<script src='/cms/jscripts/cms.event.js'></script>");
document.write("<script src='/cms/jscripts/cms.functions.js'></script>");
document.write("<script src='/cms/jscripts/cms.Timeout.js'></script>");
document.write("<script src='/inc/jscripts/Formhandler.js'></script>");
document.write("<script src='/inc/jscripts/ddmenus.js'></script>");
document.write("<script src='/inc/jscripts/Fader.js'></script>");

//------------------------------------------------------------------------------
// PHASE II: INITIALIZATION FUNCTION, CALLED ON DOCUMENT LOAD EVENT
//------------------------------------------------------------------------------

/**
 * Fader object, which takes care of the fade-in/out effects on the website.
 * @var object fader
 * @access public
 */
var fader = null;

/**
 * Initialize website. Called from <body> tag.
 *
 * The size of some of the elements on the page is specifically set in
 * resizeContainers() function. After that, ddinit() function initializes the
 * dropdown menus in the website.
 *
 * After that, the current document is checked for forms in which special
 * events need to be attached to form elements.
 *
 * Finally, I.E. is instructed not to keep a background-image cache, as that
 * keeps I.E. from flickering on mouseover. Also another fix for IE, preventing
 * the "Click here to activate this control" message in flash movies.
 * 
 * @author R.J.T. de Vries <rdevries@thirdwave.nl>
 * @return 	void
 * @access	public
 */
function init() {

	resizeContainers();
	ddinit();
	
	fader = new Fader;
	fader.init();

	formhandler = new Formhandler;
	formhandler.init();
	if ( isIE() ) {
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
		var objects = document.getElementsByTagName('object');
		for ( var i = 0; i < objects.length; i++ ) {
			objects[i].outerHTML = objects[i].outerHTML;
		}
	}
	
} // init()

/**
 * Resize all the elements on the website that could not be correctly sized
 * using css.
 *
 * @author R.J.T. de Vries <rdevries@thirdwave.nl>
 * @return 	boolean			true on success, false on failure.
 * @access	public
 */
function resizeContainers() {

	var midcol, wspace, rgtcol, lftcol_h, flashb_h, menu_h, top_h, midcol_h, h;
	
	midcol = document.getElementById('midcol');
	wspace = document.getElementById('whitespace');
	rgtcol = document.getElementById('rgtcol');

	// Set the height of some elements on the site.
	lftcol_h = getHeight(document.getElementById('textdiv'));
	flashb_h = getHeight(document.getElementById('flashbox'));
	menu_h 	 = getHeight(document.getElementById('menu'));

	// Set the height of the top-part of the site.
	top_h = flashb_h + menu_h;

	// Set the height of the middle column, if available.
	midcol_h = is_object(midcol) ? getHeight(midcol) : 0;

	// Set the height to the tallest column (either lftcol or midcol)
	h = lftcol_h > midcol_h ? lftcol_h + top_h : midcol_h + top_h;

	// Add 10 percent to the height, for some unknown reason that works better for
	// very tall columns.
	h += parseInt(h * 0.10) + 40;
	
	// Set the height of all the available columns.
	if ( is_object(midcol) ) midcol.style.height = h + 'px';
	if ( is_object(wspace) ) wspace.style.height = h + 'px';
	if ( is_object(rgtcol) ) rgtcol.style.height = h + 'px';	

} // resizeContainers()

/* end of include script */
