﻿
		/* Slider Functionality (located on index.html page)  */

		var divArray = new Array();
		var divNumber=0;
		var imagePadding=0;
		var animationSpeed=800;  //this is the speed of the animation
		var waitInterval=12000;


		var currentImage=1;

		//*********Please change these settings if you have made some changes in the HTML or CSS files!************
		var imageWidth=960;   //this is the width of a single image

		var timer=-1;

		jQuery(function(){
		getAllDivs();

		setDefaultWidth();
		setSlider();

		timer = window.setInterval("moveLeft()", waitInterval);
		});

		/**
		 *	Gets all the divs that have to be shown in the slider and fills them in an array.
		 */
		function getAllDivs(){
			//fill the divs in an array
			jQuery(".slide_set").each(function(i){
				divArray[i]=jQuery(this);
				divNumber++;
			});
		}

		/**
		 *	Moves the image wrapper to the right.
		 */
		function moveRight(){
			if(currentImage>1){
				jQuery(".wrapper ul").animate({marginLeft:"+="+animationLength}, animationSpeed);
				currentImage--;
				window.clearInterval(timer);
				timer=window.setInterval("wait()", waitInterval);
			}
		}

		function wait(){
			window.clearInterval(timer);
			timer=window.setInterval("moveLeft()", waitInterval);
		}

		/**
		 *	Moves the image wrapper to the left.
		 */
		function moveLeft(){
			if(currentImage<divNumber){
				jQuery(".wrapper ul").stop().animate({marginLeft:-animationLength*(currentImage)}, animationSpeed);
				currentImage++;
			}else{
				jQuery(".wrapper ul").stop().animate({marginLeft:0}, animationSpeed);
				currentImage=1;
			}
		}


		/**
		 *	This is the main function. It sets click event handlers to the arrows to animate the divs.
		 */
		function setSlider(){
			
			//set a click event handler for the right gradient 
			jQuery("#rightArrow").click(function(){	
				moveLeft();
				window.clearInterval(timer);
				timer=window.setInterval("wait()", waitInterval);
			});
			
			//set a click event handler for the left gradient
			jQuery("#leftArrow").click(function(){	
				moveRight();
			});
			
			jQuery("#rightArrow").mouseover(function(){	
				jQuery("#rightArrow").css({cursor:"pointer"});
			});
			
			jQuery("#leftArrow").mouseover(function(){	
				jQuery("#leftArrow").css({cursor:"pointer"});
			});
		}

		/**
		 *	Sets the width of a single div and the width of the div wrapper.
		 */
		function setDefaultWidth(){
			var allDivsWidth=0;	
			
			imagePadding=0;
			jQuery(".image_set").css({paddingLeft:imagePadding+"px", paddingRight:imagePadding+"px"});
			allDivsWidth=divNumber*(2*imagePadding+imageWidth+2);
			
			//set the width of the wrapper div
			jQuery(".wrapper ul").css({width:allDivsWidth+"px"});
			
			var marginLeft=0;
			
			//initial position of the images
			jQuery(".wrapper ul").animate({marginLeft:"-="+marginLeft},1);
			
			animationLength=imageWidth;
		}
