﻿// JavaScript Document
try {
document.execCommand('BackgroundImageCache', false, true); 
}catch(e) {}

//Smooth scroll
var smoothScroll ={
		init:function(speed){
			$("a[href^=#top]").click(function() {
				var hash = this.hash;
				if(!hash || hash == "#")
					return false;
				$($.browser.safari ? 'body' : 'html')
					.animate({scrollTop: $(hash).offset().top}, speed, "easeOutExpo");
				return false;
			});
		}
}
timerLoop=2;
var epc ={
	init:function(){
		//共通のサブフッターを読み込み
		$("#subFooterArea").load("/common/inc/subFooterArea.html");
		
		//タイマー動作
		if($("#visualArea").length){
			timerID = setInterval(function(){
				var id = "#visual0"+timerLoop;
				var btn = "#btnArea .b0"+timerLoop;
				mainVisual.rotate(id,btn,timerLoop);
				timerLoop++;
				if(timerLoop > 4){timerLoop = 1;}
			},10000)
		}
	},
	overColor:function(color,target){
		$(target).animate({ 
				backgroundColor: color
		}, 500);
	}
}


btnLock = false;
btnArea = {
	toggle:function(id){
		$("#btnArea li a").removeClass("active");
		$("a",id).addClass("active");
	}
}

mainVisual = {
	rotate:function(id1,id2,setLoop){
		if(btnLock==false){
			btnLock = true;
			timerLoop = setLoop;
			btnArea.toggle(id2);
			var notId = "#visualArea li:not("+id1+")";
			$("#visualArea li").css("z-index","1");
			$(id1).css("z-index","4").animate({ 
				left: "0"
			}, 1500 ,"easeInOutQuint",
			function(){//callback
				$(notId).css("left","960px");
				btnLock = false;
			});
		}
	}
}

$(function(){
	smoothScroll.init();
	epc.init();
	
	//トップページ用
	if($("#visualArea").length){
		$("#btnArea .b01").click(function(){
			mainVisual.rotate("#visual01",this,1);
			return false;
		});
		$("#btnArea .b02").click(function(){
			mainVisual.rotate("#visual02",this,2);
			return false;
		});
		$("#btnArea .b03").click(function(){
			mainVisual.rotate("#visual03",this,3);
			return false;
		});
		$("#btnArea .b04").click(function(){
			mainVisual.rotate("#visual04",this,4);
			return false;
		});
	}
	//扉ページ用
	if($('.overText').length){
		$('.overText').hover(
			function () {
				$(".more",this)
				.animate({
					left: "0px"
					}, 800 , "easeInOutQuint",
					function(){//callback
						$(".text",this).fadeIn(200).css("display","block");
				});
			},
			function () {
				$(".text",this).fadeOut(200);
				$(".more",this).animate({ 
					left: "310px"
					}, 800 , "easeInOutQuint");
			}
		);
	}
	//グローバルナビ
	$('#globalNavi li a').hover(
		function () {
			var check = $(this).hasClass("activeGnavi");
			if(check ==false){
				$(this)
				.animate({ 
					top: "-26px"
					}, 500 , "easeInOutQuint");
			}
		},
		function () {
			var check = $(this).hasClass("activeGnavi");
			if(check ==false){
				$(this)
				.animate({ 
					top: "0px"
					}, 200 , "easeInOutQuint");
			}
  	}
	);
	//index
	//overColor1、ローカルナビ
	$('.overColor1 a,#columnC .localNavi > li:not(.active) a').hover(
		function () {
			epc.overColor("#FC9801;",this);
		},
		function () {
			epc.overColor("#FCCF00;",this);
  	}
	);
	//overColor2、ページトップへ、ユーティリティナビ
	$('.overColor2 a,.totop a,#contact a,#sitemap a').hover(
		function () {
			epc.overColor("#FCCF00;",this);
		},
		function () {
			epc.overColor("#000000;",this);
  	}
	);
	
		
});

