/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
$jQuery(document).ready(function(){

	/* standard constants across the system 
	Note that the other settings are in the info-slide-default-settings.js file, or the specific artist file
	*/
	images = 3;
	width = 409;
	$jQuery('#loading').css("display","none");
	
	
	$jQuery("#next").click(function() {
			button = current;
			current++
		if (current == (images+1) ) {current = 1}
	animateLeft(current,button)
	});
	
	$jQuery("#previous").click(function() {
			button = current;
			current--
		if (current == 0 ) {current = images}
	animateRight(current,button)
	});
	
	$jQuery("#buttons div").click(function() {
		button=current;
		clickButton = $jQuery(this).attr('id');
		current = parseInt(clickButton.slice(1));
		if (current > button) {animateLeft(current,button)}
		if (current < button) {animateRight(current,button)}
	});
	
	/*
	$jQuery("#buttons div b").mouseover(function() {
		if (($jQuery(this).css("color")) == "#16a" || ($jQuery(this).css("color")) == "rgb(17, 102, 170)") {$jQuery(this).css("color","#000");}
	});
	
	$jQuery("#buttons div b").mouseout(function() {
		if (($jQuery(this).css("color")) == "#000" || ($jQuery(this).css("color")) == "rgb(0, 0, 0)") {$jQuery(this).css("color","#16a");}
	});
	*/
	
	function animateLeft(current,button) {
		$jQuery('#p'+current).css("left",width +"px");
		$jQuery('#p'+current).animate({"left": "0px"}, 400, "swing");
		$jQuery('#p'+button).animate({"left": -width+"px"}, 400, "swing");
		setbutton()
	}
	
	function animateRight(current,button) {
		$jQuery('#p'+current).css("left",-width+"px");
		$jQuery('#p'+current).animate({"left": "0px"}, 400, "swing");
		$jQuery('#p'+button).animate({"left": width+"px"}, 400, "swing");
		setbutton()
	}
	
	function setbutton () {
		$jQuery('#b'+button).css("backgroundPosition", "left top")
		$jQuery('#b'+button+' b').css("color","#fff");
		$jQuery('#b'+current).css("backgroundPosition", "left bottom")
		$jQuery('#b'+current+' b').css("color","#fff");
	}

});


