
window.onload = init;
function init(){


var snapleft=$('#snapsentent2').scrollLeft();
var snapleftfirst=$('.snapsentent3').width()-$('#snapsentent2').width();
var snaptm;

if(snapleft <= 0){$('.arrow_next').css("background-color","#ccc");$('.arrow_info').hide()}
if(snapleft >= snapleftfirst){$('.arrow_back').css("background-color","#ccc");}

$('.arrow_next').mouseover(function(){
	if(snapleft > 0){
		$('.arrow_back').css("background-color","#333");
		$(this).css("background-color","#1E99AE");
		snaptm=setInterval(function(){
			snapleft=snapleft-15;
			$('#snapsentent2').scrollLeft(snapleft)
			if(snapleft <= 0){
				$('.arrow_next').css("background-color","#ccc");
				clearInterval(snaptm);
				$('.arrow_info').hide()
			};
			}, 20);
	}
})
$('.arrow_next').mouseout(function(){
	if(snapleft > 0){
	$(this).css("background-color","#333");
	clearInterval(snaptm);
	}
	//alert();
})
$('.arrow_back').mouseover(function(){
	if(snapleft < snapleftfirst){
	$('.arrow_next').css("background-color","#333");
	$('.arrow_info').show()
	$(this).css("background-color","#1E99AE");
	snaptm=setInterval(function(){
		snapleft=snapleft+15;
		$('#snapsentent2').scrollLeft(snapleft)
		if(snapleft >= snapleftfirst){
			$('.arrow_back').css("background-color","#ccc");
			clearInterval(snaptm);
			};
		}, 20);
	}
})
$('.arrow_back').mouseout(function(){
	if(snapleft < snapleftfirst){
	$(this).css("background-color","#333");
	clearInterval(snaptm);
	}
	//alert();
})
						   


 };
$(document).ready(function(){
//横スクロールについては、全読み込み後に実行する
//profileページ
$('#profile_sbody2').hide();
//aboutページ
//aboutview(2,100)
						   
						   
	$('#menusentent li').each(function(){
		$(this).hide();
	})
	$('#menu li a').each(function(){
		$(this).mouseover(function(){
			var thisindex=$('#menu li a').index(this);
			var thisleft=$('#menu li').eq(0).offset();
			$('#menusentent li').eq(thisindex).css({marginLeft: thisleft.left+"px"}).show()
		})
		$(this).mouseout(function(){
			var thisindex=$('#menu li a').index(this);
			var thisleft=$('#menu li').eq(0).offset();
			$('#menusentent li').eq(thisindex).css({marginLeft: thisleft.left+"px"}).hide();
		})
   })

	$('.aboutbox').eq(0).fadeIn(2000);

//snapページ
$('.snaplist').hide();

$('.snapbackbn a').click(function(){
	$(this).animate({ 
    opacity: "hide",
    fontSize: "2em"
  }, 1000 ,"easeInOutBack",function(){snapmove()});

})
//Email移動
$('#emailbox img').css("left","600px").animate({left: "630px"}, 2000,"easeOutBounce")

})



function snapmove(){
	$('.snap').animate({ 
	paddingTop: "15px"
	}, 1000 ,"easeInOutBack",function(){snaplistview()});
}
function snaplistview(){
	$('.snaplist').slideDown()
	$('.snaplist').animate({ 
	}, 1000 ,"easeInOutBack");
}

