// 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);
}
//*********************************************************************************

function ListaMaterias(){
	$('#noticia .lista_foto').cycle({ 
		fx:      'fade', 
		after:   Conteudo_noticias,
		speed:    300, 
		timeout:  6000 
	});
}

function Conteudo_noticias(){
	$("#lista_noticias .texto").html('<span class="verdana_preto_25"><a href="noticias.php?id='+$(this).find("input#id").val()+'"><strong>'+$(this).find("input#titulo").val()+'</strong></a></span><p><span class="arial_cinza_12_666666"><strong>'+$(this).find("input#data").val()+'</strong>: '+$(this).find("input#texto").val()+'</span></p>');
	for(var an = 0;an<=2;an++){
		if($(this).find("input#n").val()==an){
			$("#lista_noticias .mini_lista ul").find("#"+an+" div#seletor").attr("class","ativo");
		}else{
			$("#lista_noticias .mini_lista ul").find("#"+an+" div#seletor").attr("class","");
		}
	}
}


function ControleAgendaTricolor(){
	/*$("#menu_destaque").click(function(){
		$("#menu_destaque").attr("class","destaque_ativo");
		$("#menu_agenda").attr("class","agenda");
		$("#destaque_agenda_conteudo .destaque").css('display','block');
		$("#destaque_agenda_conteudo .agenda").css('display','none');
	});*/
	
	$("#menu_agenda").click(function(){
		$("#menu_destaque").attr("class","destaque");
		$("#menu_agenda").attr("class","agenda_ativo");
		$("#destaque_agenda_conteudo .destaque").css('display','none');
		$("#destaque_agenda_conteudo .agenda").css('display','block');
	});
}

function Acaomenu(){
	$("#menu_elenco").hover(function(){
		$(this).find("ul").slideDown('fast');
 
	},function(){
		$(this).find("ul").slideUp('fast');
	});
}

function ControleSlide(){
	$('#slider,#slider2').nivoSlider({
		effect: 'fade',
		pauseTime: 4000,
		directionNav: true,
		directionNavHide: true,
		controlNav: false,
		keyboardNav: true,
		pauseOnHover: false,
		manualAdvance: false,
		prevText: '',
		nextText: ''
	});
}
//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; 
	}
}

function validar_socio(){

	if(document.form1.nome.value == ""){
		alert("Informe o seu nome!");
		document.form1.nome.focus();
		return false;
	};
	
	if(document.form1.telefone.value == ""){
		alert("Informe o seu telefone para contato!");
		document.form1.telefone.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.endereco.value == ""){
		alert("Informe seu endereco!");
		document.form1.endereco.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="noticias.php?id="+document.getElementById("id_not_4").value;
			document.getElementById("link_not_img").href="noticias.php?id="+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);
}
