function autoSlide(){
	var alive = $("#autoSlide").val();
	if(alive == "yes"){
		slideRight();
	}
}
function autoPdeuce(){
	var alive = $("#p2Auto").val();
	if(alive == "yes"){
		pushLeft();
	}
}
function turnAutoOff(){
	//Turn off auto slide
	$("#autoSlide").val("off");
}

function turnP2AutoOff(){
	//Turn off auto slide
	$("#p2Auto").val("off");
}

function slideLeft(){
	//Disable button
	$('.leftButton').attr("disabled", "true");

	var current = $("#currentSlide").val();
	current = current*1;
	var maxNum = $("#totalSlides").val();
	maxNum = maxNum*1;
	var nextSlide = current - 1;
	if(nextSlide < 1){
		nextSlide = maxNum;
	}
	
	// get next slide into position, set it's opacity to 0 and show it;
	var one = $("#LSlide_"+nextSlide).css("left","-955px");

	//Animate current slide off the stage and the next slide onto the page
	var four = $("#LSlide_"+nextSlide).animate({ left: "0px"}, 1000 );
	var five = $("#LSlide_"+current).animate({ left: "955px"}, 1000 );

	// Update current slide variable to be the slide we just moved onto the stage
	$("#currentSlide").val(nextSlide);
	
	//Enable button
	setTimeout("showButton('left')", 1000);
	
	for (i=0;i<=maxNum;i++){
		if(i == nextSlide){
			$("#pickLink"+i).css("border", "1px solid red");
		}else{
			$("#pickLink"+i).css("border", "0px");
		}
	}
}

function slideRight(){
	//Disable button
	$('.rightButton').attr("disabled", "true");

	var current = $("#currentSlide").val();
	current = current*1;
	var maxNum = $("#totalSlides").val();
	maxNum = maxNum*1;
	var nextSlide = current + 1;
	if(nextSlide > maxNum){
		nextSlide = 1;
	}
	
	// get next slide into position, set it's opacity to 0 and show it;
	var one = $("#LSlide_"+nextSlide).css("left","955px");

	//Animate current slide off the stage and the next slide onto the page
	var four = $("#LSlide_"+nextSlide).animate({ left: "0px"}, 1000 );
	var five = $("#LSlide_"+current).animate({ left: "-955px"}, 1000 );

	// Update current slide variable to be the slide we just moved onto the stage
	$("#currentSlide").val(nextSlide);
	
	//Enable button
	setTimeout("showButton('right')", 1000);
	
	for (i=0;i<=maxNum;i++){
		if(i == nextSlide){
			$("#pickLink"+i).css("border", "1px solid red");
		}else{
			$("#pickLink"+i).css("border", "0px");
		}
	}
}

function showButton(dir){
	$('.'+dir+'Button').removeAttr("disabled");
}
function showP2(dir){
	$('.p2'+dir).removeAttr("disabled");
}
function moveToPic(id){
	//Turn off auto slide
	$("#autoSlide").val("off");
	
	var current = $("#currentSlide").val();
	current = current*1;
	var maxNum = $("#totalSlides").val();
	maxNum = maxNum*1;
	var nextSlide = id;
	if(current != id){
		for (i=0;i<=maxNum;i++){
			if(i == id){
				$("#pickLink"+id).css("border", "1px solid red");
			}else{
				$("#pickLink"+i).css("border", "0px");
			}
		}
		// get next slide into position, set it's opacity to 0 and show it;
		var one = $("#LSlide_"+nextSlide).css("left","955px");
	
		//Animate current slide off the stage and the next slide onto the page
		var four = $("#LSlide_"+nextSlide).animate({ left: "0px"}, 1000 );
		var five = $("#LSlide_"+current).animate({ left: "-955px"}, 1000 );
	
		// Update current slide variable to be the slide we just moved onto the stage
		$("#currentSlide").val(nextSlide);

	}
}

