// JavaScript Document (gian, 21/03/06)
function CheckForm(form){
	var numElement = eval(document.getElementById(form).length);
    var i;
    var Obj  = document.getElementById(form);
    var erro = "";
    
    for (i=0;i<numElement;i++){
        
        var index = Obj.elements[i].selectedIndex;
        
        if((Obj.elements[i].type=='text')&&(Obj.elements[i].title!='')&&(Obj.elements[i].value=='')){
            erro +="preencha o campo: "+Obj.elements[i].title+".\n";
            Obj.elements[i].focus();
            break;
        }
        
        if((Obj.elements[i].type=='select-one')&&(Obj.elements[i].title!='')&&(Obj.elements[i].options[index].index==0)){
            erro +=Obj.elements[i].title+". deve ser selecionado um item.\n";
            Obj.elements[i].focus();
            break;
        }
        
        if((Obj.elements[i].type=='password')&&(Obj.elements[i].title!='')&&(Obj.elements[i].value=='')){
            erro +="preencha o campo: "+Obj.elements[i].title+".\n";
            Obj.elements[i].focus();
            break;
        }
        
        if((Obj.elements[i].type=='textarea')&&(Obj.elements[i].title!='')&&(Obj.elements[i].value=='')){
            erro += Obj.elements[i].title+".\n";
            Obj.elements[i].focus();
            break;
        }
    }
    
    //alert(erro);
    
    if(erro!=""){
        alert("Por favor, \n\n"+erro);
        return true; /*Ocorreu erro*/ 
    }else{
        return false;
    }
    
}

function horizontal() { 
	
	//alert('Oiii');

	var navItems = document.getElementById("barraCPT").getElementsByTagName("li"); 
	        
	for (var i=0; i< navItems.length; i++) { 
		if((navItems[i].className == "linkSiteAssociados") || (navItems[i].className == "subMenu")) 
		{ 
			if(navItems[i].getElementsByTagName('ul')[0] != null) 
			{ 
				navItems[i].onmouseover=function() {
					this.getElementsByTagName('ul')[0].style.display="block";
					//this.style.backgroundColor = "#f9f9f9";
				}; 
				navItems[i].onmouseout=function() {
					this.getElementsByTagName('ul')[0].style.display="none";
					//this.style.backgroundColor = "#00559F";
				}; 
			} 
		} 
	} 

} 

function CheckFormLigueMe(form){
	//	
	var erro = CheckForm(form);
	//
	if(erro==true) return false;
	
	if(document.getElementById('ddd_ligamos').value=='00' || document.getElementById('ddd_ligamos').value.length<2){
		alert('Por favor, informe um número de DDD válido!');
		document.getElementById('ddd_ligamos').focus;
		return false;
	}	
		
	if(document.getElementById('numero_ligamos').value.length<8 || document.getElementById('numero_ligamos').value=='00000000'){
		alert('Por favor, informe um número de telefone válido!');
		document.getElementById('numero_ligamos').focus;
		return false;
	}
	
	//
	if(erro==false){
		//
		dados = jQuery("#form_ligamos").serialize();
		//
		$.ajax({ 
			type: "POST", 
			url: "/classes/ligamosParaVoce.php", 
			data: dados, 
			success: function(data) {
			    //
				alert('Dados enviados com sucesso!\nPor favor, aguarde que já entramos em contato com você!');
				//
				Limpa();
				
			} 
		});
		
	}	
		
}


function Limpa(){
    var input    = document.getElementsByTagName('input')
    var select   = document.getElementsByTagName('select')
    var textarea = document.getElementsByTagName('textarea')
                
    for(var i=0; i<select.length; i++)
        select[i].selectedIndex = 0;
                        
        for(var i=0; i<textarea.length; i++)
            textarea[i].value = '';
                                           
        for(var i=0; i<input.length; i++)
            switch (input[i].type){
                case 'text'     :   input[i].value    = ''; break;
                case 'radio'    :   input[i].checked  = ''; break;
                case 'checkbox' :   input[i].checked  = ''; break; 
                case 'password' :   input[i].value    = ''; break; 
            }
                                            
}

