$j = jQuery.noConflict();

$j(function(){

       //interactive navigation
       $j('#slider_nav').jcarousel({
       scroll: 1
       });
       
       $j("#interactive_nav li a").each(function(){
              
           var mediaDir = '/wp-content/themes/twentyten/images/buttons/';   
           
           var titleAttr = $j(this).attr("title");
           
           var className = titleAttr.toLowerCase().replace(/ /g, "-");
           
           $j(this).parent().css("background", "url('"+ mediaDir + className+ ".jpg')  no-repeat scroll 0 0 transparent");
           
       });
       
       $j('#interactive_toggle a').click(function(event){
           
              event.preventDefault();
              $j('#interactive_nav').slideToggle('slow', function(){
              
              if($j(this).css("display") == "none")
              {
                     $j("#interactive_toggle").addClass('closed');
              }
              else
              {
                     $j("#interactive_toggle").removeClass('closed');
              }
              
              });
           
       });
       
       $j('#interactive_nav li').click(function(){
          
          $j(this).children().each(function(){
          
              var link = $j(this).attr('href');
              window.location = link; 
             
          
          });
              
          
       });
       //end interactive navigation
       
       //gallery
       $j('div.gallery img').click(function(){
          
         var fileName = $j(this).attr("alt");
         var galleryDir = $j(this).attr("rel");
         
         fileName =  fileName.replace('Small', 'Large');
         
         var galleryLargeImage = '/wp-content/themes/twentyten/images/gallery/' + galleryDir + '/large/' + fileName;
         
         $j('.headerimg').fadeOut('slow', function(){
              
               $j('.headerimg').html("<img src='"+ galleryLargeImage +"' alt='"+ fileName +"' />");
               
         });
         
       $j('html, body').animate({scrollTop:0}, 'fast');
       $j('.headerimg').fadeIn('slow');  
  
              
       });
       //end gallery
       
       /*Navigation make parent active*/
      var anycurrents =  $j("ul#nav_sub li.current_page_item").length;
      
      //nothing is current in the sidebar so it must be the first one
      if(anycurrents == 0)
      {
       
       $j("ul#nav_sub li:first").addClass("current_page_item");
              
      }
      
      
      
      
      




});
