// JavaScript Document
//************************************************************************
// HTTP REQUEST **********************************************************
//************************************************************************
function getHTTPObject() {
  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 (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var AjaxA = getHTTPObject();

//************************************************************************
//************************************************************************
// POP-UPS ----------------------------------------------
function page_less(url, largura, altura) {
  var url;
  
  var esquerda = (screen.width - largura)/2;
  var topo = (screen.height - altura)/2;
  window.open(url,'win','height=' + altura + ', width=' + largura + ', top=' + topo + ', left=' + esquerda);
}
//*********************************************************************************

//VALIDAÇÃO DO FORMULÁRIO
// VALIDAR - INDICAR------------------------------------
function validar_indicar(){

if(document.form1.nome.value == ""){
		alert("Informe o seu nome!");
		document.form1.nome.focus();
		return false;
	};
	
	strEmail = document.form1.email.value;
	if(strEmail == ""){
		alert("Informe seu e-mail!");
		document.form1.email.focus();
		return false;
	};
	
	if(strEmail.indexOf("@",0) == -1 || strEmail.indexOf(".",0) == -1){ 
		alert("Informe um email válido !"); 
		document.form1.email.select();
		return false; 
	};
	
	if(document.form1.nome_para.value == ""){
		alert("Informe o do para quem você deseja fazer a indicação!");
		document.form1.nome_para.focus();
		return false;
	};
	
	strEmail2 = document.form1.email_para.value;
	if(strEmail2 == ""){
		var nomepara = document.form1.nome_para.value;
		alert("IInforme o e-mail de "+nomepara+"!");
		document.form1.email_para.focus();
		return false;
	};
	
	if(strEmail2.indexOf("@",0) == -1 || strEmail2.indexOf(".",0) == -1){ 
		alert("Informe um email válido !"); 
		document.form1.email_para.select();
		return false; 
	};
	
	if(document.form1.mensagem.value == ""){
		alert("Informe sua mensagem!");
		document.form1.mensagem.focus();
		return false;
	};
	
}

function validar_contato(){
	
	if(document.form1.nome.value==""){
		alert("Informe seu nome!");
		document.form1.nome.focus();
		return false; 
	}
	
	strEmail = document.form1.email.value;
	if(strEmail == ""){
		alert("Informe seu e-mail!");
		document.form1.email.focus();
		return false;
	};
	
	if(strEmail.indexOf("@",0) == -1 || strEmail.indexOf(".",0) == -1){ 
		alert("Informe um email válido !"); 
		document.form1.email.select();
		return false; 
	};
	
	
	if(document.form1.cidade.value==""){
		alert("Informe sua cidade!");
		document.form1.cidade.focus();
		return false; 
	}
	
	if(document.form1.assunto.value==""){
		alert("Informe o assunto do contato!");
		document.form1.assunto.focus();
		return false; 
	}	
	
	if(document.form1.mensagem.value==""){
		alert("Informe sua mesagem!");
		document.form1.mensagem.focus();
		return false; 
	}
}

//===========================================
//CONFIGURAÇÕES INICIAIS
	
	var not_avaliar=""
//NOME DAS CLASSES
	var marcador = "not_marcador_vermelho";
	var marcador_ativo = "not_marcador_vermelho_ativo";
	
function seletor_not(n_not2,controle){
	
	if(n_not2==""){
		not_avaliar=n_not;
	}else{
		not_avaliar=n_not2;
	}
	switch(not_avaliar){
		case 1:
			
			//ALTERAR MARCADOR
			document.getElementById("not_marcador_1").className=marcador_ativo;
			document.getElementById("not_marcador_2").className=marcador;
			document.getElementById("not_marcador_3").className=marcador;
			document.getElementById("not_marcador_4").className=marcador;
			
			//ALTERAR DADOS
			document.getElementById("not_img").src=document.getElementById("img_not_1").value;
			document.getElementById("not_tit").innerHTML=document.getElementById("tit_not_1").value;
			
			//ALTERAR LINKS
			document.getElementById("link_not_tit").href="noticias.php?id="+document.getElementById("id_not_1").value;
			document.getElementById("link_not_img").href="noticias.php?id="+document.getElementById("id_not_1").value;
			
			if(controle==""){n_not++;}
			
		break;
		
		case 2:
		
			//ALTERAR MARCADOR
			document.getElementById("not_marcador_1").className=marcador;
			document.getElementById("not_marcador_2").className=marcador_ativo;
			document.getElementById("not_marcador_3").className=marcador;
			document.getElementById("not_marcador_4").className=marcador;
			
			//ALTERAR DADOS
			document.getElementById("not_img").src=document.getElementById("img_not_2").value;
			document.getElementById("not_tit").innerHTML=document.getElementById("tit_not_2").value;
			
			//ALTERAR LINKS
			document.getElementById("link_not_tit").href="noticias.php?id="+document.getElementById("id_not_2").value;
			document.getElementById("link_not_img").href="noticias.php?id="+document.getElementById("id_not_2").value;
			
			if(controle==""){n_not++;}
			
		break;
		
		case 3:
		
			//ALTERAR MARCADOR
			document.getElementById("not_marcador_1").className=marcador;
			document.getElementById("not_marcador_2").className=marcador;
			document.getElementById("not_marcador_3").className=marcador_ativo;
			document.getElementById("not_marcador_4").className=marcador;
			
			//ALTERAR DADOS
			document.getElementById("not_img").src=document.getElementById("img_not_3").value;
			document.getElementById("not_tit").innerHTML=document.getElementById("tit_not_3").value;
			
			//ALTERAR LINKS
			document.getElementById("link_not_tit").href="noticias.php?id="+document.getElementById("id_not_3").value;
			document.getElementById("link_not_img").href="noticias.php?id="+document.getElementById("id_not_3").value;
			
			if(controle==""){n_not++;}
			
		break;
		
		case 4:
			
			//ALTERAR MARCADOR
			document.getElementById("not_marcador_1").className=marcador;
			document.getElementById("not_marcador_2").className=marcador;
			document.getElementById("not_marcador_3").className=marcador;
			document.getElementById("not_marcador_4").className=marcador_ativo;
			
			//ALTERAR DADOS
			document.getElementById("not_img").src=document.getElementById("img_not_4").value;
			document.getElementById("not_tit").innerHTML=document.getElementById("tit_not_4").value;
			
			//ALTERAR LINKS
			document.getElementById("link_not_tit").href=document.getElementById("id_not_4").value;
			document.getElementById("link_not_img").href=document.getElementById("id_not_4").value;
			
			if(controle==""){n_not=1;}

		break;
	}
	not_avaliar="";
}

//VER NOTICIAS, FINANCIAMENTO

function outros_dados(id,pg,arq){
		
		document.getElementById("outros_dados").innerHTML = '<div align="center" style="padding:10px;"><img src="imagens/loading.gif" width="32" height="32" /></div>';
		
		AjaxA.open("GET", arq+"?id="+id+"&pagina="+pg, true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("outros_dados").innerHTML = '';
				document.getElementById("outros_dados").innerHTML = AjaxA.responseText;
			}
		}
	AjaxA.send(null);
}