$(document).ready(function() {
  $("a").bind("focus", function() {
    if (this.blur) {
      this.blur();
    }
  });

  var i = 0;
  $("*[class^=fees]").mouseover(function() {
    i = $(this).attr("class").substring(4);
  }).click(function() {
    $("*[class^=answer]").not(".answer" + i).hide();
    $(".answer" + i).show();
  });

  var j = 0;
  $("*[class^=navmenu]").hover(function() {
    image = $(this).children("img")[0];
    regex = /_a/;
    image.src = image.src.replace(regex, "_b");
    j = $(this).attr("class").substring(7);
    $("*[class^=submenuList]").hover(function(){
      $(".submenuList" + j).show();
      image = $(".navmenu" + j).children("img")[0];
      regex = /_a/;
      image.src = image.src.replace(regex, "_b");
    },function(){
      image = $(".navmenu" + j).children("img")[0];
      regex = /_b/;
      image.src = image.src.replace(regex, "_a");
      $(".submenuList" + j).hide();
    });
    $(".submenuList" + j).fadeIn('medium');
  },function() {
    $("*[class^=submenuList]").not('.navmenu'+j).hide();
    image = $(this).children("img")[0];
    regex = /_b/;
    image.src = image.src.replace(regex, "_a");
  });

  $(".sub").hover(function(){
    $(this).css( {
      "background" : "url(image/submit_b.png) no-repeat top left"
    });
  }, function() {
    $(this).removeAttr("style");
  });

  $(".reset").hover(function(){
    $(this).css( {
      "background" : "url(image/reset_b.png) no-repeat top left"
    });
  }, function() {
    $(this).removeAttr("style");
  });

  var index = 0;
  $("*[class^=question]").mouseover(function() {
    index = $(this).attr("class").substring(8);
  }).click(function() {
    $("*[class^=answer]").not(".answer" + index).hide();
    $(".answer" + index).slideDown("slow");
  });
  
  $(".tOurFees tr,.servicesT tr").hover( function() {
    $(this).css( {
      "background" : "#fbdbb2",
      "color" : "brown"
    });
  }, function() {
    $(this).removeAttr("style");
  });

  function countChecked(){
    var n = $("input:checked").length;
    $(".servicesAnswer").text("You answered 'Yes' " + n + " times");
  }
  countChecked();
  $(":checkbox").click(countChecked);
});