//verifica se CPF já existe no Banco de dados 
function validaCPFCNPJ(url, metodo, modo)
{
        var cpfcnpj = document.getElementById('dadospasso1').cpfcnpj.value;
        remoto  = new ajax();
		// verifica se está marcado Jurídica ou física (dá o golpe através do dia de nascimento)
        if (document.getElementById('dadospasso1').dia.disabled == 1){
		xmlhttp = remoto.enviar(url + "?cpfcnpj=" + cpfcnpj + "&pessoa=J", metodo, modo );
		}else{
		xmlhttp = remoto.enviar(url + "?cpfcnpj=" + cpfcnpj + "&pessoa=F", metodo, modo );
		}
		if(xmlhttp == "True") {
                document.getElementById('cpfcnpj').className = 'forminvalido';
                document.getElementById('alerta').className = 'alerta2';
                if (document.getElementById('dadospasso1').dia.disabled == 1){
					document.getElementById("alerta").innerHTML = 'Esse CNPJ já está cadastrado!';
				}else{
					document.getElementById("alerta").innerHTML = 'Esse CPF já está cadastrado!';
				}
        } else {
                document.getElementById('cpfcnpj').className = '';
                document.getElementById('alerta').className = '';
                document.getElementById("alerta").innerHTML = '';
		}       
}
//Avaliação Cliente
function votaCliente(url,metodo,modo,iddiv)
{
	vota = new ajax();
	xmlhttp = vota.enviar(url,metodo,modo);

	if (xmlhttp != ""){
		
		document.getElementById('votacao'+iddiv).className = 'alerta2';
		document.getElementById('votacao'+iddiv).innerHTML = xmlhttp;
	}
}
// Testa Usuario
function testaUsuario(url,metodo,modo)
{
		remoto  = new ajax();
		usuario = document.getElementById("usuarioCliente").value;
		xmlhttp = remoto.enviar(url+'&usuario='+usuario,'POST',false);
		if(xmlhttp == "True") {
			document.getElementById("alertaUsuario").innerHTML = 'Usuário já existe!';
			return false;
		}else{
			document.getElementById("alertaUsuario").innerHTML = '';
		}
}
//Filtra Cidade
function filtraCidade(url, metodo, modo)
{
        var cidade = document.getElementById('dadospasso1').cidade.value;
        remoto  = new ajax();
		xmlhttp = remoto.enviar(url + "?cidade=" + cidade, metodo, modo );
	
		if(xmlhttp != "") {
                document.getElementById("divbairro").innerHTML = xmlhttp;
        }       
}
//Filtra Bairro
function filtraBairro(url, metodo, modo)
{
        var bairro = document.getElementById('dadospasso1').bairro.value;
        remoto  = new ajax();
		xmlhttp = remoto.enviar(url + "?bairro=" + bairro, metodo, modo );
	
		if(xmlhttp != "") {
                document.getElementById("divlogradouro").innerHTML = xmlhttp;
        }       
}
//Filtra Cidade do Topo
function filtraCidadeTopo(url, metodo, modo)
{
        var cidade = document.getElementById('dadostopo').cidadetopo.value;
        remoto  = new ajax();
		xmlhttp = remoto.enviar(url + "?cidadetopo=" + cidade, metodo, modo );
	
		if(xmlhttp != "") {
                document.getElementById("divbairrotopo").innerHTML = xmlhttp;
        }       
}
//Filtra Categoria
function filtraCategoria(url, metodo, modo)
{
        var categoria = document.getElementById('dadospasso2').categoriapasso2.value;
        remoto  = new ajax();
		xmlhttp = remoto.enviar(url + "?categoriapasso2=" + categoria, metodo, modo );
	
		if(xmlhttp != "") {
                document.getElementById("divsubcategoriapasso2").innerHTML = xmlhttp;
        }       
}
//Preenche endereço automaticamente
function preencheCEP(url, metodo, modo)
{
        var cep = document.getElementById('dadospasso1').cep.value;
        remoto  = new ajax();
		if (!cep == ""){
			xmlhttp = remoto.enviar(url + "?ceppasso1=" + cep, metodo, modo );
	
			if(xmlhttp != "True") {
				document.getElementById("preencheCEP").innerHTML = xmlhttp;
        	}
		}
}
//Máscara CEP/CPF/etc...
function formatar_mascara(src, mascara)
{
	var campo = src.value.length;
	var saida = mascara.substring(0,1);
	var texto = mascara.substring(campo);
	if(texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}
//Define numero de caracteres em um textarea
function maxChar(maxchar,idshow)
{
	idshow.value = maxchar - document.dados.jj.value.length;
}
//Desatica Nascimento
function desativaNascimento()
{
	document.dados.dia.disabled = 1;
	document.dados.mes.disabled = 1;
	document.dados.ano.disabled = 1;
	document.getElementById('namecpfcnpj').innerHTML = 'CNPJ';
	document.getElementById('cpfcnpj').setAttribute('maxlength', 14);
	document.getElementById('cpfcnpj').setAttribute('onblur', 'javascript:ValidaCNPJ(this.value,document.dados);');	
}
//Ativa data de nascimento
function ativaNascimento()
{
	document.dados.dia.disabled = 0;
	document.dados.mes.disabled = 0;
	document.dados.ano.disabled = 0;
	document.getElementById('namecpfcnpj').innerHTML = 'CPF';
	document.getElementById('cpfcnpj').setAttribute('maxlength', 11);
	document.getElementById('cpfcnpj').setAttribute('onblur', 'javascript:Verifica_cpf(document.dados);');		
}
//Desativa data de nascimento
function desativaHorario()
{
	if (document.dados.horaAbre.value == "24") {
		document.dados.horaFecha.disabled = 1;
	}
	else{
		document.dados.horaFecha.disabled = 0;
	}
}
// Funções da página Resultados
$(document).ready(function(){
	
	$(".toggle_container").hide();

	$("h2.trigger").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});
	
	$("h2.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("slow,");
	});

});

