var d1440_vCurrent = 0;
var d1440_vTotal = 0;
var d1440_vDuration = 5000;
var d1440_intInterval = 0;
var d1440_vGo = 1;
var d1440_vIsPause = false;
var d1440_tmp = 20;
var d1440_title;

jQuery(document).ready(function() {	
	d1440_vTotal = $(".d1440_slides").children().size() -1;
	$(".d1440_info").text($(".d1440_slide").attr("title"));	
	d1440_intInterval = setInterval(d1440_fnLoop, d1440_vDuration);
			
	$("#d1440_object").find(".d1440_slide").each(function(i) { 
		d1440_tmp = ((i - 1)*960) - ((d1440_vCurrent -1)*960);
		$(this).animate({"left": d1440_tmp+"px"}, 500);
	});
	
	$("#btn_pauseplay").click(function() {
		if(d1440_vIsPause){
			d1440_fnChange();
			d1440_vIsPause = false;
			$("#btn_pauseplay").removeClass("d1440_btn_play");
			$("#btn_pauseplay").addClass("d1440_btn_pause");
		} else {
			clearInterval(d1440_intInterval);
			d1440_vIsPause = true;
			$("#btn_pauseplay").removeClass("d1440_btn_pause");
			$("#btn_pauseplay").addClass("d1440_btn_play");
		}
	});
	$("#btn_prev").click(function() {
		d1440_fnChange();
		d1440_vGo = -1;
	});
		
	$("#btn_next").click(function() {
		d1440_fnChange();
		d1440_vGo = 1;
	});
});

function d1440_fnChange(){
	clearInterval(d1440_intInterval);
	d1440_intInterval = setInterval(d1440_fnLoop, d1440_vDuration);
	d1440_fnLoop();
}

function d1440_fnLoop(){
	if(d1440_vGo == 1){
		d1440_vCurrent == d1440_vTotal ? d1440_vCurrent = 0 : d1440_vCurrent++;
	} else {
		d1440_vCurrent == 0 ? d1440_vCurrent = d1440_vTotal : d1440_vCurrent--;
	}
	
	$("#d1440_object").find(".d1440_slide").each(function(i) { 
		
		if(i == d1440_vCurrent){
			d1440_title = $(this).attr("title");
			$(".d1440_info").animate({ opacity: 'hide', "left": "-50px"}, 250,function(){
				$(".d1440_info").text(d1440_title).animate({ opacity: 'show', "left": "0px"}, 500);
			});
		} 
		

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


}







