$(function(){
	$('#main_logo a').hover(function() {
		$(this).children('img').stop().animate({opacity: 0}, 650);
	}, function() {
		$(this).children('img').stop().animate({opacity: 1}, 1000);
	});
	
	

	
	$('.banner,.stills img').animate({opacity: .4},0);
	
	$('.banner,.stills img').hover(function() {
		$(this).stop().animate({opacity: 1}, 325);
	}, function() {
		$(this).stop().animate({opacity: .4}, 500);
	});
	
	
	//For stills only might want to include separately
	var ul_height = $('.stills ul').css('height');
	var margin = $('.stills ul').css('margin-top');
	ul_height = parseFloat(ul_height,10);
	margin = parseFloat(margin,10);
	var row_height = ul_height + margin;
	
	var ul = $('.stills ul').size();
	var inc = 3*row_height;
	var height = 0;
	
	var max_height = ul*row_height*-1;
	
	$('#prev img').animate({opacity: .5},0);
	if(height-inc <= max_height) //hide next button if it can't be used
	{
		$('#next img').animate({opacity: .5},1000);
	}
	
	$('#next').click(function() {
		if(height-inc > max_height)
		{
			height -= inc;
			$('.stills').animate({top :  height + "px"},1000);
		}
		
		if(height-inc <= max_height) //hide next button if it can't be used
		{
			$('#next img').animate({opacity: .5},1000);
		}
		
		if(height < -inc+1)
		{
			$('#prev img').animate({opacity: 1},1000);
		}
		return false;
	});
	
	$('#prev').click(function() {
		if(height < -inc+1)
		{
			height += inc;
			$('.stills').animate({"top" :  height + "px"},1000);
		}
		
		if(height > -inc+1)
		{
			$('#prev img').animate({opacity: .5},1000);
		}
		
		if(height-inc > max_height) //show next button if possible
		{
			$('#next img').animate({opacity: 1},1000);
		}
		return false;
	});
	
	//For video pages only, might want to include separately
	var j = 0;
	$('#video').click(function() {
		j++;
		var i = document.getElementById('video').GetRate();
		if(i>0)
		{
			$('#sidebar').stop().animate({opacity: .15}, 200);
			$('#credits').stop().animate({opacity: .15}, 200);
		}
		else
		{
			$('#sidebar').stop().animate({opacity: 1}, 500);
			$('#credits').stop().animate({opacity: 1}, 500);
		}
		if(j == 1)
		{
			$('#sidebar').stop().animate({opacity: .15}, 200);
			$('#credits').stop().animate({opacity: .15}, 200);
		}
	});
	
	$('*').mouseover(function() {
		var i = document.getElementById('video').GetRate();
		
		if(i<1)
		{
			$('#sidebar').stop().animate({opacity: 1}, 3000);
			$('#credits').stop().animate({opacity: 1}, 3000);
		}
	});
});