function ajax() {
	  var xmlhttp;
	  /*@cc_on
	  @if (@_jscript_version >= 5)
		try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
			xmlhttp = false;
		  }
		}
	  @else
	  xmlhttp = false;
	  @end @*/
	  //if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try{
			xmlhttp = new XMLHttpRequest();
		}catch(ee){
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(E){
					xmlhttp = false;
				}
			}
		}	  return xmlhttp;
	}
		
	function dollar() {
		http=ajax();
		http.open("POST","/pieces/cotacao_dollar.php",true);
		http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http.send("iniciar=");
		http.onreadystatechange = function() {
			if (http.readyState == 4) {
				document.getElementById("cotdollar").innerHTML = http.responseText;	
				http=null;
			}
		}
	}
	
	function Janela(theURL,winName,features) {
		var teste = window.open(theURL,winName,features);
		if(teste != null) teste.focus();
	}
	
	var reEmail1 = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	function doEmail(pStr, pFmt)
	{
		eval("reEmail = reEmail" + pFmt);
		if (reEmail.test(pStr)) {
			return true;
		} else if (pStr != null && pStr != "") {
			return false;
		}
	} // doEmail
	
	function ckemail(trab){
		trab=trab.toLowerCase()
		var novo=false
		if ((trab.indexOf("@", 2) == -1) || (trab.indexOf(".", 3) == -1) || (trab.indexOf("@.", 1) != -1) || (trab.indexOf(".@", 1) != -1)) novo=true	
		var pode="0123456789.@_-abcdefghijklmnopqrstuvwxyz"
		for (i=0;i<=trab.length;i++){
			swork = trab.charAt(i);
			if (pode.indexOf(swork, 0) == -1) novo = true		
		}
		return novo
	}
		
	function ccalend(acao,mes,ano) {
		document.getElementById("calendario").innerHTML = "<p align='center'>Aguarde...</p>";
		http=ajax();
		http.open("POST","/pieces/calendario.php",true);
		http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http.send("load=true&ano="+ano+"&mes="+mes);
		http.onreadystatechange = function() {
			if (http.readyState == 4) {
				document.getElementById("calendario").innerHTML = http.responseText;	
				http=null;
			}
		}	
	}

	function fechabanner() {
		document.getElementById("banner_lateral").style.display="none";	
		http=ajax();
		http.open("GET","/pieces/fechar_banner_lateral.php",true);
		http.send(null);
		http=null;
	}

	MateriasPassadasVisivel = false;
	document.onmouseup = function() {
		if(MateriasPassadasVisivel) {
			document.getElementById("materiasEdicaoAnterior").style.visibility = 'hidden';
			MateriasPassadasVisivel = false;
		}
	}
	
	function MateriasPassadasLinkOpen() {
		if(!MateriasPassadasVisivel) {
			document.getElementById("materiasEdicaoAnterior").style.visibility = 'visible';
			MateriasPassadasVisivel = true;
		} 	
	}
	
	function BuscarInterno() {
		frm=document.forms['buscaInterna'];
		if(frm.buscaStr.value != '' && frm.buscaStr.value != 'Pesquisar') {
			return window.frm.submit();
		} else return false;
	}

