$(document).ready(function() {

  ////
  // Search Box
  // Set initial value
  $("#searchbox").val("Search")
                 .css("color", "#666666");
  
  //Show Hide when focus/unfocus
  $("#searchbox").livequery(function() {
    
    $(this).focus(function() {
      $(this).val("")
             .css("color", "#000000");
    });
    $(this).blur(function() {
      $(this).val("Search")
             .css("color", "#666666");
    });    
  });

    
  ////
  // Footer Drop Downs  
  // When a user selects an article, take user to that article
  $("select.footer_select_option").livequery('change', function() {
    var article = $(this).val();
    var pre = 'http://' + document.domain;
    parent.location = pre + "/home/FootHealth/" + article; 
  });
  ////
  // Credit Card Form Helper
  // Month
  $("#credit_card_month").val("mm");
  $("#credit_card_month").livequery(function() {
    $(this).focus(function() {
      if ($(this).val() == "mm") {
        $(this).val("");
      }
    });
    $(this).blur(function() {
      if ($(this).val() == "") {
        $(this).val("mm");
      } else if ($(this).val() > 12) {
        alert("The Value for month must be 12 or less!");
      }
    });
  });
  // Year
  $("#credit_card_year").val("yyyy");
  $("#credit_card_year").livequery(function() {
    $(this).focus(function() {
      if ($(this).val() == "yyyy") {
        $(this).val("");
      }
    });
    $(this).blur(function() {
      if ($(this).val() == "") {
        $(this).val("yyyy");
      }
    });
  });
  
  ////
  // Sub Menus
  //
  
  //initial hide of menus
  $(".sub_nav_ul").hide();
  
  
  $("ul#nav li").livequery(function(){
    var TheMenu = "#" + $(this).attr('class');
    var TheParentC = $(this).attr('class');
    var TheParent = "." + TheParentC;
    var TheParentS = TheParentC + "_sel";
    
    $(this)
      .hover(function(){
        $(TheMenu).show(1,function() {
          $(TheParent).attr('class', TheParentC + "_sel");
          $(this)
            .hover(function() {
              $(this).show();
              $(TheParent).attr('class', TheParentC + "_sel");
            }, function() {
              $(this).hide();
              $("."+TheParentS).attr('class', TheParentC);
            });
        });
      }, function() {
        $(TheMenu).hide();
        $("."+TheParentS).attr('class', TheParentC);
      });    

    
  });  

});
