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;
	}
		
	var bg			= document.getElementById('bg');
	var container	= document.getElementById('container');
	var logo		= document.getElementById('logo');
	var menu		= document.getElementById('menu');
	var noticias	= document.getElementById('noticias');
	var content		= document.getElementById('content');
	var flash		= document.getElementById('flash');
	var decLayer	= document.getElementById('decorative-layer');
	
	var margin		= Math.round((y - 598) / 2);	
	
	if(margin < 0)margin = 0;
	if(bg)bg.style.marginTop = margin + 'px';
	if(container)container.style.height = margin + 560 + 'px';
	if(logo)logo.style.top = margin + 'px';
	if(menu)menu.style.paddingTop = margin + 'px';
	if(noticias)noticias.style.top = margin + 525 + 'px';
	if(content)content.style.top = margin + 23 + 'px';
	if(flash)
		flash.style.top		= margin + 86 + 'px';
	
	if(decLayer)	
		decLayer.style.display = x < 998 ? 'none' : 'block';
	CookieUtils.set('CNT_margin', margin);		
	
	/* Centraliza BG */
	
	if( y < 598 )y = 598;
	
	var oMargin = Math.round((-1200 + y)/2);
	var oBody	= document.getElementsByTagName('body');
	
	CookieUtils.set('CNT_bg_pos','center ' + oMargin + 'px');
	
	oBody[0].style.backgroundPosition = CookieUtils.get('CNT_bg_pos') || '';
	resize_flash();
}

window.onresize = Centralize;