function bodyOnReady(func){
//by Micox - based in jquery bindReady and Diego Perini IEContentLoaded
//flag global para indicar que já rodou e function que roda realmente
done = false
init = function(){ if(!done) { done=true; func() } }
var d=document; //apelido para o document
//pra quem tem o DOMContent (FF)
if(document.addEventListener){ d.addEventListener("DOMContentLoaded", init, false );}

if( /msie/i.test( navigator.userAgent ) ){ //IE
(function () {
try { // throws errors until after ondocumentready 
d.documentElement.doScroll("left");
} catch (e) {
setTimeout(arguments.callee, 10); return;
}
// no errors, fire
init();
})();
}
if ( window.opera ){
d.addEventListener( "DOMContentLoaded", function () {
if (done) return;
//no opera, os estilos só são habilitados no fim do DOMready
for (var i = 0; i < d.styleSheets.length; i++){
if (d.styleSheets[i].disabled)
setTimeout( arguments.callee, 10 ); return;
}
// fire
init();
}, false);
}
if (/webkit/i.test( navigator.userAgent )){ //safari's
if(done) return;
//testando o readyState igual a loaded ou complete
if ( /loaded|complete/i.test(d.readyState)===false ) {
setTimeout( arguments.callee, 10 ); return;
}
init();
}
//se nada funfou eu mando a velha window.onload lenta mesmo
if(!done) window.onload = init
}


function sizethis() {
	        
 var xScroll, yScroll;

if (window.innerHeight && window.scrollMaxY) {	
	xScroll = window.innerWidth + window.scrollMaxX;
	yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	xScroll = document.body.scrollWidth;
	yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	xScroll = document.body.offsetWidth;
	yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;

if (self.innerHeight) {	// all except Explorer
	if(document.documentElement.clientWidth){
		windowWidth = document.documentElement.clientWidth; 
	} else {
		windowWidth = self.innerWidth;
	}
	windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
	windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
}	

// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
	pageHeight = windowHeight;
} else { 
	pageHeight = yScroll;
}

// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){	
	pageWidth = xScroll;		
} else {
	pageWidth = windowWidth;
}

return [pageWidth,pageHeight];
}

function showdeadcenterdiv(Xwidth,Yheight,divid) { 
// First, determine how much the visitor has scrolled 

var scrolledX, scrolledY; 
if( self.pageYOffset ) { 
scrolledX = self.pageXOffset; 
scrolledY = self.pageYOffset; 
} else if( document.documentElement && document.documentElement.scrollTop ) { 
scrolledX = document.documentElement.scrollLeft; 
scrolledY = document.documentElement.scrollTop; 
} else if( document.body ) { 
scrolledX = document.body.scrollLeft; 
scrolledY = document.body.scrollTop; 
} 

// Next, determine the coordinates of the center of browser's window 

var centerX, centerY; 
if( self.innerHeight ) { 
centerX = self.innerWidth; 
centerY = self.innerHeight; 
} else if( document.documentElement && document.documentElement.clientHeight ) { 
centerX = document.documentElement.clientWidth; 
centerY = document.documentElement.clientHeight; 
} else if( document.body ) { 
centerX = document.body.clientWidth; 
centerY = document.body.clientHeight; 
} 

// Xwidth is the width of the div, Yheight is the height of the 
// div passed as arguments to the function: 
var leftOffset = scrolledX + (centerX - Xwidth) / 2; 
var topOffset = scrolledY + (centerY - Yheight) / 2; 
// The initial width and height of the div can be set in the 
// style sheet with display:none; divid is passed as an argument to // the function 
var o=document.getElementById(divid); 
var r=o.style; 
r.position='absolute'; 
r.top = topOffset + 'px'; 
r.left = leftOffset + 'px'; 
r.display = "block"; 
}
