/**
 * 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 clientWidth = 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;
	}
	if(document.getElementById('rightHome')) document.getElementById('content').style.width = '530px';
	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 : (document.getElementById('rightHome')) ? document.getElementById('rightHome').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
	if ( content){
	document.getElementById('content').style.height = divHeights + 'px';
	if( document.getElementById( 'rightHome') ) {
		document.getElementById('rightHome').style.height = divHeights + 'px';
	} else {
		document.getElementById('right').style.height = divHeights + 'px';
	}
	}
	if(document.getElementById('logo')) document.getElementById('logo').style.height = divHeights + 'px';
	
	

	
		/***********************************************
	 *******           HOME SPECIAL           ******
	 ***********************************************/

	if( document.getElementById( 'content_home') )
	
	{
		if( document.getElementById( 'home_left' ) ) hl = document.getElementById( 'home_left' ).offsetHeight;
		if( document.getElementById( 'home_right' ) ) hr = document.getElementById( 'home_right' ).offsetHeight;
	
		var home_top = 0;
		home_top = document.getElementById( 'home_top' ).offsetHeight;

		if( hl > hr )
			contentheight = hl + top + menu + footer + home_top;
		else
			contentheight = hr + top + menu + footer + home_top;
		
		if(clientHeight > contentheight) {
			totalheight = clientHeight - menu - home_top - footer - 23;
		} else {
			totalheight = contentheight - home_top - footer;
		}
		document.getElementById('content_home').style.height = (totalheight) + 'px';
	}

}

