		
		// AtomWorks.co.uk - Feature Header v1
		
		// Requires easing.
		
		
		
		/****************************
				 Functions
		****************************/
		
		rotationSpeed = 15000 ;
		slideSpeed = 1000 ;
		fadeSpeed = 1500 ;
		easeType = "easeOutQuad" ;
		cssURL="http://www.atomworks.co.uk/wp-content/themes/atomworks/"
		
		
		
		// Set variables
				
		var currentPanel = "#awf-thumb-1" ;
		var intransit = false ;
		var playing = true ;
		var awfrotate ;
		
		// Sets up an index for referencing IDs
		
		var thumbList = new Array(6) ; 
		
		thumbList[0] = new Array(3) ;
		thumbList[0][0] = false ;
		thumbList[0][1] = false ;
		thumbList[0][2] = false ;
		
		thumbList[1] = new Array(3) ;
		thumbList[1][0] = "#awf-thumb-1" ;
		thumbList[1][1] = "#awf-image-1" ;
		thumbList[1][2] = "#awf-text-1" ;
		
		thumbList[2] = new Array(3) ;
		thumbList[2][0] = "#awf-thumb-2" ;
		thumbList[2][1] = "#awf-image-2" ;
		thumbList[2][2] = "#awf-text-2" ;
		
		thumbList[3] = new Array(3) ;
		thumbList[3][0] = "#awf-thumb-3" ;
		thumbList[3][1] = "#awf-image-3" ;
		thumbList[3][2] = "#awf-text-3" ;
		
		thumbList[4] = new Array(3) ;
		thumbList[4][0] = "#awf-thumb-4" ;
		thumbList[4][1] = "#awf-image-4" ;
		thumbList[4][2] = "#awf-text-4" ;
		
		thumbList[5] = new Array(3) ;
		thumbList[5][0] = "#awf-thumb-5" ;
		thumbList[5][1] = "#awf-image-5" ;
		thumbList[5][2] = "#awf-text-5" ;
		
		
		/****************************
				 Functions
		****************************/
		
		function playpause(){
			
			// Switch function for play/pause button.
			
			if(playing == true){		
				
				featurePause() ;
			
			} else {
			
				featurePlay() ;
				
			}
			
		}
		
		function featurePause(){
		
			clearInterval(window.awfrotate) ;
			jQuery("#awf-playpause").css("background-image", "url(" + cssURL + "images/feature-play.png)");
			playing = false ;
			
		}
		
		function featurePlay(){
		
			nextItem() ;
			window.awfrotate = setInterval("nextItem()", rotationSpeed) ;
			jQuery("#awf-playpause").css("background-image", "url(" + cssURL + "images/feature-pause.png)");
			playing = true ;
			
		}	
		
		function featureButtons(){
			
			// Sets up the button behaviours for the thumbs
			
			i = 1 ;
			
			while(i <= 5){
	
				jQuery("#awf-thumb-" + i).mousedown(function(){
					
					featurePause();
					actionChange("#" + jQuery(this).attr("id")) ;
				
				}) ;
				
				i++ ;
			}	
		
		}
		
		function actionChange(target){
				
				if(intransit == false){
					
					intransit = true ;
					
					fromRef = arrayAddress(currentPanel) ;
					toRef = arrayAddress(target) ; ;
					
					// Moves thumbnails up and down		
					
			
					jQuery(thumbList[toRef][0]).animate({top: "55px", opacity: "0"}, fadeSpeed,easeType) ;
					
					
					jQuery(thumbList[fromRef][0]).fadeOut(0);
					jQuery(thumbList[fromRef][0]).css({top: "0px",opacity: "1"}) ;
					jQuery(thumbList[fromRef][0]).fadeIn(fadeSpeed) ;
					
					//Moves image
					
					jQuery(thumbList[fromRef][1]).animate({top: "275px"},slideSpeed,easeType,function(){ 
						
						jQuery(thumbList[toRef][1]).animate({left: "0px"},slideSpeed,easeType) ;
						jQuery(thumbList[fromRef][1]).css({left: "465px", top: "0px"}) ;
					
					} ) ;
					
					
					// Move text
					
					jQuery(thumbList[fromRef][2]).animate({top: "-275px"},slideSpeed,easeType,function(){ 
						
						jQuery(thumbList[toRef][2]).animate({left: "0px"},slideSpeed,easeType) ;
						jQuery(thumbList[fromRef][2]).css({left: "-495px", top: "0px"}) ;
					
					} ) ;
					
					
					currentPanel = "#" + jQuery(target).attr("id") ;
					
					// Fade in playpause div
					
					jQuery("#awf-playpause").fadeOut(fadeSpeed, function(){
						ppcoords = jQuery(target).css("left") ;
						jQuery("#awf-playpause").css("left", ppcoords) ;
						jQuery("#awf-playpause").fadeIn(fadeSpeed) ;
						intransit = false ;
					}) ;
					
					
				
				}
			
		}
		
		
		function arrayAddress(x){
			
			// Used to get the ID of a button and look up its reference in the thumbList array
			
			switch(x){
				case thumbList[1][0]: return 1 ;
				case thumbList[2][0]: return 2 ;
				case thumbList[3][0]: return 3 ;
				case thumbList[4][0]: return 4 ;
				case thumbList[5][0]: return 5 ;
				default: return "FAIL" ;
			}
		
		}
		
		
		function nextItem(){
			
			// Activates the next button in sequence
				
			if(arrayAddress(currentPanel) + 1 <= 5){
				next = arrayAddress(currentPanel) + 1 ;
			} else {
				next = 1 ;
			}
			
			
			actionChange(thumbList[next][0]) ;
			
		}
		
		function prevItem(){
			
			// Activates the previous button in sequence
			
			if(arrayAddress(currentPanel) - 1 >= 1){
				prev = arrayAddress(currentPanel) - 1 ;
			} else {
				prev = 5 ;
			}			
			
			actionChange(thumbList[prev][0]) ;
			
		}
		
		
		jQuery(document).ready(function(){
			
			/****************************
					 Initialise
			****************************/
			
			featureButtons() ;
			
			jQuery("#awf-next").mousedown(function(){
				
				featurePause();
				nextItem();
				
			}) ;
			
			
			jQuery("#awf-prev").mousedown(function(){			
				
				featurePause();
				prevItem();
				
			}) ;
			
			jQuery("#awf-playpause").mousedown(function(){	playpause();	}) ;
			
			window.awfrotate = setInterval("nextItem()", rotationSpeed) ;
						
		}) ;
	
