// JavaScript Document
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function controlarMenu(ida, idb){
	document.getElementById(ida).style.display = 'none';
	document.getElementById(idb).style.display = 'block';
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function ajax(pagina, elem, valor, opcao, carregar, tempo, pagina2){
	if(carregar){
		$("#"+elem).html('<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle"><font class="ftcarregando">Carregando...</font></td></tr></table>');	
	}
	switch(opcao){
		case(0):
			el = elem;
		break;
		case(1):
			organizarAlert(pagina2,true);
			ajax(pagina, 'msg', valor, 0, false, '', '');
			setTimeout("ocultarLayer('alert','"+pagina2+"')",tempo);
		break;
	}
	if(opcao == 0){
		$.ajax({
			type: "POST",
			url : pagina,
			data: valor,
			success: function(retorno){
				if(el != ''){
					$("#"+el).html(retorno);	
				}
			}
		});
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function chamarPagina(op){
	switch(op){
		case 1://cia. candongas
			pag  = "ciacandongas.php";
			onde = 'conteudo';
		break;
		case 2://teatro empresarial
			pag = "teatroempresarial.php";
			onde = 'conteudo';
		break;
		case 3://repertorio
			pag = "repertorio.php";
			onde = 'conteudo';
		break;
		case 4://clientes
			pag = "clientes.php";
			onde = 'conteudo';
		break;
		case 5://parceiros
			pag = "parceiros.php";
			onde = 'conteudo';
		break;
		case 6://clipping
			pag = "clipping.php";
			onde = 'conteudo';
		break;
		case 7://blog
			pag = "";
			onde = 'conteudo';
		break;
		case 8://conteudo
			pag = "contato.php";
			onde = 'conteudo';
		break;
		case 9://repertorio - teatro empresarial
			pag = "repertorio_teatro.php";
			onde = 'repertorio_cont';
		break;
		case 10://repertorio - cursos e oficinas
			pag = "repertorio_cursos.php";
			onde = 'repertorio_cont';
		break;
		case 11://repertorio - espetáculos
			pag = "repertorio_espetaculos.php";
			onde = 'repertorio_cont';
		break;		
	}
	ajax(pag, onde, '', 0, true, '', '');
}

function chamarPaginaTxt(op,id){
	switch(op){
		case 1://cia. candongas
			pag  = "clipping_texto.php";
			onde = 'clipping_cont';
		break;
		case 2://teatro empresarial
			pag = "noticia_texto.php";
			onde = 'conteudo';
		break;	
	}
	ajax(pag, onde, 'id='+id, 0, true, '', '');
}

function enviarContato(){
	document.getElementById('sucesso').innerHTML = "Aguarde. Enviando mensagem.";
	
	var strPost = '';
	strPost += 'nome='+document.getElementById('nome').value;
	strPost += '&email='+document.getElementById('email').value;
	strPost += '&msg='+document.getElementById('msg').value;
	
	ajax('enviar_contato.php', 'sucesso', strPost, 0, false, '', '');
	
}

function limparCampo(elem){
	switch(elem.value){
		case "Digite seu Email.":	
			elem.value = '';
		break;
		case "Email cadastrado com sucesso.":	
			elem.value = '';
		break;
		case "Este email já está cadastrado.":	
			elem.value = '';	
		break;		
	}
}

function cadastrarEmail(){
	var vl = document.getElementById('email_news').value;
	if(vl.search(/^([a-z]|[A-Z]|[0-9]|[.]|[_])+[@]([a-z]|[A-Z])+[.]((([a-z]|[A-Z]){2,})|(([a-z]|[A-Z]){2,}[.]([a-z]|[A-Z]){2,}))$/) == -1){
		alert("Email inválido.");
		return false;
	}
	var strPost = '';
	strPost += 'email='+vl;
	ajax('cadastrar_email.php', 'camponews', strPost, 0, true, '', '');
}

function removerEmail(){
	var vl = document.getElementById('email_rem').value;
	if(vl.search(/^([a-z]|[A-Z]|[0-9]|[.]|[_])+[@]([a-z]|[A-Z])+[.]((([a-z]|[A-Z]){2,})|(([a-z]|[A-Z]){2,}[.]([a-z]|[A-Z]){2,}))$/) == -1){
		alert("Email inválido.");
		return false;
	}
	var strPost = '';
	strPost += 'email='+vl;
	ajax('remover_email_script.php', 'camporem', strPost, 0, true, '', '');
}

/*
var auxmsg = '';
var arraux = new Array(1);
arraux[0]  = '';
arraux[1]  = '';
arraux[2]  = '';
arraux[3]  = '';    //linha para arquivos
arraux[4]  = '';    //lista controle de menu e submenu
arraux[5]  = '';
arraux[6]  = '@1@'; //lista controle paginacao (Geral)
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function limparGlobais(){
	var tam = arraux.length;
	for(i=0; i<tam; i++){
		arraux[i] = '';	
	}
	arraux[6]  = '@1@';
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// url_encode version 1.0 
function url_encode(str) { 
	if(str == undefined){
		str = '';	
	}
	var hex_chars = "0123456789ABCDEF"; 
	var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
	var n, strCode, hex1, hex2, strEncode = ""; 
	
	for(n = 0; n < str.length; n++) { 
		if (noEncode.test(str.charAt(n))) { 
			strEncode += str.charAt(n); 
		} else { 
		strCode = str.charCodeAt(n); 
		hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
		hex2 = hex_chars.charAt(strCode % 16); 
		strEncode += "%" + (hex1 + hex2); 
		} 
	} 
	return strEncode; 
 } 
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 // url_decode version 1.0 
 function url_decode(str) { 
	  var n, strCode, strDecode = ""; 

	  for (n = 0; n < str.length; n++) { 
			if (str.charAt(n) == "%") { 
				 strCode = str.charAt(n + 1) + str.charAt(n + 2); 
				 strDecode += String.fromCharCode(parseInt(strCode, 16)); 
				 n += 2; 
			} else { 
				 strDecode += str.charAt(n); 
			} 
	  } 

	  return strDecode; 
 } 
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function posicionarLayer(id,w1,h1){
	var w = document.body.clientWidth;
	var h = document.body.clientHeight;
	var l = ((w-w1) / 2); 
	var t = ((h-h1) / 2);
	$("#"+id).css({left:l});
	$("#"+id).css({top:t});
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function gerLista(elem, op, idaux){
	var lst = arraux[idaux];
	expReg1 = eval('/@'+elem+'@/');
	aux = (lst.search(expReg1) == -1) ? true : false;
	if(op){ //Inserir
		if(aux){ //Não tem o elemento na lista (faz a inserção);
			arraux[idaux] = lst + '@' + elem + '@';
			return true;
		}else{ //Tem elemento (não faz a inserção);
			return false;
		}
	}else{ //Remover
		if(aux){ //Não tem elemento na lista (não faz a remoção);
			return false;
		}else{ //Tem elemento (faz a remoção);
			arraux[idaux] = lst.replace('@' + elem + '@','');
			return true; 
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function gerenciarArvoreMenu(indice, tipo, pag){
	var cam = $("#imgsubmenu"+indice).attr("cam");
	if(tipo == 'mod'){
		if($("#submenu"+indice+"").css("display") == 'block'){
			$("#submenu"+indice+"").css({display:"none"});
			$("#imgsubmenu"+indice+"").attr({src:cam+"seta_baixo.gif"});
		}else{
			$("#submenu"+indice+"").css({display:"block"});
			$("#imgsubmenu"+indice+"").attr({src:cam+"seta_cima.gif"});
		}
	}else{
		if($("#submenu"+indice+"").css("display") == 'block'){
			$("#submenu"+indice+"").css({display:"none"});
			$("#imgsubmenu"+indice+"").attr({src:cam+"mais.gif"});
		}else{
			$("#submenu"+indice+"").css({display:"block"});
			$("#imgsubmenu"+indice+"").attr({src:cam+"menos.gif"});
		}
	}
	//==============================
	var retorno = gerLista(indice, true, 4);
	if(retorno){
		strPost = "indice="+indice;
		ajax(pag, "submenucont"+indice, strPost, 0, true);	
	}	
	//==============================
}

function organizarAlert(pag,op){
	document.body.scrollTop = 0;
	if(op){
		$("#conteudo").html('');	
		$("#alert").css({visibility:"visible"});
	}else{
		
	}
	$("#msg").html('Aguarde...');
	$("#alert_x").html("<img src='img/alert_fechar.gif' width='25' height='25' class='cursor' onClick='ocultarLayer(\"alert\",\""+pag+"\")'>");
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function ocultarLayer(id,pag){
	if($("#"+id).css("visibility") == 'visible'){
		$("#"+id).css({visibility:"hidden"});
		if(pag != ''){
			ajax(pag, 'conteudo', '', 0, true, '','');
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function msgAlert(pag, msg){
	$("#msg").html(msg);
	$("#conteudo").html('');	
	$("#alert").css({visibility:"visible"});	
	setTimeout("ocultarLayer('alert','"+pag+"')",2500);
}








//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function controlarAbas(id, quant){
	for(i=0; i<quant; i++){
		if(i == id){
			document.getElementById("aba_"+i).className = "abasel";
			$("#div_"+i+"").css({display:"block"});
		}else{
			document.getElementById("aba_"+i).className = "abades";
			$("#div_"+i+"").css({display:"none"});
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function mudaCor(id,class){
	document.getElementById(id).className = class;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function selecionarItemExcluir(id){
   var existe = gerLista(id, true, 5);
	if(!existe){
		gerLista(id, false, 5);
		$("#iex_"+id).attr({src:"img/excluir.gif"});		
	}else{
		$("#iex_"+id).attr({src:"img/excluir2.gif"});		
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function checarIndExc(valor, id){
	if(arraux[5] == ''){
		$("#e"+id).html('&nbsp;Selecione ao menos um item para excluir');
		return false;
	}
	$("#e"+id).html('');
	return true;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function controlePaginacao(numpag, totalpag, idcontrole, strPost, pag){
	var existe = gerLista(numpag, true, 6);
	if(existe){
		strPost = strPost + '&pag='+numpag;
		ajax(pag, 'div_pag_'+numpag, strPost, 0, true, '', '');
	}
	for(i = 1; i <=totalpag; i++){
		if(i == numpag){
			$("#div_pag_"+i).css({display:"block"});
		}else{
			$("#div_pag_"+i).css({display:"none"});
		}
	}		 
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function inserirLinha(comp, pag, quant, ext, op1){
	var qt  = (1 + stringToFloat($("#quant"+ext).attr("value")));
	if(qt <= quant){
		$("#quant"+ext).attr({value:qt});
		
		var ult = (1 + stringToFloat($("#ult"+ext).attr("value")));
		$("#ult"+ext).attr({value:ult});

		var td = document.createElement("td");
		td.id  = 'td_'+ comp + '' + ult;
		var tr = document.createElement("tr");
		tr.id  = 'tr_'+ comp + '' + ult;
		///td.setAttribute('colspan', '4');
		
		document.getElementById('tbody_'+ comp + '' + ext).appendChild(tr);
		document.getElementById(tr.id).appendChild(td);
		
	
		var strPost = '';
		strPost = strPost + 'ult='+ult;	
		strPost = strPost + '&comp='+comp;	
		strPost = strPost + '&ext='+ext;	
		
		if(op1){
			listaLinhas(ult);
		}
		ajax(pag, td.id, strPost, 0, true, '', '');
	}
	totalLinha(qt,'quant'+ext);
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function listaLinhas(vl){
   var existe = gerLista(vl, true, 3);
	if(!existe){
		gerLista(vl, false, 3);
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function totalLinha(valor, id){
	if(valor == '0'){
		$("#e"+id).html('Insira um arquivo');
		return false;	
	}else{
		$("#e"+id).html('');
		return true;
	}
	
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function erroRadio(elem, id, idop){
	if(elem.checked == true){
		$("#"+idop).attr({value:elem.value});
		$("#"+id).html('');
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function removerLinha(pai, filho, ext, vl, op1, op2){
	if($("#op"+ext).attr("value") == vl){
		$("#op"+ext).attr({value:""});
	}
	if($("#lst"+ext).attr("value") == undefined){
		arraux[3] = '';	
	}else{
		arraux[3] = $("#lst"+ext).attr("value");
	}
	if(op1){
		var qt  = (stringToFloat($("#quant"+ext).attr("value")) - 1);
		$("#quant"+ext).attr({value:qt});
	}
	if(op2){
		listaLinhas(vl);	
	}
	var epai = document.getElementById(pai);
	var efilho = document.getElementById(filho);
	epai.removeChild(efilho);
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function stringToFloat(x){
	if(x != ""){
		tmp = parseFloat(x.replace(",","."),2);
		return tmp;
	}else{
		return 0;
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//So para campos de arquivos com radio button.
function checarDestaque(form, opc){
	var doc = eval('document.'+form);
	var tam = doc.elements.length;
	var auxop = true;
	for(i=0; i<tam; i++){
		if((doc.elements[i].type == 'radio')&&(doc.elements[i].checked == true)){
			$("#"+opc).attr({value:doc.elements[i].value});
			auxop = false;
		}
	}
	if(auxop){
		$("#e"+opc).html("Selecione um arquivo para destaque");	
		return false;
	}
	return true;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function checarOpcao(valor, id){
	if($("#"+id).attr("hab") == 'ok'){
		ext = id.split('_');
		if((valor == '')&&($("#quant_"+ext[1]).attr("value") != 0)){
			$("#e"+id).html("Selecione um arquivo para destaque");
			return false	
		}else{
			$("#e"+id).html("");		
			return true	
		}
	}else{
		return true;	
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function doDate(pStr, pFmt){
	eval("reDate = reDate" + pFmt);
		if (reDate.test(pStr)) {
			return true;
		}else if (pStr != null && pStr != "") {
			return false
	}
} // doDate

var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;
var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
var reDate  = reDate4;
var hora1   = /^([0-1]{1}[0-9]{1}|2[0-3]{1}):([0-5]{1}[0-9]{1})$/;
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function checarData(valor, id){
	if(valor.length > 10){
		var data = valor.split("/");
		var dia_dt = data[0];
		var mes_dt = data[1];
		var ano_dt = stringToFloat(data[2]);
		var parte1 = !(ano_dt % 4 == 0 && ano_dt % 100 != 0);
		var parte2 = !(ano_dt % 400 == 0);
		if((dia_dt == '29' ) && (mes_dt == '02') && parte1 && parte2){
			$("#e"+id).html("Data inválida");	
			return false;
		}
	}
	if(!doDate(valor, 4)){
		$("#e"+id).html("Data inválida");	
		return false;
	}
	$("#e"+id).html("");	
	return true;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function bloquearDesbloquearData(vl, compl){
	switch (vl){
		case "entre":
			document.getElementById('data_ini'+compl).disabled = false;	
			document.getElementById('data_ini'+compl).className = 'form01';
			$("#data_ini"+compl).attr({funcao:"checarData"});
			
			document.getElementById('data_fim'+compl).disabled = false;	
			document.getElementById('a'+compl).innerHTML = 'a';	
			document.getElementById('data_fim'+compl).className = 'form01';
			$("#data_fim"+compl).attr({funcao:"checarData"});
		break;
		case "":
			document.getElementById('data_ini'+compl).disabled = true;	
			document.getElementById('data_ini'+compl).className = 'form03';
			$("#edata_ini"+compl).html("");
			$("#data_ini"+compl).attr({funcao:""});
			
			document.getElementById('data_fim'+compl).disabled = true;	
			document.getElementById('a'+compl).innerHTML = '';	
			document.getElementById('data_fim'+compl).className = 'form03';
			$("#edata_fim"+compl).html("");
			$("#data_fim"+compl).attr({funcao:""});
		break;
		default:
			document.getElementById('data_ini'+compl).disabled = false;	
			document.getElementById('data_ini'+compl).className = 'form01';	
			$("#data_ini"+compl).attr({funcao:"checarData"});
			
			document.getElementById('data_fim'+compl).disabled = true;	
			document.getElementById('a'+compl).innerHTML = '';	
			document.getElementById('data_fim'+compl).className = 'form03';	
			$("#edata_fim"+compl).html("");
			$("#data_fim"+compl).attr({funcao:""});
		break;
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
$(function() {
	$("#imgbarraesq").click(function() {
		controlarLateral($("#imgbarraesq").attr("param"));
	});												
});
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
$(function() {
	$("#imgbarradir").click(function() {
		controlarLateral($("#imgbarradir").attr("param"));
	});												
});
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
function controlarLateral(ext){
	$(function() {
      var cam = $("#imgbarra"+ext).attr("cam");
		if($("#tbbarra"+ext).css("display") == 'block'){
			$("#tbbarra"+ext).css({display:"none"});
			if(ext == 'esq'){
				$("#imgbarra"+ext).attr({src:cam+"seta_direita.gif"});
			}else{
				$("#imgbarra"+ext).attr({src:cam+"seta_esquerda.gif"});
			}
		}else{
			$("#tbbarra"+ext).css({display:"block"});
			if(ext == 'esq'){
				$("#imgbarra"+ext).attr({src:cam+"seta_esquerda.gif"});
			}else{
				$("#imgbarra"+ext).attr({src:cam+"seta_direita.gif"});
			}
		}
	});
}
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=




/**
function pegarAlturaJanela() {
	var janleaAltura = 0;
	if (typeof(window.innerHeight) == 'number') {
		janleaAltura = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			janleaAltura = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				janleaAltura = document.body.clientHeight;
			}
		}
	}
	return janleaAltura;
}
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/*function controlarAltura(){
	var cabAlt = document.getElementById('cabecalho').offsetHeight;
	var cabRod = document.getElementById('rodape').offsetHeight;
	var valor = cabAlt + cabRod;
	valor = pegarAlturaJanela() - valor;
	if(navigator.appName != 'Microsoft Internet Explorer'){
		valor = valor - 20;
	}
	$("#tbesquerda").attr({height:valor});
}
*/



//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
var ultimo = 0;
var ultimosel = 0;
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
function abrir(val,valida,j){
	// abre o submenu escondido
	if(valida){
		if(document.getElementById(val).style.display == 'none'){
				document.getElementById(val).style.display = 'block';
		}else{
			document.getElementById(val).style.display = 'none';
		}
		muda(j);
	}
}
**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
/**
function muda(j){
	// altera o simbolo de aberto (+) para fechado (-)
	var x = eval("document." + j + ".src");
	var y = eval("document." + j + ".src").substr(0,(x.length - 5));
	x = x.substr((x.length - 5),x.length);
	if(x == "1.gif"){
		eval("document." + j + ".src = '" + y + "2.gif'");
	}else{
		eval("document." + j + ".src = '" + y + "1.gif'");
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function selecionar(url,sel){
	if(url != ""){
		//ajax
		atualizarDiv('conteudo','null',url,'ajax_menu');
		if(ultimosel != sel){
		// marcando o quadrado de seleção
			var x = eval("document." + sel + ".src");
			y = x.substr((x.length - 5),x.length);
			z = x.substr(0,(x.length - 5));
			if(y == "2.gif"){
				eval("document." + sel + ".src = '" + z + "1.gif'");
			}
			if(ultimo != 0){
				eval("document." + ultimosel + ".src = 'img/" + ultimo + "'");
			}
			y = x.substr((x.length - 9),x.length);
			ultimo = y;
			ultimosel = sel;
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function mostrarEsconder(lstid, id) {
	temp = lstid.split(';');
	for(i = 0; i<temp.length; i++){
		if(temp[i] == 'div_'+id){
			document.getElementById(temp[i]).style.display = "block";
		}else{
			document.getElementById(temp[i]).style.display = "none";			
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function brCorTd(divs, id) {
	temp = divs.split(';');
	for(i = 0; i<temp.length; i++){
		if(temp[i] == 'td_'+id){
			//document.getElementById(temp[i]).bgColor = "#5D0000";
			document.getElementById(temp[i]).className = "aba01";
			
		}else{
			//document.getElementById(temp[i]).bgColor = "#CCCCCC";	
			document.getElementById(temp[i]).className = "aba02";
		}
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function checarCNPJ(valor, id){
	if(valida_CNPJ(valor)){
		document.getElementById('e'+id).innerHTML = '';
		return true;
	}else{
		document.getElementById('e'+id).innerHTML = 'CNPJ inválido';
		return false;
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function limpa_string(S)
{
// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	for (var i=0; i<S.length; i++)
	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)
		{
			temp=temp+digito
		}
	}
	return temp
}

function stringToFloat(x){
	alert(x);
	if(x != ""){
		tmp = parseFloat(x.replace(",","."),2);
		return tmp;
	}else{
		return 0;
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
fmtMoney = function(n, c, d, t){ //v1.0
    var m = (c = Math.abs(c) + 1 ? c : 2, d = d || ",", t = t || ".",
        /(\d+)(?:(\.\d+)|)/.exec(n + "")), x = m[1].length > 3 ? m[1].length % 3 : 0;
    return (x ? m[1].substr(0, x) + t : "") + m[1].substr(x).replace(/(\d{3})(?=\d)/g,
        "$1" + t) + (c ? d + (+m[2] || 0).toFixed(c).substr(2) : "");
};
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function stringReplace(valor, novo, antigo){
	tmp = valor.split(antigo);
	str = tmp.join(novo);
	return str;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function verificarStatusRastreamento(elem, id){
	if((elem.value == "Previsão de Entrega") || (elem.value == "Fábrica - MG") || (elem.value == "Fábrica - SP") || (elem.value == "Fábrica - RJ") || (elem.value == "Fábrica - ES")){
		document.getElementById(id).disabled  = false;
		document.getElementById(id).className = 'form01';	
		document.getElementById(id).setAttribute('funcao','checarData');
	}else{
		document.getElementById(id).disabled  = true;
		document.getElementById(id).className = 'form01dis';
		document.getElementById(id).setAttribute('funcao','');
		document.getElementById(id).value = '';
		document.getElementById('e'+id).innerHTML = '';
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function compararSenha(valor, id){
	var s1 = document.getElementById('nova1_ins');
	var s2 = document.getElementById('nova2_ins');
	if(s1.value == s2.value){
		document.getElementById('e'+s2.id).innerHTML = '';
		return true;
	}else{
		document.getElementById('e'+s2.id).innerHTML = 'Senhas nao conferem';
		return false;
	}
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function valida_CPF(s)
{
	var i;
	s = limpa_string(s);
	var comp = 00000000000;
	for (i=0; i<=9; i++)
	{
		if(s == comp)
		{
			return false;
		}
		comp = comp + 11111111111; 
	}
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
    if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function valida_CNPJ(s)
{
	var i;
	s = limpa_string(s);
	var comp = 00000000000000;
	for (i=0; i<=9; i++)
	{
		if(s == comp)
		{
			return false;
		}
		comp = comp + 11111111111111; 
	}	
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
function removerHistorico(id, ind){
	document.getElementById('historico').innerHTML = "<font class='ftlabel'>Aguarde...</font>";
	atualizarDiv('historico', 'id='+ id +'&ind='+ ind, 'rastreamento_remover_historico.php', 'ajax_padrao');
}
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
var glstrPost = "";

**/
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
