






































































































var Agente=navigator.userAgent.toUpperCase();
if(1+Agente.indexOf('MSIE'))var sBrowser='IE';
else if(1+Agente.indexOf('FIREFOX'))var sBrowser='FF';
else if(1+Agente.indexOf('CHROME'))var sBrowser='CH';
else if(1+Agente.indexOf('SAFARI'))var sBrowser='SA';
else if(1+Agente.indexOf('OPERA'))var sBrowser='OP';
else var sBrowser='NS';

if (document.all)
	var tagDisplay = "block";
else
	var tagDisplay = "table-row";

defaultStatus = "Iupex Ingressos";

function calcularValorIngresso2() {
	cfgTotalCategs 	= document.frmConfigurar.cfgTotalCategs.value;
	cfgTaxaServico	= document.frmConfigurar.cfgTaxaServico.value;
	total_parcial	= 0;

	for (i=0; i<=cfgTotalCategs-1; i++) {
		categ 			= document.frmConfigurar["cfgCateg_"+i].value;
		
		try {
			qtd_unico 	= document.frmConfigurar["qtd_unico_"+categ].value;
			
			if (qtd_unico) {
				valor_unico = moeda2float(document.getElementById("valor_unico_"+categ).innerHTML);
				
				document.getElementById("valor_parcial_"+categ).innerHTML = float2moeda(valor_unico * qtd_unico);
				document.getElementById("qtd_total_"+categ).innerHTML = qtd_unico;
				
			} else {
				document.getElementById("valor_parcial_"+categ).innerHTML = "";
				document.getElementById("qtd_total_"+categ).innerHTML = "";
			}
		} catch(err) {}
		
		
		try {
			qtd_masc	= document.frmConfigurar["qtd_masc_"+categ].value;		
			qtd_fem		= document.frmConfigurar["qtd_fem_"+categ].value;	
			
			if (qtd_masc || qtd_fem) {
				valor_masc = moeda2float(document.getElementById("valor_masc_"+categ).innerHTML);
				valor_fem  = moeda2float(document.getElementById("valor_fem_"+categ).innerHTML);
				
				if (!qtd_masc) {
					total_valor_masc = 0;
					qtd_masc = 0;
				} else
					total_valor_masc = valor_masc * qtd_masc;

				if (!qtd_fem) {
					total_valor_fem = 0;
					qtd_fem = 0;
				} else
					total_valor_fem = valor_fem * qtd_fem;
					
				document.getElementById("valor_parcial_"+categ).innerHTML = float2moeda(total_valor_masc + total_valor_fem);
				document.getElementById("qtd_total_"+categ).innerHTML = parseInt(qtd_masc) + parseInt(qtd_fem);
				
			} else {
				document.getElementById("valor_parcial_"+categ).innerHTML = "";
				document.getElementById("qtd_total_"+categ).innerHTML = "";
			}
			
		} catch(err) {}
		
		valor_parcial 	= document.getElementById("valor_parcial_"+categ).innerHTML;
		if (valor_parcial)
			total_parcial = total_parcial + moeda2float(valor_parcial);
	}

	if (total_parcial) {
		document.getElementById("valor_total_parcial").innerHTML = float2moeda(total_parcial);

		taxa_servico	= roundNumber(total_parcial * (cfgTaxaServico/100));
		valor_compra 	= total_parcial + taxa_servico;
		
		document.getElementById("valor_taxa_servico").innerHTML = float2moeda(taxa_servico);
		document.getElementById("valor_total").innerHTML = float2moeda(valor_compra);
		
		//parcelas(float2moeda(valor_compra), 1);
		
		//atualizando hiddens
		document.frmConfigurar.cfg_valor_total_parcial.value 	= float2moeda(total_parcial);
		document.frmConfigurar.cfg_valor_servico.value 			= float2moeda(taxa_servico);
		document.frmConfigurar.cfg_valor_compra.value			= float2moeda(valor_compra);
	}
}

