// JavaScript Document
$(function(){
	var Column = $("#indexNews li").size();//初期要素数
	$("#indexNews p").css({cursor :"pointer"});//h3をポインタ化
	var run = true;	
	//console.log(Column);
	$("#indexNews li").clone().appendTo("#indexNews ul");//要素複製
	//$("#indexNews li").clone().prependTo("#indexNews ul");
	$("#indexNewsColumnEntry").css("width", 325*$("#indexNews li").size()+"px"); //ulの横幅指定 sizeは要素の数
	$("#indexNewsColumnEntry").css("margin-left", "-" + 325*Column+ "px");
	//戻る
	$("#indexNewsPrev").click(function(){
			if(run){
				run=!run;
				$("#indexNews ul").animate({
						marginLeft: parseInt($("#indexNews ul").css("margin-left"))+325+"px" },"slow","swing" ,
						function(){
							$("#indexNews ul").css("margin-left","0px");
							$("#indexNews li:last").insertBefore("#indexNews li:first");
							run=!run;
							}
					)};
		
				});
	//進む
	$("#indexNewsNext").click(function(){
			if(run){
				run=!run;
				$("#indexNews ul").animate({
						marginLeft: parseInt($("#indexNews ul").css("margin-left"))+ -325+"px" },"slow","swing" ,
						function(){
							$("#indexNews ul").css("margin-left","0px");
							$("#indexNews li:first").insertAfter("#indexNews li:last");
							run=!run;
							}
					)};
		
				});

	var timerID = setInterval(function(){
	$("#indexNewsNext").click()
	},5000);
});



	
