// JavaScript Document
$(function(){
		   
		//初期設定
		var base = "#container #innerHeader #newStaffPhoto";
		var ul = base + " ul";
		var li = ul + " li";
		var next = base + " #prevPhoto";
		var prev = base + " #nextPhoto";
		var con = 140;
		
		   $(ul).css("width",con*$(li).size()+"px");
		   $(li+":last").prependTo(ul);
		   $(ul).css("margin-left","-"+con+"px");
		   $(li+":last").prependTo(ul);
		   $(ul).css("margin-left","-"+con+"px");
		   //戻るボタン
		   $(next).click(function(){
									$(next+" a,"+prev+" a").hide();
									$(ul).animate({marginLeft : parseInt($(ul).css("margin-left"))+con+"px"},"slow","swing",
									  function(){
										  $(li+":last").prependTo(ul);
										  $(ul).css("margin-left","-"+con+"px");
										  $(next+" a,"+prev+" a").show();
									  });
									return false;
									});
			//進むボタン
			$(prev).click(function(){
									$(next+" a,"+prev+" a").hide();
									$(ul).animate({marginLeft : parseInt($(ul).css("margin-left"))-con+"px"},"slow","swing",
									  function(){
										  $(li+":first").appendTo(ul);
										  $(ul).css("margin-left","-"+con+"px");
										  $(next+" a,"+prev+" a").show();
									  });
									return false;
									});
	var timerID = setInterval(function(){
		$(prev).click();
	},1800);
	$(base + " #prevPhoto a,"+base + " #nextPhoto a").click(function(){
		clearInterval(timerID);
	}); 
});



