	// Constants
	var frameChangeSizeX = 0;
	var frameChangeSizeY = 255;
	var startPositionX = 0;
	var startPositionY = 0;
	
	// Variables
	var xPosition = 0;
	var yPosition = 0;
	var currentIndexPosition = 0;
	var minIndexPosition = 0;
	var frameMove = false;
	var animationDelay = 10000; // In milliseconds

	jQuery(document).ready(function(){
		
		// Gets the number of pictures being shown from the number of existing divs.
		minIndexPosition = ((jQuery(".albumpic").length) - 1) * -1;
	
		// Any button click action.
		jQuery('.albumbutton').click(function(){
		
			// Resets timeout for the automatic scroller
			clearTimeout(timeController);
			timeController = setInterval(moverItem, animationDelay);

			// Determines positions for scroller animation actions.
			var currentPlace = parseInt(jQuery('.album-container').css("left"));
			var strButtonId = jQuery(this).attr('id');
			if((strButtonId == 'album-previousbutton') && (currentIndexPosition < 0)) {
				currentIndexPosition += 1;
				frameMove = true;
			}
			else if((strButtonId == 'album-firstbutton') && (currentIndexPosition < 0)) {
				currentIndexPosition = 0;
				frameMove = true;
			}
			else if((strButtonId == 'album-nextbutton') && (currentIndexPosition > minIndexPosition)) {
				currentIndexPosition -= 1;
				frameMove = true;
			}
			else if((strButtonId == 'album-lastbutton') && (currentIndexPosition > minIndexPosition)) {
				currentIndexPosition = minIndexPosition;
				frameMove = true;
			}
			else {
				frameMove = false;
			}

			// Animation actions for scroller.
			if (frameMove) {
			    xPosition = startPositionX + (frameChangeSizeX * currentIndexPosition) + 'px';
			    yPosition = startPositionY + (frameChangeSizeY * currentIndexPosition) + 'px';
			    jQuery(".album-container").animate({ "left": xPosition, "top": yPosition }, { duration: 350, easing: "easeInOutExpo" });
			}
			
			// Buttons will be disabled accordingly
			if(currentIndexPosition == 0) {
				jQuery('.albumbutton:lt(2)').css('background-position','0 -44px').addClass('disabled');
				jQuery('.albumbutton:gt(1)').css('background-position','0 0').removeClass('disabled');
			}
			else if(currentIndexPosition == minIndexPosition) {
				jQuery('.albumbutton:gt(1)').css('background-position','0 -44px').addClass('disabled');
				jQuery('.albumbutton:lt(2)').css('background-position','0 0').removeClass('disabled');
			}
			else {
				jQuery('.albumbutton').css('background-position','0 0').removeClass('disabled');
			}			

		})
		.
		hover(
			function(){
				jQuery(this).css('background-position','0 -22px');
				jQuery(this).css('cursor','arrow');
			}
			,
			function(){
				jQuery(this).css('background-position','0 0');
			}
		);
		
		var timeController = setInterval(moverItem, animationDelay);
			
    });

	// Timer function will animate the box automatically.
	function moverItem() {
		if(currentIndexPosition > minIndexPosition) {
			jQuery("#album-nextbutton").trigger('click');
		}
		else {
			jQuery("#album-firstbutton").trigger('click');			
		}
	}
