


function openAjax() {
	var ajax;
	try {
		ajax = new XMLHttpRequest();
	} catch(ee) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				ajax = false;
			}
		}
	}
	return ajax;
}
function Id(i)
{
	return document.getElementById(i);
}
function Tn(tn)
{
	return document.getElementsByTagName(tn);
}
function showRodape(){
	Id('rodape2').style.display='none';
	Id('rodape1').style.display='block';
}
function hiddenRodape(){
	Id('rodape1').style.display='none';
	Id('rodape2').style.display='block';
}
function mostra(x)
{
	var mostraid = Id('cliente'+x);
	var mostraleg = Id('legenda'+x);
	var mostraclass = Tn('div');
	for(var i=0; i<mostraclass.length; i++)
	{
		var iten = mostraclass[i];
		if(iten.className == 'cliente')
		{
			iten.style.display = 'none';
			iten.style.borderColor = '#440000';
		}
		if(iten.className == 'legenda')
		{
			iten.style.backgroundColor = '#f1f0f0';
			iten.style.borderColor = '#440000';
			iten.style.color= '#440000';
		}
	}
	mostraid.style.display = 'block';
	mostraleg.style.backgroundColor = '#440000';
	mostraid.style.backgroundColor = '#440000';
	mostraleg.style.borderColor = '#440000';
	mostraid.style.borderColor = '#440000';
	mostraleg.style.color = '#f1f0f0';
}
time='';
y='';
function troca(x, u)
{
	y = u;
	if(x<u)
	{
		mostra(x);
		x++;
		time = setTimeout('troca('+x+','+u+')', 3000);
	}
	else
	{
		x=1;
		time = setTimeout('troca('+x+','+u+')', 0);
	}	
}
function _stop(){
	clearTimeout(time);
}
function _play(x){
	troca(x, y);
}
function carregaPg(x){
	var img = Tn('img');
	var _img;
	var _link;
	_link = x.href;	
	_link = _link.substr(33);
	for(i=0; i<img.length; i++)
	{
		if(img[i].id=='link')
		{
			_img = img[i].src;
			if(_img.search(_link) == -1){
				_img = _img.replace("2", "1");
				img[i].src=_img;
			}
			else
			{
				_img = _img.replace("1", "2");
				img[i].src=_img;
			}
		}
	}
	
	//abrePg(_link);
	//return false;
}
function abrePg(x) {
	var ajax = openAjax();
	var conteudo = Id('corpo');
	if(x=='home'){
		setTimeout('_play(1)',1000);
	}
	exibirBgBody();
	ajax.open('GET', x+'.php', true);
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 1) {
			loading(true);
		}
		if (ajax.readyState == 4) {
			if (ajax.status == 200) {
				conteudo.innerHTML = ajax.responseText;
				setTimeout('loading(false)',1000);
				setTimeout('removerDivs()',1000);
			} 
		}
	}
	ajax.send(null);
}
function exibirBgBody() {
	// Seleciona a tag body. item(0) por que só existe uma tag body
	var tagBody = Tn('body').item(0);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage = getPageSize();
	// Vamos criar uma tag div
	var bgBody = document.createElement('div');
	// Setar o atributo ID a div criada
	bgBody.setAttribute('id','bgBody');
	// Essa div terá o tamanho exato da página
	bgBody.style.height = arrayPageSize[1] + 'px';
	// Essa div terá a largura exata da página
	bgBody.style.width = arrayPageSize[0] + 'px';
	// Evita criar a div novamente
	if (!Id('bgBody')) {
		tagBody.insertBefore(bgBody, tagBody.firstChild);
	}	
}
function loading(opt) {
	if (opt == true) {
		// A tag que receberá a img de loading
		var refer = Id('bgBody');
		// O tamanho da referida tag
		var referHeight = refer.offsetHeight;
		// Dizemos que os elementos dentro dela será alinhado ao centro
		refer.style.textAlign = 'center';
		// Criamos uma imagem, img.
		var img = document.createElement('img');
		// Informamos o caminho da img
		img.setAttribute('src','img/loader.gif');
		// Setamos um atributo ID na img criada
		img.setAttribute('id','loading');
		// Definimos seu tamanho
		img.setAttribute('width','130');
		// Dizemos que o margin-top será a metada do tamanho da div
		img.style.marginTop = (referHeight /3) + 'px';
		// Evita que seja criada duas ou mais img de loading
		if (!document.getElementById('loading')) {
			// Insere a img na tag informada na variável refer
			refer.insertBefore(img, refer.firstChild);
		}
	} else if (opt == false) {
		// Referenciamos a img de login através de seu ID
		var imgLoading = Id('loading');
		// Removemos a img de loading
		if (imgLoading) {
			imgLoading.parentNode.removeChild(imgLoading);
		}
	}
}
function removerDivs() {
	var bgBody = Id('bgBody');
	bgBody.style.display='none';
	bgBody.parentNode.removeChild(bgBody);

}
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) 

}
function fecha(){
	var alvo = Id('banner');
	alvo.style.display='none';
	var alvo2 = Id('sombra');
	alvo2.style.display='none';
}
function abre(){
	var alvo = Id('banner');
	alvo.style.display='block';
	var alvo2 = Id('sombra');
	alvo2.style.display='block';
}