function profileopen(){
	$('#profile').animate({ 
    marginTop: "15px"
  }, 1000,"easeInOutBack",function(){
	$('#profile_sbody2').slideDown(1000, function(){$('#profile_detail').hide()})
	  }
  
  );

}
function aboutview(ino,loopno){
	$('.aboutbox').each(function(){
		$(this).show();
	})
	/**ここから***/
var interval = 10;
//var loopno = 30;
var i=0;
var scroltm;
var thistop=$('.about_scrollbox').scrollTop();//押した時点での位置
var moveto=500*ino-thistop;//必要なスクロール量
var movenow;//必要なスクロール量
	scroltm=setInterval(function(){
		i++;
		movenow=thistop+(moveto*i/loopno);
		$('.about_scrollbox').scrollTop(movenow)
		if(i == loopno){clearInterval(scroltm);};
		}, 10);

	/*ここまで*/
}
//設定ここから
var menuname="menus";//メニューを囲むクラス名を指定
var bigimg="bigimg";//拡大画像に設定したクラス
//拡大表示用画像のファイル名につく接尾語
var newbigimg="_big";
//オーバーした時のCSS
var overCSS = "menuover"
//アウトした時のCSS
var outCSS = "menuout"

//設定ここまで

  


//ここから、フッター追従
var y_scroll;
var uphm=0;
var uph;


$(document).ready(function(){
uph = $('#fbox').offset();
uph = uph.top;//移動ボックスのウインドウ上での初期絶対縦位置
	//全部のボタンのCSSをマウスアウト用のクラスに設定
	$("."+menuname+" [menuno]").each(function(){

				 $(this).addClass(outCSS);
				 $(this).removeClass(overCSS);
				 });
	//最初の一つのボックスのみ表示
	$("."+menuname+" [menuno='1']").removeClass(outCSS).addClass(overCSS);
	
    // ここに実際の処理を記述します。
	
	$("."+menuname+" [menuno]").each(function(){
		var box=$(this);
		var a_this="";
		//メニューに使われている画像名を調べ、拡大画像の名前を決めます。
		//内側にimgがある場合
	   if($(this).find("img").attr("src")){
		   a_this=$(this).find("img").attr("src");
		//画像それ自体の場合
	   }else{
		   a_this=$(this).attr("src");
	   }
	   //拡大画像名
		var newimg=a_this.replace(/(.+?)(\.jpg|\.gif|\.png)/, "$1"+newbigimg+"$2")
		//画像をスワップ
		var thisoverswap=new Image();
		var thisoutswap=new Image();
		if(document.images){
		thisoverswap.src=newimg;
		thisoutswap.src=a_this;
		}

    $(this).mouseover(function(){
						   var pbox=$(this).parents("."+menuname);//alert(pbox.html())
						   var pbox2=pbox.find(".bigimg");//alert(pbox2.attr("src"))
							   pbox.find("."+bigimg).attr('src',newimg);
							   pbox.find(" [menuno]").each(function(){//alert($(this).html())
																		 $(this).removeClass(overCSS).addClass(outCSS);
																		 });

							   pbox.find(" [menubox='"+box.attr("menuno")+"']").show();
							   $(this).removeClass(outCSS).addClass(overCSS);
							   });
	});

//初期フッター追従
/*uphm = $('#fbox').offset();
var wheight=$(window).height();
y_scroll=$(window).scrollTop();	
$('#fbox').css({top: wheight+y_scroll-uph+15});
$('#fbox').hide()
$('#fbox').fadeIn("slow")*/
fscroll()

$(window).resize(function () {fscroll()})
$(window).scroll(function () {fscroll()})
//lightbox用
if($('.gallery').size() != 0){
	$('.gallery a').lightBox({fixedNavigation:true});
}

})

function fscroll(){
uphm = $('#fbox').offset();
var wheight=$(window).height();
y_scroll=$(window).scrollTop();	
$('#fbox').stop();
$('#fbox').animate({top: wheight+y_scroll-uph+15},1000,"easeOutCirc",function(){uphm = $('#fbox').offset();});
}
//diaryの日付表示
function diarydate(thisdate){
	$('#diarysententbox').fadeOut("slow",function(){diarydate2(thisdate);})
}

function diarydate2(thisdate){
	$(".snapsentent1 .snaplist2").slideUp("fast",function(){$(this).remove()})
		$.get("diary_date.cfm?thisdate="+thisdate, function(data){
			$(".snapsentent1").prepend(data)
			$(".snapsentent1 .snaplist2").hide();
			$(".snapsentent1 .snaplist2").slideDown("slow");
		});
	
}


