//variaveis globais para uso da dinamica da pagina
var corLINK = "#02F2F2";
var corAntes = "";
var mostraContato = "";
var Requisicao = false;
//funcao de uso da pagina tvmidia 

//funcao que define qual melhor arquivo css para o navegador
function define_css(){
  //alert(browserName);
  //novo_acesso(0);
  corLINK = "#02F2F2";
  top10(0);
  //carrega_home();
}

function pagina_alternativa(cor,propaganda){
  corLINK = cor;
  giro_item();
  if(propaganda > 0){
    //alert("ola");
   window.open("http://www.egrana.com.br/popunder.aspx?CD_Usuario=4491","popunder","toolbar=no,menubar=no,scrollbars=no,status=no,resisable=no,top=10,left=320");
     }
}

function js(){
  var end = "";
  var numero = 2;
  var ban = Math.floor(Math.random()* numero);
  if(ban == 1){
    end="http://www.educajogos.com.br";
  }else{
    end="http://www.x3download.com.br/";
  }
  window.open(end,'','"menubar=yes,toolbar=yes,location=yes,scrollbars=yes,status=yes,resizable=yes,top=0,left=0,width=1024,height=768"');
  window.focus();
}

//funcao que mostra msg alerta
function mostra_alerta(){
  alert("CLICK na IMAGEM para acessar DOWNLOAD.");
}

//função que anima o menu
function anima(texto,cor,x){
  document.getElementById("animeMenu").innerHTML = texto;
  document.getElementById("animeMenu").style.color = cor;
  document.getElementById("animeMenu").style.left = x+"px";
}
//funcao que retira o menu
function retiraAnima(){
  document.getElementById("animeMenu").innerHTML = "";
  document.getElementById("animeMenu").style.left = "0px";
  document.getElementById("animeMenu").style.top = "0px"; 
}

//função que cria ajax para a todas as versões de navegadores 
function criaAjax(){
      try{
        //Firefox, opera, 8.0, Safira
        ajax = new XMLHttpRequest();
      }catch(e){
        //Internet Explorer
        try{
          ajax = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
          try{
            ajax =  new ActiveXObject("Microsoft.XMLHTTP");
          }catch(e){
            alert("Seu browser não suporta AJAX");
            return false;
          }
        }
        
    }
  }  
//------------------------------------------------------------------------------

//funcao que carregara home
function carrega_home(){
   var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/home/lista.php";    
   }else{
    end = "http://tvmidia.net/modulo/home/lista.php";
   } 
   criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            Requisicao = false;
          }else{
              //erro no carregar imagen  
          }
        }else{
          //carregando
          var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
          document.getElementById("centro_mostra").innerHTML = html;
        }
       }
      
       ajax.send(null); 
}

//------------------------------------------------------------------------------

//funcao que carrega home
function pagina_home(inicio){
  var end = location;
  str_2 = new String(end);
  str_2 = str_2.substring(0,10);
  if(str_2 == "http://www"){
    end = "http://www.tvmidia.net/modulo/home/lista.php";    
  }else{
    end = "http://tvmidia.net/modulo/home/lista.php";
  }
   criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            Requisicao = false;
            muda_para_seriado(0);
            scroll('0','0');
            top10(0)
          }else{
              //erro no carregar imagen  
          }
        }else{
          //carregando
        }
       }
       parans = "inicio="+inicio;
       ajax.send(parans);  
}

//funcao que mostrara item na tela 
function mostra_item(id,id_categoria,id_banner){
  var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/item/mostra.php";    
   }else{
    end = "http://tvmidia.net/modulo/item/mostra.php";
   }
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            Requisicao = false;
            muda_para_seriado(id_categoria);
            recupera_banner(id_banner,id);
            scroll('0','0');
            
          }else{
              //erro no carregar imagen  
          }
        }else{
          //carregando
        }
       }
       var parans = "id="+id;
       ajax.send(parans); 
}

//funcao busca links topico 
function links_topico(id){
  var onde = "links"+id;
  var text = document.getElementById(onde).innerHTML;
  if(text != ""){
    document.getElementById(onde).innerHTML = "";
    return false;
  }else{
    var end ="../../modulo/link/lista.php";
  }
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){
          if(ajax.status == 200){
            document.getElementById(onde).innerHTML=ajax.responseText;
            Requisicao = false;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
           var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
          document.getElementById(onde).innerHTML = html;
        }
       }
       var parans = "id="+id;
       ajax.send(parans);
} 


