var url_site="http://www.rubensotoni.com.br"
var titulo_site="www.rubensotoni.com.br"
function favoritos(){if (document.all)window.external.AddFavorite(url_site,titulo_site)}

function validaForm(){
         //validar nome
         d = document.boasnoticias;
         if (d.nome.value == ""){
               alert("O campo " + d.nome.name + " deve ser preenchido!");
               d.nome.focus();
               return false;
         }
         //validar email
         if (d.email.value == ""){
               alert("O campo " + d.email.name + " deve ser preenchido!");
               d.email.focus();
               return false;
         }
         //validar email(verificao de endereco eletronico)
         parte1 = d.email.value.indexOf("@");
         parte2 = d.email.value.indexOf(".");
         parte3 = d.email.value.length;
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
               alert("O campo " + d.email.name + " deve conter um endereco eletronico!");
               d.email.focus();
               return false;
         }

}
function submenu(menu){

        if(menu == "imprensa"){
           document.getElementById("imprensa").style.display = 'block';
        } else {
           document.getElementById("imprensa").style.display = 'none';
        }
        if(menu == "audio"){
           document.getElementById("audio").style.display = 'block';
        } else {
           document.getElementById("audio").style.display = 'none';
        }
        if(menu == "info"){
           document.getElementById("info").style.display = 'block';
        } else {
           document.getElementById("info").style.display = 'none';
        }
        if(menu == "conheca"){
           document.getElementById("conheca").style.display = 'block';
        } else {
           document.getElementById("conheca").style.display = 'none';
        }
        if(menu == "projetos"){
           document.getElementById("projetos").style.display = 'block';
        } else {
           document.getElementById("projetos").style.display = 'none';
        }


}
function toggleDiv(element){
       document.title = "Dep. Federal Rubens Otoni  - Site Oficial - Notícias, Trajetórias, Projetos de Lei, Agenda...";
//      var element = "pergunte";
          var display = document.getElementById(element).style.display;
      if(display == 'none')
      {
        document.getElementById(element).style.display = 'block';
      }
      else if(display == 'block')
      {
        document.getElementById(element).style.display = 'none';
      }
}

function closeDiv(element){
        document.getElementById(element).style.display = 'none';
}
/* RELOGIO */
var timeID=null;
var timerRunning=false;
function stopclock (){
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning=false;
        }
function startclock (){
        stopclock ();
        showtime ();
        }
function showtime() {
        var now=new Date();
        var hours= now.getHours();
        var minutes= now.getMinutes();
        var seconds= now.getSeconds();
        var timeValue=""+ hours;
        timeValue += ((minutes<10) ? ":0" : ":") + minutes
        timeValue += ((seconds<10) ? ":0" : ":") + seconds

        document.getElementById('relogio').innerHTML=timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;
        }

function imprimir(cat,id) {

   var width = 620;
   var height = 550;
   var left = 99;
   var top = 99;
   var URL = "?l=imprimir&cat="+cat+"&id="+id;
   window.open(URL, id, 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function pac() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=bannerPac";
   window.open(URL,'PAC', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function odm() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=bannerOdm";
   window.open(URL,'odm', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function Fanos() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=banner10anos";
   window.open(URL,'10anos', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function prouni() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=bannerProuni";
   window.open(URL,'prouni', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function biodiesel() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=bannerBiodiesel";
   window.open(URL,'biodiesel', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function falecomodep() {

   var width = 370;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/index.php?l=bannerFalecomodep";
   window.open(URL,'falecomodep', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function mulher() {

   var width = 625;
   var height = 350;
   var left = 99;
   var top = 99;
   var URL = "http://www.rubensotoni.com.br/mulher.html";
   window.open(URL,'mulher', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=yes, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // textarea
field.value = field.value.substring(0, maxlimit);

else
countfield.value = maxlimit - field.value.length;
}

function aleatorio(inferior,superior){
    numPosibilidades = superior - inferior
    aleat = Math.random() * numPosibilidades
    aleat = Math.floor(aleat)
    return parseInt(inferior) + aleat
}

function dame_code_aleatorio(){
        code = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e")
        code_aleatorio = "";
        code_end = "";
        for (i=0;i<6;i++){
                pos = aleatorio(0,code.length)
                code_aleatorio += "<img src='images/chaves/"+code[pos]+".gif'>";
                code_end += code[pos];
        }
    return code_aleatorio

}
function checar(code){
        if(document.getElementById('codigo').value==code)
        {
                var nome = document.form.nome.value;
                var email = document.form.email.value;
                var assunto = document.form.assunto.value;
                var pergunta = document.form.pergunta.value;

                if (nome=='' || email=='' || pergunta=='' || assunto=='')
                {
                        alert ('Todos os campos do formulario devem ser preenchidos.');
                        return false;
                } else {
          document.form.submit();
                }

        } else
        {
                        alert('Verifique o código informado');
        }
}
function playlist()
{
if (lista.style.display == "none")
{
lista.style.display = "";
}
else
{
lista.style.display = "none";
}
}

function track(musica)
{
         window.top.juke.location="jukebox/jukebox.php?p=00"+musica;
         document.getElementById("faixa").value = musica;
}

function avancar()
{
       var valor = document.getElementById("faixa").value;
       if(valor==''){
              var valor = 2;
              var musica = 2;
              document.getElementById("faixa").value = 2;
       } else {

         var musica = eval(valor)+1;
         if(musica==4){
                  document.getElementById("faixa").value = 1;
                  var musica = 1;
         }
         else {
                  document.getElementById("faixa").value = musica;
         }
       }
       window.top.juke.location="jukebox/jukebox.php?p=00"+musica;
}

function voltar()
{
       var valor = document.getElementById("faixa").value;
       if(valor==''){
              var valor = 3;
              var musica = 3;
              document.getElementById("faixa").value = 3;
       } else {

         var musica = eval(valor)-1;
         if(musica==0){
                  document.getElementById("faixa").value = 3;
                  var musica = 3;
         }
         else {
                  document.getElementById("faixa").value = musica;
         }
       }
       window.top.juke.location="jukebox/jukebox.php?p=00"+musica;
}

function stop()
{
       var musica = document.getElementById("faixa").value;
       if(musica==''){
              var musica = 1;
       }
       document.getElementById("faixa").value = musica;
       window.top.juke.location="jukebox/jukebox.php";

}
function play()
{
       var musica = document.getElementById("faixa").value;
       if(musica==''){
              var musica = 1;
       }
       document.getElementById("faixa").value = musica;
       window.top.juke.location="jukebox/jukebox.php?p=00"+musica;

}


function swf(){
theObjects = document.getElementsByTagName("embed");
for (var i = 0; i < theObjects.length; i++) {
theObjects[i].outerHTML = theObjects[i].outerHTML;
}}