function preloadHoverImages() {
  $("img").each(function() {
  
    var src = $(this).attr("src");
    if(src.indexOf("base") != -1) {
    
      var img = new Image();
      img.src = src.replace(/base/, "hover");
    }
  });
} 

$(document).ready(function() {
 
  // load the hover images
  preloadHoverImages();
   
  // assign the rollover code
  $(".ro").hover(
    function() {
     
      var src = $(this).attr("src");
      if(src.indexOf('/inactive') == -1) {
        src = src.replace(/active/, "base");      
        $(this).attr("src", src.replace(/base/, "hover"));
      }
    },
    function() {
     
      var src = $(this).attr("src");
      if(src.indexOf('/inactive') == -1) {
        src = src.replace(/active/, "hover");
        $(this).attr("src", src.replace(/hover/, "base"));
      }
    }
  ).mousedown(function() {

      var src = $(this).attr("src");
      if(src.indexOf('/inactive') == -1) {
        src = src.replace(/base/, "hover");
        $(this).attr("src", src.replace(/hover/, "active"));   
      }
      
  }).mouseup(function() {
      
      var src = $(this).attr("src");
      if(src.indexOf('/inactive') == -1) {
        src = src.replace(/base/, "active");
        $(this).attr("src", src.replace(/active/, "hover")); 
      }
  });
 
  $("div.center-block").hover(
    function() { //alert($(this).find(".faq-hide").css('display'));
     if($(this).find(".faq-hide").css('display') == 'none')
     {
      if ($("h3 a", this).length > 0) {
        var cnt = $(".content", this).css("background-image");
        $(".content", this).css("background-image", cnt.replace(/base/, 'hover'));

        var top = $(".top", this).css('background-image');
        $(".top", this).css('background-image', top.replace(/base/, 'hover'));
        
        var btm = $(".bottom", this).css('background-image');
        $(".bottom", this).css('background-image', btm.replace(/base/, 'hover'));
      }
     }
    },
    function() { 
    
      if ($("h3 a", this).length > 0) {
        var cnt = $(".content", this).css('background-image');
        $(".content", this).css('background-image', cnt.replace(/hover/, 'base'));

        var top = $(".top", this).css('background-image');
        $(".top", this).css('background-image', top.replace(/hover/, 'base'));
        
        var btm = $(".bottom", this).css('background-image');
        $(".bottom", this).css('background-image', btm.replace(/hover/, 'base'));
      }
    });
    
	$("div.center-block .faq-block h3 a").click(
	  function() {
       if($(this).parent().parent().children(".faq-hide").css('display') == 'none')
       {
         $(this).parent().parent().parent().mouseout();
         $("div.center-block .faq-block .faq-hide").hide();
	       $(this).parent().parent().children(".faq-hide").show();
       }
       else
       {
        $(this).parent().parent().children(".faq-hide").hide();
       }
      return false;
    }
	);
    
 
});