//funcao que recupera banner do item
function recupera_banner(id,id_item){
   var end ="../../modulo/item/banner.php";
   criaAjax();
    Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            document.getElementById("banner2").innerHTML="";
            document.getElementById("banner2").style.backgroundImage="url("+ajax.responseText+")";
            novo_acesso(id_item);
            Requisicao = true;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "id="+id;
       ajax.send(parans);

}

//funcao que tira banner
function tira_banner(){
document.getElementById("banner2").style.backgroundImage="url()";
}

//funcao que recupera sinopse
function recupera_sinopse(id){
  var onde = "mostra_sinopse"+id;
  var text = document.getElementById(onde).innerHTML;
  if(text != ""){
    document.getElementById(onde).innerHTML = "";
  }else{
    var end ="../../modulo/item/sinopse.php";
  
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){
          if(ajax.status == 200){
            text = ajax.responseText;
            if(text.length > 27){
               text = text.substr(0,100);
               text = text+"....."; 
               document.getElementById(onde).innerHTML= text; 
            }else{
              document.getElementById(onde).innerHTML = text;
            }
            Requisicao = false;
          }else{
              //erro no carregar imagen 
             
          }
        }else{
          //carregando
          var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>  CARREGANDO...</div>";
          document.getElementById(onde).innerHTML = html;
        }
       }
       var parans = "id="+id;
       ajax.send(parans);
  }   
}

//area de funcoes que vão mudar area de links laterais
function muda_para_seriado(id){
  var imgF = "";
  var nome = "";
  if(id == 2){
    nome = "S&Eacute;RIES";
    corLINK = "#00FA19";
    imgF = "class_principal";
  }else{
    if(id == 8){
      nome = "FILMES";
      corLINK = "#FB03B9";
      imgF = "class_principal_filme";
    }else{
      if(id == 3){
        nome = "ANIME";
        corLINK = "#68039D";
        imgF = "class_principal_anime";
      }else{
        if(id == 0){
          nome = "HOME";
          corLINK = "#02F2F2";
          imgF = "class_principal";
           document.getElementById("banner2").innerHTML= "<embed class='class_banner_wibi' src='imagens/wibi.swf'  wmode='transparent'>";
        }else{
           nome = "CONTATO";
          corLINK = "#F5FA03";
          imgF = "class_principal";
        }
      }
    }
  }
  document.getElementById("sessao1").innerHTML = nome;
  document.getElementById("sessao1").style.color = corLINK;
  document.getElementById("sessao2").style.color = corLINK;
  document.getElementById("sessao3").style.color = corLINK;
  document.getElementById("sessao4").style.color = corLINK;
  document.getElementById("sessao5").style.color = corLINK;
  document.getElementById("sessao6").style.color = corLINK;
  document.getElementById("barra_sessao1").style.borderColor = corLINK;
  document.getElementById("barra_sessao2").style.borderColor = corLINK;
  document.getElementById("barra_sessao3").style.borderColor = corLINK;
  document.getElementById("barra_sessao4").style.borderColor = corLINK;
  document.getElementById("barra_sessao5").style.borderColor = corLINK;
  document.getElementById("barra_sessao6").style.borderColor = corLINK;
  //document.getElementById("principal").className=imgF;
}

//funcao que muda cor de link
function muda_cor(x){
  corAntes = x.style.color;
    x.style.color = corLINK;
}

//funcao que retira cor
function retira_cor(x){
  x.style.color = corAntes;
  window.status="";
}

//funcao que chama pagina de filme
function pagina_filme(inicio,categoria){
  tira_banner();
  var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/filme/lista.php";    
   }else{
    end = "http://tvmidia.net/modulo/filme/lista.php";
   }
  criaAjax();
    Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            muda_para_seriado(categoria);
            scroll('0','0');
            top10(categoria);
            Requisicao = false;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "inicio="+inicio+"&categoria="+categoria;
       ajax.send(parans);
}

//funcao que chama pagina de series
function pagina_serie(inicio,categoria){
  tira_banner();
  var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/serie/lista.php";    
   }else{
    end = "http://tvmidia.net/modulo/serie/lista.php";
   }
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            Requisicao = false;
            muda_para_seriado(categoria);
             scroll('0','0');
             top10(categoria)
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "inicio="+inicio+"&categoria="+categoria;
       ajax.send(parans);
}

