/*
 * jsファイル
 */

function widget(){
	$("body").everyTime(5000, "myTimer", function(timer) {
		$("#home section#beta section.case .photobox dl:last").animate({"opacity":0},1000,function(){
				$(this).prependTo($(this).parent()).css({"opacity":1});
		});
	});
}

$(function(){
	$('#wp-calendar .move').click(
		function(){
			$("#calendar_move input#calendar_month").val($(this).attr("title"));
			$("#calendar_move").submit();
			return false;
		}
	);
	
	$('#wp-calendar .move_day').click(
		function(){
			$("#calendar_move_day input#calendar_day").val($(this).attr("title"));
			//alert($(this).attr("title"));
			$("#calendar_move_day").submit();
			return false;
		}
	);
	
	$('#custom_post_monthly_list .move').click(
		function(){
			$("#custom_post_monthly_move input#custom_post_monthly").val($(this).attr("title"));
			$("#custom_post_monthly_move").submit();
			return false;
		}
	);
});

/*
 * ticker
 */

$(function() {	
	//ticker切り替え速度(ms)
	var interval = 5000;
	
	//fadeIn/fadeOut速度(ms)
	var fadetime = 500;
	
	//移動速度(ms)
	var movetime = 1000;
	
	//#tickerの高さを取得
	var ticker_height = $('#ticker ul li').height();
		
	//初期設定
	$("#ticker ul li:not(:first)").css({"opacity":0}).hide();
	
	function move(){
		//setInterval
		setTimeout(function callback(){
			//1番目の要素をフェイドアウト
			$("#ticker ul li:first").animate({"opacity":0},fadetime);
			//2番目の要素をフェイドイン
			$("#ticker ul li:eq(1)").show().animate({"opacity":1},fadetime);
			//ul全体を上に移動
			$("#ticker ul").animate({"margin-top": 0 - ticker_height + "px"},{easing: 'easeOutBack', duration: movetime, complete:function(){
										//移動終了後、先頭の要素を末尾へ移動し、アニメーションした分だけ下へ移動
										$("#ticker ul li:first").appendTo("#ticker ul");
										$("#ticker ul").css("margin-top", "0px");
									}
			});
		setTimeout(callback, interval);
		},interval);
	}
	
	//実行
	move();
});