/* Validar Revista*/
/*	function SolicitarRevista(form){
	alert('Oiii');	
	erros = new Array();
	expressoes = {
		'rev_cep': /^[0-9]{5}-[0-9]{3}$/,
		'rev_telefone': /^\([0-9]{2}\)[0-9]{4}-[0-9]{4}$/
	};

	$("input, select","#formSolicitarRevista form").each(function(){
		id = $(this).attr("id");
		if(($(this).val() == "") && $(this).attr("id") != "rev_complemento"){
			erros.push($("label[for="+id+"]").html()+" é obrigatório.");
		}else if((expressoes[id] != undefined) && (!expressoes[id].test($(this).val()))){
			erros.push($("label[for="+id+"]").html()+" inválido.");
		}
	});
	
	if(erros.length) {
		alert("Alguns erros foram encontrados:\n\n"+erros.join("\n")+"\n\n por favor, corrija-os");
	} else {
		$("button",form).attr("disabled","disabled");
		$("button",form).html("Registrando...");
		dados = $(form).serialize();
		$.ajax({
			type: "GET",
			data: {id: 16},
			url: "/contaclique.php"
		});
		$.ajax({ 
		  type: "POST", 
		  url: "/pieces/solicitarRevista.php", 
		  data: dados, 
		  success: function(data) {
			 alert(data);
			$("button",form).removeAttr("disabled");
			$("button",form).html("Solicitar Revista");
			$('#formSolicitarRevista').fadeOut();
		  } 
		});	
	}
	}
*/
function SolicitarRevista(){
		
	erros = new Array();
		
	if( jQuery("#rev_nome").val() == "")  erros.push("- Informe o nome.");
	if( jQuery("#rev_endereco").val() == "")  erros.push("- Informe o endereço.");
	if( jQuery("#rev_numero").val() == "")  erros.push("- Informe o número.");
	if( jQuery("#rev_complemento").val() == "")  erros.push("- Informe o complemento.");
	if( jQuery("#rev_bairro").val() == "")  erros.push("- Informe o bairro.");
	if( jQuery("#rev_cidade").val() == "")  erros.push("- Informe o cidade.");
	if( jQuery("#rev_estado").val() == "")  erros.push("- Informe o estado.");
	if( jQuery("#rev_cep").val() == "")  erros.push("- Informe o cep.");
	if( jQuery("#rev_telefone").val() == "") erros.push("- Informe o telefone.");
		
	var cont_erro = erros.length;
		
	if(cont_erro>0) {
		alert("Alguns erros foram encontrados:\n\n"+erros.join("\n")+"\n\n por favor, corrija-os");
	} else {
			
					
		$("button","#formRevistaReceba").attr("disabled","disabled");
		$("button","#formRevistaReceba").html("Registrando...");
		//$("button",form).html("Registrando...");
			
		var dados = $("#formRevistaReceba").serialize();
			
		$.ajax({
			type: "GET",
			data: {id: 16},
			url: "/contaclique.php"
		});
				
		$.ajax({ 
			type: "POST", 
			url: "/pieces/solicitarRevista.php", 
			data: dados, 
			success: function(data) {
				//alert('Passei aqui');
				$("button","#formRevistaReceba").removeAttr("disabled");
				$("button","#formRevistaReceba").html("Solicitar Revista");
				//$('#formRevista').fadeOut();
				$('#formSolicitarRevista').fadeOut();
				Limpa();
			} 
		});	
	}
			
}	

function abreJanelaReceberSwot(){
	
	var width   = 600;
	var height = 400;
	
	var left   = 99;
	var top    = 99;
	
	window.open('/cont/raiz/receber-swot.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaTabelaComissaoVendas(){
	
	var width   = 600;
	var height = 400;
	var left   = 99;
	var top    = 99;
	
	window.open('/cont/raiz/receber-controle-comissao-vendedor.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaAnaliseCredito(){
	
	var width   = 600;
	var height = 400;
	
	var left   = 99;
	var top    = 99;
	
	window.open('/cont/raiz/receber-analise-credito.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaReceberAdvertenciaEmpregado(){

  var width   = 600;
  var height = 400;
	
  var left   = 99;
  var top    = 99;

 window.open('/cont/raiz/receber-advertencia-empregado.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaReceberPrincipiosBasicosNegociacao(){
  
  var width   = 600;
  var height = 400;

  var left   = 99;
  var top    = 99;

  window.open('/cont/raiz/receber-principios-basicos-negociacao.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaAvaliandoSuaOrganizacao(){
  
  var width   = 600;
  var height = 400;
  
  var left   = 99;
  var top    = 99;

  window.open('/cont/raiz/receber-avaliando-sua-organizacao.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaDesenvolvimentoDaAtencao(){
	  
  var width   = 600;
  var height = 400;
  	  
  var left   = 99;
  var top    = 99;
	
  window.open('/cont/raiz/receber-desenvolvimento-da-atencao.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaReceberCaptacaoRecursosExternos(){
	  
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-captacao-recursos-externos.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaContasPagar(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-controle-de-contas-a-pagar.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function abreJanelaVendasInternet(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-aumentar-vendas-internet.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreJanelaBancoMadeira(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-atelie-de-madeira.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abrePerfilEmpreendedor(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-perfil-empreendedor.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abrePlanoCIM(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-plano-CIM.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreTabeladeComposiçãodoCaixadaEmpresa(){
	 
	  var width   = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-tabela-composicao-caixa-empresa.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function abreReceberItensQuePodemComporUmBriefing(){
	 
	  var width  = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-itens-que-podem-compor-um-briefing.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function abreReceberTabelaModeloDescricaoPerfil(){
	 
	  var width  = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-elabore-perfil-funcionario-que-voce-precisa.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function abreReceberNoveManeirasDemanda(){
	 
	  var width  = 600;
	  var height = 400;
	  	  
	  var left   = 99;
	  var top    = 99;
		
	  window.open('/cont/raiz/receber-nove-maneiras-de-construir-a-demanda.php','janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
