/**
 * This javasript code, will create a full html page.
 * The vars that are being used are the div names of the main divs being used.
 *
 *	+-main------------------------------------------------------+
 *	| +-top---------------------------------------------------+ |
 *	| |                                                       | |
 *	| |                                                       | |
 *	| +-------------------------------------------------------+ |
 *	| +-body--------------------------------------------------+ |
 *	| | +-menu----------------------------------------------+ | |
 *	| | |                                                   | | |
 *	| | +---------------------------------------------------+ | |
 *	| | +-content---------------------------------+ +-right-+ | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | |                                         | |       | | |
 *	| | +-----------------------------------------+ +-------+ | |
 *	| +-------------------------------------------------------+ |
 *	| +-bottom------------------------------------------------+ |
 *	| |                                                       | |
 *	| |                                                       | |
 *	| +-------------------------------------------------------+ |
 *	+-----------------------------------------------------------+
 *
 * It is verry important to add this javascript under the last html tag </html>. 
 * Otherwise the divs can't be loaded in the right order.
 *
 * Good to know: if you use any margin's, add the value in the calculation:
 * document.body.clientHeight-top.offsetHeight-menu.offsetHeight - MARGIN'S VALUE
 * so try to avoid margin in the main divs, use them in the div inside the main
 * divs.
 */

function set( )
{
	var clientHeight = 0;
	var cleintWidth = 0;
	if (typeof window.innerWidth != 'undefined') {
		clientHeight = window.innerHeight;
		clientWidth = window.innerWidth;
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	}
	// older versions of IE
	else {
		clientHeight = document.getElementsByTagName('body')[0].clientHeight;
		clientWidth = document.getElementsByTagName('body')[0].clientWidth;
	}
	
	var top = (document.getElementById('top')) ? document.getElementById('top').offsetHeight : 0 ;
	var menu = (document.getElementById('menu')) ? document.getElementById('menu').offsetHeight : 0 ;
	var content = (document.getElementById('content')) ? document.getElementById('content').offsetHeight : 0 ;
	var right = (document.getElementById('right')) ? document.getElementById('right').offsetHeight : 0 ;
	var footer = (document.getElementById('footer')) ? document.getElementById('footer').offsetHeight : 0 ;

	var divHeights = 0;
	var largest = 0;
	
	if( content > right ) {
		largest = content;
        } else {
		largest = right;
	}
	
	if((largest + top + menu + footer) > clientHeight ) {
		divHeights = largest;
	} else {
		divHeights = clientHeight - top - menu - footer;
	}
	// setting all the heights
	document.getElementById('content').style.height = divHeights + 'px';
	document.getElementById('right').style.height = divHeights + 'px';
	if(document.getElementById('logo')) document.getElementById('logo').style.height = divHeights + 'px';

	
	/***********************************************
	 *******           HOME SPECIAL           ******
	 ***********************************************/
	if( document.getElementById( 'home') )
	{
		var home = document.getElementById('home');
		var contentWidth = (document.getElementById('content')) ? document.getElementById('content').offsetWidth : 0;

		// Determine the width of the home divs (content width / 2 minus the padding)
		document.getElementById('hometl').style.width = (contentWidth / 2) - 40 + 'px';
		document.getElementById('hometr').style.width = (contentWidth / 2) - 40 + 'px';
		document.getElementById('homebl').style.width = (contentWidth / 2) - 40 + 'px';
		document.getElementById('homebr').style.width = (contentWidth / 2) - 50 + 'px';


		if( document.getElementById( 'hometl' ) ) tl = document.getElementById( 'hometl' ).offsetHeight;
		if( document.getElementById( 'hometr' ) ) tr = document.getElementById( 'hometr' ).offsetHeight;
		if( document.getElementById( 'homebl' ) ) bl = document.getElementById( 'homebl' ).offsetHeight;
		if( document.getElementById( 'homebr' ) ) br = document.getElementById( 'homebr' ).offsetHeight;
		if( ( tl + bl ) > ( tr + br ) )
			if( tl > bl )
				contentheight = tl;
			else
				contentheight = bl;
		else
			if( tr > br )
				contentheight = tr;
			else
				contentheight = br;
		document.getElementById('hometl').style.height = (contentheight) - 20 + 'px';
		document.getElementById('hometr').style.height = (contentheight) - 20 + 'px';
		document.getElementById('homebl').style.height = (contentheight) + 'px';
		document.getElementById('homebr').style.height = (contentheight) + 'px';
		document.getElementById('right').style.height = (contentheight*2) + 'px';
		document.getElementById('content').style.height = (contentheight*2) + 'px';

		// Determine the position of groepslogo
		home.style.left = ((clientWidth-(contentWidth+document.getElementById('right').offsetWidth))/2) + document.getElementById('hometl').offsetWidth - (document.getElementById('home').offsetWidth / 2) + 'px';
		home.style.top = top+menu+document.getElementById('breadcrumptrail').offsetHeight+contentheight-(document.getElementById('home').offsetHeight / 2) +'px';//(content.offsetHeight / 2) + top + 'px';
	}
}