/* ---------------------------- 
[Global Javascript]

Project: 	Mercer University - Be the Bear - HTML5 Presentation
Last change:	12/5/11 (File created)
Assigned to:	Third Wave Digital (www.thirdwavedigital.com)
------------------------------- */

$(document).ready(function() {
	
	/* ---------------------------- */
	/* iOS Specific
	/* ---------------------------- */		
	
	//Disable save image dialog on iOS devices
	document.body.style.webkitTouchCallout="none"; 
	
	/* ---------------------------- */
	/* Left & Right Movement + Arrows
	/* ---------------------------- */
	
	var studentsX = $("#students").position().left; 
	var studentsIncrement = 500;
	var studentsDuration = 1500;
	
	var foregroundX = $("#foreground").position().left; 
	var foregroundIncrement = 200;
	var foregroundDuration = 2500;

	function moveLeft() {
		//Move the students
		if (studentsX < 580) {
			$("#students").css("left",studentsX+=studentsIncrement);
		};
		//Move the foreground
		$("#foreground").css("left",foregroundX+=foregroundIncrement );
	
		//Show & hide the nav arrows
		if (studentsX >= 580) {
			$("#move-left").hide();
		} else {
			$("#move-right").show();
		};

	};
	function moveRight() {
		//Move the students
		if (studentsX > -2100) {
			$("#students").css("left",studentsX-=studentsIncrement);
		};
		//Move the foreground
		$("#foreground").css("left",foregroundX-=foregroundIncrement);
		
		//Show & hide the nav arrows
		if (studentsX <= -2100) {
			$("#move-right").hide();
		} else {
			$("#move-left").show();
		};
	};
	
	$("#move-left").click(function(){
    	moveLeft();
		return false;
	});
	
	$("#move-right").click(function(){
    	moveRight();
		return false;
	});

	
	  	
});
