/* SGP INFRONT - Gerado em:08/12/2011 */
// 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;
}

WebFontConfig = {
    google: { families: [ 'Open+Sans::latin' ] }
  };
  (function() {
    var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
      '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
  })();

function URLEncode(clearString) {
    var output = '';
    var x = 0;
    clearString = clearString.toString();
    var regex = /(^[a-zA-Z0-9_.]*)/;
    while (x < clearString.length) {
      var match = regex.exec(clearString.substr(x));
      if (match != null && match.length > 1 && match[1] != '') {
        output += match[1];
        x += match[1].length;
      } else {
        if (clearString[x] == ' ')
          output += '+';
        else {
          var charCode = clearString.charCodeAt(x);
          var hexVal = charCode.toString(16);
          output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
        }
        x++;
      }
    }
    return output;
  }
  function URLDecode (encodedString) {
    var output = encodedString;
    var binVal, thisString;
    var myregexp = /(%[^%]{2})/;
    while ((match = myregexp.exec(output)) != null
               && match.length > 1
               && match[1] != '') {
      binVal = parseInt(match[1].substr(1),16);
      thisString = String.fromCharCode(binVal);
      output = output.replace(match[1], thisString);
    }
    return output;
  }


//Busca TOPO
function go_busca(){
  var busca_campo = returnObjById('busca_campo');
  var busca_destino = '/pesquisa/' + URLEncode(busca_campo.value);
  if ( busca_campo.value == '' || busca_campo.value == 'Pesquisa...' ){
    alert('Busca inválida.');
    return false;
  }else{
    document.nav_login.action=busca_destino;
    document.nav_login.submit();
  }
}

$(document).ready(function() {
  
  $('#busca_campo').keyup(function(e) {
    //alert(e.keyCode);
    if(e.keyCode == 13) {
      go_busca();
    }
  });
  
   $(".hover_social").hover(      
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/header/" + temp_id + "_cor.png");
      },
      function() {
        temp_id = this.id;
        $(this).attr("src", "/images/_custom/header/" + temp_id + ".png");
      });
  
  
});