/*
function parcelas(valor, loading) {	
	if (loading) {
		document.getElementById("tableParcelas").style.display='none';
		document.getElementById("loadingParcelas").style.display='block';	
		window.setTimeout("parcelas("+valor+", 0)", 1000);	
		
		var oXmlHttp = zXmlHttp.createRequest();		
		oXmlHttp.open('GET', '/getParcelas.php?valor='+valor, false);
		oXmlHttp.send(null);
		
		var tableParcelas = oXmlHttp.responseText;
		
		if (tableParcelas) document.getElementById("tableParcelas").innerHTML = tableParcelas;

	} else {
		document.getElementById("loadingParcelas").style.display='none';
		document.getElementById("tableParcelas").style.display='block';
	}
}
*/

function validaFinalPedido() {
	preencheu = false;
	botoes = frmPedido.pagamento.length;
	for (i=0;i<botoes;i++) {
		if (frmPedido.pagamento[i].checked) {
			preencheu = true;
			break; 
		}
	}
	
	if (!preencheu) {
		alert("Escolha a forma de pagamento");
		return false;
	} else {
		document.frmPedido.btFinalizar.disabled	= true;
		document.getElementById("txtFinalizacao").innerHTML = "aguarde redirecionamento...";
	}
}

function GravaPedido() {
	var oXmlHttp = zXmlHttp.createRequest();
	
	oXmlHttp.open('GET', '/pagamento_exec.php?action=insert', false);
	oXmlHttp.send(null);

	codigo_pedido = oXmlHttp.responseText;

	if (oXmlHttp.status == 200 && codigo_pedido) {
		document.frmPedido.btFinalizar.disabled	= true;
		//document.getElementById("txtFinalizacao").innerHTML = "uma nova janela foi aberta, faça o pagamento para concluir sua compra";
		
		window.location="/recibo.php";
		
		return false;
	} else {
		alert("Ocorreu um erro ao finalizar a compra, informe ao suporte: " + oXmlHttp.statusText);
		return false;
	} 
}


function float2moeda(num) {
   x = 0;

   if(num<0) {
      num = Math.abs(num);
      x = 1;
   }   if(isNaN(num)) num = "0";
      cents = Math.floor((num*100+0.5)%100);

   num = Math.floor((num*100+0.5)/100).toString();

   if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+'.'
               +num.substring(num.length-(4*i+3));   ret = num + ',' + cents;   if (x == 1) ret = ' - ' + ret;return ret;
}

function moeda2float(moeda){
   moeda = moeda.replace(".","");
   moeda = moeda.replace(",",".");
   return parseFloat(moeda);
}

function roundNumber(rnum) {
   return Math.round(rnum*Math.pow(10,2))/Math.pow(10,2);
}


function logado(on) {
	document.getElementById("loading").style.display='block';
	
	if (on) {
		document.getElementById("box-formu").style.display='none';
		document.getElementById("box-formu2").style.display='block';
	} else {
		document.getElementById("box-formu").style.display='block';
		document.getElementById("box-formu2").style.display='none';
	}

	document.getElementById("loading").style.display='none';

}

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}


function listarSubCategs(valor) {	
	http.open("GET", "/site/modulos/pessoas/produtos.php?id=" + valor + "&action=carregaSubCateg", true);
	http.onreadystatechange = handleHttpResponseCategs;  
	http.send(null);
}

function handleHttpResponseCategs() { 
	campo_select = document.formPesquisa.subcateg;
	
	if (http.readyState == 4) {
		campo_select.options.length = 0;
		results = http.responseText.split(",");		
		
		for (i=0; i < results.length-1; i++ ) {
			string = results[i].split( "|" );

			campo_select.options[i] = new Option( decodeBase64(string[0]), string[1] );
		}
	}
}

function isEmail(field) {	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(field))) { 
		return false;
	} else {
		return true;
	}
}

function trim(field) {
	return field.replace(/^\s*/, "").replace(/\s*$/, "");
}

