// JANELA EM DIV **************************************************************
function abreDiv(){ 
document.getElementById("abre_status").style.display = 'block';
document.getElementById("layer_um").style.display = 'none';
document.getElementById("Layer3").style.display = 'none';
}

function fechaTudo(){ 
document.getElementById("abre_status").style.display = 'block';
document.getElementById("abre_status").style.display = 'none';
document.getElementById("Layer3").style.display = 'none';
}

// ABRE POP UP REDIMENSIONÁVEL **************************************************************
	function MM_openBrWindow(theURL,winName,features) 
		{
		window.open(theURL,winName,features);
		}

// SELECIONA E COPIA TEXTEAREA **************************************************************
function selectCode()
    { 
  if(document.pad.text.value.length>0) 
      { 
    textRange = document.pad.text.createTextRange();
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    document.pad.text.focus(); 
    document.pad.text.select();
    alert ("Código copiado.");
      } 
  else alert('Não há o que copiar!') 
    } 

// VALIDA FORM COMENTÁRIOS **************************************************************
function publicacomentesite(){

if(document.comentesite.nome.value=="" || document.comentesite.nome.value.length < 0)
{
alert( "Por favor, seu nome... Quem é você???" );
document.comentesite.nome.focus();
return false;
}

if( document.comentesite.email.value.length < 0  || document.comentesite.email.value.indexOf('@')==-1 || document.comentesite.email.value.indexOf('.')==-1 )
{
alert( "Por favor, informe seu e-mail! Você precisará validar seu comentário!" );
document.comentesite.email.focus();
return false;
}

if(document.comentesite.titulocomentario.value=="" || document.comentesite.titulocomentario.value.length < 0)
{
alert( "Esqueceu de dá um título a seu comentário..." );
document.comentesite.titulocomentario.focus();
return false;
}

if(document.comentesite.anti2.value=="" || document.comentesite.anti2.value.length < 0)
{
alert( "Por favor, verifique o ANTI-SPAM! Repita no segundo campo, os número que você ver no primeiro!" );
document.comentesite.anti2.focus();
return false;
}

if(document.comentesite.anti2.value!=document.comentesite.anti.value)
{
alert( "Por favor, verifique o ANTI-SPAM! Repita no segundo campo, os número que você ver no primeiro!" );
document.comentesite.anti2.focus();
return false;
}

if(document.comentesite.comentario.value=="" || document.comentesite.comentario.value.length < 0)
{
alert( "Bahhhh! Você não escreveu um comentário..." );
document.comentesite.comentario.focus();
return false;
}

return true;
}

// JANELA EM DIV LIVRO **************************************************************
function abreDivL(){ 
document.getElementById("box_menu_select_livros").style.display = 'block';
}

function fechaTudoL(){ 
document.getElementById("box_menu_select_livros").style.display = 'none';
}



// EXPANDE **************************************************************
function toggle(obj) { 
var el = document.getElementById(obj); 
if ( el.style.display != 'none' ) { 
el.style.display = 'none'; 
} 
else { 
el.style.display = ''; 
} 
}

var head="display:''"
img1=new Image()
img1.src="closed.gif"
img2=new Image()
img2.src="open.gif"

function change(){
   if(!document.all)
      return
   if (event.srcElement.id=="foldheader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+1]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url(open.gif)"
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url(closed.gif)"
      }
   }
}

document.onclick=change


// ABRE DIV **************************************************************
    function mostraPageDiv(nota) { 


        var tipBrowser = 0; 
        var mostraDiv= ""; 


        if ( mostraDiv != "" && mostraDiv != null ) { 
            escondeDiv(nota,'','show') 
        } 
        else escondeDiv(nota,'','show') 
    } 


    function econtaObj(n, d) { //v4.0 
        var p,i,x; 
        if(!d) d=document; 
          if((p=n.indexOf("?"))>0&&parent.frames.length) { 
            d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); 
            } 
        if(!(x=d[n])&&d.all) x=d.all[n]; 
        for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
        x=econtaObj(n,d.layers[i].document); 
        if(!x && document.getElementById) x=document.getElementById(n); 
return x; 
    } 


    function escondeDiv() { //v3.0 
      var i,p,v,obj,args=escondeDiv.arguments; 
      for (i=0; i<(args.length-2); i+=3) 
          if ((obj=econtaObj(args[i]))!=null) { 
              v=args[i+2]; 
            if (obj.style) { 
                obj=obj.style; 
v=(v=='show')?'visible':(v='hide')?'hidden':v; 
            } 
            obj.visibility=v; } 
    } 


// JANELA EM DIV MENU **************************************************************
function abreDivL(){ 
document.getElementById("div_canais").style.display = 'block';
}
function fechaTudoL(){ 
document.getElementById("div_canais").style.display = 'none';
}

// JANELA EM DIV login **************************************************************
function abreDivLogin(){ 
document.getElementById("div_login").style.display = 'block';
}
function fechaTudoLogin(){ 
document.getElementById("div_login").style.display = 'none';
}



// LOGIN **************************************************************
var navegador = navigator.userAgent.toLowerCase(); //Cria e atribui à variável global 'navegador' (em caracteres minúsculos) o nome e a versão do navegador

//Cria uma variável global chamada 'xmlhttp'
var xmlhttp; 


//Função que inicia o objeto XMLHttpRequest

