window.ignoreBg = null;

function Centralize(ignoreBg)
{
	if(ignoreBg == null)ignoreBg = window.ignoreBg;
	window.ignoreBg = ignoreBg;

	var x,y;
	var resX, resY;

	resX = screen.width;
	CookieUtils.set('width',resX);

	resY = screen.height;
	CookieUtils.set('height',resY);

	if (self.innerHeight)
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	/* 494: área central da tela (barras superior e inferior + espaço entre elas) */
	/* 83: espaço superior e inferior mínimo */

	var bg	= document.getElementById('bg_flash');
	if(bg) {
		bg.style.height = y+'px';
		if(navigator.userAgent.indexOf('MSIE 6.0') != -1) bg.getElementsByTagName('object')[0].height = y+'px';
		if(navigator.userAgent.indexOf('MSIE 6.0') != -1) document.getElementById('container').style.visibility = 'visible';
	}

	if(resY < 768) {
		document.getElementsByTagName(navigator.userAgent.indexOf('WebKit') == -1 ? 'html' : 'body')[0].style.overflow = 'hidden';
	}

	var container	= document.getElementById('area');
	var margin		= Math.round((y - (83 * 2) - 460) / 2);
	if(margin < -83) margin = -83;

	container.style.marginTop = margin + 'px';
	CookieUtils.set('CNT_area',margin + 'px');

	/* Centraliza BG */
	var oMargin = Math.round((y-container.offsetHeight)/2);
	var oBody	= document.getElementsByTagName('body');
	oBody[0].style.border = 'none'

	oBody[0].style.height = y+'px';
	CookieUtils.set('CNT_bg_pos','center');
	oBody[0].style.backgroundPosition = CookieUtils.get('CNT_bg_pos');

	if(x-container.offsetWidth > 0)
	{
		var width	= ((x-container.offsetWidth)/2)+603;
		if(navigator.userAgent.indexOf('Firefox') != -1) {
			width -= 10;
		}

		CookieUtils.set('CNT_menu_sup', width + 'px');
		CookieUtils.set('CNT_menu_inf', (width + 155) + 'px');
		CookieUtils.set('CNT_times_bar',(width + 155) + 'px');
	}
}

window.onresize = Centralize;