//Larger thumbnail preview 
$(document).ready(function(){
$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '9998'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-50px', 
			marginLeft: '-110px', 
			top: '50%', 
			left: '50%', 
			width: '350px', 
			height: '350px',
			padding: '0px' 
		}, 200);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '90px', 
			height: '60px', 
			padding: '5px'
		}, 400);
});
//Swap Image on Click
$("ul.thumb li a").click(function() {
		
		var mainImage = $(this).attr("href"); //Find Image Name
		$("#main_view img").attr({ src: mainImage });
		return false;		
	});
 
});
//Função desconhecida (Robersom)
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	//Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})


//Arredondamento
$(document).ready(function(){

$("div.destaquesbox").corner("15px");
$("div#conteudo").corner("15px");
$("div#vendedor").corner("15px");
$("div#todasascetegorias").corner("15px");
$("div#contatos").corner("15px");
$("div#anunciar").corner("15px");
$("div#empregos").corner("15px");
$("div#representantes").corner("15px");
$("div#faq").corner("15px");
$("div#bemvindo").corner("15px");
$("div#comparar").corner("15px");
$("div#clientes").corner("15px");
$("div#pacotes").corner("15px");
$("div#anunciar").corner("15px");
$("div.aeallpg").corner("8px");
$("div.aepgini").corner("8px");
$("div.aedestaque").corner("8px");
$("div.aebanner").corner("8px");
$("div#bemvindo").corner("15px");
$("div.chat").corner("10px");
$("div.boxchamadachatvendedor").corner("8px");
$("div.menuabadois").corner("6px");
$("div.agenda").corner("6px");



});
// Jquery Lightbox
$(document).ready(function(){
				//Examples of how to assign the ColorBox event to elements.
				$("a[rel='jack']").colorbox({transition:"fade"});
				$("a[rel='dogs']").colorbox({transition:"elastic"});
				$("a[rel='river']").colorbox({transition:"none", width:"75%", height:"75%"});
				$(".slideshow").colorbox({slideshow:true});
				$("a.single").colorbox({}, function(){
					alert('Howdy, this is an example callback.');
				});
				$("a[title='Homer Defined']").colorbox();
				$(".flash").colorbox({href:"../content/flash.html"});
				$("a[href='login.asp']").colorbox({width:"650px", height:"380px", iframe:false});
				$("a[href='selecionarsubcategorias.asp']").colorbox({width:"55%", height:"50%", iframe:false});
				$("a[href='notificacoes.asp']").colorbox({width:"800px", height:"600px", iframe:false});
				$("a[href='falarcomvendedormsg.asp']").colorbox({width:"50%", height:"50%", iframe:false});
				$("a[href='dadosclientes.asp']").colorbox({width:"50%", height:"50%", iframe:false});
				$("a[href='loginVendedor.asp']").colorbox({width:"650px", height:"380px", iframe:false});		
				$("a[href='telefonesUteis.asp']").colorbox({width:"400px", height:"500px", iframe:false});		
				
				//Example of preserving a JavaScript event for inline calls.
				$("#click").click(function(){ 
					$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
					return false;
				});
				$("#inline").colorbox({width:"50%", inline:true, href:"#inline_example1", title:"hello"});
			});
