/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com -  NEA DIGITAL all rights reserved.

=================================================================== */
$(document).ready(function(){
current = 1;
button = 1;
images = 9;

$('#b1').css("backgroundPosition", "left bottom")
$('#b1 b').css("color","#fff");

$("#next").click(function() {
		button = current;
		current++
	if (current == (images+1) ) {current = 1}
		animate(current,button)
});

$("#previous").click(function() {
		button = current;
		current--
	if (current == 0 ) {current = images}
		animate(current,button)
});

$("#buttons div").click(function() {
	button=current;
	clickButton = $(this).attr('id');
	current = clickButton.substr(1,2);
	animate(current,button)
});

$("#buttons div b").mouseover(function() {
	if (($(this).css("color")) == "#3f697d" || ($(this).css("color")) == "rgb(63, 105, 125)") {$(this).css("color","#7fa9bd");}
});

$("#buttons div b").mouseout(function() {
	if (($(this).css("color")) == "#7fa9bd" || ($(this).css("color")) == "rgb(127, 169, 189)") {$(this).css("color","#3f697d");}
});

function animate(pY,bY) {

	move = -(current-1)*540;

	$('#slide').animate({"left": move + "px"}, 500, "swing");

	$('#b'+bY).css("backgroundPosition", "left top")
	$('#b'+bY+' b').css("color","#3f697d");

	$('#b'+pY).css("backgroundPosition", "left bottom")
	$('#b'+pY+' b').css("color","#fff");
}

});

