function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}




//=======================================================================



function addFlash (URL, WIDTH, HEIGHT, TRANSPARENT)
{
	document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
	document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');
	document.write (' <param name="movie" value="'+ URL +'" />');
	document.write (' <param name="quality" value="best" />');

	if ( TRANSPARENT ) {
	  document.write (' <param name="Wmode" value="Transparent" />');
	}

	document.write (' <embed src="'+ URL +'" quality="best" ');

	if ( TRANSPARENT ) {
	document.write (' Wmode = "transparent" ');
	}

	document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
	document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
	document.write (' </object>');

}
//==================================================================
function noticias(pagina){
		
		for(i=1;i<=4;i++){
			document.getElementById('abaNot'+i).style.backgroundColor = "#FFFFFF";
			document.getElementById('boxNot'+i).style.display = "none";
			document.getElementById('titAbaNot'+i).className = "titulos_abas";
		}
		
		document.getElementById('abaNot'+pagina).style.backgroundColor = "#FFFFFF";
		document.getElementById('boxNot'+pagina).style.display = "block";
		document.getElementById('titAbaNot'+pagina).className = "titulos_abas_sel";
	}

var actPage = null;
var intervalID = null;
function noticias_abas(pagina,interval){
	
	if(!interval)
	{
		actPage = pagina;
		clearTimeout(intervalID);
	}
	
	for(i=1;i<=4;i++){
		document.getElementById('abaNot'+i).style.backgroundColor = "#FFFFFF";
		document.getElementById('boxNot'+i).style.display = "none";
		document.getElementById('titAbaNot'+i).className = "titulos_abas";
	}
	
	document.getElementById('abaNot'+pagina).style.backgroundColor = "#FFFFFF";
	document.getElementById('boxNot'+pagina).style.display = "block";
	document.getElementById('titAbaNot'+pagina).className = "titulos_abas titulos_abas_sel";
	
	startRotation();
}

function startRotation() {
	if(actPage<4)
	{
		page = (actPage*1)+1;
	
		intervalID = setTimeout("noticias_abas("+page+",true);",5000);
	}
	
	if(actPage==3)
		actPage = 0;
	else
		actPage++;
}

//==================================================================
	
	
//=====================================================================

// Define variável global
var xmlhttp;
var varIdEnquete;
function enviaEnquete(varForm,qtidade,idEnquete) {

// Define variáveis
var varQtidade = qtidade;
var varResposta = "";
varIdEnquete = idEnquete;
var i;


// Atribui valores as variáveis
//varResposta  = escape(varForm.resposta.value);
for(i=1;i<=varQtidade;i++){
	if (document.getElementById("resp_"+i).checked == true) {
		varResposta  = document.getElementById("resp_"+i).value;
	}
	
}

// Instancia o objeto, dependendo do navagador
if (window.XMLHttpRequest) {
 xmlhttp = new XMLHttpRequest();  
} else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
} else {
 alert("Seu navegador n&atilde;o suporta XMLHttpRequest.");
 return;
}

   xmlhttp.open("POST", "enquete_processa.php", true); 

   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
   xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
   xmlhttp.setRequestHeader("Pragma", "no-cache");
   
xmlhttp.onreadystatechange = processReqChangeEnq;

   xmlhttp.send("resposta=" + varResposta);
   //alert("OK");
}


function processReqChangeEnq() {

document.getElementById("div_respostaEnq").innerHTML = "Processando dados...";
   if (xmlhttp.readyState == 4) { 
 if (xmlhttp.status == 200) {
  // xmlhttp.responseText, recebe o valor da variavel $msg de cadastro.php
  if(xmlhttp.responseText == 1) {
	  
   document.getElementById("div_respostaEnq").innerHTML = "<br><br>VOTO COMPUTADO COM SUCESSO";
   document.getElementById("formularioEnq").style.display = "none";
   document.getElementById("resultadoEnq").style.display = "block";
   
   verResultado(varIdEnquete);
   
  } else
   document.getElementById("div_respostaEnq").innerHTML = xmlhttp.responseText;
  
       } else {
           alert("Problemas ao carregar o arquivo.");
       }
   }

}





//=====================================================================================


var req;

function loadXMLDoc22(url,valor)
{
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange22;
        req.open("GET", url+"?f="+valor, true);
        req.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange22;
            req.open("GET", url+"?f="+valor, true);
            req.send();
        }
    }
}