function pushLeft(){
	//Disable button
	$('.p2Left').attr("disabled", "true");
	var increment = $("#p2increment").val();
	var current = $("#currentP2").val();
	current = current*1;
	var maxNum = $("#totalP2").val();
	maxNum = maxNum*1;
	var nextSlide = current - 1;
	if(nextSlide < 1){
		nextSlide = maxNum;
	}
	
	//declare which 5 images are on the stage
	var stage = []; // array to put all 5 image ids into
	var x = current;
	var next = 0;
	for (i=0;i<4;i++){
		if(i == 0){
			next = current;
		}else{
			next = next + 1;
		}
		if(next > maxNum){
			next = 1;
		}
		stage[i] = next;
	}
	// get next slide into position, set it's opacity to 0 and show it;
	var one = $("#p"+nextSlide).css("left","-"+increment+"px");
	
	//alert("Current: " +current+"\nMax: "+maxNum+"\nOff Stage: " + nextSlide + "\nOn Stage: "+stage);
	
	//Animate current slides off the stage and the next slide onto the page
	var four = $("#p"+nextSlide).animate({ left: "0px"}, 2000 );
	x = 1;
	var move = increment;
	for (i=0;i<4;i++){
		move = increment * x;
		$("#p"+stage[i]).animate({ left: move+"px"}, 2000 );
		x++;
	}
	
	// Update current slide variable to be the slide we just moved onto the stage
	$("#currentP2").val(nextSlide);
	//Enable button
	setTimeout("showP2('Left')", 2000);
}

function pushRight(){
	//Disable button
	$('.p2Right').attr("disabled", "true");
	var increment = $("#p2increment").val();
	var current = $("#currentP2").val();
	current = current*1;
	var maxNum = $("#totalP2").val();
	maxNum = maxNum*1;
	var nextUp = current +1;
	if(nextUp > maxNum){
		nextUp = 1;
	}
	var nextSlide = current + 4;

	//declare which 5 images are on the stage
	var stage = []; // array to put all 5 image ids into
	var x = current;
	var next = 0;
	for (i=0;i<4;i++){
		if(i == 0){
			next = current;
		}else{
			next = next + 1;
		}
		if(next > maxNum){
			next = 1;
		}
		stage[i] = next;
	}

	if(nextSlide > maxNum){
		nextSlide = nextSlide - maxNum;
	}
	//alert("Current: " +current+"\nMax: "+maxNum+"\nOff Stage: " + nextSlide + "\nOn Stage: "+stage);
	
	// get next slide into position, set it's opacity to 0 and show it;
	var one = $("#p"+nextSlide).css("left","885px");
	var move = 885 - increment;

	//Animate current slides off the stage and the next slide onto the page
	var four = $("#p"+nextSlide).animate({ left: move+"px"}, 2000 );
	for (i=3;i>=0;i--){
		if(i != 5){
			move = move - increment;
		}
		$("#p"+stage[i]).animate({ left: move+"px"}, 2000 );
	}
	
	// Update current slide variable to be the slide we just moved onto the stage
	$("#currentP2").val(nextUp);
	//Enable button
	setTimeout("showP2('Right')", 2000);
}

function sortNumber(a,b)
{
	return b - a;
}

function homeCopy () {
	var stage=$("#homeStage").val();
	if (stage=='show') {
		$("#homeCopy").show();
		$("#homeStage").val('noShow');
	}
	else {
		$("#homeCopy").hide();
		$("#homeStage").val('show');
	}
}
function hideMe() {
	$("#arrowHide").hide();
}
function showMe() {
	$("#arrowHide").show();
}

/* THESE TWO FUNCTION TURN OFF THE NUMBER NAV OR TURN IT BACK ON AS NEEDED */
function hideNumbers(){
	$("#pictureNav").hide();
}
function showNumbers(){
	$("#pictureNav").show();
}

// case study show hide elements

function show(id) {
	document.getElementById(id).style.display = 'block';
}

function hide(id) {
	document.getElementById(id).style.display = 'none';
}			

