//http://www.noupe.com/tutorial/drop-down-menu-jquery-css.html
jQuery(function($) {
  
  // Main Menu Rollovers
  $("#menu-main-menu li a").hover(function() {
    $(this).parent().find("ul.sub-menu li").delay(50).slideDown('fast');
    $(this).parent().hover(function() {
    }, function(){
      $(this).parent().find("ul.sub-menu li").slideUp('fast');
    });

    }).hover(function() {
      $(this).addClass("subhover"); 
    }, function(){
      $(this).removeClass("subhover");
  });

  // Disable parent click
  $("li:has(ul)").hover(function () {
    $(this).children("a").click(function () {
      return false;
    });
  });
  
  // Project Rollovers
  $("#project_menu li a").hover(function() {
    $(this).parent().find("ul.children li").delay(50).slideDown('fast');
    $(this).parent().hover(function() {
    }, function(){
      $(this).parent().find("ul.children li").slideUp('fast');
    });

    }).hover(function() {
      $(this).addClass("subhover"); 
    }, function(){
      $(this).removeClass("subhover");
  });
  
  // Highlite News Category if we are on a single page
  if(is_single) {
    $("#menu-item-382").addClass("current-menu-parent");
  }
  
  // Email hint
  $('.email_field')
    .focus(function() {
      var location = $(this).val();
      if (location == 'example@email.com') {
        $(this).val('').css({color: '#333'});
      }
    })
    .blur(function() {
      var location = $(this).val();
      if (location == '') {
        $(this).val('example@email.com').css({color: '#bbb'});
      }
    });
    
  // Open PDF in new window
  $("a.pdf_open").click(function(e){
    var url = $(this).attr('href');
    var w = parseInt((screen.width/100) * 80);
    var h = parseInt((screen.height/100) * 80);
    var l = parseInt((screen.availWidth/2) - (w/2));
    var t = parseInt((screen.availHeight/2) - (h/2));
    newWindow = window.open(url,"pdf_window","menubar=1,resizable=1,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t);
    newWindow.focus();
    e.preventDefault();
  });
    
});