//funcao que chama pagina de series
function pagina_anime(inicio,categoria){
  tira_banner();
  var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/anime/lista.php";    
   }else{
    end = "http://tvmidia.net/modulo/anime/lista.php";
   }
    criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            document.getElementById("centro_mostra").innerHTML=ajax.responseText;
            muda_para_seriado(categoria);
            scroll('0','0');
            top10(categoria);
            Requisicao = true;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "inicio="+inicio+"&categoria="+categoria;
       ajax.send(parans);
}

//funcao que abre link para o downlaod
function abre_link(url){
  var end ="";
   end = location;
   if(end == "http://www.tvmidia.net/"){
    end = "http://www.tvmidia.net/modulo/propaganda/propaganda.php";    
   }else{
    end = "http://tvmidia.net/modulo/propaganda/propaganda.php";
   }
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            text = ajax.responseText;
            if(text == "certo"){
              window.open('http://tvmidia.net/view/propaganda/','_blank');    
            }else{
              alert("ERRO NO INSERIR ACESSO.");
            }
            Requisicao = true;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "url="+url;
       ajax.send(parans);
}


//funcao que vai inserir acesso
function novo_acesso(id){
  var end ="../../modulo/acessos/acesso.php";
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            text = ajax.responseText;
            if(text != "certo"){
              alert("ERRO NO INSERIR ACESSO.");
            }
            Requisicao = true;
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "id="+id;
       ajax.send(parans); 
}

//funcao que listara os top10
function top10(categoria){
  var end ="modulo/acessos/top10.php";
  criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            text = ajax.responseText;
            document.getElementById("item_sessao_topmais").innerHTML = text;  
            Requisicao = false;
            giro_item();
          }else{
              //erro no carregar imagen 
            
          }
        }else{
          //carregando
        }
       }
       var parans = "categoria="+categoria;
       ajax.send(parans); 
}

//funcao que realizara a busca de item
function busca_item(){
    var end = location;
      str_2 = new String(end);
      str_2 = str_2.substring(0,10);
      if(str_2 == "http://www"){
        end ="http://www.tvmidia.net/modulo/busca/busca.php";
      }else{
        end ="http:/tvmidia.net/modulo/busca/busca.php";
      }
    criaAjax();
      Requisicao = true;
      ajax.open("POST",end,true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange=function(){
        if(ajax.readyState == 4){ 
          if(ajax.status == 200){
            text = ajax.responseText;
            if(text == "nenhum"){
              document.getElementById("erroB").innerHTML = "Nenhum valor retornado.";
            }else{
              document.getElementById("busca").value = "";
              var cat = document.getElementsByName("categoria");
               for(var i=0; i<cat.length;i++){
                  cat[i].checked == false;
              }
              document.getElementById("erroB").innerHTML = "";  
              document.getElementById("centro_mostra").innerHTML = text;
            }
            Requisicao = false; 
          }else{
              //erro no carregar imagen 
          }
        }else{
          //carregando
        }
       }
       var busca = document.getElementById("busca").value;
       if(busca == ""){
        document.getElementById("erroB").innerHTML ="Digite titulo para busca.";  
        return false;
       }else{
         document.getElementById("erroB").innerHTML ="";
       }
       var categoria = document.getElementsByName("categoria");   
       var id_c = "";
       for(var i=0; i<categoria.length;i++){
        if(categoria[i].checked == true){
          id_c = id_c+categoria[i].value;  
        } 
      }
      var parans = "id_categoria="+id_c+"&busca="+busca;
      //alert(id_c);
      //alert(busca);
      ajax.send(parans); 
   
} 

//-------area de funcoes de comentario------------
//funcao que chama pagina de cadastro de comentario
function pagina_cadastro_comentario(){
  
   var text = document.getElementById("novoC").innerHTML;
   if(text != ""){
      document.getElementById("novoC").innerHTML = "";
   }else{
     var end = location;
      str_2 = new String(end);
      str_2 = str_2.substring(0,10);
      if(str_2 == "http://www"){
        end ="http://www.tvmidia.net/view/comentario/cadastro.php";
      }else{
        end ="http:/tvmidia.net/view/comentario/cadastro.php";
      }
    
    criaAjax();
        Requisicao = true;
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){ 
            if(ajax.status == 200){
                document.getElementById("novoC").innerHTML = ajax.responseText;
                Requisicao = false;
            }else{
                //erro no carregar imagen 
            }
          }else{
            //carregando
             var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
             document.getElementById("novoC").innerHTML = html;
          }
        }
       ajax.send(null);
  }
}

