// JavaScript Document 
/*####################################
#   Home Page Slide Show      01.30.09 - John 
#    v 0.2  - 05.27.08 - John {added timed auto-scrolling} 
#  Rotates ads in sidebar if javascript is enabled and jQuery exists 
####################################*/

var slideshowRunning = true;


if (typeof jQuery != 'undefined') {	// First Check for jQuery  
	
	function slideShowNext(){
		// get the Id - 0-9 ONLY, rewrite if past 10 projects
		var slideNumber = $("#slideshow_list li.current").attr("id").substr(13);
		//alert(slideNumber);
		slideNumber = parseInt(slideNumber);
		
		//alert(slideNumber);
		if(slideNumber < numProjects){ 		//Not the last project
		
			// Hide the currently visible project 
			$("#slideshow_list li.current").removeClass("current").hide();
			// Show Next project + add class 'current' to it 
			slideNumber++;
			$("#slideshow_li_"+slideNumber).addClass("current").show();
																   
		}else{ 			// Return to First
			$("#slideshow_list li.current").removeClass("current").hide();											
			$("#slideshow_li_1").addClass("current").show();
		}
		
		// nullify click 
		return false;
	}
	
	function startTime(){
				/*$('#slideshow_list').everyTime(5000, 'autostart', function(i) {
						if(slideshowRunning == true){
							slideShowNext();		
						}
				});*/
				if(animating = true){
					setInterval("slideShowNext()", 5000);
				}
				
			}

	
	$(document).ready(function() {
		if ($("#slideshow_list").lenght) {
			animating = true;
			numProjects = $("#slideshow_list").children().length;
			startTime();
		}
	});
	
	
	
	
	
}else{	// jQuery wasn't loaded 
 console.log('The jQuery Library is missing!');
}