//
// Sets the size of div id 'content'
//
function setContentSize()
{
	// current windowsize
	var winwidth = windowSize('width');
	var winheight = windowSize('height');

	// stylesheet vertical and logo size
	var minwidth = parseInt(getStyle(document.getElementById('vertical'), "width"));
	var minheight = parseInt(getStyle(document.getElementById('Content'), "top")); // height of the header

	var contentPaddingTop = 0;//20; // get dynamically?
	var contentPaddingBottom = 0;//20; // get dynamically?

	// ie differs in width and height detection
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		contentPaddingTop = 0;
		contentPaddingBottom = 0;
	}

	// set content size
	//setStyle('Content', "width", (winwidth - minwidth) + "px"); // replaced with CSS change. Inline style code changes cannot be undone/overwritten by stylesheets which causes printing problems!

	var theRules = new Array();

	for (var o = 0; o < document.styleSheets.length; o++)
	{
		if(document.styleSheets[o].href != null && document.styleSheets[o].href.indexOf("screen.css") != -1)
		{
			if (document.styleSheets[o].cssRules)
				theRules = document.styleSheets[o].cssRules;
			else if (document.styleSheets[o].rules)
				theRules = document.styleSheets[o].rules;
		}
	}

	var i;
	for(i=0; theRules[i]; i++)
	{
		if(theRules[i].selectorText == '#Content')
		{
			theRules[i].style.width = (winwidth - minwidth) + "px";
		}
	}
	setStyle('Content', "height", (winheight - minheight) - contentPaddingTop - contentPaddingBottom + "px");
	//alert((document.getElementById('modExternalPageTop'));
	//if((document.getElementById('modExternalPageTop'))

	var modExternalPageTopHeight;
	modExternalPageTopHeight = getStyle(document.getElementById('modExternalPageTop'), "height");
	if(modExternalPageTopHeight != undefined)
	{
		modExternalPageTopHeight = parseInt(modExternalPageTopHeight);
	}
	else
	{
		modExternalPageTopHeight = 0;
	}

	// in case of externalmodule
	try{
		setStyle('modExternalPage', "height", parseInt(getStyle(document.getElementById('Content'), "height")) - modExternalPageTopHeight - 4 + "px");
	}catch(err){}

	// also set bar sizes. in ie7 they disappear when coolmenus4 is hovered and exited. width 999px fixes this, but doesnt work with anchor links (<a name="">)
	setStyle('horizontal', "width", winwidth + "px");
	setStyle('vertical', "height", winheight + "px");
}

function getStyle(el, style)
{
try{
   if(!document.getElementById) return;

     var value = el.style[toCamelCase(style)];

    if(!value)

        if(document.defaultView)

            value = document.defaultView.

                 getComputedStyle(el, "").getPropertyValue(style);



        else if(el.currentStyle)

            value = el.currentStyle[toCamelCase(style)];

     return value;
}catch(err){}
}

function setStyle(objId, style, value) {

	try{
   		document.getElementById(objId).style[style] = value;
    }catch(err) {}
}

function toCamelCase( sInput ) {

    var oStringList = sInput.split('-');

    if(oStringList.length == 1)

        return oStringList[0];

    var ret = sInput.indexOf("-") == 0 ?

       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];

    for(var i = 1, len = oStringList.length; i < len; i++){

        var s = oStringList[i];

        ret += s.charAt(0).toUpperCase() + s.substring(1)

    }

    return ret;

}

function windowSize(what) {

	var winWidth = 0;
	var winHeight = 0;


	// Niet Internet Explorer

	if(typeof(window.innerWidth) == 'number'){
		winWidth = window.innerWidth;
		winHeight = window.innerHeight;}

	// Internet Explorer 6 - Standards Compliant

	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){

		winWidth = document.documentElement.clientWidth;
		winHeight = document.documentElement.clientHeight;}

	// Internet Explorer 4+

	else if(document.body && (document.body.clientWidth || document.body.clientHeight)){

		winWidth = document.body.clientWidth;
		winHeight = document.body.clientHeight;}

	// Teruggeven

	if(what == 'width'){
		return winWidth;}
	else if(what == 'height'){
		return winHeight;}

}