$(function(){
/*----------------------------------------------------------------
    画像切り替え
----------------------------------------------------------------*/
    $(".over").imgchange({ name: "-o"});
    $(".oimg").imgover();

    $(".hover").imghover();

	$("#gnavi .child").menudown();

	$("#menu .child > a, #rnavi .child > a, #pagenavi .child > a").accordion();

	$("#in-footer").footNavi();

	$("ul.latest-news").newscroll();
	$(".photobox li a").clickimg({ target: ".photobox .main-photo"})

/*----------------------------------------------------------------
    フォントサイズ変更
----------------------------------------------------------------*/
    var history = $.cookie('fontSize');
	var elm = $('body');
	if(history) elm.addClass(history);
	$("#font-set a").click(function(){
		var set  = $(this).attr('class');
		var font = "";
		$("body").removeClass("font-min").removeClass("font-big");
		$("html").removeClass("font-min").removeClass("font-big");
		if(set == "min") {
			font = "font-min";
		} else if(set == "big") {
			font = "font-big";
		} else {
			font = "";
		}
		$.cookie('fontSize', font);
		if(font) $("body").addClass(font);
		if(font) $("html").addClass(font);
		return false;
	});

/*----------------------------------------------------------------
    タブ
----------------------------------------------------------------*/
	$(".tabbox").css("display", "none");
	$("#shiken").css("display", "block");

	$("#tab a").click(function(){
		var target = $(this).attr('href');
		if(target == "#shiken") {
			$(".shiken-img").attr('src','site/img/index/tab-01-o.gif');
			$(".seisan-img").attr('src','site/img/index/tab-02.gif');
		} else if(target == "#seisan") {
			$(".shiken-img").attr('src','site/img/index/tab-01.gif');
			$(".seisan-img").attr('src','site/img/index/tab-02-o.gif');
		}
		$(".tabbox").css("display", "none");
		$(target).css("display", "block");
		return false;
	});

/*----------------------------------------------------------------
    サイドバースライド
----------------------------------------------------------------*/
	if(!$("#index").length) {
		var posi = $("#sidebar").offset();
		$(window).scroll(function(){
			var mainh = $("#main").innerHeight();
			var sideh = $("#sidebar").height();
			var maxt  = mainh - sideh - 200;
			var top = $(window).scrollTop();
			var settop = top - posi.top;
			if(posi.top < top && settop < maxt) {
				$("#sidebar").stop().animate({ paddingTop: settop + "px"}, { duration: 1000, easing: "easeOutExpo"});
			} else if(top < 60) {
				$("#sidebar").stop().animate({ paddingTop: "0px"}, { duration: 1000, easing: "easeOutExpo"});
			}
		});
	}

/*----------------------------------------------------------------
    インデックスアニメーションJS
----------------------------------------------------------------*/
if($("#index").length) {
$(window).bind("load", function() {
	var flag = 0;
	var flagrec = 1;
	var stage = $("#key > div");
	var stage1li = $("#stage1 li");
	var mw = $("body").width();
	$("body").css({
		width: mw + "px",
		overflow: "hidden"
	});
	$(window).resize(function() {
		var mw = $(window).width();
		$("body").css({
			width: mw + "px"
		});
	});
	$("#key > div").not("#stage1").css({
		opacity: 0,
		display: "none"
	});
	$("#stage1 p").css({
		right: "0px",
		opacity: 0
	});
	stage1li.css({
		top: "-50px",
		opacity: 0
	});
	$("#stage1 .main").css("opacity", 0).stop().animate({
		left: "30px",
		top: "85px",
		width: "378px",
		height: "263px",
		opacity: 1
	}, {duration: 1800, easing: "easeInExpo", complete: function(){
		$("#stage1 p").stop().animate({
			right: "50px",
			opacity: 1
		}, { duration: 1000, easing: "easeOutExpo"});
		stage1li.eq(0).stop().animate({
			top: "0px",
			opacity: 1
		}, { duration: 1800, easing: "easeOutExpo"});
		stage1li.eq(1).stop().animate({
			top: "0px",
			opacity: 1
		}, { duration: 2400, easing: "easeOutExpo"});
		stage1li.eq(2).stop().animate({
			top: "0px",
			opacity: 1
		}, { duration: 3000, easing: "easeOutExpo"});
	}});
	var animflug = 0;
	var flaglastone = stage.length-2;
	var flaglast = stage.length-1;
	$("#scroll .right").click(function(){
		if(animflug == 0){
			var flagold=flag;
			animflug = 1;
			stage.eq(flag).animate({ left: "-920px", opacity: 0}, { duration: 1200, easing: "swing", complete: function(){ $(this).css({ display: "none", opacity: 0});}});
			(stage.length - 1 > flag)? flag++ : flag = 0;
			if(flag != 0 && flag != flaglastone && flag != flaglast){
				if(flagold == 0){
					if(flagrec != flag){
						flag = flagrec;
					}
				}else if(flagrec == flagold){
					flag = flaglastone;
				}
			}
			stage.eq(flag).css({ display: "block", left: "950px"}).animate({ left: "10px", opacity: 1}, { duration: 1200, easing: "swing", complete: function(){animflug = 0;}});
		}
	});
	$("#scroll .left").click(function(){
		if(animflug == 0){
			var flagold=flag;
			animflug = 1;
			stage.eq(flag).animate({ left: "920px", opacity: 0}, { duration: 1200, easing: "swing", complete: function(){ $(this).css({ display: "none", opacity: 0});}});
			(0 < flag)? flag-- : flag = stage.length - 1;
			if(flag != 0 && flag != flaglastone && flag != flaglast){
				if(flagold == flaglastone){
					if(flagrec != flag){
						flag = flagrec;
					}
				}else if(flagrec == flagold){
					flag = 0;
				}
			}
			stage.eq(flag).css({ display: "block", left: "-950px"}).animate({ left: "10px", opacity: 1}, { duration: 1200, easing: "swing", complete: function(){animflug = 0;}});
		}
	});

	$("#index #content .onc").hover(function(){
		if(this.id && flag != this.id){
		stage.not(stage.eq(this.id)).stop().animate({ opacity: 0}, { duration: 1200, easing: "swing", complete: function(){ $(this).css({ display: "none", opacity: 0});}});
		var old = flag;
		flag = this.id;
		flagrec = this.id;
		stage.eq(flag).css({ display: "block", left: "10px", zIndex: 200}).stop()
		.animate({ opacity: 1}, { duration: 1200, easing: "swing", complete: function(){ animflug = 0;}});
		}
		/*
		if(this.id && flag != this.id && animflug == 0){
		animflug = 1;
		stage.eq(flag).css({ zIndex: 100});
		var old = flag;
		flag = this.id;
		flagrec = this.id;
		stage.eq(flag).css({ display: "block", left: "10px", zIndex: 200}).stop()
		.animate({ opacity: 1}, { duration: 1200, easing: "swing", complete: function(){ animflug = 0; stage.eq(old).css({ display: "none", opacity: 0});}});
		}
		*/
	},function(){});
});
}
});

function load() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("gmap"));
        map.addControl(new GLargeMapControl());
        map.setCenter(new GLatLng(36.154749,137.903379), 13);
        var marker = new GMarker(new GLatLng(36.154749,137.903379));
        map.addOverlay(marker);
    }
}

