function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		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
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


var objBody = document.getElementsByTagName("body").item(0);

var wFrame = 990;
var hFrame = 620;
var objOverlay;
var objIframe;
var objClose;

function initLightbox(){
	var objBody = document.getElementsByTagName("body").item(0);
	
	 	objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.style.border = 'none';
		objOverlay.style.position = 'absolute';
		objOverlay.style.top = '0';
		objOverlay.style.left = '0';
		objOverlay.style.zIndex = '90';
		objOverlay.style.width = '100%';
		objBody.insertBefore(objOverlay, objBody.firstChild); 
	
	 	objIframe = document.createElement("iframe");
		objIframe.setAttribute('id','iframe');
		objIframe.style.display = 'none';
		objIframe.style.position = 'absolute';
		objIframe.style.zIndex = '100';
		objIframe.style.width = wFrame+'px';
		objIframe.style.height = hFrame+'px';
		objIframe.scrolling = "no";
		objIframe.frameborder = "0";
		objIframe.src = 'http://f1.braskem.com.br/';
		objBody.insertBefore(objIframe, objOverlay.firstChild); 
	
	 	objClose = document.createElement("a");
		objIframe.setAttribute('id','linkFechar');
		objClose.href = 'javascript:hideContents();';
		//objClose.style.background = "url(../../img/pt/close_small.gif) no-repeat right";
		objClose.title = "Fechar janela";
		objClose.style.width = "132px";
		objClose.style.height= "23px";		
		objClose.style.textAlign= "right";		
		objClose.style.fontSize= "12px";		
		objClose.style.position = 'absolute';
		objClose.style.top = '0';
		objClose.style.zIndex = '110';
		objClose.innerHTML = '[X] Fechar janela';
		objBody.insertBefore(objClose, objIframe.firstChild); 

	printContents();

}
function hideContents(){
	objOverlay.style.display="none"; objIframe.style.display="none"; objClose.style.display="none";
}
function printContents(){
	var arrayPageSize = getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
	objIframe.style.display = 'block';
	if((arrayPageSize[3]>550)&&(arrayPageSize[3]<650)){
		objIframe.style.top = ((arrayPageSize[3]-hFrame)/2)+40 + "px";
		objClose.style.top = (arrayPageSize[3]-hFrame)/2 + "px";
		objIframe.style.right = (arrayPageSize[2]-wFrame)/2 + "px";
		objClose.style.right = ((arrayPageSize[2]-wFrame)/2)-8 + "px";
		return false;
	}
	else if(arrayPageSize[3]<550){
		objIframe.style.top = "50px";
		objClose.style.top = "15px";
		objIframe.style.right = "0px";
		objClose.style.right = "0px";
		return false;
	}
	objIframe.style.top = (arrayPageSize[3]-hFrame)/2 + "px";
	objClose.style.top = ((arrayPageSize[3]-hFrame)/2)-40 + "px";
	objIframe.style.right = (arrayPageSize[2]-wFrame)/2 + "px";
	objClose.style.right = ((arrayPageSize[2]-wFrame)/2) + "px";
}


function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
	window.onresize=printContents;

}
//addLoadEvent(initLightbox);
