/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {
	//same as $(document).ready();
	$(function() {
        $('.site-meta .search a').click(function(){
            if($(this).hasClass('active')){
                $(this).removeClass('active');
            } else {
                $(this).addClass('active');
            }
            $(this).next('#searchform').slideToggle('fast');
            return false;
        });
        $('.stories .slides').after('<div class="slides-nav"><ul>').cycle({
            fx: 'fade',
            speed: 500,
            pause: 1,
            timeout: 10000,
            pager: '.stories .slides-nav ul',
            pagerAnchorBuilder: function(idx, slide) {
                $('.stories .slides-nav ul').css({'width':(idx +1)*20 +'px'});
                return '<li><a href="#">' + (idx + 1) + '</a></li>'; 
            } 
        });
        
        $('.hero li').hover(
            function () {
                $(this).find('.door').animate({ height: '85px' }, 300, function() { });
            }, 
            function () {
                $(this).find('.door').animate({ height: '42px' }, 300, function() { });
            }
        );
        
        $('.gallery a').each(function(){
            newTitle = $(this).closest('dl').find('.wp-caption-text').html();
            $(this).attr('title', newTitle);
            $(this).attr('rel', 'gallery1');
        });
        
        $('.gallery a').fancybox({
	       'titlePosition' 		: 'inside'
        });
	});    
    
	$(window).bind("load", function() { });
	
})(jQuery);



