$(document).ready(function() {
  var ie6 = $.browser.msie && $.browser.version < 7;
  
  $('#MainNav li').mouseenter(function(e) {
    $(this).find('.subnav').show();
    if (ie6) $('select:not(".search-support select")').hide();
  }).mouseleave(function(e) {
    $(this).find('.subnav').hide();
    if (ie6) $('select:not(".search-support select")').show();
  });
  
  var initVal = $('#GlobalSearch input').val();
  $('#GlobalSearch input')
    .focus(function(){
      if (this.value == initVal) this.value = "";
    })
      .blur(function(){
        if (this.value == "") this.value = initVal;
      })
  var currLoc = String(window.location);
  currLoc = currLoc.substr(currLoc.indexOf("/")+1);
  currLoc = currLoc.substr(currLoc.indexOf("/")+1);
  currLoc = currLoc.substr(currLoc.indexOf("/")+1);
  var language = currLoc.substr(0,currLoc.indexOf("/"));
  
  $('#SearchBox').keypress(function(e){
    if (e.which == 13) {
      e.preventDefault();
      window.location.href = '/' + language + '/search?q='+$(this).val();
    }
  });
});
