/*
	Author: 
	Company: 
	Date Created: 
	Date Last: 
	Description: jQuery used to operate the image slide.
*/

//Document Ready
$(function(){
		   
	//Item Quantity to display at 1 time
	var ContentItemDisplayQuantity = 1
		   
	//Finds the Content Item Width
	var ContentItemWidth = $('#SlideContent li').width();
	//alert(ContentItemWidth);
	
	//Finds how many Content Items there are. 
	var ContentItemQuantity = $('#SlideContent li').length;
	//alert(ContentItemQuantity);
	
	//Set the width of #SlideContent.
	var SlideContentWidth = ContentItemQuantity * (ContentItemWidth);
	$('#SlideContent').css('width',SlideContentWidth); //Should this be the css width?
	//alert(SlideContentWidth);
	
	//Slide list items to the right on "#RightArrow" click.
	$('#RightArrow').click(function(){
		//Prevent animation queue.		
		$('.Arrow').hide();
		
		$('#SlideContent').animate({
			marginLeft:'-=' + ContentItemWidth + ''
		}, 'slow', 'swing',
			function(){
				//Hide/Show right button.
				if ($('#SlideContent').css('marginLeft') == (SlideContentWidth - (SlideContentWidth + ((ContentItemQuantity-ContentItemDisplayQuantity) * ContentItemWidth))) + "px"){
					//$('#RightArrow').fadeOut();
					$('#RightArrow').hide();
				}
				else{
					//$('#RightArrow').fadeIn();
					$('#RightArrow').show();
				}
				//Hide/Show Left button.
				if ($('#SlideContent').css('marginLeft') == "0px"){
					//$('#LeftArrow').fadeOut();
					$('#LeftArrow').hide();
				}
				else{
					//$('#LeftArrow').fadeIn();
					$('#LeftArrow').show();
				}
			}
		);
	});
	
	//Slide list items to the right on "LeftArrow" click.
	$('#LeftArrow').click(function(){
		//Prevent animation queue.
		$('.Arrow').hide();
		
		$('#SlideContent').animate({
			marginLeft:'+=' + ContentItemWidth + ''
		}, 'slow', 'swing',
			function(){
				//Hide/Show right button.
				if ($('#SlideContent').css('marginLeft') == (SlideContentWidth - (SlideContentWidth + (4 * ContentItemWidth))) + "px"){
					//$('#RightArrow').fadeOut();
					$('#RightArrow').hide();
				}
				else{
					//$('#RightArrow').fadeIn();
					$('#RightArrow').show();
				}
				//Hide/Show Left button.
				if ($('#SlideContent').css('marginLeft') == "0px"){
					//$('#LeftArrow').fadeOut();
					$('#LeftArrow').hide();
				}
				else{
					//$('#LeftArrow').fadeIn();
					$('#LeftArrow').show();
				}
			}
		);
	});
	
	//Display overlay on hover.
	//$('#SlideContent li').hover(function(){
		//$(this).children('a:first').append('<img src="images/overlay-slide.png" width="269" height="116" alt="" title="" class="Overlay" />');
	//}, function(){
		//$('.Overlay').remove();
	//});
	
});