function validaCadastro() {
	var nome			 = trim(document.formCadastro.nome.value);
	var data_nascimento  = trim(document.formCadastro.data_nascimento.value); 
	var fone_residencial = trim(document.formCadastro.fone_residencial.value); 
	var fone_celular	 = trim(document.formCadastro.fone_celular.value); 
	var validadeCPF		 = validaCPF(document.formCadastro.cpf.value);
	
	if (nome == "") {
		alert("Informe seu nome!");
		document.formCadastro.nome.focus();
		return false;

	} else if (nome.length < 8) {
		alert("Preencha seu nome de forma correta!");
		document.formCadastro.nome.focus();
		return false;

	} else if (data_nascimento == "") {
		alert("Informe sua data de nascimento!");
		document.formCadastro.data_nascimento.focus();
		return false;
		
	} else if (data_nascimento.length < 10) {
		alert("Preencha sua data de nascimento de forma correta!");
		document.formCadastro.data_nascimento.focus();
		return false;

	} else if (fone_residencial == "") {
		alert("Informe um telefone fixo para contato");
		document.formCadastro.fone_residencial.focus();
		return false;

	} else if (fone_residencial.length < 14) {
		alert("Preencha o telefone fixo de forma correta!");
		document.formCadastro.fone_residencial.focus();
		return false;

	/*
	} else if (fone_celular == "") {
		alert("Informe seu telefone celular!");
		document.formCadastro.fone_celular.focus();
		return false;
		
	} else if (fone_celular.length < 14) {
		alert("Celular inválido!");
		document.formCadastro.fone_celular.focus();
		return false;
	*/

	} else if (document.formCadastro.cpf.value.length < 14) {
		alert("CPF inválido!");
		document.formCadastro.cpf.focus();
		return false;
	
	} else if (!validadeCPF) {
		alert("CPF inválido!!");
		document.formCadastro.cpf.focus();
		return false;
		
	} else if (document.formCadastro.sexo.value == "") {
		alert("Informe seu sexo!");
		document.formCadastro.sexo.focus();
		return false;

	} else if (document.formCadastro.endereco.value == "") {
		alert("Informe seu endereço!");
		document.formCadastro.endereco.focus();
		return false;
		
	} else if (document.formCadastro.bairro.value == "") {
		alert("Informe seu bairro!");
		document.formCadastro.bairro.focus();
		return false;

	} else if (document.formCadastro.cep_.value == "") {
		alert("Informe seu CEP!");
		document.formCadastro.cep_.focus();
		return false;
		
	} else if (document.formCadastro.cidade.value == "" || document.formCadastro.cidade.value == "0") {
		alert("Informe sua cidade!");
		return false;

	} else if (!isEmail(document.formCadastro.email.value)) {
		alert("E-mail inválido!");
		document.formCadastro.email.focus();
		return false;
		
	} else if (document.formCadastro.email.value != document.formCadastro.email2.value) {
		alert("E-mails não são iguais!");
		document.formCadastro.email.focus();
		return false;
		
	} else if (document.formCadastro.senha.value == "") {
		alert("Informe sua senha!");
		document.formCadastro.senha.focus();
		return false;
		
	} else if (document.formCadastro.senha.value != document.formCadastro.senha2.value) {
		alert("Senhas não são iguais!");
		document.formCadastro.senha.focus();
		return false;

	} else {
		
		return true;
	}		
}

