// Simple JavaScript Rotating Banner Using jQuery
// www.mclelun.com
var jqb_vCurrent2 = 0;
var jqb_vTotal2 = 0;
var jqb_vDuration2 = 5000;
var jqb_intInterval2 = 0;
var jqb_vGo2 = 1;
var jqb_vIsPause2 = false;
var jqb_tmp2 = 20;
var jqb_title2;

jQuery(document).ready(function() {	
	jqb_vTotal2 = $(".jqb_slides2").children().size() -1;
	$(".jqb_info2").text($(".jqb_slide2").attr("title"));	
	jqb_intInterval2 = setInterval(jqb_fnLoop2, jqb_vDuration2);
			
	$("#jqb_object2").find(".jqb_slide2").each(function(i) { 
		jqb_tmp2 = ((i - 1)*211) - ((jqb_vCurrent2 -1)*211);
		$(this).animate({"left": jqb_tmp2+"px"}, 500);
	});
	
	$("#btn_pauseplay2").click(function() {
		if(jqb_vIsPause2){
			jqb_fnChange2();
			jqb_vIsPause2 = false;
			$("#btn_pauseplay2").removeClass("jqb_btn_play2");
			$("#btn_pauseplay2").addClass("jqb_btn_pause2");
		} else {
			clearInterval(jqb_intInterval2);
			jqb_vIsPause2 = true;
			$("#btn_pauseplay2").removeClass("jqb_btn_pause2");
			$("#btn_pauseplay2").addClass("jqb_btn_play2");
		}
	});
	$("#btn_prev2").click(function() {
		jqb_vGo2 = -1;
		jqb_fnChange2();
	});
		
	$("#btn_next2").click(function() {
		jqb_vGo2 = 1;
		jqb_fnChange2();
	});
});

function jqb_fnChange2(){
	clearInterval(jqb_intInterval2);
	jqb_intInterval2 = setInterval(jqb_fnLoop2, jqb_vDuration2);
	jqb_fnLoop2();
}

function jqb_fnLoop2(){
	if(jqb_vGo2 == 1){
		jqb_vCurrent2 == jqb_vTotal2 ? jqb_vCurrent2 = 0 : jqb_vCurrent2++;
	} else {
		jqb_vCurrent2 == 0 ? jqb_vCurrent2 = jqb_vTotal2 : jqb_vCurrent2--;
	}
	
	$("#jqb_object2").find(".jqb_slide2").each(function(i) { 
		
		if(i == jqb_vCurrent2){
			jqb_title2 = $(this).attr("title");
			$(".jqb_info2").animate({ opacity: 'hide', "left": "-50px"}, 136,function(){
				$(".jqb_info2").text(jqb_title2).animate({ opacity: 'show', "left": "0px"}, 500);
			});
		} 
		

		//Horizontal Scrolling
		jqb_tmp2 = ((i - 1)*211) - ((jqb_vCurrent2 -1)*211);
		$(this).animate({"left": jqb_tmp2+"px"}, 500);
		
		/*
		//Fade In & Fade Out
		if(i == jqb_vCurrent2){
			$(".jqb_info2").text($(this).attr("title"));
			$(this).animate({ opacity: 'show', height: 'show' }, 500);
		} else {
			$(this).animate({ opacity: 'hide', height: 'hide' }, 500);
		}
		*/
		
	});


}







