// When DOM is ready, prepare portfolio
$(document).ready(function()
{
   var katalystJS = new KatalystJS();
   katalystJS.prepareElements();
});

var KatalystJS = function() 
{
   var footerSearchEl;
   var footerSearchDefaultTxt = "Enter search terms";
   
   prepareElements = function()
   {
      
      footerSearchEl = $('#search_text');
      footerSearchEl.focus(function(e){  
         $(this).addClass("active");
         if($(this).attr("value") == footerSearchDefaultTxt) $(this).attr("value", "");  
      });  
      footerSearchEl.blur(function(e){  
         $(this).removeClass("active");
         if($(this).attr("value") == "") $(this).attr("value", footerSearchDefaultTxt);  
      });
      
      
      $("#archive_select").change(function (){
         window.location = $("#archive_select option:selected").val();
      });
      
      
      if ( $('#about_imgs').length > 0 )
      {         
         $('#about_imgs').innerfade({
            speed: 1000,
            timeout: 5000,
            type: 'sequence',
            containerheight: '360px'
         });
      }
      
      if ( $('.book .imgs img').length > 0 )
      {
         $('.book .imgs img').load(function () {
            $(this).fadeIn();
         });
      }
      
      
      if ( $(".book .thumbs a").length > 0)
      {        
         $(".book .thumbs a").click(function () {
         
            if( !$(this).hasClass(".selected") )
            {
               var a = $(this);
               var src = a.attr('href');
               var img = $(".imgs img", a.parent().parent()).get(0);
            
               $(this).siblings().removeClass('selected');
               $(this).addClass('selected');
                        
               img.src = src;
               $(img).css({display:'none'});
            }
                                 
            return false;
         });
      
      }
      
      
      
      
      
             
   }
   this.prepareElements = prepareElements;
}