// Simple JavaScript Rotating Banner Using jQuery
// www.mclelun.com
var jqb3_vCurrent = 0;
var jqb3_vTotal = 0;
var jqb3_vDuration = 7300;
var jqb3_intInterval = 0;
var jqb3_vGo = 1;
var jqb3_vIsPause = false;
var jqb3_tmp = 20;
var jqb3_title;

jQuery(document).ready(function() {	
	jqb3_vTotal = $(".jqb3_slides").children().size() -1;
	$(".jqb3_info").text($(".jqb3_slide").attr("title"));	
	jqb3_intInterval = setInterval(jqb3_fnLoop, jqb3_vDuration);
			
	$("#jqb3_object").find(".jqb3_slide").each(function(i) { 
		jqb3_tmp = ((i - 1)*560) - ((jqb3_vCurrent -1)*560);
		$(this).animate({"left": jqb3_tmp+"px"}, 500);
	});
	
	$("#btn3_pauseplay").click(function() {
		if(jqb3_vIsPause){
			jqb3_fnChange();
			jqb3_vIsPause = false;
			$("#btn3_pauseplay").removeClass("jqb3_btn_play");
			$("#btn3_pauseplay").addClass("jqb3_btn_pause");
		} else {
			clearInterval(jqb3_intInterval);
			jqb3_vIsPause = true;
			$("#btn3_pauseplay").removeClass("jqb3_btn_pause");
			$("#btn3_pauseplay").addClass("jqb3_btn_play");
		}
	});
	$("#btn3_prev").click(function() {
		jqb3_fnChange();
		jqb3_vGo = -1;
	});
		
	$("#btn3_next").click(function() {
		jqb3_fnChange();
		jqb3_vGo = 1;
	});
});

function jqb3_fnChange(){
	clearInterval(jqb3_intInterval);
	jqb3_intInterval = setInterval(jqb3_fnLoop, jqb3_vDuration);
	jqb3_fnLoop();
}

function jqb3_fnLoop(){
	if(jqb3_vGo == 1){
		jqb3_vCurrent == jqb3_vTotal ? jqb3_vCurrent = 0 : jqb3_vCurrent++;
	} else {
		jqb3_vCurrent == 0 ? jqb3_vCurrent = jqb3_vTotal : jqb3_vCurrent--;
	}
	
	$("#jqb3_object").find(".jqb3_slide").each(function(i) { 
		
		/*if(i == jqb3_vCurrent){
			jqb3_title = $(this).attr("title");
			$(".jqb3_info").animate({ opacity: 'hide', "left": "-50px"}, 250,function(){
				$(".jqb3_info").text(jqb3_title).animate({ opacity: 'show', "left": "0px"}, 500);
			});
		} */
		

		//Horizontal Scrolling
		jqb3_tmp = ((i - 1)*560) - ((jqb3_vCurrent -1)*560);
		$(this).animate({"left": jqb3_tmp+"px"}, 500);
		
		/*
		//Fade In & Fade Out
		if(i == jqb3_vCurrent){
			$(".jqb3_info").text($(this).attr("title"));
			$(this).animate({ opacity: 'show', height: 'show' }, 500);
		} else {
			$(this).animate({ opacity: 'hide', height: 'hide' }, 500);
		}
		*/
		
	});


}







