/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
$(document).ready(function(){
current1 = 1;
button1 = 1;
images = 10;
width = 427;

$('#p1').animate({"left": "0px"}, 400, "swing");
$('#b1').css("backgroundPosition", "left bottom")
$('#b1 b').css("color","#fff");

$("#next").click(function() {
		button1 = current1;
		current1++
	if (current1 == (images+1) ) {current1 = 1}
animateLeft(current1,button1)
});

$("#previous").click(function() {
		button1 = current1;
		current1--
	if (current1 == 0 ) {current1 = images}
animateRight(current1,button1)
});

$("#buttons1 div").click(function() {
	button1=current1;
	clickButton = $(this).attr('id');
	current1 = parseInt(clickButton.slice(1));
	if (current1 > button1) {animateLeft(current1,button1)}
	if (current1 < button1) {animateRight(current1,button1)}
});

$("#buttons1 div b").mouseover(function() {
	if (($(this).css("color")) == "#16a" || ($(this).css("color")) == "rgb(17, 102, 170)") {$(this).css("color","#000");}
});

$("#buttons1 div b").mouseout(function() {
	if (($(this).css("color")) == "#000" || ($(this).css("color")) == "rgb(0, 0, 0)") {$(this).css("color","#16a");}
});


function animateLeft(current1,button1) {
	$('#p'+current1).css("left",width +"px");
	$('#p'+current1).animate({"left": "0px"}, 400, "swing");
	$('#p'+button1).animate({"left": -width+"px"}, 400, "swing");
	setbutton()
}

function animateRight(current1,button1) {
	$('#p'+current1).css("left",-width+"px");
	$('#p'+current1).animate({"left": "0px"}, 400, "swing");
	$('#p'+button1).animate({"left": width+"px"}, 400, "swing");
	setbutton()
}

function setbutton () {
	$('#b'+button1).css("backgroundPosition", "left top")
	$('#b'+button1+' b').css("color","#16a");
	$('#b'+current1).css("backgroundPosition", "left bottom")
	$('#b'+current1+' b').css("color","#fff");
}

/* pestaņa 2 */ 
/* **************************************************************** */
current2 = 1;
button2 = 1;
images = 10;
width = 427;

$('#q1').animate({"left": "0px"}, 400, "swing");
$('#c1').css("backgroundPosition", "left bottom")
$('#c1 b').css("color","#fff");

$("#next").click(function() {
		button2 = current2;
		current2++
	if (current2 == (images+1) ) {current2 = 1}
animateLeft2(current2,button2)
});

$("#previous").click(function() {
		button2 = current2;
		current2--
	if (current2 == 0 ) {current2 = images}
animateRight2(current2,button2)
});

$("#buttons2 div").click(function() {
	button2=current2;
	clickButton = $(this).attr('id');
	current2 = parseInt(clickButton.slice(1));
	if (current2 > button2) {animateLeft2(current2,button2)}
	if (current2 < button2) {animateRight2(current2,button2)}
});

$("#buttons2 div b").mouseover(function() {
	if (($(this).css("color")) == "#16a" || ($(this).css("color")) == "rgb(17, 102, 170)") {$(this).css("color","#000");}
});

$("#buttons2 div b").mouseout(function() {
	if (($(this).css("color")) == "#000" || ($(this).css("color")) == "rgb(0, 0, 0)") {$(this).css("color","#16a");}
});


function animateLeft2(current2,button2) {
	$('#q'+current2).css("left",width +"px");
	$('#q'+current2).animate({"left": "0px"}, 400, "swing");
	$('#q'+button2).animate({"left": -width+"px"}, 400, "swing");
	setbutton2()
}

function animateRight2(current2,button2) {
	$('#q'+current2).css("left",-width+"px");
	$('#q'+current2).animate({"left": "0px"}, 400, "swing");
	$('#q'+button2).animate({"left": width+"px"}, 400, "swing");
	setbutton2()
}

function setbutton2 () {
	$('#c'+button2).css("backgroundPosition", "left top")
	$('#c'+button2+' b').css("color","#16a");
	$('#c'+current2).css("backgroundPosition", "left bottom")
	$('#c'+current2+' b').css("color","#fff");
}

/* **************************************************************** */


/* pestaņa 3 */ 
/* **************************************************************** */
current3 = 1;
button3 = 1;
images = 10;
width = 427;

$('#r1').animate({"left": "0px"}, 400, "swing");
$('#d1').css("backgroundPosition", "left bottom")
$('#d1 b').css("color","#fff");

$("#next").click(function() {
		button3 = current3;
		current3++
	if (current3 == (images+1) ) {current3 = 1}
animateLeft3(current3,button3)
});

$("#previous").click(function() {
		button3 = current3;
		current3--
	if (current3 == 0 ) {current3 = images}
animateRight3(current3,button3)
});

$("#buttons3 div").click(function() {
	button3=current3;
	clickButton = $(this).attr('id');
	current3 = parseInt(clickButton.slice(1));
	if (current3 > button3) {animateLeft3(current3,button3)}
	if (current3 < button3) {animateRight3(current3,button3)}
});

$("#buttons3 div b").mouseover(function() {
	if (($(this).css("color")) == "#16a" || ($(this).css("color")) == "rgb(17, 102, 170)") {$(this).css("color","#000");}
});

$("#buttons3 div b").mouseout(function() {
	if (($(this).css("color")) == "#000" || ($(this).css("color")) == "rgb(0, 0, 0)") {$(this).css("color","#16a");}
});


function animateLeft3(current3,button3) {
	$('#r'+current3).css("left",width +"px");
	$('#r'+current3).animate({"left": "0px"}, 400, "swing");
	$('#r'+button3).animate({"left": -width+"px"}, 400, "swing");
	setbutton3()
}

function animateRight3(current3,button3) {
	$('#r'+current3).css("left",-width+"px");
	$('#r'+current3).animate({"left": "0px"}, 400, "swing");
	$('#r'+button3).animate({"left": width+"px"}, 400, "swing");
	setbutton3()
}

function setbutton3 () {
	$('#d'+button3).css("backgroundPosition", "left top")
	$('#d'+button3+' b').css("color","#16a");
	$('#d'+current3).css("backgroundPosition", "left bottom")
	$('#d'+current3+' b').css("color","#fff");
}

/* **************************************************************** */

});






