var windowHeight = 0 ;
var windowWidth = 0 ;

function windowService() {
	try {
		setSize() ;
	} catch(e) {
		//alert(e)
	}
	window.setTimeout("windowService()",50) ;
}

function setSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	
	if(windowWidth != myWidth && document.getElementById('refticker')) {
		windowWidth = myWidth ;
		document.getElementById('refticker').style.width = windowWidth ;
	}
	
	if(windowHeight != myHeight) {
		//window.alert( 'windowHeight = ' + windowHeight + ' and height = ' + myHeight );
		windowHeight = myHeight ;
		var minHeight = 660 ;
		if(myHeight > minHeight) {
			spare = ( myHeight - minHeight ) / 2 ;
			setSpare(spare) ;
		} else {
			setSpare(1) ;
		}
		//window.alert( 'windowHeight = ' + windowHeight + ' and height = ' + myHeight );
	}
}

function setSpare(spare) {
	setSession(spare) ;
	document.getElementById('sparetop').style.height = spare ;
	document.getElementById('sparetopimage').height = spare ;
	/*
	if(document.getElementById('refticker')) {
		if(spare>48)
			spare = spare - 48 ;
		else
			spare = 1;
	}
	*/
	document.getElementById('sparebottom').style.height = spare ;
	document.getElementById('sparebottomimage').height = spare ;
}

function setSession(spare) {
	new Ajax.Updater('setsession', 'library/setsession.php', 
		{
			method: 'get',
			parameters: 
			{ 
				spare: spare
			}
		}
	);
}