// JavaScript Document
//função redimensiona

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 - 18;
	} 
	else 
	{
		pageWidth = xScroll;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

var Window =
{
	
	'_open': function(div,divW,divH) 
	{
		
		$.blockUI();
		
		//if (document.all)
		//var pos = evt.clientY;
		//else
		// var pos = window.pageYOffset;
		
		var pageSize = getPageSize();
		
		var objScroll = getPageScroll();
		//alert(objScroll[1]);
		
		var winW = pageSize[0];
		var winY = pageSize[1];
		
		//menos a largura da div
		var w = (winW - divW) / 2;
		 //menos a altura da div
		//var y = (winY - 500) / 2;
		
		var y = objScroll[1] + 20;
		//alert(w);
		//alert(y);
		
		document.getElementById(div).style.left = w + 'px';
		document.getElementById(div).style.top = y + 'px';
		$("#"+div).width(divW)
		$("#"+div).show('slow');
		/*document.getElementById(div).style.display = 'block';*/
	},
	
	'_close': function(div)
	{
		/*document.getElementById(div).style.display='none';*/
		$("#"+div).hide('slow');
		$("#"+div).empty();
		$.unblockUI();
	},
	
	'_closeEfect': function(div)
	{
		/*document.getElementById(div).style.display='none';*/
		$("#"+div).hide(function(){					 
			$("#"+div).animate({left: 50, opacity: 1},"slow");
		});
		$("#"+div).empty();
		$.unblockUI();
	},
	
	'openWin': function(url, name, w, h, s) 
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+s+',resizable=no';
	//	winprop = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes';
		
		win = window.open(url, name, winprops)
		if(parseInt(navigator.appVersion) >= 4) 
		{
			win.window.focus(); 
		}
	}
}

