﻿jQuery.noConflict();

// FUNÇÕES PARA AS ABAS DE WEBMAIL, PAINEL DE CONTROLE E REPRESENTANTE VIRTUAL
jQuery(document).ready(function() {

	//Carregando as páginas
	jQuery(".tab_content").hide(); //Esconde todo o conteudo
	jQuery("ul.tabs li:first").addClass("active1").show(); //Ativa a primeira aba
	jQuery(".tab_content:first").show(); //mostra o conteudo da primeira aba


	//Evento de On Click
	jQuery("ul.tabs li").click(function() {

		jQuery("ul.tabs li").removeClass("active1"); //Remove a classe ativa
		jQuery("ul.tabs li").removeClass("active2"); //Remove a classe ativa
		jQuery("ul.tabs li").removeClass("active3"); //Remove a classe ativa
		
		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		if(activeTab == '#Webmail') { jQuery(this).addClass("active1"); }
		else if(activeTab == '#PainelControle') { jQuery(this).addClass("active2"); }
		else if(activeTab == '#RepresentanteVirtual') { jQuery(this).addClass("active3"); }

		//jQuery("ul.tabs li").removeClass("active"); //Remove a classe ativa
		//jQuery(this).addClass("active"); //Adiciona a classe "active"
		jQuery(".tab_content").hide(); //Esconde conteudo da aba
		

		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

});
jQuery(document).ready(function() {
	function showvalue(arg) {
		alert(arg);
		//arg.visible(false);
} 
try {
		oHandler = jQuery("body select").msDropDown().data("dd");
		//alert($.msDropDown.version);
		//$.msDropDown.create("body select");
		jQuery("#ver").html(jQuery.msDropDown.version);
		} catch(e) {
			alert("Error: "+e.message);
		}
})
	
jQuery(document).ready(function() {
 
	//Set Default State of each portfolio piece
	jQuery(".paging").show();
	jQuery(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = jQuery(".window").width();
	var imageSum = jQuery(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	jQuery(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = jQuery.active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
 
		jQuery(".paging a").removeClass('active'); //Remove all active class
		jQuery.active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		jQuery(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			jQuery.active = jQuery('.paging a.active').next();
			if ( jQuery.active.length === 0) { //If paging reaches the end...
				$active = jQuery('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	jQuery(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
jQuery(".paging a").click(function() {	
		jQuery.active = jQuery(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});
jQuery(document).ready(function() {
	// initialize tooltip
	jQuery(".TooltipExpresso a[title]").tooltip({
	 
	   // tweak the position
	   offset: [10, 2],
	 
	   // use the "slide" effect
	   effect: 'slide'
	 
	// add dynamic plugin with optional configuration for bottom edge
	}).dynamic({ bottom: { direction: 'down', bounce: true } });
});

function verificaFormPainel(form)
{
	if((form.login_name.value=="") || (form.login_name.value=="login") ){
	   alert('Preencha o campo login.');
	}
	else if(form.passwd.value=="" || form.passwd.value=="senha")
		{
			alert('Preencha o campo senha.');
		}
		else if((form.dominio.value=="") || (form.dominio.value=="seudominio.com.br"))
			 {
				alert('Preencha o campo domínio.');
			 
			 }else{
    			form.action="http://cpanel."+form.dominio.value+":2083/";
				form.submit();
			 }

}

function verificaFormEmail(form)
{
	var action = form.imapuser.value;
	var dominio;
	
	if((form.imapuser.value=="") || (form.imapuser.value=="email@dominio.com.br") ){
	   alert('Preencha o campo e-mail.');
	}
	else if(form.pass.value=="" || form.pass.value=="senha")
		{
			alert('Preencha o campo senha.');
		}
		else if(!cad_email(form.imapuser))
   			 {
       		   return false;
			  }
			    else{
					dominio=action.split('@');
					action=dominio[1];
					form.action="http://webmail."+action;
					form.submit();
				}
}

function goChat(){
	window.open('../chat/client.php', 'links', 'width=800,height=600,top=20,left=50,menubar=no,toolbar=no,scrollbars=1,resizable=no,status=no');	
}

function go_pass_one(plano_escolhido){
	document.seleciona_plano.plano.value = plano_escolhido;
	document.seleciona_plano.submit();	
}
function go_pass_two(){
	if(!document.getElementById('dominiocadR').checked && !document.getElementById('dominiocadP').checked && !document.getElementById('dominiocadS').checked ){
		alert("É necessário informar o Tipo de domínio que você pretende registrar.");
	}
	else if((document.seleciona_dominio.dominio.value=="" || document.seleciona_dominio.dominio.value=="sua empresa" )|| document.seleciona_dominio.extensao.value=="" ){
		alert("É necessário informar o domínio que você pretende registrar.");
	}else if(document.getElementById("verificacaodominio").value==""){
		alert("É necessário validar o domínio selecionado.")
	}
	else{
		document.seleciona_dominio.submit();	
	}
}
function go_pass_three(){
	
	if((document.seleciona_servicesadd.reservasdedominio.checked)&&(document.seleciona_servicesadd.dominioreservado.value=="")){
		alert("É necessário informar o domínio a ser reservado. Clique em alterar para registrar um domínio");	
	}else if(verifica_espacoadd()){
		alert("É necessário informar a quantidade a ser reservada.");	
	}else if(verifica_selecionamento_servico()){
		alert("É necessário selecionar pelo menos um serviço.");	
	}
	else{
		document.seleciona_servicesadd.submit();	
	}
}
function verifica_espacoadd(){
	if(document.seleciona_servicesadd.espacoadd){
		if((document.seleciona_servicesadd.espacoadd.checked)&&(document.seleciona_servicesadd.espacoaddqtd.value=="")){
			return true;	
		}else{
			return false;	
		}
	}else{
		return false;	
	}	
}
function verifica_selecionamento_servico(){
	if(document.seleciona_servicesadd.espacoadd){
		return false;	
	}else{
		if(!document.seleciona_servicesadd.ftpmultiusuario.checked && !document.seleciona_servicesadd.pacotesdeemail.checked && !document.seleciona_servicesadd.reservasdedominio.checked && !document.seleciona_servicesadd.autenticacao.checked && !document.seleciona_servicesadd.emailmarketing.checked && !document.seleciona_servicesadd.sitepqempresas.checked && !document.seleciona_servicesadd.comercioeletronico.checked ){
		  return true;
		}
		else{
			return false;	
		}
	}
}

function esqueciMinhaSenha(){
	if(document.autenticacao.user.value=="" || document.autenticacao.user.value=="E-mail"){
		alert("É necessário informar o campo E-MAIL  para solicitar a recuperação de senha.");
		document.autenticacao.user.focus();		
	}else if(!cad_email(document.autenticacao.user)){
		alert("É necessário preencher o campo E-MAIL corretamente.");
		document.autenticacao.user.focus();	
	}else{
		document.autenticacao.remember.value="1";
		document.autenticacao.submit();
	}		
}

function alteraValorCaixaPostal(opcao){
	var valor;	
	if(opcao=="5"){
		valor="R$ 7,90";
	}else if(opcao=="15"){
		valor="R$ 18,00";
	}else if(opcao=="30"){
		valor="R$ 25,00";
	}else if(opcao=="50"){
		valor="R$ 40,00";
	}else if(opcao=="100"){
		valor="R$ 75,00";
	}
	document.getElementById('valorCaixaPostal').innerHTML=valor;	
}

function alteraValorSqlServer(opcao){
	var valor;	
	if(opcao=="200MB"){
		valor="R$ 29,00";
	}else if(opcao=="350MB"){
		valor="R$ 45,00";
	}else if(opcao=="500MB"){
		valor="R$ 65,00";
	}else if(opcao=="1GB"){
		valor="R$ 95,00";
	}	
	document.getElementById('valorSqlServer').innerHTML=valor;	
}

function go_pass_four(tipo){
	if(tipo=="login"){
		if(document.autenticacao.user.value=="" || document.autenticacao.user.value=="E-mail"){
			alert("Informe seu email para acessar seu cadastro.");
			document.autenticacao.user.focus();
		}else if(document.autenticacao.password.value=="" || document.autenticacao.password.value=="Senha"){
			alert("Informe sua senha para acessar seu cadastro.");
			document.autenticacao.password.focus();
		}else{
			document.autenticacao.submit();	
		}
	}else{
		document.autenticacao.action="index.php?goto=contratacao_passo_quatro";
		document.autenticacao.submit();	
	}
}

function Dominio(formulario,dominio,retorno,tipo)
{
	var responded = "";
	if(formulario.extensao.value=="expresso.com.br") { //document.getElementById("imgokfail").src = "imgs/btn_ok.gif"; 
		if(retorno!="false"){
			document.getElementById('verificacaodominio').value="1";								
			document.getElementById('boxRespostaProcura').innerHTML='<h3 style="width:120px;">Subdomínio Expresso Digital ;Clique em "Próximo Passo"</h3>';
		}
		else{
			alert("Subdomínio Expresso Digital.");
		}
	}
	if(formulario.dominio.value == "" || formulario.dominio.value == "sua empresa") { alert("Preencha o domínio desejado.");  }
	else if(formulario.extensao.value == "--------") { alert("Escolha uma extensão para o domínio desejado.");  }
	else {
		ajax = new ajaxInit();
		if(ajax){
			ajax.open("GET", "includes/dominio/dominio.php?dominio="+dominio, true);
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 4) {
		   			if(ajax.status == 200) {
											
		   				result = ajax.responseText;
		   				if(result.indexOf('LIVRE') > 0) {
							if(retorno=="false"){
		   						document.getElementById('Pesquisar').innerHTML="<a href='javascript:toolbarRegistreSubmit(document.frmdom,\""+dominio+"\");' title='Pesquisar' class='btn_prossseguirdominio' style='text-indent:-9000px;'>Prosseguir</a>";
								alert("Domínio disponível.");
							}
							else{
								if(tipo=="busca"){
										document.getElementById('verificacaodominio').value="r";								
										document.getElementById('boxRespostaProcura').innerHTML='<h3 style="width:120px;">Domínio livre. Clique em "Próximo Passo"</h3>';
								}
								else if(tipo=="passo"){
										document.getElementById('verificacaodominio').value="1";								
										document.getElementById('boxRespostaProcura').innerHTML='<h3 style="width:120px;">Domínio livre. Clique em "Próximo Passo"</h3>';
								}
							}
							
		   				}
		   				else {
							if(retorno=="false"){
								document.getElementById('Pesquisar').innerHTML="<a href='javascript:Dominio(document.frmdom,document.frmdom.dominio.value+\".\"+document.frmdom.extensao.value, \"false\");' title='Pesquisar' class='btn_dominioregistrado' style='text-indent:-9000px;'>Pesquisar</a>";
								alert("Domínio registrado.");
							}
							else{
								if(tipo=="busca"){
									//document.getElementById('reservaBox').style.display="none";
									document.getElementById('verificacaodominio').value="h";
									document.getElementById('boxRespostaProcura').innerHTML='<h3 style="width:120px;">Domínio registrado. Se for seu clique em "Próximo Passo"</h3>';
								}
								else if(tipo=='passo'){
									document.getElementById('verificacaodominio').value="1";
									document.getElementById('boxRespostaProcura').innerHTML='<h3 style="width:120px;">Domínio registrado. Se for seu clique em "Próximo Passo"</h3>';
								}
							}
		   				}
		      		}
		      		else {
			        	alert(ajax.statusText);
		      		}
		    	}
		  	}
		  	ajax.send(null);
		}
	}
}

function toolbarRegistreSubmit(formulario, dominio){
	if(formulario.dominio.value+"."+formulario.extensao.value==dominio){
		formulario.reservasdedominio.value= formulario.dominio.value+"."+formulario.extensao.value;
		formulario.submit();	
	}
}

function change_color_dominio(selected){
	if(selected=="S"){
		document.getElementById("utilizar_dominio").style.color="#ec7700";
		document.getElementById("possuo_dominio").style.color="#6D6D6D";
		document.getElementById("registrar_dominio").style.color="#6D6D6D";	
		document.getElementById("subdominio_expresso").selected="selected";
	
	}else if(selected=="R"){
		document.getElementById("utilizar_dominio").style.color="#6D6D6D";
		document.getElementById("possuo_dominio").style.color="#6D6D6D";
		document.getElementById("registrar_dominio").style.color="#ec7700";		
		document.getElementById("DominPadrao").selected="selected";
		
	}else{
		document.getElementById("utilizar_dominio").style.color="#6D6D6D";
		document.getElementById("possuo_dominio").style.color="#ec7700";
		document.getElementById("registrar_dominio").style.color="#6D6D6D";
		document.getElementById("DominPadrao").selected="selected";	
	}
	
	jQuery(document).ready(function() {
				
			try {
					oHandler = jQuery("body select").msDropDown().data("dd");
					//alert($.msDropDown.version);
					//$.msDropDown.create("body select");
					jQuery("#ver").html(jQuery.msDropDown.version);
					} catch(e) {
						alert("Error: "+e.message);
					}
	});
}

function refazerPesquisa(form){
	if(form.verificacaodominio.value=="1"){
		form.verificacaodominio.value="";
		document.getElementById('boxRespostaProcura').innerHTML='<a href="javascript:Dominio(document.seleciona_dominio,document.seleciona_dominio.dominio.value+\'.\'+document.seleciona_dominio.extensao.value,\'true\',\'passo\');" title="Pesquisar" class="btn_pesquisar" style="text-indent:-9000px;float:left;margin-top:15px;margin-left:-28px;">Pesquisar</a>';		
	}
}

function change_price(periodo){
	
	var url="planos.php?periodo="+periodo ;
	ajax = ajaxInit();
		 if(ajax)
		{
		   ajax.open("GET",url, true);

		   ajax.onreadystatechange = function()
		   {
		   		if(ajax.readyState == 4)
		   		{
		   			if(ajax.status == 200)
		   			{
		   				eval(ajax.responseText);
		      		}
		      		else
		      		{
			        	alert(ajax.statusText);
		      		}
		    	}
		  	}
		  	ajax.send(null);
		}	

}

function number(campo){    
	var digits="0123456789"      
	var campo_temp       
	for (var i=0;i<campo.value.length;i++){    
			campo_temp=campo.value.substring(i,i+1)     
			if (digits.indexOf(campo_temp)==-1){         
					campo.value = campo.value.substring(0,i);          
					break;    }    
}}

function seleciona_servico_add(servicoid, checkbox){
	var elemento = "row_"+servicoid;
	var elementoedit="edit_"+servicoid;
	
	if(servicoid=="reservasdedominio"){ var parametro="dominiobr";}else if(servicoid=="pacotesdeemail"){ var parametro="pacotesemail";}else if(servicoid=="autenticacao"){ var parametro="autenticacao";}else if(servicoid=="emailmarketing"){ var parametro = "emailmkt"; }else if(servicoid=="desenvolvimentonews"){ var parametro = "emailmkt";}else if(servicoid=="comercioeletronico"){ var parametro = "comercio_eletronico";}else if(servicoid=="sitepqempresas"){ var parametro = "sitepqempresas";}
			
	if(checkbox.checked){
		document.getElementById(elemento).style.backgroundColor="#d3ffa3";
		if(servicoid=="reservasdedominio"|| servicoid=="pacotesdeemail"|| servicoid=="autenticacao" || servicoid=="emailmarketing" || servicoid=="desenvolvimentonews" || servicoid=="comercioeletronico" || servicoid=="sitepqempresas" ){
			document.getElementById(elementoedit).innerHTML="<img src='imgs/edit.png'  border='0' style='float:left; margin-right:3px;'/><a href='index.php?goto="+parametro+"' class='linklaranja'>Alterar</a>";
			if(servicoid=="emailmarketing"){
				var caixadesenvnews='<li id="row_desenvolvimentonews"><div id="ListServOpcionais"><fieldset><input type="checkbox" onclick="seleciona_servico_add(\'desenvolvimentonews\', this);" name="desenvolvimentonews"><label>Desenvolvimento Newsletter</label></fieldset></div><div id="ListDescOpcionais"><h1>Desenvolvimento da News</h1><input type="hidden" value="Desenvolvimento da News" name="desenvolvimentonewstipo"><div id="edit_desenvolvimentonews"></div></div><div id="ListValorOpcionais"><h1>R$ 200,00</h1></div></li>';
				$(caixadesenvnews).appendTo("#listagemServicosOpcionais");
			}
		}
	}else{
		document.getElementById(elemento).style.backgroundColor="#FFFFFF";	
		if(servicoid=="reservasdedominio"|| servicoid=="pacotesdeemail"|| servicoid=="autenticacao" || servicoid=="emailmarketing" || servicoid=="desenvolvimentonews" || servicoid=="comercioeletronico" || servicoid=="sitepqempresas" ){
			var elementoedit="edit_"+servicoid;
			document.getElementById(elementoedit).innerHTML="";
			if(servicoid=="emailmarketing"){
				$("#row_desenvolvimentonews").remove();
			}	
		}
	}	
}

function change_pessoa(pessoa){
	if(pessoa=="PJ"){
		document.getElementById('link_pessoa').innerHTML="Se você é Pessoa Física <a href='javascript:change_pessoa(\"PF\");' title='Pessoa Física'>clique aqui</a>";
		document.getElementById('type_pessoa').innerHTML="Dados Pessoa Jurídica";
		document.getElementById('box_razaosocial').style.display="";	
		document.getElementById('box_ie').style.display="";
		document.getElementById('label_nome').innerHTML="Nome Completo do Reponsável*";	
		document.getElementById('label_data').innerHTML="Data de Fundação*";
		document.getElementById('label_profissao').innerHTML="Atividade";
		document.getElementById('box_cnpj').style.display="";
		document.getElementById('label_telefone').innerHTML="Telefone Comercial*";
		document.cadastro.tipopessoa.value="PJ";
	}else{
		document.getElementById('link_pessoa').innerHTML="Se você é Pessoa Jurídica <a href='javascript:change_pessoa(\"PJ\");' title='Pessoa Jurídica'>clique aqui</a>";
		document.getElementById('type_pessoa').innerHTML="Dados Pessoa Física";
		document.getElementById('box_razaosocial').style.display="none";
		document.getElementById('box_ie').style.display="none";	
		document.getElementById('label_nome').innerHTML="Nome Completo*";	
		document.getElementById('label_data').innerHTML="Data de Nascimento*";
		document.getElementById('label_profissao').innerHTML="Profissão";
		document.getElementById('box_cnpj').style.display="none";
		document.getElementById('label_telefone').innerHTML="Telefone Residencial*";
		document.cadastro.tipopessoa.value="PF";
	}	
}

function search_cep(cep){
	var url="getcep.php?cep="+cep ;
	ajax = ajaxInit();
		 if(ajax)
		{
		   ajax.open("GET",url, true);

		   ajax.onreadystatechange = function()
		   {
		   		if(ajax.readyState == 4)
		   		{
		   			if(ajax.status == 200)
		   			{
		   				eval(ajax.responseText);
		      		}
		      		else
		      		{
			        	alert(ajax.statusText);
		      		}
		    	}
		  	}
		  	ajax.send(null);
		}	
}

function confirma_solicitacao(){

	if(document.cadastro.tipopessoa.value=="PJ" && document.cadastro.razaosocial.value==""){
		alert("É necessário preencher o campo RAZÃO SOCIAL.");
		document.cadastro.razaosocial.focus();
	}else if(document.cadastro.tipopessoa.value=="PJ" && document.cadastro.ie.value==""){
		alert("É necessário preencher o campo INSCRIÇÃO ESTADUAL.");
		document.cadastro.ie.focus();
	}else if(document.cadastro.tipopessoa.value=="PJ" && document.cadastro.cnpj.value==""){
		alert("É necessário preencher o campo CNPJ.");
		document.cadastro.ie.focus();
	}else if(document.cadastro.nome.value==""){
		alert("É necessário preencher o campo NOME.");
		document.cadastro.nome.focus();
	}else if(document.cadastro.email.value==""){
		alert("É necessário preencher o campo E-MAIL.");
		document.cadastro.email.focus();
	}else if(!cad_email(document.cadastro.email)){
		alert("É necessário preencher o campo E-MAIL corretamente.");
		document.cadastro.email.focus();	
	}else if(document.cadastro.email.value != document.cadastro.emailconfirm.value){
		alert("O E-MAIL de confirmação está diferente do original.");
		document.cadastro.emailconfirm.focus();	
	}
	else if(document.cadastro.rg.value==""){
		alert("É necessário preencher o RG.");
		document.cadastro.rg.focus();
	}
	else if(document.cadastro.cpf.value==""){
		alert("É necessário preencher o CPF.");
		document.cadastro.cpf.focus();
	}else if(document.cadastro.dtanasc.value==""){
		if(document.cadastro.tipopessoa.value=="PF"){
			alert("É necessário preencher o campo Data de Nascimento.");
		}else{
			alert("É necessário preencher o campo Data de Fundação.")
		}
		document.cadastro.dtanasc.focus();
	}else if(document.cadastro.senha.value==""){
		alert("É necessário preencher o campo SENHA.");
		document.cadastro.senha.focus();
	}else if(document.cadastro.senha.value!=document.cadastro.senhaconfirm.value){
		alert("A senha de confirmação está diferente.");
		document.cadastro.senhaconfirm.focus();
	}else if(document.cadastro.telefone.value==""){
		if(document.cadastro.tipopessoa.value=="PF"){
			alert("É necessário preencher o campo TELEFONE RESIDENCIAL.");
		}else{
			alert("É necessário preencher o campo TELEFONE COMERCIAL.")
		}
		document.cadastro.telefone.focus();
	}else if(document.cadastro.endereco.value==""){
		alert("É necessário preencher o campo ENDEREÇO.");
	}else if(document.cadastro.bairro.value==""){
		alert("É necessário preencher o campo BAIRRO.");
	}else if(document.cadastro.cidade.value==""){
		alert("É necessário preencher o campo CIDADE.");
	}else if(document.cadastro.estado.value==""){
		alert("É necessário preencher o campo ESTADO.");
	}else if(!document.getElementById('tipodepagamentoB').checked && !document.getElementById('tipodepagamentoPD').checked && !document.getElementById('tipodepagamentoD').checked){
		alert("É necessário informar o TIPO DE PAGAMENTO.");
	}else if(document.getElementById('tipodepagamentoD').checked && !document.getElementById('depositoBB').checked && !document.getElementById('depositoBradesco').checked && !document.getElementById('depositoItau').checked){
		alert("É necessário informar o BANCO PARA DEPÓSITO.");
	}else if(document.getElementById('tipodepagamentoPD').checked && !document.getElementById('crtHipercard').checked && !document.getElementById('crtAmerican').checked && !document.getElementById('crtAura').checked && !document.getElementById('crtDinners').checked && !document.getElementById('crtMaster').checked && !document.getElementById('crtVisa').checked){
		alert("É necessário informar a BANDEIRA DO CARTÃO que será efetuado o pagamento.");
	}else if(!document.cadastro.TermosDeContrato.checked){
		alert("É necessário estar de acordo com as condições de uso.");
	}else if(document.cadastro.servicosContratados){
		alert("Você não tem nenhum seviço selecionado!");	
	}
	else{
		document.cadastro.submit();	
	}
}

 
function show_contract(){
	if(document.getElementById('contract').style.display=="none"){
		document.getElementById('contract').style.display="";	
	}else{
		document.getElementById('contract').style.display="none";
	}
}

function enviar_contato(form){
	if(form.nome.value==""){
		alert("É necessário preencher o campo NOME.");
		form.nome.focus();	
	}
	else if(form.email.value==""){
		alert("É necessário preencher o campo E-MAIL.");
		form.email.focus();	
	}
	else if(!cad_email(form.email)){
		alert("É necessário preencher o campo E-MAIL corretamente.");
		form.email.focus();	
	}
	else if(form.departamento.value==""){
		alert("É necessário selecionar o DEPARTAMENTO.");
		form.departamento.focus();	
	}
	else if(form.msg.value==""){
		alert("É necessário preencher o campo MENSAGEM.");
		form.msg.focus();	
	}
	else{
		form.submit();	
	}	
}

function cad_email(email)
{
    var texto_email_inva = "É necessário preencher o campo E-MAIL corretamente !";
    var BadChars = "*|,\":<>[]{}`\'';()&$#% ";
    var GoodChars = "@.";
    var posarroba = email.value.indexOf ('@',0);
    if (email.length < 6)
    {
        email.value = "";
        email.focus();
        return false;
    }
    for (var i = 0; i < email.length; i++)
    {
        if (BadChars.value.indexOf(email.charAt(i)) != -1)
        {
            email.value = "";
            email.focus();
            return false;
        }
    }
    for (var i = 0; i < GoodChars.length; i++)
    {
        if (email.value.indexOf(GoodChars.charAt(i)) == -1)
        {
          	email.value = "";
            email.focus();
            return false;
        }
        if (email.value.indexOf(GoodChars.charAt(i),0) == 0)
        {
            
            email.value = "";
            email.focus();
            return false;
        }
        if (email.value.lastIndexOf(GoodChars.charAt(i)) > email.length-3)
        {
           
            email.value = "";
            email.focus();
            return false;
        }
    }
    if(email.value.lastIndexOf('@') > email.value.lastIndexOf('.'))
    {
       
        email.value = "";
        email.focus();
        return false;
    }
    if(email.value.indexOf ('@.',0) != -1 || email.value.indexOf ('.@',0) != -1)
    {
       
        email.value = "";
        email.focus();
        return false;
    }
    if (email.value.indexOf ('@',posarroba+1) != -1)
    {
       
        email.value = "";
        email.focus();
        return false;
    }
    return true;
}