//funcao que inseri comentario para o item 
function inserir_comentario(id){
  var end = location;
  str_2 = new String(end);
  str_2 = str_2.substring(0,10);
  if(str_2 == "http://www"){
    end ="http://www.tvmidia.net/modulo/comentario/cadastro.php";
  }else{
    end ="http://tvmidia.net/modulo/comentario/cadastro.php"; 
  }
  criaAjax();
  Requisicao = true;  
  ajax.open("POST",end,true);
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  ajax.onreadystatechange=function(){
    if(ajax.readyState == 4){ 
      if(ajax.status == 200){
        var texto = ajax.responseText;
        if(texto == "certo"){
          document.getElementById("novoC").innerHTML = "Obrigado por Comentar";
          comentarios(id);  
        }else{
          document.getElementById("erroC").innerHTML = "erro no inserir comentario.";
        }
        Requisicao = true;
      }else{
        //erro no carregar imagen 
      }
    }else{
      //carregando
       
    }
  }
  var nome = document.getElementById("nome").value;
  var txt = document.getElementById("email").value;
  var comentario = document.getElementById("comentario").value;
  if(nome != ""){
    if(comentario != ""){
      if((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7))){
        document.getElementById("erroC").innerHTML = "ERRO e-mail invalido.";
      }else{
        if(txt != ""){
          var parans = "nome="+nome+"&comentario="+comentario+"&email="+txt+"&id_item="+id;
          document.getElementById("erroC").innerHTML = "";
          ajax.send(parans);
        }else{
           document.getElementById("erroC").innerHTML = "ERRO no campo e-mail.";
        }  
      }
    }else{
      document.getElementById("erroC").innerHTML = "ERRO no campo cometario.";    
    }
  }else{
    document.getElementById("erroC").innerHTML = "ERRO no campo Nome.";
  }  
}

//funcao que mostra comentarios na tela
function comentarios(id_item){
var text = document.getElementById("comentarios").innerHTML;
   if(text != ""){
      document.getElementById("comentarios").innerHTML = "";
   }else{   
    end = location;
    str_2 = new String(end);
    str_2 = str_2.substring(0,10);
    if(str_2 == "http://www"){
      end ="http://www.tvmidia.net/modulo/comentario/lista.php";
    }else{
       end ="http://tvmidia.net/modulo/comentario/lista.php";
    }
    criaAjax();
      Requisicao = true;
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){ 
            if(ajax.status == 200){
                  document.getElementById("comentarios").innerHTML =ajax.responseText;              
            }else{
                //erro no carregar imagen 
            }
          }else{
            //carregando
            var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
            document.getElementById("comentarios").innerHTML = html;
          }
          Requisicao = false;
        }
        var parans = "id_item="+id_item;
       ajax.send(parans);
  }
}

//funcao que fazem parte de contato
function pagina_contato(onde){
  mostraContato = onde;
  if(onde != "centro_mostra"){
    var text = document.getElementById(onde).innerHTML;
    if(text != ""){
      document.getElementById(onde).innerHTML="";
      return false;
    }    
  }
  end = location;
  str_2 = new String(end);
  str_2 = str_2.substring(0,10);
  if(str_2 == "http://www"){
    end = "http://www.tvmidia.net/view/contato/contato.html";    
  }else{
    end = "http://tvmidia.net/view/contato/contato.html";
  }
  criaAjax();
    Requisicao = true;
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){ 
            if(ajax.status == 200){
                  document.getElementById(onde).innerHTML =ajax.responseText;
                  if(onde == "centro_mostra"){
                    muda_para_seriado(5);  
                  }              
            }else{
                //erro no carregar imagen 
            }
            Requisicao = false;
          }else{
            //carregando
            var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
            document.getElementById(onde).innerHTML = html;
          }
        }
        ajax.send(null);  
}

