//////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARS
////for boxes on home
var left=0.5;						// root X position in percent (1=100%)
var top=0.5;						// root Y position in percent

//////////////////////////////////////////////////////////////////////////////////////////////// GENERAL FUNCTIONS
function cleanVar(x) { if (x.toString().indexOf('px')>-1) { x=parseInt(x.toString().substring(0,x.toString().indexOf('px'))); } return x; }
function gbid(id) { return document.getElementById(id); }
function trace(x) { 
	if (!gbid('trace')) { document.body.innerHTML+='<div id="trace"></div>'; }
	gbid('trace').innerHTML+='<br>'+x; }
//////////////////////////////////////////////////////////////////////////////////////////////// GENERAL FUNCTIONS


//////////////////////////////////////////////////////////////////////////////////////////////// ROOT OPERATIONS
var windowW=0;
var windowH=0;
var rootW=0;
var rootH=0;
function initRoot() {
	if (gbid('root')) {
		rootW=cleanVar(gbid('root').style.width); 
		//rootH=cleanVar(gbid('root').style.height);
		centerBodyDiv(); }
	
}
function centerBodyDiv() {
	if (rootW!=0) {
		if (document.body.clientWidth!=windowW) {
			windowW=document.body.clientWidth;
			newLeft=Math.floor((windowW*left)-(rootW/2));
			if (newLeft<0) { newLeft=0; } 
			document.getElementById('root').style.left=newLeft+'px';
		}
		/*if (document.body.clientHeight!=windowH) {
			windowH=document.body.clientHeight;
			newTop=Math.floor((windowH*top)-(rootH/2));
			if (newTop<0) { newTop=0; } 
			document.getElementById('root').style.top=newTop+'px';
		}*/
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////// ROOT OPERATIONS


function init() {
	initRoot();
}
function anim() {
	centerBodyDiv();
}
window.setInterval('anim()',1);