function processReqChange22()
{
    // apenas quando o estado for "completado"
    document.getElementById('resultadoEnq').innerHTML = "<span style=\"font-family: verdana; font-size: 12px; \">&nbsp;&nbsp;<b>carregando...</b>&nbsp;&nbsp;</span>";
    if (req.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (req.status == 200) {
            // procura pela div id="resultado" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById('resultadoEnq').innerHTML = req.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + req.statusText);
        }
    }
}

function verResultado(valor)
{
document.getElementById("formularioEnq").style.display = "none";
document.getElementById("div_respostaEnq").style.display = "none";
loadXMLDoc22("enquete_resultado.php",valor);
}

//=====================================================================

function estiloErro(){
	document.getElementById("div_respostaEnq").style.backgroundColor='#FFFF00';
}


//======================================================================
/*
function horoscopo(signo){
	document.getElementById('boxSigno'+signo).style.display = "block";
	document.getElementById('listaSignos').style.display = "none";
}
*/



var reqH;

function loadXMLDocH(url,valor)
{
    reqH = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        reqH = new XMLHttpRequest();
        reqH.onreadystatechange = processReqChangeH;
        reqH.open("GET", url+"?signo="+valor, true);
        reqH.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        reqH = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqH) {
            reqH.onreadystatechange = processReqChangeH;
            reqH.open("GET", url+"?signo="+valor, true);
            reqH.send();
        }
    }
}

function processReqChangeH()
{
    // apenas quando o estado for "completado"
    document.getElementById('boxSigno').innerHTML = "<span style=\"font-family: verdana; font-size: 12px; \">&nbsp;&nbsp;<b>carregando...</b>&nbsp;&nbsp;</span>";
    if (reqH.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (reqH.status == 200) {
            // procura pela div id="resultado" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById('boxSigno').innerHTML = reqH.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + reqH.statusText);
        }
    }
}

function horoscopo(valor)
{
document.getElementById("listaSignos").style.display = "none";
document.getElementById("boxSigno").style.display = "block";
loadXMLDocH("signos.php",valor);
}



function fecharSigno(){
	document.getElementById('boxSigno').style.display = "none";
	document.getElementById('listaSignos').style.display = "block";
}



//===========================================================================


function previa(campo,valor){
	
	var nomeTipo;
	
		if(campo == "tipo"){
			if(valor == 0){nomeTipo = "";}
			if(valor == 1){nomeTipo = ", Vende-se, ";}
			if(valor == 2){nomeTipo = ", Compra-se, ";}
			if(valor == 3){nomeTipo = ", Aluga-se, ";}
			if(valor == 4){nomeTipo = ", Ofereço, ";}
			if(valor == 5){nomeTipo = ", Procura-se, ";}
			if(valor == 6){nomeTipo = ", Precisa-se, ";}
		}
	
		if(campo == "titulo"){document.getElementById('prev_titulo').innerHTML = valor;}
		if(campo == "tipo"){document.getElementById('prev_tipo').innerHTML = nomeTipo;}
		if(campo == "texto"){document.getElementById('prev_texto').innerHTML = "&nbsp;" + valor;}
		if(campo == "preco"){document.getElementById('prev_preco').innerHTML = "<strong>Preço R$:</strong>&nbsp;" + valor;}
		if(campo == "fone"){document.getElementById('prev_fone').innerHTML = "<strong>Fone:</strong>&nbsp;" + valor;}
		if(campo == "contato"){document.getElementById('prev_contato').innerHTML = "<strong>&nbsp;com:</strong>&nbsp;" + valor;}
		
		
}








//====================================================================




	var browserName=navigator.appName; 
	function fechaFoto(){
		document.getElementById('div_ampliarFoto').style.display = 'none';
		document.getElementById('div_ampliarFoto').innerHTML = '';
	}
	
	function abreFoto(valor,id,tipo,larg,alt){
		
		
		
		if (browserName=="Microsoft Internet Explorer")
		{
			window.open('mostraFoto.php?id=' + id + '&tipo=' + tipo,'popup','width='+larg+',height='+alt+',scrolling=auto,top=200,left=200')
		}
		else
		{
			
				document.getElementById('div_ampliarFoto').style.display = 'block';
				document.getElementById('div_ampliarFoto').innerHTML = '<div style="padding: 5px 5px 5px 5px;border:#000000 1px solid;"><span class="texto_menor">Clique na foto para fechar</span><br><img src="' + valor + '"></div>';
			
		}
	}
	
	
	
//================================================================================

function showStars(valor,dir){
	for(i=1;i<=valor;i++){
		document.getElementById('star__' + i).src = dir + "imagens/icn_star_full_19x20.jpg";
	}
}