//Validação campos vazios
function validaForm(){
d = document.dados;
        //validar nome
        if (d.nomeCandidato.value == ""){
             d.nomeCandidato.focus();
             d.nomeCandidato.value = "Campo Obrigatório";
			 d.nomeCandidato.style.color = 'red';
		 	return false;
        }
        //validar data de nascimento
        var dia1 = parseInt(d.dia.value)
        var mes1 = d.mes.value
        switch (mes1) {
  case '02':
         if  (dia1 > 29) 
		alert("Data não existe, favor corrigir!");
		break;
  case '04':
         if  (dia1 > 30) 
		alert("Data não existe, favor corrigir!");
		break;
  case '06':
         if  (dia1 > 30) 
		alert("Data não existe, favor corrigir!");
         break;
  case '09':
         if  (dia1 > 30) 
		alert("Data não existe, favor corrigir!");
         break;
  case '11':
         if  (dia1 > 30) 
		alert("Data não existe, favor corrigir!");
         break;
        }
		//validar email
         if (d.email.value == ""){
                   d.email.focus();
				   d.email.value = "Campo Obrigatório";
				   d.email.style.color = 'red';
				   return false;
         }
         //validar email(verificao de endereco eletrônico)
         parte1 = d.email.value.indexOf("@");
         parte2 = d.email.value.indexOf(".");
         parte3 = d.email.value.length;
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
                   alert ("Formato de e-mail inválido!");
                   d.email.focus();
                   return false;
         }
         //validar telefone
         if (d.telefone1.value == "" || d.ddd1.value == ""){
                   d.telefone1.focus();
				   d.telefone1.value = "Campo Obrigatório";
				   d.telefone1.style.color = 'red';
				   return false;
         }
		//validar endereco
		          if (d.endereco.value == ""){
                   d.endereco.focus();
				   d.endereco.value = "Campo Obrigatório";
				   d.endereco.style.color = 'red';
				   return false;
         }
		//validar cidade
		          if (d.cidade.value == ""){
                   d.cidade.focus();
				   d.cidade.value = "Campo Obrigatório";
				   d.cidade.style.color = 'red';
				   return false;
         }
		//validar bairro
         if (d.bairro.value == ""){
                   d.bairro.focus();
				   d.bairro.value = "Campo Obrigatório";
				   d.bairro.style.color = 'red';
				   return false;
         }
         //validar telefone(verificacao se contem apenas numeros)
         if (isNaN(d.telefone1.value)){
                   alert ("O campo Telefone deve conter apenas numeros!");
                   d.telefone1.focus();
                   return false;
         }
         //validar telefone(verificacao se contem apenas numeros)
         if (foneReferencia.value != ""){
		 	if (isNaN(d.foneReferencia.value)){
                   alert ("O campo Telefone da Empresa deve conter apenas numeros!");
                   d.foneReferencia.focus();
                   return false;
         	}
		 }
		 return true;
}