function objetoXML() {

if (navegador.indexOf('msie') != -1) { //Internet Explorer

var controle = (navegador.indexOf('msie 5') != -1) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; //Operador ternário que adiciona o objeto padrão do seu navegador (caso for o IE) à variável 'controle'

try {

xmlhttp = new ActiveXObject(controle); //Inicia o objeto no IE

} catch (e) { }

} else { //Firefox, Safari, Mozilla

xmlhttp = new XMLHttpRequest(); //Inicia o objeto no Firefox, Safari, Mozilla

}

}

//Função que envia o formulário

function enviarForm(url, campos, destino) {

//Atribui à variável 'elemento' o elemento que irá receber a página postada
var elemento = document.getElementById(destino); 

//Executa a função objetoXML()
objetoXML(); 

//Se o objeto de 'xmlhttp' não estiver true
if (!xmlhttp) {

//Insere no 'elemento' o texto atribuído
elemento.innerHTML = 'Impossível iniciar o objeto XMLHttpRequest.'; 

return;

} else { 

//Insere no 'elemento' o texto atribuído
elemento.innerHTML = 'ddd'; 

}

xmlhttp.onreadystatechange = function () {

//Se a requisição estiver completada
if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) { 

//Se o status da requisição estiver OK
if (xmlhttp.status == 200) {

//Insere no 'elemento' a página postada
elemento.innerHTML = xmlhttp.responseText; 

} else { 

//Insere no 'elemento' o texto atribuído
elemento.innerHMTL = 'Página não encontrada!'; 

}

}

}

//Abre a página que receberá os campos do formulário
xmlhttp.open('POST', url+'?'+campos, true);

//Envia o formulário com dados da variável 'campos' (passado por parâmetro)
xmlhttp.send(campos); 

setTimeout("location.reload();",3000)

}
// FIM LOGIN **************************************************************


// FORM CADASTRO **************************************************************
function formcad(){

if(document.formcadastro.nomeusuario.value=="" || document.formcadastro.nomeusuario.value.length < 0)
{
alert( "Qual o seu nome, hein? Hum, diz aí... qual seu nome???" );
document.formcadastro.nomeusuario.focus();
return false;
}

if( document.formcadastro.emailusuario.value.length < 0  || document.formcadastro.emailusuario.value.indexOf('@')==-1 || document.formcadastro.emailusuario.value.indexOf('.')==-1 )
{
alert( "O e-mail é necessário..." );
document.formcadastro.emailusuario.focus();
return false;
}

if(document.formcadastro.apelido.value=="" || document.formcadastro.apelido.value.length < 0)
{
alert( "Epa!!! Escolha um apelido... diga-nos como deseja ser identificado no GuiaDoClique!" );
document.formcadastro.apelido.focus();
return false;
}

if(document.formcadastro.cidade.value=="" || document.formcadastro.cidade.value.length < 0)
{
alert( "Em que cidade você mora???" );
document.formcadastro.cidade.focus();
return false;
}

if(document.formcadastro.cidade.value=="" || document.formcadastro.cidade.value.length < 0)
{
alert( "Em que cidade você mora???" );
document.formcadastro.cidade.focus();
return false;
}

if(document.formcadastro.cep.value=="" || document.formcadastro.cep.value.length < 0)
{
alert( "Sem CEP, nada feito! Só pode se cadastrar se informar um CEP válido!" );
document.formcadastro.cep.focus();
return false;
}

if(document.formcadastro.digitocep.value=="" || document.formcadastro.digitocep.value.length < 0)
{
alert( "Sem CEP, nada feito! Só pode se cadastrar se informar um CEP válido!" );
document.formcadastro.digitocep.focus();
return false;
}

if(document.formcadastro.datanascimento.value=="" || document.formcadastro.datanascimento.value.length < 0)
{
alert( "Precisamos que nos diga sua Data de Nascimento. Informe neste formato (dd/mm/aa) ok!" );
document.formcadastro.datanascimento.focus();
return false;
}

if(document.formcadastro.senha1.value=="" || document.formcadastro.senha2.value.length < 0)
{
alert( "Escolha uma senha, e repita a danada no campo indicado!" );
document.formcadastro.senha1.focus();
return false;
}


return true;
}
// FIM FORM CADASTRO **************************************************************

// SÓ LETRAS **************************************************************
function PermiteSoLetras()
{
  var tecla = window.event.keyCode;
  tecla     = String.fromCharCode(tecla);
  if(!((tecla != "0") && (tecla != "1") && (tecla != "2") && (tecla != "3") && (tecla != "4") && (tecla != "5") && (tecla != "6") && (tecla != "7") && (tecla != "8") && (tecla != "9") && (tecla != "-") && (tecla != "=") && (tecla != "!") && (tecla != "@") && (tecla != "#") && (tecla != "$") && (tecla != "%") && (tecla != "¨") && (tecla != "&") && (tecla != "*") && (tecla != "(") && (tecla != ")") && (tecla != "_") && (tecla != "+") && (tecla != "|") && (tecla != ",") && (tecla != "<") && (tecla != ".") && (tecla != ">") && (tecla != ";") && (tecla != ":") && (tecla != "?") && (tecla != "/") && (tecla != "[") && (tecla != "]") && (tecla != "{") && (tecla != "}")))
  {
    window.event.keyCode = 0;
  }
}
// FIM SÓ LETRAS **************************************************************