/* SGP INFRONT - Gerado em:30/09/2010 */
// Pop-Up Padrão do Site
function pop_master(url,a,l,sb)
{
        if (sb=="0"){
                saida_sb = "no";
        }else{
                saida_sb = "yes";
        }
        popupWin = window.open(url,'new_page','width=' + l + ',height=' + a + ',scrollbars=' + saida_sb + '');
}

// Crossbrowser GET ELEMENT BY ID
function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

$(document).ready(function() {
    $(".fade").hover(      
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/layout/" + temp_id + "_over.jpg");
      },
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/layout/" + temp_id + ".jpg");
      });
    
    $(".over2").hover(      
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/layout/" + temp_id + "_over.jpg");
        if ( temp_id == 'top_tweeter' ){        
          if ($("#texto_contato").is(":hidden")) {
                $("#texto_contato").text('Nosso Twitter').fadeIn("fast");
              } else {
              $("#texto_contato").hide();
            $("#texto_contato").text('Nosso Twitter').fadeIn("fast");            
            }        
        } else if ( temp_id == 'top_rss' ) {
          if ($("#texto_contato").is(":hidden")) {
                $("#texto_contato").text('Nosso RSS').fadeIn("fast");
              } else {
              $("#texto_contato").hide();
            $("#texto_contato").text('Nosso RSS').fadeIn("fast");            
            }
        }else if ( temp_id == 'top_email' ) {
          if ($("#texto_contato").is(":hidden")) {
                $("#texto_contato").text('Fale conosco').fadeIn("fast");
              } else {
              $("#texto_contato").hide();
            $("#texto_contato").text('Fale conosco').fadeIn("fast");            
            }
        }        
      },
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/layout/" + temp_id + ".jpg");
        $("#texto_contato").fadeOut("fast");
      });

  });



$(document).ready(function() {
  $("#busca_bt").click(function () { 
    busca();
    });
  
  $('#busca_fm').keyup(function(e) {
    //alert(e.keyCode);
    if(e.keyCode == 13) {
      busca();
    }
  });
});


function retira_acentos(palavra) {
    com_acento = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ';
    sem_acento = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC';
    nova='';
    for(i=0;i<palavra.length;i++) {
        if (com_acento.search(palavra.substr(i,1))>=0) {
            nova+=sem_acento.substr(com_acento.search(palavra.substr(i,1)),1);
        } else {
            nova+=palavra.substr(i,1);
        }
    }
    return nova;
}

function busca(){
  var txt = retira_acentos($("#busca_fm").val());

    if ( txt == '' ) {
     alert('Busca vazia');
   }

  else if ( txt.length < 4 ) {
     alert('Para utilizar a busca digite pelo menos 4 caracteres.');
   }

  else{
     location.href='/busca/' + txt;
   }
}
