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


/* ////////////////////////////// */
/* ////////////////////////////// */
//seletor das últimas notícias
function select_not(cont){
	if(cont==1){
		not01();
		cont++;
	}else if(cont==2){
		not02();
		cont++;
	}else if(cont==3){
		not03();
		cont++;
	}else if(cont==4){
		not04();
		cont=1;
	}
}
function not01(a){
	document.getElementById("id01_not").src = bt_01_at;
	document.getElementById("id02_not").src = bt_02_de;
	document.getElementById("id03_not").src = bt_03_de;
	document.getElementById("id04_not").src = bt_04_de;
	
	document.getElementById("destaque_not").src= img_not01;
	document.getElementById("titulo_not").innerHTML= titulo_not01;
	document.getElementById("subtitulo_not").innerHTML= subtitulo_not01;
	document.getElementById("link").href= link_not01;
	document.getElementById("link2").href= link_not01;
	document.getElementById("link3").href= link_not01;
	if(a!=""){cont=2; a="";}
}


function not02(a){
	document.getElementById("id01_not").src = bt_01_de;
	document.getElementById("id02_not").src = bt_02_at;
	document.getElementById("id03_not").src = bt_03_de;
	document.getElementById("id04_not").src = bt_04_de;
	
	document.getElementById("destaque_not").src= img_not02;
	document.getElementById("titulo_not").innerHTML= titulo_not02;
	document.getElementById("subtitulo_not").innerHTML= subtitulo_not02;
	document.getElementById("link").href= link_not02;
	document.getElementById("link2").href= link_not02;
	document.getElementById("link3").href= link_not02;
	if(a!=""){cont=3; a="";}
}

function not03(a){
	document.getElementById("id01_not").src = bt_01_de;
	document.getElementById("id02_not").src = bt_02_de;
	document.getElementById("id03_not").src = bt_03_at;
	document.getElementById("id04_not").src = bt_04_de;
	
	document.getElementById("destaque_not").src= img_not03;
	document.getElementById("titulo_not").innerHTML= titulo_not03;
	document.getElementById("subtitulo_not").innerHTML= subtitulo_not03;
	document.getElementById("link").href= link_not03;
	document.getElementById("link2").href= link_not03;
	document.getElementById("link3").href= link_not03;
	if(a!=""){cont=4; a="";}
}

function not04(a){
	document.getElementById("id01_not").src = bt_01_de;
	document.getElementById("id02_not").src = bt_02_de;
	document.getElementById("id03_not").src = bt_03_de;
	document.getElementById("id04_not").src = bt_04_at;
	
	document.getElementById("destaque_not").src= img_not04;
	document.getElementById("titulo_not").innerHTML= titulo_not04;
	document.getElementById("subtitulo_not").innerHTML= subtitulo_not04;
	document.getElementById("link").href= link_not04;
	document.getElementById("link2").href= link_not04;
	document.getElementById("link3").href= link_not04;
	if(a!=""){cont=1; a="";}
}
/* ////////////////////////////// */


/* ////////////////////////////// */
/* ////////////////////////////// */

function abrir_mural(id, template) {
  var url;
  var largura = 790;
  var altura = 550;
  

  url = "muraldefotos/templates/"+template+"/index.php?mur_id="+id;

  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 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 janelaClass (URL){ 
   window.open(URL,"classificados","width=576,height=415,left=30,top=50,scrollbars=yes") 
}
/* ////////////////////////////// */
/* Canais*/

function abrir_canal(url,tipo){
	if(tipo=="local"){
		location.href=url;
	}else{
		window.open(url,'','','');
	}
}

/* ////////////////////////////// */

/*Validar busca*/
function validar_busca(){

	if(document.form_busca.palavra.value == ""){
		alert("Informe sobre o que deseja pesquisar!");
		document.form_busca.palavra.focus();
		return false;
	};
	
}

/*Validar busca menu*/
function validar_busca_menu(){

	if(document.form_busca_menu.palavra.value == ""){
		alert("Informe sobre o que deseja pesquisar!");
		document.form_busca_menu.palavra.focus();
		return false;
	};
	
}


/*Validar comentar*/
function validar_comentar(){

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.cidade.value == ""){
		alert("Informe sua cidade!");
		document.form1.cidade.focus();
		return false;
	};
	
	if(document.form1.comentario.value == ""){
		alert("Faça seu comentário!");
		document.form1.comentario.focus();
		return false;
	};
	
}

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

//========================================================================
//NOTICIAS
var carregando = "<span class=\"verdana_preto_11\">Carregando...</span>";

function ver_manchetes()
{
		document.getElementById("ler_manchetes").innerHTML = carregando;
		
		AjaxA.open("GET", "manchetes.php", true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("ler_manchetes").innerHTML = '';
				document.getElementById("ler_manchetes").innerHTML = AjaxA.responseText;
        	}
		}
    	AjaxA.send(null);
}

function dados_colunista(id, col, pg, a)
{
		//ULTIMAS NOTÍCIAS
		// CARREGANDO...
		document.getElementById("not_colunista").innerHTML = carregando;
		
		AjaxA.open("GET", "colunista.php?col_not="+col, true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("not_colunista").innerHTML = '';
				document.getElementById("not_colunista").innerHTML = AjaxA.responseText;
        	}
		}
    	AjaxA.send(null)
	if(a==1){
		document.getElementById("not_mais").innerHTML = carregando;
		setTimeout(function(){ mais_not(id, col, pg, a); }, 1000);
	}
}

function mais_not(id, col, pg, a)
{
		//ULTIMAS NOTÍCIAS
		// CARREGANDO...
		document.getElementById("not_mais").innerHTML = carregando;
		
		AjaxA.open("GET", "mais_noticias.php?id_not="+id+"&col_not="+col+"&pagina="+pg, true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("not_mais").innerHTML = '';
				document.getElementById("not_mais").innerHTML = AjaxA.responseText;
        	}
		}
    	AjaxA.send(null)
	if(a==1){
		document.getElementById("not_relacionadas").innerHTML = carregando;
		setTimeout(function(){ not_rel(id, col, pg, a); }, 1000);
	}
}

function not_rel(id, col, pg, a)
{
		//ULTIMAS NOTÍCIAS
		// CARREGANDO...
		document.getElementById("not_relacionadas").innerHTML = carregando;
		
		AjaxA.open("GET", "noticias_rel.php?id_not="+id+"&col_not="+col+"&pagina="+pg, true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("not_relacionadas").innerHTML = '';
				document.getElementById("not_relacionadas").innerHTML = AjaxA.responseText;
        	}
		}
    	AjaxA.send(null)
	if(a==1){
		document.getElementById("not_mais_lidas").innerHTML = carregando;
		setTimeout(function(){ not_mais_lidas(id, col, pg); }, 1000);
	}
}

function not_mais_lidas(id, col, pg)
{
		//ULTIMAS NOTÍCIAS
		// CARREGANDO...
		document.getElementById("not_mais_lidas").innerHTML = carregando;
		
		AjaxA.open("GET", "noticias_mais_lidas.php?id_not="+id+"&col_not="+col+"&pagina="+pg, true);
		AjaxA.onreadystatechange=function(){
			if(AjaxA.readyState==4){
				document.getElementById("not_mais_lidas").innerHTML = '';
				document.getElementById("not_mais_lidas").innerHTML = AjaxA.responseText;
        	}
		}
    	AjaxA.send(null)
}