//Valida Passo 1
function validaPasso1(){
d = document.dados;

		//validar plano
         if (!document.getElementById('radioPlano1').checked && !document.getElementById('radioPlano2').checked && !document.getElementById('radioPlano3').checked ){
                   alert('Selecione um pacote!');
				   document.getElementById('radioPlano1').focus();
				   return false;
         }
		//validar pessoa (J ou F)
         if (!document.getElementById('pessoaf').checked && !document.getElementById('pessoaj').checked){
				   alert('Selecione o tipo de anunciante!');
				  document.getElementById('pessoaj').focus();
				   return false;
         }
		//validar CPF / CNPJ
		   if ((document.getElementById('cpfcnpj').className == "alerta2") || (document.getElementById('cpfcnpj').value == "")){
					document.getElementById('alerta').innerHTML = 'Favor preencher corretamente!'+document.getElementById('radioPlano1').checked;
					document.getElementById('cpfcnpj').focus();
					return false;
           }else if (document.getElementById('pessoaf').checked && document.getElementById('pessoaf').value == "F" && document.getElementById('cpfcnpj').value.length != 11){
					document.getElementById('alerta').innerHTML = 'Favor preencher corretamente!';
					document.getElementById('cpfcnpj').focus();
					return false;
		   }else if (document.getElementById('pessoaj').checked && document.getElementById('pessoaj').value == "J" && document.getElementById('cpfcnpj').value.length != 14){
					document.getElementById('alerta').innerHTML = 'Favor preencher corretamente!';
					document.getElementById('cpfcnpj').focus();
					return false;
		   }
		   
		//validar cidade
         if (d.cidade.value == "0"){
				   alert('Selecione a cidade!');
				   d.cidade.focus();
				   return false;
         }
		//validar bairro
         if (d.bairro.value == "0"){
				   alert('Selecione o bairro!');
				   d.bairro.focus();
				   return false;
         }
		//validar logradouro
         if (d.logradouro.value == "0"){
				   alert('Selecione o logradouro!');
				   d.logradouro.focus();
				   return false;
         }
		//validar número
         if (d.numero.value == ""){
					document.getElementById("alertaNumero").innerHTML = 'Campo obrigatório!';
					d.numero.focus();
				    return false;
         }else{
					document.getElementById("alertaNumero").innerHTML = '';
		 }
		//validar responsável
         if (d.responsavel.value == ""){
					document.getElementById("alertaResponsavel").innerHTML = 'Campo obrigatório!';
					d.responsavel.focus();
				    return false;
         }else{
					document.getElementById("alertaResponsavel").innerHTML = '';
		 }
          //validar email(verificao de endereco eletrônico)
         parte1 = d.email.value.indexOf("@");
         parte2 = d.email.value.indexOf(".");
         parte3 = d.email.value.length;
		 if (d.email.value == ""){
					document.getElementById("alertaEmail").innerHTML = 'Campo Obrigatório!';
					d.email.focus();
		 }else{
					document.getElementById("alertaEmail").innerHTML = '';
		 }
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
					document.getElementById("alertaEmail").innerHTML = 'E-mail Inválido!';
					d.email.focus();
                    return false;
         }else{
					document.getElementById("alertaEmail").innerHTML = '';
		 }

		//validar DDD e telefone
         if ((d.ddd1.value == "" || d.telefone1.value == "") && (d.ddd2.value == "" || d.telefone2.value == "")){
					document.getElementById("alertaTelefone").innerHTML = 'Preencha pelo menos um número de telefone"';
					d.ddd1.focus();
				    return false;
         }		 					
         //validar telefone(verificacao se contem apenas numeros)
         if (isNaN(d.telefone1.value) || isNaN(d.telefone2.value)){
					document.getElementById("alertaTelefone").innerHTML = 'No telefone devem conter somente números"';
					d.ddd1.focus();
                   return false;
         }
		 return true;
}
//Valida Passo 2
function validaPasso2(){
d = document.dados;

		//valida razão
         if (d.razao.value == ""){
					document.getElementById("alertaRazao").innerHTML = 'Campo obrigatório!';
					d.razao.focus();
				   return false;
         }else{
					document.getElementById("alertaRazao").innerHTML = '';
		 }
		//validar slogan
         if (d.slogan.value == ""){
					document.getElementById("alertaSlogan").innerHTML = 'Campo obrigatório!';
					d.slogan.focus();
				   return false;
         }else{
					document.getElementById("alertaSlogan").innerHTML = '';
		 }
         //validar descrição
         if (d.descricao.value.length < 30){
					document.getElementById("alertaDescricao").innerHTML = 'Descrição deve ter no mínimo 30 caracteres!';
					d.descricao.focus();
				   return false;
         }else{
					document.getElementById("alertaDescricao").innerHTML = '';
					if (d.descricao.value.length > 400){
						document.getElementById("alertaDescricao").innerHTML = 'Descrição deve ter no máximo 400 caracteres!';
						return false;
					}else{
						document.getElementById("alertaDescricao").innerHTML = '';
					}
		 }
		 if (d.categoriapasso2.value == "0" && d.naoAchei.value ==""){
		 			alert('Selecione uma categoria!');
					d.categoriapasso2.focus();
					return false;
		 }
		 if (d.subcategoria1.value == d.subcategoria2.value || (d.subcategoria2.value == d.subcategoria3.value && d.subcategoria3.value!= "0" ) || d.subcategoria1.value == d.subcategoria3.value){
		 			document.getElementById("alertaSub").innerHTML = 'Subcategorias não podem ser iguais!';
					d.subcategoria1.focus();
					return false;
		 }else{
		 			document.getElementById("alertaSub").innerHTML = '';
		 }
		 return true;
}
//Valida Passo 3
function validaPasso3(){
	d = document.dados;
		//validar código do vendedor
         if (d.codVendedor.value != ""){
//		AJAX			document.getElementById("alertaCodVendedor").innerHTML = 'Campo obrigatório!';
//		AJAX			d.codVendedor.focus();
//				   return false;
         }else{
//					document.getElementById("alertaCodVendedor").innerHTML = '';
		 }
         //validar usuario
         if (d.usuarioCliente.value.length < 2){
					document.getElementById("alertaUsuario").innerHTML = 'Usuário deve ter no mínimo 2 caracteres!';
					d.usuarioCliente.focus();
				   return false;
         }else{
		 	return testaUsuario('ajax.asp?testaUsuario=1','POST',false);
		 }
         //validar email(verificao de endereco eletrônico)
         parte1 = d.loginCliente.value.indexOf("@");
         parte2 = d.loginCliente.value.indexOf(".");
         parte3 = d.loginCliente.value.length;
		 if (d.loginCliente.value == ""){
					document.getElementById("alertaLogin").innerHTML = 'Campo Obrigatório!';
					d.loginCliente.focus();
		 }else{
					document.getElementById("alertaLogin").innerHTML = '';
		 }
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
					document.getElementById("alertaLogin").innerHTML = 'E-mail Inválido!';
					d.loginCliente.focus();
                    return false;
         }else{
					document.getElementById("alertaLogin").innerHTML = '';
		 }
		 //validar aceito contrato
         if (!d.aceito.checked){
					document.getElementById("alertaContrato").innerHTML = 'Você deve aceitar o contrato para prosseguir!';
				   	d.aceito.focus();
				   	return false;
         }else{
					document.getElementById("alertaContrato").innerHTML = '';
		 }
}
//Caracteres
function limita(input,div,num){
	falta = num - document.getElementById(input).value.length;
	document.getElementById(div).innerHTML = falta + ' Caracteres restantes.';
}