function clearStars(valor,dir){
	for(i=(valor+1);i<=5;i++){
		document.getElementById('star__' + i).src = dir + "imagens/icn_star_empty_19x20.jpg";
	}
}





//=====================================================================================


var reqVoto;

function loadXMLDoc2Voto(url,valor,idFoto)
{
    reqVoto = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        reqVoto = new XMLHttpRequest();
        reqVoto.onreadystatechange = processReqChange2Voto;
        reqVoto.open("GET", url+"?v="+valor+"&idFoto="+idFoto, true);
        reqVoto.send(null);
		//alert("1 "+valor);
		//alert("1 "+idFoto);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        reqVoto = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqVoto) {
            reqVoto.onreadystatechange = processReqChange2Voto;
            reqVoto.open("GET", url+"?v="+valor+"&idFoto="+idFoto, true);
            reqVoto.send();
			//alert("1 "+valor);
			//alert("1 "+idFoto);
        }
    }
}

function processReqChange2Voto()
{
    // apenas quando o estado for "completado"
    document.getElementById('votacao').innerHTML = "<span style=\"font-family: verdana; font-size: 12px; \">&nbsp;&nbsp;<b>carregando...</b>&nbsp;&nbsp;</span>";
    if (reqVoto.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (reqVoto.status == 200) {
            // procura pela div id="resultado" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById('votacao').innerHTML = reqVoto.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + reqVoto.statusText);
        }
    }
}

function setStars(valor,idFoto)
{
//alert(valor);
loadXMLDoc2Voto("add_voto.php",valor,idFoto);
}



//============================================================================


function exibeForm(){
if(document.getElementById("formularioSug").style.display == "none"){
	document.getElementById("formularioSug").style.display = "block";
	document.getElementById("formularioSug").style.clear = "both";
	document.getElementById("formularioSug").style.height = "280px";
	document.getElementById("respostaSugestao").style.display = "block";
	document.getElementById("respostaSugestao").innerHTML = "<span onclick=\"fechaCaixa();exibeForm();\" style=\"cursor:pointer;color:#FFFFFF;font-size:14px;font-weight:bold;\"><br>FECHAR</span>";
}
else
{
	document.getElementById("formularioSug").style.display = "none";
	document.getElementById("formularioSug").style.height = "0";
}
}


//==============================================================================


function escondeLayer(){
	document.getElementById('div_Publicidade_flutuante').style.visibility='hidden';
}

function escondeLayer2(){
	document.getElementById('div_Publicidade_flutuante-Luan').style.visibility='hidden';
}


function escondeLayerFotos(){
	document.getElementById('div_Publicidade_flutuanteFotos').style.visibility='hidden';
}


function escondeLayerIndex(){
	document.getElementById('div_Publicidade_flutuanteIndex').style.visibility='hidden';
}


function escondeLayerIndex2(){
	document.getElementById('div_Publicidade_flutuanteIndex2').style.visibility='hidden';
}





//==========================================================================================
//CARREGAR PAGINAS TvGuia
var reqTvGuia;

function loadXMLDocTvGuia(url,video,verflash)
{
    reqTvGuia = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        reqTvGuia = new XMLHttpRequest();
        reqTvGuia.onreadystatechange = processReqChangeTvGuia;
        reqTvGuia.open("GET", url+"?video="+video+"&amp;verflash="+verflash, true);
        reqTvGuia.send(null);
    // Procura por uma versao ActiveX (IE)
    } else if (window.ActiveXObject) {
        reqTvGuia = new ActiveXObject("Microsoft.XMLHTTP");
        if (reqTvGuia) {
            reqTvGuia.onreadystatechange = processReqChangeTvGuia;
            reqTvGuia.open("GET", url+"?video="+video+"&amp;verflash="+verflash, true);
            reqTvGuia.send();
        }
    }
}

function processReqChangeTvGuia()
{
    // apenas quando o estado for "completado"
    document.getElementById('tvguia_player').innerHTML = "<span style=\"font-family: verdana; font-size: 12px; \"><br><br>&nbsp;&nbsp;<b>carregando...</b>&nbsp;&nbsp;</span>";
    if (reqTvGuia.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (reqTvGuia.status == 200) {
            // procura pela div id="resultado" e insere o conteudo
            // retornado nela, como texto HTML
            document.getElementById('tvguia_player').innerHTML = reqTvGuia.responseText;
        } else {
            alert("Houve um problema ao obter os dados:\n" + reqTvGuia.statusText);
        }
    }
}

function abrirVideo(video,verflash)
{
	loadXMLDocTvGuia("tvguia_player.php",video,verflash);
}

//==========================================================================================