function validaCPF(cpf){ // Verifica a validade do CPF informado
	var msg = "CPF válido";
	var sch;
	var nRecebeCPF, nSoma, nresultado1, nresultado2, ns, nx;
	var arrNumero = Array(11);

	nRecebeCPF = cpf;
	ns = "";
	for(nx=0;nx<nRecebeCPF.length;nx++){
		sch = nRecebeCPF.substring(nx,nx+1);
		sch = parseInt(sch);
		sch = new String(sch);
		if(sch != "NaN"){
			ns += sch;
		}
	}

	nRecebeCPF = ns

	tudoIgual = 1; // Verifica se todos os números são iguais
	for (i = 1; i < nRecebeCPF.length; i++) {
		if (nRecebeCPF.substring(i-1, i) != nRecebeCPF.substring(i, i+1)){
			tudoIgual = 0;
		}
	}

	if(nRecebeCPF.length != 11){
		msg = "Quantidade de dígitos inferior a quantidade de dígitos de CPF";
		resultado = false;
	}
	else if(tudoIgual == 1){
		msg = "Todos us números são iguais";
		resultado = false;
	}
	else if(nRecebeCPF == "12345678909"){
		msg = "Número de CPF inexistente";
		resultado = false;
	}
	else{
		arrNumero[0] = nRecebeCPF.substring(0,1);
		arrNumero[1] = nRecebeCPF.substring(1,2);
		arrNumero[2] = nRecebeCPF.substring(2,3);
		arrNumero[3] = nRecebeCPF.substring(3,4);
		arrNumero[4] = nRecebeCPF.substring(4,5);
		arrNumero[5] = nRecebeCPF.substring(5,6);
		arrNumero[6] = nRecebeCPF.substring(6,7);
		arrNumero[7] = nRecebeCPF.substring(7,8);
		arrNumero[8] = nRecebeCPF.substring(8,9);
		arrNumero[9] = nRecebeCPF.substring(9,10);
		arrNumero[10] = nRecebeCPF.substring(10,11);

		nSoma = 10 * arrNumero[0] + 9 * arrNumero[1] + 8 * arrNumero[2] + 7 * arrNumero[3] + 6 * arrNumero[4] + 5 * arrNumero[5] + 4 * arrNumero[6] + 3 * arrNumero[7] + 2 * arrNumero[8]
		nSoma = nSoma-(11*parseInt(nSoma/11));

		if(nSoma == 0 || nSoma == 1){
			nresultado1 = 0;
		}
		else{
			nresultado1 = 11-nSoma;
		}

		if(nresultado1 == arrNumero[9]){
			nSoma = arrNumero[0] * 11 + arrNumero[1] * 10 + arrNumero[2] * 9 + arrNumero[3] * 8 + arrNumero[4] * 7 + arrNumero[5] * 6 + arrNumero[6] * 5 + arrNumero[7] * 4 + arrNumero[8] * 3 + arrNumero[9] * 2
			nSoma = nSoma-(11*parseInt(nSoma/11));
			if(nSoma == 0 || nSoma == 1){
				nresultado2 = 0;
			}
			else{
				nresultado2 = 11 - nSoma;
			}

			if(nresultado2 == arrNumero[10]){
				resultado = true;
			}
			else{
				msg = "CPF inválido";
				resultado = false;
			}
		}
		else{
			msg = "CPF inválido";
			resultado = false;
		}
	}
	//resultado = msg;
	return resultado;
}

function validaFormRecomende() {
	var nome_from   = trim(document.frmRecomende.nome_from.value);
	var email_form  = trim(document.frmRecomende.email_form.value);
	var nome_to     = trim(document.frmRecomende.nome_to.value);
	var email_to    = trim(document.frmRecomende.email_to.value);

	if (nome_from == "") {
		alert("Informe seu nome!");
		document.frmRecomende.nome_from.focus();
		return false;
	}

	if (!isEmail(email_form)) {
		alert("E-mail inválido!");
		document.frmRecomende.email_form.focus();
		return false;
	}

	if (nome_to == "") {
		alert("Informe o nome do destinatário!");
		document.frmRecomende.nome_to.focus();
		return false;
	}

	if (!isEmail(email_to)) {
		alert("E-mail inválido!");
		document.frmRecomende.email_to.focus();
		return false;
	}
}

function confirmaIndicacao(trDisplay) {	
	if (!trDisplay) {
		parent.document.getElementById("trConfirmaIndic").style.display='block';
		parent.document.frmRecomende.nome_to.value="";
		parent.document.frmRecomende.email_to.value="";	

		window.setTimeout("confirmaIndicacao(1)", 4000);
	} else {
		parent.document.getElementById("trConfirmaIndic").style.display='none';
	}
}

