// JavaScript Document
/*
 * SPB_AD jQuery
 * Copyright (c) 2009 http://sharepointboost.com 
 */
 
jQuery(function($){
	var index = 0;
	$('<div id="flow"></div>').appendTo("#SPB_ADjQuery");

	//Slide changes the contents of navigation	
	$("#ADjQ_Nav li").click(function(){ //hover Other click
		if(MyTime){
			clearInterval(MyTime);
		}
		index  =  $("#ADjQ_Nav li").index(this);
		MyTime = setTimeout(function(){
		ShowjQueryFlash(index);
		$('#ADjQ_Content').stop();
		} , 0);

	}, function(){
		clearInterval(MyTime);
		MyTime = setInterval(function(){
		ShowjQueryFlash(index);
		index++;
		if(index==4){index=0;}
		} , 5000);
	});
	//Sliding stop animation, animation started off.
	 $('#ADjQ_Content').hover(function(){
			  if(MyTime){
				 clearInterval(MyTime);
			  }
	 },function(){
				MyTime = setInterval(function(){
				ShowjQueryFlash(index);
				index++;
				if(index==4){index=0;}
			  } ,5000);
	 });
	//Auto Play
	var MyTime = setInterval(function(){
		ShowjQueryFlash(index);
		index++;
		if(index==4){index=0;}
	} , 5000);
});
function ShowjQueryFlash(i) {
$("#ADjQ_Content div").eq(i).animate({opacity: 1},1000).css({"z-index": "1"}).siblings().animate({opacity: 0},1000).css({"z-index": "0"});
$("#flow").animate({ left: i*122+5 +"px"}, 300 ); //Slide the slider
$("#ADjQ_Nav li").eq(i).addClass("current").siblings().removeClass("current");
}