// JavaScript Document

var gBrowserSupported = false;
var 	pisoWidth = 110,
		pisoHeight = 110;

if (document.getElementById || document.all) {
  gBrowserSupported = true;
}

xAddEventListener(window, 'load', winOnLoad, false);

function winOnLoad()
{
  if (gBrowserSupported) {
    winOnResize();
    xAddEventListener(window, 'resize', winOnResize, false);
	MainHeigth();
	bdy = xGetElementById("body");
	bdy.style.visibility = 'visible';
  }
}

function MainHeigth(){
	mainDiv = xGetElementById('Main');
	mainDivHeight = xHeight(mainDiv) ;
	mainDivHeight = (mainDivHeight >= pisoHeight) ? mainDivHeight : pisoHeight;
	pisos = Math.floor(mainDivHeight / pisoHeight);
	newSize = pisoHeight * pisos;
	offset = 16;
	xResizeTo(mainDiv,778,newSize+offset);
}

function winOnResize()
{
  var
    screenWidth = xClientWidth(),
	page = xGetElementById('body'),
	pageWidth = xWidth(page),
	pageLeftX = (screenWidth / 2) - (pageWidth / 2),
	offset = (pageLeftX % pisoWidth),
	bdy = xGetElementsByTagName('body');
	bdy[0].style.backgroundPosition = Math.floor(offset) + "px 7px";
	
}