<!--
/***************************************************
Sliding Image System
Copyright© 2008 Apollo Internet Media
Coded by Justin  Kercher.
****************************************************/

//required vars
	var curpan = 1;
	var totalpans = 8;
	var movetime = 10;
	var moveTurboMultiply = 1; //Turbo multiplier used when jumpin rooms. do NOT change from 1.
	var maxmove = 686; //number of pixels layers scroll when nav button pressed.  Should match the width of the parent layer.
	var moveamount = 0; //indicates number of pixels moved during the current move phase. do NOT change this.
	var locked = false; //prevent sliding when sliding already in progress
	var protectedRoom = 7; //Room that requries password to gain access.
	var access = false;
	var roomsSlide = 1; //number of rooms to slide
	var pURL; //url to goto when hotspot is clicked. set with the displayHotSpot function.
	var login; //hold user login id
	
	function initSlider() {
			displayRoomMenu();
	}
	
	//function to triger panel mover
	function moveLeft() {
		//only start moving panels to the left if there is another to the right
		if(curpan < totalpans && !locked) {
			//determine if we can proceed to next slide if it is protected
			if(curpan == protectedRoom && access==false) {
					alert("You must be logged in before you can access the staff room.");
			} else {		
				curpan++;
				roomsSlide = 1;
				
				//if not first layer, hide the move left icon
				if(curpan!=1)  
					document.getElementById("divLeft").style.display="block";

				//if last layer, hide right icon
				if(curpan==totalpans || (access==false && curpan==protectedRoom))
					document.getElementById("divRight").style.display="none";
				
				locked = true;
				//display the appropriate menu now
				displayRoomMenu();				
				scrollLeft();
			}
		}
	}
	
	//function to triger panel mover
	function moveRight() {
		//only start moving panels to the left if there is another to the right
		if(curpan > 1 && !locked) {
			//set the timeout
			curpan--;
			roomsSlide = 1;
			//if first layer, hide the move left icon
			if(curpan==1)  
				document.getElementById("divLeft").style.display="none";
			
			//if last layer, hide icon
			if(curpan!=totalpans || (access==false && curpan!=protectedRoom))
					document.getElementById("divRight").style.display="block";
			
			locked = true;
			//display the appropriate menu now
			displayRoomMenu();
			scrollRight();
		}
	}
	
	//functiont to scroll layers to the left
	function scrollLeft() {
		//check we still have space to move
		if(moveamount < maxmove) {
			//move all panels to the left
			for(var i=1;i<=totalpans;i++) {
				//get string of current element position
				var pos = document.getElementById("pan"+i).style.left;
				//find the int
				var left = parseInt(pos.replace("px",""));
				//set the new value				
				document.getElementById("pan"+i).style.left = (left-(movetime*moveTurboMultiply))+"px";
			}
			moveamount+=  (movetime*moveTurboMultiply);
			setTimeout(scrollLeft, 1);
		}
		else {
			//reset moved temp var
			moveamount = 0;
			//determine if we have to slide to anther room after the current one
			if(roomsSlide > 1) {
				roomsSlide--;
				setTimeout(scrollLeft, 1);
			}
			else {
				locked= false;
				//reset turbo
				moveTurboMultiply = 1;
			}
		}
	}
	
	//functiont to scroll layers to the left
	function scrollRight() {
		//check we still have space to move
		if(moveamount < maxmove) {
			//move all panels to the left
			for(var i=1;i<=totalpans;i++) {
				//get string of current element position
				var pos = document.getElementById("pan"+i).style.left;
				//find the int
				var left = parseInt(pos.replace("px",""));
				//set the new value				
				document.getElementById("pan"+i).style.left = (left+(movetime*moveTurboMultiply))+"px";
			}
			moveamount+= (movetime*moveTurboMultiply);
			setTimeout(scrollRight, 1);
		}
		else {
			//reset moved temp var
			moveamount = 0;
			//determine if we have to slide to anther room after the current one
			if(roomsSlide > 1) {
				roomsSlide--;
				setTimeout(scrollRight, 1);
			}
			else {
				locked= false;
				//reset turbo
				moveTurboMultiply = 1;				
			}
		}
	}
	
	
	//function to jump to a specific room number
	function jumpRoom(room) {
		var jroom = room;
		//check to see if already scrolling
		if(!locked) {
			//only move if room number is valid and not already at the desired room
			if(jroom > 0 && jroom <= protectedRoom && curpan != jroom) {
				//set the turbo multiplier
				moveTurboMultiply = 1;
				//determine if desired room is to the left or right of current position
				//need to move to the right
				if(jroom > curpan) {
					//determine number of rooms to jump
					var jumpPans = jroom - curpan;
					roomsSlide = jumpPans;
					//update the current room number before we start scrolling
					curpan = jroom;
					locked= true;
	
					//if not first layer, hide the move left icon
					if(curpan!=1)  
						document.getElementById("divLeft").style.display="block";
	
					//if last layer, hide right icon
					if(curpan==totalpans || (access==false && curpan==protectedRoom))
						document.getElementById("divRight").style.display="none";
					
					//display the appropriate menu now
					displayRoomMenu();
									
					scrollLeft();
				}
				//need to move to the left
				else {
					//determine number of rooms to jump
					var jumpPans = curpan - jroom;
					roomsSlide = jumpPans;
					//update the current room number before we start scrolling
					curpan = jroom;
					locked= true;
					
					//if first layer, hide the move left icon
					if(curpan==1)  
						document.getElementById("divLeft").style.display="none";
				
					//if last layer, hide icon
					if(curpan!=totalpans || (access==false && curpan!=protectedRoom))
						document.getElementById("divRight").style.display="block";
					
					//display the appropriate menu now
					displayRoomMenu();
					
					scrollRight();
				}
			}
		}
	}
	 
	//function to display the menu for the current room.
	function displayRoomMenu() {
		//We need to pull the appropriate menu content from an exclude file via ajax.
		xmlHttp=GetXmlHttpObject();
		if(xmlHttp==null) {
			alert("Your browser does not support the xmlHTTP object.");
			return false;
		}
		
		//url to email sender script
		var url="menus.asp"
		
		//add parameters to the end
		url = url + "?roomID=" + curpan + "&usr=" + login;
		url = url + "&sid=" + Math.random();
		xmlHttp.onreadystatechange=updateMenu;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
	
	function updateMenu() {
		if(xmlHttp.readyState==4 || xmlHttp.readysState=="complete") {
				document.getElementById("menu_grey_middle").innerHTML = xmlHttp.responseText;
		}
	}
	
	//AJAX function to log staff in and retrieve contents for staff room
	function staffLogin(){
		xmlHttp=GetXmlHttpObject();
		if(xmlHttp==null) {
			alert("Your browser does not support the xmlHTTP object.");
			return false;
		}
		
		//url to email sender script
		var url="login.asp"
		login = document.getElementById("txtlogin").value;
		password = document.getElementById("txtpass").value;
		
		//add parameters to the end
		url = url + "?txtlogin=" + document.getElementById("txtlogin").value;
		url = url + "&txtpass=" + document.getElementById("txtpass").value;
		url = url + "&sid=" + Math.random();
		xmlHttp.onreadystatechange=checkLogin;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
	
	//function for return AJAX login function
	function checkLogin() {
		if(xmlHttp.readyState==4 || xmlHttp.readysState=="complete") {
			//Check Login Result from AJAX
			var returnHTML = xmlHttp.responseText;
			//if not failed login
			if(returnHTML != "<!--FAILED-->") {
				//send the room code to the room layer
				access=true;
				document.getElementById("divLogin").innerHTML = "<b>You are now logged in.</b>";
				document.getElementById("divProtected").innerHTML = returnHTML;			
				
				moveLeft();
			}
			else {	
				alert("Sorry, your staff login details could not be verified.");
			}
		}
	}
	
	function GetXmlHttpObject() {
		var objXMLHttp=null;
		if(window.XMLHttpRequest) {
			objXMLHttp = new XMLHttpRequest();
		}
		else if(window.ActiveXObject) {
			objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return objXMLHttp;
	}
	
	
	//Function to display hotspot
	function displayHotspot(trigger, text, url) {
		if(!locked) {
			//store the URL to trigger
			//check that url doesn't already contain a ?
			if(url.indexOf("?") == -1)
				pURL = url+"?roomID="+curpan;
			else
				pURL = url+"&roomID="+curpan;
			
			//get location for hotspot layer from coords of trigger
			var xpos = parseInt(trigger.style.left.replace("px",""));
			var ypos = parseInt(trigger.style.top.replace("px",""));
			
			//get dimensions of trigger so we can center the hotspot
			var width = parseInt(trigger.style.width.replace("px",""));
			var height = parseInt(trigger.style.height.replace("px",""));		
			
			//adapt positions
			xpos = xpos+width/2-75;
			ypos = ypos+height/2-75;
			
			//reset the image to the animation starts again
			document.getElementById("divHotSpot").style.left = xpos+"px";
			document.getElementById("divHotSpot").style.top = ypos+"px";
			document.getElementById("divHotSpot").style.display="block";
			document.getElementById("divHotSpot").style.background.src = "images/selection.gif";
			document.getElementById("divHotSpotContent").innerHTML = text;
			//alert(xpos + ":" + ypos);
			
		}
	}

//function to hide the hotspot
	function hideHotSpot() {
		document.getElementById("divHotSpot").style.display="none";
	}
	
	//function to launch hotspot ur
	function launchURL() {
		//Added to launch all http links in a new window
		//For IMAGE LIBRARY!
		if(pURL.indexOf("http://") > -1) {
			//open in new window
			window.open(pURL,'mywindow','width=980,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')
		}
		else {
			document.location.href=pURL;
		}
	}
	
	
	/* fading layer technique */
	//fades layer in and out
	ie5  = (document.all && document.getElementById);
	ns6 = (!document.all && document.getElementById);
	opac3 = 0;
	
	
	
	/* fading layer technique */
	//fades layer in and out
	ie5  = (document.all && document.getElementById);
	ns6 = (!document.all && document.getElementById);
	opac3 = 0;
	 
	function opacIn(layer) {
		alert(opac3);
	    if(opac3 < 100){

	        opac3+=5;			
		    if(ie5) document.getElementById(layer).filters.alpha.opacity = opac3;
		    if(ns6) document.getElementById(layer).style.MozOpacity = opac3/100;
			document.getElementById(layer).style.KhtmlOpacity  = opac3/100;
			
	        setTimeout('opacIn("' + layer + '")', 1);
	    } 
	}
 
	function opacOut(layer) {
    	if(opac3 > 0){
	        opac3-=5;
	        if(ie5) document.getElementById(layer).filters.alpha.opacity = opac3;
	        if(ns6) document.getElementById(layer).style.MozOpacity = opac3/100;
			document.getElementById(layer).style.KhtmlOpacity  = opac3/100;
	        setTimeout('opacOut("' + layer + '")', 1);
	    }
}

	
-->
