var __timer_num = -1;
var __timer_num2 = -1;
var __tid;
var __tid2;
function init_anim()
{
	__tid=setInterval("fade_in_post()",100);
	fade_in_future_post();
	fade_in_contents_page();
	set_accordion();
}
function set_accordion()
{
	//アコーディオン
	$(".accordion dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".accordion dd").css("display","none");
	$(".accordion dt").click(function(){
		$(this).next().slideToggle("slow");
	});
}
function fade_in_contents_page()
{
	if(__timer_num2 == -1)
	{
		__tid2=setInterval("fade_in_contents_page()",250);
		__timer_num2=0;
	}else{
		clearInterval(__tid2);
		jQuery("#content_page").animate({opacity:1.0},1000);
		jQuery(".single-post").animate({opacity:1.0},1000);
		jQuery(".single-sidebar").animate({opacity:1.0},1000);
	}
}
function fade_in_future_post()
{
	jQuery("#future_post").animate({opacity:1.0},1000);
}
function fade_in_post()
{
	if(__timer_num == -1)
	{
		__timer_num=0;
		clearInterval(__tid);
		__tid=setInterval("fade_in_post()",100);
	}else{
		jQuery(".post").eq(__timer_num).animate({opacity:1.0},1000);
		__timer_num++;
		if(__timer_num >= jQuery(".post").length)
		{
			clearInterval(__tid);
			//postにもマウスイベントを設定
			init_with_post();
		}
	}
}
function init_with_post()
{
	jQuery(".post").mouseover(function(eventObject)
	{
		jQuery(".postmetadata",this).stop().animate({opacity:0.5},200);
		jQuery(".entry",this).stop().animate({opacity:0.5},200);
		jQuery("h2",this).stop().animate({opacity:0.5},200);
		jQuery(".postdate",this).stop().animate({opacity:0.5},200);
	});
	jQuery(".post").mouseout(function()
	{
		jQuery(".postmetadata",this).stop().animate({opacity:1.0},500);
		jQuery(".entry",this).stop().animate({opacity:1.0},500);
		jQuery("h2",this).stop().animate({opacity:1.0},500);
		jQuery(".postdate",this).stop().animate({opacity:1.0},500);
	});
	
}

function init_with_load()
{
	//上部メニュー,FUTURE
	jQuery(".page_item").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},200);
	});
	jQuery(".page_item").mouseout(function()
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//FUTURE
	jQuery("#future_post").mouseover(function(eventObject)
	{
		//jQuery(this).stop().animate({opacity:0.5},500);
		jQuery(".future_title",this).stop().animate({opacity:0.5},200);
		jQuery(".future_img",this).stop().animate({opacity:0.5},200);
		jQuery(".postmetadata",this).stop().animate({opacity:0.5},200);
		jQuery("h2",this).stop().animate({opacity:0.5},200);
		jQuery(".postdate",this).stop().animate({opacity:0.5},200);
		jQuery(".postcon",this).stop().animate({opacity:0.5},200);
	});
	jQuery("#future_post").mouseout(function()
	{
		//jQuery(this).stop().animate({opacity:1.0},500);
		jQuery(".future_title",this).stop().animate({opacity:1.0},500);
		jQuery(".future_img",this).stop().animate({opacity:1.0},500);
		jQuery(".postmetadata",this).stop().animate({opacity:1.0},500);
		jQuery("h2",this).stop().animate({opacity:1.0},500);
		jQuery(".postdate",this).stop().animate({opacity:1.0},500);
		jQuery(".postcon",this).stop().animate({opacity:1.0},500);
	});
	//retweet button(vert)
	jQuery(".retweet").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery(".retweet").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//tweet number
	jQuery(".twt_num a").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery(".twt_num a").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//footer banner
	jQuery(".link_img").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery(".link_img").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});

	//disp_mode
	jQuery("#disp_mode img").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery("#disp_mode img").mouseout(function()
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//sort_mode
	jQuery("#sort_mode img").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery("#sort_mode img").mouseout(function()
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//検索
	jQuery("#searchsubmit").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery("#searchsubmit").mouseout(function()
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//コンタクト　送信
	jQuery(".send_btn").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery(".send_btn").mouseout(function()
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//rss mail
	jQuery("#chip a").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery("#chip a").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//中ページバナー
	jQuery(".side-banner").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery(".side-banner").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});
	//topに戻るボタン
	jQuery("#to_top a").mouseover(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:0.5},500);
	});
	jQuery("#to_top a").mouseout(function(eventObject)
	{
		jQuery(this).stop().animate({opacity:1.0},500);
	});

	/***cookie操作***/
	//mode
	jQuery(".mode_text").mousedown(function(eventObject)
	{
		set_cookie_val("text");
	});
	jQuery(".mode_photo").mousedown(function(eventObject)
	{
		set_cookie_val("text_photo");
	});
	//LOGO
	jQuery("#logo").mousedown(function(eventObject)
	{
		set_cookie_val("text_photo");
	});
}
//formのチェック
function check_form()
{
	var flg_t  = false;
	var flg_ml = false;
	var flg_ms = false;
	if(document.contact.title.value == ""){
		flg_t = true;
	}
	if(document.contact.mailadress.value == ""){
		flg_ml = true;
	}
	if(document.contact.message.value == ""){
		flg_ms = true;
	}
	if(flg_t == true || flg_ml == true || flg_ms == true)
	{
		alert("すべての項目を記入してください");
		return false;
	}
}

//set_cookie
function set_cookie_val(val)
{
	document.cookie = "disp_mode="+val;
}

//メーラー立ち上げ
function mail_to() {
	var my_antname = "hogehoge";
	var domain = "hoge.com";
	var msg = "このまま送信してください。";
	var sbj = "メールマガジン登録";
	this.location.href = "mailto:" + my_antname + "@" + domain + "?subject=" + sbj + "&body=" + msg; 
}

//topへ戻る
function backToTop() {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	
	if (document.documentElement) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	
	if (document.body) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	
	window.scrollTo(Math.floor(x / 2.0), Math.floor(y / 2.0));
	
	if (x > 0 || y > 0) {
		window.setTimeout("backToTop()", 25);
	}
}