//Valida suporte (vendedor/cliente)
function validaSuporte(){
d = document.suporte;
        //validar mensagem
        if (d.mensagem.value == ""){
			document.getElementById("alertaMensagem").innerHTML = 'Campo Obrigatório!';
			d.mensagem.focus();
		 	return false;
        }else{
			document.getElementById("alertaMensagem").innerHTML = '';	
		}
        //validar problema
        if (d.problema.value == "0"){
			document.getElementById("alertaProblema").innerHTML = 'Por favor, selecione o tipo de problema!';
			d.problema.focus();
		 	return false;
        }else{
			document.getElementById("alertaProblema").innerHTML = '';	
		}
return true;
}

function validaContatosLateral(){
d = document.contato;
        //validar nome
        if (d.nomeContato.value == ""){
             d.nomeContato.focus();
             d.nomeContato.value = "Campo Obrigatório";
			 d.nomeContato.style.color = 'red';
		 	return false;
        }
		
		//validar email
        if (d.emailContato.value == ""){
             d.emailContato.focus();
			 d.emailContato.value = "Campo Obrigatório";
			 d.emailContato.style.color = 'red';
			 return false;
        }
         //validar emailContato(verificao de endereco eletrônico)
         parte1 = d.emailContato.value.indexOf("@");
         parte2 = d.emailContato.value.indexOf(".");
         parte3 = d.emailContato.value.length;
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
                   alert ("Formato de e-mail inválido!");
                   d.emailContato.focus();
                   return false;
         }
		//validar mensagemContato
         if (d.mensagemContato.value == ""){
                   d.mensagemContato.focus();
				   d.mensagemContato.value = "Campo Obrigatório";
				   d.mensagemContato.style.color = 'red';
				   return false;
         }
		 return true;
}
//Validação CPF
<!--
function Verifica_cpf(formulario) {
var cpf = formulario.cpfcnpj.value; // Recebe o valor digitado no campo


// Aqui começa a checagem do cpf
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = cpf.substr(9, 2); // Retira os dois últimos dígitos do número informado

// Desemembra o número do cpf na array DIGITO
for (I=0; I<=8; I++) {
  DIGITO[I] = cpf.substr( I, 1);
}

// Calcula o valor do 10º dígito da verificação
POSICAO = 10;
SOMA = 0;
   for (I=0; I<=8; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
}
   else{
       DIGITO[9] = 11 - DIGITO[9];
}

// Calcula o valor do 11º dígito da verificação
POSICAO = 11;
SOMA = 0;
   for (I=0; I<=9; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[10] = SOMA % 11;
   if (DIGITO[10] < 2) {
        DIGITO[10] = 0;
   }
   else {
        DIGITO[10] = 11 - DIGITO[10];
   }

// Verifica se os valores dos dígitos verificadores conferem
DV = DIGITO[9] * 10 + DIGITO[10];
   if (DV != DV_INFORMADO) {
      formulario.cpfcnpj.className = 'forminvalido';
      document.getElementById('alerta').className = 'alerta2';
      document.getElementById("alerta").innerHTML = 'Esse CPF é inválido!';
      return false;
   } else {
	   validaCPFCNPJ('ajax.asp', 'POST', false);
	   
   }
}
//-->

//Validação CPF2

function Verifica_cpf2(formulario) {
var cpf = formulario.cpfcnpj.value; // Recebe o valor digitado no campo


// Aqui começa a checagem do cpf
var POSICAO, I, SOMA, DV, DV_INFORMADO;
var DIGITO = new Array(10);
DV_INFORMADO = cpf.substr(9, 2); // Retira os dois últimos dígitos do número informado

// Desemembra o número do cpf na array DIGITO
for (I=0; I<=8; I++) {
  DIGITO[I] = cpf.substr( I, 1);
}

// Calcula o valor do 10º dígito da verificação
POSICAO = 10;
SOMA = 0;
   for (I=0; I<=8; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[9] = SOMA % 11;
   if (DIGITO[9] < 2) {
        DIGITO[9] = 0;
}
   else{
       DIGITO[9] = 11 - DIGITO[9];
}

// Calcula o valor do 11º dígito da verificação
POSICAO = 11;
SOMA = 0;
   for (I=0; I<=9; I++) {
      SOMA = SOMA + DIGITO[I] * POSICAO;
      POSICAO = POSICAO - 1;
   }
DIGITO[10] = SOMA % 11;
   if (DIGITO[10] < 2) {
        DIGITO[10] = 0;
   }
   else {
        DIGITO[10] = 11 - DIGITO[10];
   }

// Verifica se os valores dos dígitos verificadores conferem
DV = DIGITO[9] * 10 + DIGITO[10];
   if (DV != DV_INFORMADO) {
      formulario.cpfcnpj.className = 'forminvalido';
      document.getElementById('alerta').className = 'alerta2';
      document.getElementById("alerta").innerHTML = 'Esse CPF é inválido!';
      return false;
   } else {
	   formulario.cpfcnpj.className = 'form';
      document.getElementById('alerta').className = '';
      document.getElementById("alerta").innerHTML = '';
	  document.getElementById("cpfcnpj").focus();
	  return true;
	   
   }
}
//-->



//Validação CNPJ
function ValidaCNPJ(cnpj,formulario) {

  var i = 0;
  var l = 0;
  var strNum = "";
  var strMul = "6543298765432";
  var character = "";
  var iValido = 1;
  var iSoma = 0;
  var strNum_base = "";
  var iLenNum_base = 0;
  var iLenMul = 0;
  var iSoma = 0;
  var strNum_base = 0;
  var iLenNum_base = 0;

  l = cnpj.length;
  for (i = 0; i < l; i++) {
        caracter = cnpj.substring(i,i+1)
        if ((caracter >= '0') && (caracter <= '9'))
           strNum = strNum + caracter;
  };

  strNum_base = strNum.substring(0,12);
  iLenNum_base = strNum_base.length - 1;
  iLenMul = strMul.length - 1;
  for(i = 0;i < 12; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;

  strNum_base = strNum_base + iSoma;
  iSoma = 0;
  iLenNum_base = strNum_base.length - 1
  for(i = 0; i < 13; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10)

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;
  strNum_base = strNum_base + iSoma;
  if(strNum != strNum_base){
      formulario.cpfcnpj.className = 'forminvalido';
      document.getElementById('alerta').className = 'alerta2';
      document.getElementById("alerta").innerHTML = 'Esse CNPJ é inválido!';
	  return (false);
  } else {
	   validaCPFCNPJ('ajax.asp', 'POST', false);
	   
   }

}

//Abas do Menu do Cliente
$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});

//Estrelas Votação
function estrelas(){
$("#stars-wrapper2").stars({
	inputType: "select"
});
}

//Relógio da Inicial


function UR_Start() 
{
	UR_Nu = new Date;
	UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
	document.getElementById("ur").innerHTML = UR_Indhold;
	setTimeout("UR_Start()",1000);
}
function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}