$(function(){
// DOM Loaded 	
	//init js styles 
    $('body').addClass('hasJS');
	$('.movie').fadeIn(3000);
	// cycle functions    
	$('.gallery .bigimg').wrapAll('<div class="bigimgs">').parents('.gallery').prepend('<ul class="menu" id="feature_gallery_pager">').cycle({ 
        fx:'fade', 
        easing: 'swing', 
        inDelay:    250,
        drop:       40, 
        timeout:    3000,
		width: '300px',
		before:  onBefore,
        slideExpr: '.bigimg', 
        pager:      '#feature_gallery_pager',
		pagerAnchorBuilder: function(idx, slide){ 
			var folderName = $('#content').attr('title');				
			return '<li><a href="#"><img src="/images/'+folderName+'/'+slide.id+'" class="thumb"><span></span></a></li>';
       }		
    });		
	//jcarousel functions
	$(function() {
		jQuery('#feature_gallery_pager').jcarousel({
			vertical: false,
			auto: 10,
			scroll:4,
			visible:4
		});
	});	
	
	//glowing leftnav buttons on hover	
	var folderName = $('#content').attr('title');
	var pagesName = $('#leftLinks a.'+folderName+'').attr('title');	
	$('#leftLinks a').animate({
	opacity: 0.5
	}),0;
	$('a.'+folderName+'').animate({
	opacity: 1.0
	}),100;	
	$('a.'+folderName+'').text('~'+pagesName+'~');
	$('#leftLinks a').hover(function(){   
		$(this).fadeTo("fast", 1.0);   
		},function(){ 	
		$(this).fadeTo("fast", 0.5);
		$('a.'+folderName+'').animate({opacity: 1.0});
	});
	//glowing thumbnails on hover
	$('.thumb').animate({
	opacity: 0.5
	}),3000;
	$('img.thumb').hover(function(){   
		$(this).fadeTo("fast", 1.0);   
		},function(){ 	
		$(this).fadeTo("fast", 0.5);   
	});
	
	function onBefore() { 
		$('img.thumb').each(function(){
			$(this).load( 
				function(){ 
					$(this).thumb({height: 1, opacity: 1} );
				} 
			);			
		});
	}; 
});
