var $j = jQuery.noConflict();

$j(function(){
	 $j("h2:contains('Home')").hide();
	 $j("#headerimg2").css("backgroundImage","url('/wp-content/themes/uscs/images/header"+Math.ceil(Math.random()*15)+".jpg')");
     $j('td.nav').hover(

          function(){

               clearNavText($j(this).attr("id"));

               $j("#"+$j(this).attr("id")+"2 > div").fadeIn("fast");

               switch($j(this).attr("id")){

                    case "worship":

                         var sLeft = ($j("#page").offset().left + 155) + "px";

                         $j("#worship_text").css({position:"absolute",top:"170px",left:sLeft}).fadeIn("slow");

                         break;

                    case "academics":

                         var sLeft = ($j("#page").offset().left + 310) + "px";

                         $j("#academics_text").css({position:"absolute",top:"155px",left:sLeft}).fadeIn("slow");

                         break;

                    case "missions":

                         var sLeft = ($j("#page").offset().left + 470) + "px";

                         $j("#missions_text").css({position:"absolute",top:"170px",left:sLeft}).fadeIn("slow");

                         break;

                    case "leadership":

                         var sLeft = ($j("#page").offset().left + 265) + "px";

                         $j("#leadership_text").css({position:"absolute",top:"170px",left:sLeft}).fadeIn("slow");

                         break;

                    case "adventure":

                         var sLeft = ($j("#page").offset().left + 420) + "px";

                         $j("#adventure_text").css({position:"absolute",top:"150px",left:sLeft}).fadeIn("slow");

                         break;

               }

          },

          function(){

               clearNavText($j(this).attr("id"));

          }

     ).click(function(){

          window.location = "/"+$j(this).attr("id");

     });

     function clearNavText(id){

          $j("#"+id+"2 > div").fadeOut("slow");

          $j("#worship_text").hide();

          $j("#academics_text").hide();

          $j("#missions_text").hide();

          $j("#leadership_text").hide();

          $j("#adventure_text").hide();

     }

     $j('tr.nav').hover(

          function(){

               $j("#headerimg2").fadeTo("slow",0.33);

          },

          function(){

               $j("#headerimg2").fadeTo("slow",1);

               clearNavText(0);

          }

     );

     $j('#logo button').hover(

          function(){

               $j(this).css("background-position","0% -19px");

          },

          function(){

               $j(this).css("background-position","0% 0%");

          }

     );

     

});