function senha(form) {
	if (form == 1)
		var email = document.frmLogin.email;		
	else if (form ==2)
		var email = document.frmLogin2.email;
	
	if (!email.value) {
		alert("Informe seu e-mail!");
		email.focus();
	} else {
		window.open("/exec.php?action=senha&email="+email.value+"&form="+form, "hddFrame");
	}
}

function displayMSG(msg, trDisplay) {
	if (!trDisplay) {
		parent.document.getElementById('txtMsg').innerHTML=msg;	
		window.setTimeout("displayMSG('', 1)", 5000);
	} else {
		parent.document.getElementById('txtMsg').innerHTML='';
	}
}

function displayMSG2(msg, trDisplay) {
	if (!trDisplay) {
		parent.document.getElementById('txtMsg2').innerHTML=msg;
		window.setTimeout("displayMSG2('', 1)", 5000);
	} else {
		parent.document.getElementById('txtMsg2').innerHTML='';
	}
}

function logoff() {
	window.open("/exec.php?action=logoff", "hddFrame");
}

function ir(url) {
	window.location=url;	
}

function twVerificaTamanho(target)
{
	var StrLen;
	var nome = 0;
	var adicional;
	var maximo;
	maximo = 140;
	adicional = 0;
	StrLen = adicional;

	if (document.all.comentario.value.length != "" )
	{
		StrLen = StrLen + document.all.comentario.value.length;
	}
	if (StrLen == 1 && document.all.comentario.value.substring(0,1) == " ")
	{
		document.all.comentario.value = "";
		StrLen = StrLen - 1;
	}
	if (StrLen > maximo)
	{
		document.all.comentario.value = document.all.comentario.value.substring(0,maximo-1);
		StrLen = StrLen - 1;
	}
   document.all.caract.value = maximo - StrLen;
}

function twlimpa_msg()
{
	document.all.comentario.value = "";
}

function validaFormComente() {
	var msg = trim(document.frmComentar.comentario.value);
	
	if (msg=="") {
		displayMSG2("Informe sua mensagem! <br><br>");
		return false;
	} 
}

function confirmaExclusao(id) {
	if (window.confirm("Confirma exclusão desta mensagem?")) {
		document.frmComentarios.id.value=id;	
		document.frmComentarios.submit();
	}
}

function validaCarrinho() {
	if (!document.frmConfigurar.cfg_valor_total_parcial.value) {
		alert("Informe a quantidade desejada de cada ingresso!");
		return false;
	}
	
	//alert(document.frmConfigurar.cfg_valor_total_parcial.value);
	//alert(document.frmConfigurar.cfg_valor_servico.value);
	//alert(document.frmConfigurar.cfg_valor_compra.value);
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}

function f_soNumeros(v){
    return v.replace(/\D/g,"")
}

function parcelas(opt) {
	switch (opt) {
		case "visa":
			document.getElementById('parcelas_visa').style.visibility='visible';
			document.getElementById('parcelas_master').style.visibility='hidden';
			document.getElementById('parcelas_diners').style.visibility='hidden';
			break;
		
		case "visa_electron":
			document.getElementById('parcelas_visa').style.visibility='hidden';
			document.getElementById('parcelas_master').style.visibility='hidden';
			document.getElementById('parcelas_diners').style.visibility='hidden';
			break;
			
		case "pagseguro":
			document.getElementById('parcelas_visa').style.visibility='hidden';
			document.getElementById('parcelas_master').style.visibility='hidden';
			document.getElementById('parcelas_diners').style.visibility='hidden';
			break;
			
		case "master":
			document.getElementById('parcelas_visa').style.visibility='hidden';
			document.getElementById('parcelas_master').style.visibility='visible';
			document.getElementById('parcelas_diners').style.visibility='hidden';
			break;
			
		case "diners":
			document.getElementById('parcelas_visa').style.visibility='hidden';
			document.getElementById('parcelas_master').style.visibility='hidden';
			document.getElementById('parcelas_diners').style.visibility='visible';
			break;
	}
}