//funcao que chamara o script que mandara o e-mail
function enviar_email(onde){
  end = location;
  str_2 = new String(end);
  str_2 = str_2.substring(0,10);
  if(str_2 == "http://www"){
    end = "http://www.tvmidia.net/modulo/email/envia.php";    
  }else{
    end = "http://tvmidia.net/modulo/email/envia.php";
  }
   criaAjax();
    Requisicao = true;
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){ 
            if(ajax.status == 200){
              var texto = ajax.responseText;
              if(texto == "certo"){
                document.getElementById(mostraContato).innerHTML ="<h4 align='center' style='color:"+corLINK+"'>Mensagem Enviada.</h4>";              
              }else{
                document.getElementById("erroContato").innerHTML = "<h5 align='center' style='color:rgb(255,0,0)'>ERRO no envio, tente mais tarde.</h5>";  
              }
              Requisicao = false;
            }else{
                //erro no carregar imagen 
            }
          }else{
            //carregando
            var html = "<div class='class_link' align='center'><img src='http://www.tvmidia.net/imagens/carregar.gif'>CARREGANDO...</div>";
            document.getElementById("erroContato").innerHTML = html;
          }
        }
  var nome = document.getElementById("nome").value;
  var txt = document.getElementById("email").value;
  var mensagem = document.getElementById("mensagem").value;
  var assunto =  document.getElementById("assunto").value;
  if(nome != ""){
    if(mensagem != ""){
      if((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7))){
        document.getElementById("erroC").innerHTML = "ERRO e-mail invalido.";
      }else{
        if(txt != ""){
          if(assunto != ""){
            var parans = "nome="+nome+"&mensagem="+mensagem+"&email="+txt+"&assunto="+assunto+"&onde="+onde;
            document.getElementById("erroContato").innerHTML = "";
            ajax.send(parans);
          }else{
            document.getElementById("erroContato").innerHTML = "ERRO no campo assunto.";
          }
        }else{
           document.getElementById("erroContato").innerHTML = "ERRO no campo e-mail.";
        }  
      }
    }else{
      document.getElementById("erroContato").innerHTML = "ERRO no campo mensagem.";    
    }
  }else{
    document.getElementById("erroContato").innerHTML = "ERRO no campo Nome.";
  }  
}
//fim de area de e-mail


//funcao que giral e coloca item no veja Tambem 
function giro_item(){
  if(Requisicao == false){
   end = location;
    str_2 = new String(end);
    str_2 = str_2.substring(0,10);
    if(str_2 == "http://www"){
      end = "http://www.tvmidia.net/modulo/home/vejaT.php";    
    }else{
      end = "http://tvmidia.net/modulo/home/vejaT.php";
    }
    criaAjax();
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){
            if(ajax.status == 200){
              var text = ajax.responseText;
              if(text != "erro"){
                document.getElementById("vejaT").innerHTML=ajax.responseText;
              }else{
                 document.getElementById("vejaT").innerHTML= "ERRO no reuperar Itens.";
              }
              setTimeout('giro_item()',20000);              
            }else{
                //erro no carregar imagen  
            }
          }else{
            //carregando
          }
         }
         ajax.send(null);
   }else{
      setTimeout('giro_item()',10000);
   } 
}
//------------------------------------------------------------------------------------------------------------

//funções da enquete
function votar_enquete(){
    Requisicao == true;
    end = location;
    str_2 = new String(end);
    str_2 = str_2.substring(0,10);
    if(str_2 == "http://www"){
      end = "http://www.tvmidia.net/modulo/enquete/votar.php";    
    }else{
      end = "http://tvmidia.net/modulo/enquete/votar.php";
    }
   criaAjax();
        ajax.open("POST",end,true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange=function(){
          if(ajax.readyState == 4){
            if(ajax.status == 200){
              document.getElementById("item_sessao_enquete").innerHTML=ajax.responseText;
              Requisicao == false;              
            }else{
                //erro no carregar imagen  
            }
          }else{
            //carregando
          }
         }
      var categoria = document.getElementsByName("enquete");
      var id_c = "";
      for(var i=0; i<categoria.length;i++){
        if(categoria[i].checked == true){
          id_c = id_c+categoria[i].value;  
        } 
      }
      if(id_c != ""){
        var parans = "id_p="+id_c;
        ajax.send(parans);
      }else{
        alert("algun erro acorrido.");
      }
}

function deixaVisivel(id,e){
  var nome = "lj"+id;
  var PY = e.clientY;
  var PX = e.clientX;
  //alert(e.clientY);
  var resolucao = screen.width;
  var metadeR = resolucao/2;
  if(PX > metadeR){
     PX = PX-500; 
  }else{
    PX = parseFloat(PX) + parseFloat("16");
  }
  //alert();
  PY = PY+document.body.scrollTop;
  document.getElementById(nome).style.top=PY+"px";
  document.getElementById(nome).style.left=PX+"px";
  document.getElementById(nome).style.visibility = "visible"; 
}

function deixaInvisivel(id){
  var nome = "lj"+id;
  document.getElementById(nome).style.visibility = "hidden";
}

