$(document).ready( function() {
	
	if($("#fs_container").length){
			$('#fs_container').parent().append('<a href="#" title="next" id="next2">next</a>');
			$('#fs_container').parent().append('<a href="#" title="previous" id="prev2">previous</a>');
			$('#fs_container a#next2').click(function(){
				return false;
				});
			$('#fs_container a#prev2').click(function(){
				return false;
				});
			$('#fs_container').cycle({
				fx:     'fade',
				timeout: 0,
				next:   '#next2',
				prev:   '#prev2'
			});
		}
	
	$('#mycarousel').jcarousel({
				vertical: true,
				animation: 'slow',
				scroll: 2
    });
	
	if($("#left-coming-soon").length){
		$('#defaultCountdown').countdown({until: $.countdown.UTCDate(-7, releaseDay), description: 'until release day!'}); 
	}
	
	
	
	$('#main-recent-releases').each(function(){

        var rrTitle = 0, rrBlurb = 0, rrGenre = 0, rrLength = 0;
        var overallTitle = 0, overallBlurb = 0, overallGenre = 0, overallLength = 0;
        
        var parent = $(this);
            
        $('div',parent).each(function(){
            var product = $(this);
            
            rrTitle = $('h3',product).height();
            if(rrTitle > overallTitle){ overallTitle = rrTitle; }
            
            rrBlurb = $('p.blurb',product).height();
            if(rrBlurb > overallBlurb){ overallBlurb = rrBlurb; }
            
            rrGenre = $('p.genre',product).height();
            if(rrGenre > overallGenre){ overallGenre = rrGenre; }
            
            rrLength = $('p.length',product).height();
            if(rrLength > overallLength){ overallLength = rrLength; }
        });
        
        $('h3', parent).css({height: overallTitle + "px"});
        $('p.blurb', parent).css({height: overallBlurb + "px"});
        $('p.genre', parent).css({height: overallGenre + "px"});
        $('p.length', parent).css({height: overallLength + "px"});
        
        
    });
	
	
	$('.category-block').each(function(){
		
		var rrTitle = 0, rrBlurb = 0, rrGenre = 0, rrLength = 0;
		var overallTitle = 0, overallBlurb = 0, overallGenre = 0, overallLength = 0;
		
		var parent = $(this);
			
		$('div',parent).each(function(){
			var product = $(this);
			
			rrTitle = $('h3',product).height();
			if(rrTitle > overallTitle){ overallTitle = rrTitle; }
			
			rrBlurb = $('p.blurb',product).height();
			if(rrBlurb > overallBlurb){ overallBlurb = rrBlurb; }
			
			rrGenre = $('p.genre',product).height();
			if(rrGenre > overallGenre){ overallGenre = rrGenre; }
			
			rrLength = $('p.length',product).height();
			if(rrLength > overallLength){ overallLength = rrLength; }
		});
		
		$('h3', parent).css({height: overallTitle + "px"});
		$('p.blurb', parent).css({height: overallBlurb + "px"});
		$('p.genre', parent).css({height: overallGenre + "px"});
		$('p.length', parent).css({height: overallLength + "px"});
		
		
	});
	
	
	$('div.series div.book-list').each(function(){
		
		var rrTitle = 0, rrBlurb = 0, rrGenre = 0, rrLength = 0;
		var overallTitle = 0, overallBlurb = 0, overallGenre = 0, overallLength = 0;
		
		var parent = $(this);
		
		$('div.span-4',parent).each(function(){
			var product = $(this);

			rrTitle = $('h3',product).height();
			if(rrTitle > overallTitle){ overallTitle = rrTitle; }
			
			rrGenre = $('p.genre',product).height();
			if(rrGenre > overallGenre){ overallGenre = rrGenre; }
			
			rrLength = $('p.length',product).height();
			if(rrLength > overallLength){ overallLength = rrLength; }
		});
		
		$('h3', parent).css({height: overallTitle + "px"});
		$('p.genre', parent).css({height: overallGenre + "px"});
		$('p.length', parent).css({height: overallLength + "px"});
		
		
	});
	
	
	
	
});
