jQuery.fn.prepareSubnav = function() {
  //$(this).parent().find("a").css({
  //  "top": "-100px",
  //  "height": "122px"
  //}); //css
  //$(this).parent().find("ul.subnav").css("opacity", "0");
  
  $(this).parent().hover(function(){
    $(this).find("a:first").stop();
    $(this).find("ul.subnav").stop();
    $(this).parent().stop();
    $(this).find("a:first").css("color", "#007ea1");
    $(this).find("a:first").animate({
      "top": "-110px",
      "height": "133px"
    }, 350); //this.animate
    $(this).find("ul.subnav").animate({
      "marginTop": "-72px"
    }, 350);
    
    if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)
    {
      $(this).parent().animate({
        "bottom": "-110px"
      }, 350);
    }
      
  },
  function(){
     $(this).find("a:first").stop();
     $(this).find("ul.subnav").stop();
     $(this).parent().stop();
     $(this).find("a:first").css("color", "#ffffff");
     $(this).css("marginTop", "157px");
      $(this).find("a:first").animate({
        "top": "0",
        "height": "23px"
      }, 350); //this.animate
      $(this).find("ul.subnav").animate({
        "marginTop": "39px"
      }, 350);
      
      if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)
      {
        $(this).parent().animate({
          "bottom": "-1px"
        }, 350);
      }
  }); //parent.hover
  
  
  //subnav li hover
  
  $(this).find("li a").each(function(){
    $(this).hover(function(){
      $(this).css("background-color", "#333");
      $(this).animate({
        "opacity": ".9"
        }, 0);
    }, function(){
      $(this).css("background-color", "transparent");
      $(this).animate({
        "opacity": "1"
        }, 0);
    });
  });
}; //attachSubnav

jQuery.fn.prepareNav = function() {
  
  //wrap featured and body ad in relative positioned div to pull their z-index abover nav menu
  $("#content div:first").wrap('<div id="featured_container"></div>');
  $("#featured_container").css("position", "relative");
  $("#featured_container").css("zIndex", "3000");
  $("#featured_container").height(($("#content div:eq(1)").height() + 30));
  $("#content div:eq(1)").css("position", "absolute");
  $("#content div:eq(1)").css("zIndex", "3000");
  
  $("#body_ad").wrap('<div id="body_ad_container"></div>');
  $("#body_ad_container").css("position", "relative");
  $("#body_ad_container").css("zIndex", "3000");
  $("#body_ad_container").css("height", "260px");
  $("#body_ad").css({
    "position": "absolute",
    "zIndex": "3000"
  });
  $("#body_ad").css("zIndex", "3000");
  
  $('.subnav').css('display', 'block');
  
  
  $("#content").prepend('<div id="menu_hider">&nbsp;</div>');
  $("#menu_hider").css({
    "width": "960px",
    "height": "75px",
    "position": "absolute",
    "zIndex": "2500",
    "background": "#fff",
    "top": "0px",
    "left": "0px"
  });
  
  return this.each(function(){
  $(this).css("position", "relative");
    $(this).find("a:first").css({
      "position": "relative",
      "zIndex": "2000",
      "background": "#000"
    });
    $(this).hover(function(){
      $(this).find("a:first").stop();
      $(this).parent().stop();
      $(this).css("color", "#007ea1");
      $(this).find("a:first").animate({
        "top": "-15px",
        "height": "38px"
      }, 200); //this.animate
      
      if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)
      {
        $(this).parent().animate({
          "bottom": "-15px"
        }, 200);
      }
    },
    function(){
      $(this).find("a:first").stop();
      $(this).parent().stop();
      $(this).css("color", "#ffffff");
      $(this).find("a:first").animate({
        "top": "0",
        "height": "23px"
      }, 200); //this.animate
      
      if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)
      {
        $(this).parent().animate({
          "bottom": "-1px"
        }, 200);
      }
    }); //this.hover
    
    //Now attach the subnavs
    $(this).find("ul.subnav").prepareSubnav();
    
  }); //this.each
}; //prepareNav
