
// HOME -------------------------------------------------------------------------------------

var mainVisual;
var hvrObj;
$(function(){
	if($("body.home").length > 0){
		$("#globalNav a").find("img").removeClass("hover");
		$("#headVisual p:first").addClass("active");
	}
});

$(window).load(function(){
	$("#headVisual .inner p:first").fadeIn(1200,function(){
		$("#headVisual").append('<a id="visualHover" style="width:1300px; height:343px; position:absolute; left:-170px; top: 0px; z-index:30; display:block; background-color:#ffffff;"></a>');
		$("#visualHover").css("opacity",0);
		$("#visualHover").hover(
			function(){
				hvrObj = $("#headVisual .active");
				var tmpBg = hvrObj.css("background-image");
				$(this).css("background-image",tmpBg);
				$(this).animate({"opacity":1.0},400);
				mainVisual.cycle('pause');
			},
			function(){
				$(this).animate({"opacity":0},400,function(){
					$(this).css("background-image","none");
				});
				mainVisual.cycle('resume');
			}
		);
		$("#headVisual .inner").css("background","none");
		mainVisual = $('#headVisual .inner').cycle({
			speed: 1200,
			timeout: 5500,
			easing: 'easeOutSine',
			fx: 'fade'/*,
			random:1*/,
			before: function(nowObj, nextObj){
				$(nowObj).removeClass("active");
				var tmpClass1 = $(nowObj).attr("class");
				$("#globalNav ."+tmpClass1+" img").animate({"opacity":1.0},600);
				var tmpClass2 = $(nextObj).attr("class");
				$(nextObj).addClass("active");
				var tmpURL = $(nextObj).find("a").attr("href");
				$("#visualHover").attr("href",tmpURL);
				$("#globalNav ."+tmpClass2+" img").animate({"opacity":0},600);
			}
		});
		$("#globalNav a").each(function(idx){ 
			$(this).hover(
				function(){
					mainVisual.cycle(idx);
					mainVisual.cycle('pause');
				},
				function(){
					mainVisual.cycle('resume');
				}
			);
		});
		$("#headVisual img").hover(
			function(){
				mainVisual.cycle('pause');
			},
			function(){
				mainVisual.cycle('resume');
			}
		);
	});
});












