// JavaScript Document
function Ajax(){
	var ajax;
	try {
	  ajax = new XMLHttpRequest();
	} 
	catch (e) {
		try {
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) {
			try {
			  ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {
			  alert("Seu browser não da suporte à AJAX!");
			  return false;
			}
		}
	}
	return ajax;
}

function Navegador() {
	var caminho = "";
	var navegador = navigator.appVersion;
	var navegador = navegador.split(" ");
	var tipo   = navegador[2];
	
	if ( tipo == "MSIE" ) {
		var versao = navegador[3];	
		if ( versao == "8.0;" ) {
			caminho = "_ie8";
		}
		if ( versao == "7.0;" ) {
			caminho = "_ie7";
		}
		if ( versao == "6.0;" )  {
			caminho = "_ie6";
		}
	}
	else if ( tipo == "U;" ) {
		caminho = "_ch";
	}
	else if ( tipo == "pt-BR)" ) {
		caminho = "_ff";
	}
	else {
		caminho = "_ff";
	}
	
	document.write('<link rel="stylesheet" type="text/css" href="../style/style'+ caminho + '.css">')
}

function AbreFecha( id ) {
	if ( document.getElementById(id).style.display == "none"  ) {
		document.getElementById(id).style.display = "block";
	}
	else {
		document.getElementById(id).style.display = "none";
	}
}

function TrocaValor ( id, valor ) {
	if ( valor == id ) {
		document.getElementById(id).value = "";		
	}
	if ( valor == "" ) {
		document.getElementById(id).value = id;		
	}
}

function PreLoadImages() { //v3.0
     var d = document; 
	 if (d.images) { 
	 	if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i,j = d.MM_p.length, a = PreLoadImages.arguments; 
		for ( i=0; i < a.length; i++) {
			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j] = new Image; d.MM_p[j++].src=a[i];
			}
		}
	}
}

function BotaoAtivo (id, tag, classe) {
	var ArrayTag = document.getElementsByTagName(tag);
	for ( i=0; i < ArrayTag.length; i++) {
		if ( ( ArrayTag[i].className == classe ) || ( ArrayTag[i].className == classe + '_over' ) ) {
			if ( ArrayTag[i].id == id ) {
				if ( ArrayTag[i].className == classe + '_over' ) {
					ArrayTag[i].className = classe;
				}
				else {
					ArrayTag[i].className = classe + '_over';
				}
			}
			else {
				ArrayTag[i].className = classe;
			}
		}
	}
}

function BotaoCheck ( id, classe ) {
	var resultado = classe.indexOf("_over"); 
	if ( Number(resultado) > 0 ) {
		document.getElementById(id).value = 'S';
	}
	else {
		document.getElementById(id).value = 'N';
	}
}

var selectId     = "";
var selectAtivo  = "";
var selectAltura = "";

function SelExp( id, fim, mais ) {
	document.getElementById(id).style.visibility = "visible";
	var altura = document.getElementById(id).style.height;
		altura = altura.split("p");
		altura = altura[0];
	if ( Number(altura) < Number(fim) ) {
		var px_altura  = Number(altura) + Number(mais);
		document.getElementById(id).style.height = px_altura + 'px';
		window.setTimeout("SelExp('" + id +"', '" + fim +"', '" + mais +"')", 1);
	}
	if ( Number(altura) == Number(fim) ) {
		selectAltura = Number(fim);
		selectAtivo  = "S";
		selectId  = id;
	}
}

function SelEnc( id, menos ) {
	var altura = document.getElementById(id).style.height;
		altura = altura.split("p");
		altura = altura[0];
	if ( Number(altura) > 1  ) {
		var px_altura  = Number(altura) - Number(menos);
		document.getElementById(id).style.height = px_altura + 'px';
		window.setTimeout("SelEnc('" + id + "', " + menos + ")", 1);
	}
	if ( Number(altura) == 0  ) {
		selectAtivo = "";
		selectAltura = "";
		document.getElementById(id).style.visibility = "hidden";
	}
}

window.onload=function() { 
	elementos = document.body.getElementsByTagName('*'); 
	for( i = 0; i < elementos.length; i++) { 
		if ( elementos[i].onclick == undefined ){
			elementos[i].onclick = function () {
				if ( this.tagName == 'LI') {
					if ( this.className == 'opcao_ativa' ) {
						Id = 'lista_' + this.title;
						var title = document.getElementById(Id).title;	
						var	title = title.split("_");
						var	fim   = title[0];
						var	mais  = title[1];

						if ( selectAtivo == "S"){
							SelExp(Id, fim, mais);
							SelEnc(selectId, mais);
						}
						if ( selectAtivo == ""){
							SelExp(Id, fim, mais);
						}
					}
					if ( this.className == 'li_op' ) {
						document.getElementById('ativa_' + this.title).innerHTML = this.innerHTML;
						document.getElementById('valor_' + this.title).value = this.id;
						selectId = 'lista_' + this.title;
						selectAtivo = "";
						var title = document.getElementById(selectId).title;	
						var	title = title.split("_");
						var	menos = title[1];
						
						if ( selectAltura != "" ) {	
							SelEnc(selectId, menos);
						}
					}
				}
				else {
					if ( selectAtivo == 'S' ) {
						if ( selectAltura != '' ) {
							var title = document.getElementById(selectId).title;	
							var	title = title.split("_");
							var	menos = title[1];
							selectAtivo = "";
							SelEnc(selectId, menos);
						}
					}
				}
			}
		}
	} 
}

function Resize() {
	var largura = document.body.clientWidth;
	var navegador = navigator.appVersion;
	var navegador = navegador.split(" ");
	var tipo   = navegador[2];
	if ( tipo == "MSIE" ) {
		var versao = navegador[3];
		if ( versao == "6.0;" ) {
			if ( largura < 896 ) {
				document.getElementById('geral').style.width = '895px';
			}
			else {
				document.getElementById('geral').style.width = '';
			}
		}
	}
}

function Retorno() {
	var largura = document.body.clientWidth;
	var altura = document.body.clientHeight;
		
	document.getElementById('retorno_capa').style.width = largura + 'px';
	document.getElementById('retorno_capa').style.height = altura + 'px';
	
	document.getElementById('retorno_capa').style.display = 'block';
	document.getElementById('retorno').style.display = 'block';
}

function AbaHome( id_aba_on ) {
	
	if ( id_aba_on == 'cp_destaques' ) {
		document.getElementById('cp_destaques').className = 'cp_destaques';
		document.getElementById('cp_lancamentos').className = 'cp_lancamentos' + '_off';
		document.getElementById('destaques').style.display = 'block';
		document.getElementById('lancamentos').style.display = 'none';
	}
	else if ( id_aba_on == 'cp_lancamentos' ) {
		document.getElementById('cp_lancamentos').className = 'cp_lancamentos';
		document.getElementById('cp_destaques').className = 'cp_destaques' + '_off';
		document.getElementById('lancamentos').style.display = 'block';
		document.getElementById('destaques').style.display = 'none';
	}
}















