
// ### CONST ###
var NAVI_BASE_Y = 360;

var NAVI_INIT_Y = 317;
/*
var NAVI_INIT_MAIN_Y = NAVI_INIT_Y - (148 + 8 + 21);
var NAVI_INIT_SUB_Y = NAVI_INIT_Y - 11;
*/
var NAVI_INIT_MAIN_Y = NAVI_BASE_Y - (148 + 8 + 21);
var NAVI_INIT_SUB_Y = NAVI_BASE_Y - 11;

var NAVI_STEP_MAIN_Y = 43;
//var NAVI_STEP_SUB_Y = 22;
var NAVI_STEP_SUB_Y = 20;


// ### Page Settings ###
var topPage;

var idxNaviMain;
var idxNaviSub;

var naviBarA01;
var naviBarB01;
var naviBarB02;
var naviBarC01;
var naviBarD01;
var naviBarD02;


// ### Private Properties ###
var enableContents;
var toTopCont;
var fromSubCont;
var naviLink;
var innerLink;
var showTop;


// * Device Info *
var deviceType;
var deviceVer;
var isSmartPhone;


// ##################################
//          	* jQuery *
// ##################################

/*	-----------------------------
 *	jQuery
 *	----------------------------- */
$(function(){
//	$('#debug').prepend("jQuery (function)<br />");
});

/*	-----------------------------
 *	jQuery - ready
 *	----------------------------- */
$(document).ready(function() {
//	$('#debug').prepend("jQuery - ready<br />");
	init();
});

/*	-----------------------------
 *	jQuery - load
 *	----------------------------- */
$(window).load(function() {
//	$('#debug').prepend("jQuery - load<br />");
//	init();

	if (topPage && !toTopCont) {
		//alert("load");
		initSite(!toTopCont);
	}
});

/*	-----------------------------
 *	jQuery - unload
 *	----------------------------- */
$(window).unload(function() {
//	$('#debug').prepend("jQuery - unload<br />");
});


/*	-----------------------------
 *	jQuery - scroll
 *	----------------------------- */
$(window).scroll(function(){
	chackToTop();
});

/*	-----------------------------
 *	jQuery - resize
 *	----------------------------- */
$(window).resize(function(){
	
});





// ##################################
//          * initialize *
// ##################################

/**
 * init
 * 
 */
function init() {
	
	enableContents = false;
	
	// ### jquery.exfixed.js ###
	$('#bgImage, #navi, #debug, #initLine, #toTop').exFixed();
	
	// ### jquery.check.agent.js ###
	$(document.body).checkAgent();
	isSmartPhone = $.getAgent('smartphone');
	deviceType = $.getAgent('device');
	deviceVer = $.getAgent('version');
	/*
	$('#debug').prepend(isSmartPhone + "<br />");
	$('#debug').prepend(deviceType + "<br />");
	$('#debug').prepend(deviceVer + "<br />");
	*/
	$(window).scroll(adjustNavigation);
	$(window).resize(adjustNavigation);
	if (isSmartPhone) {
		document.addEventListener("touchmove", adjustNavigation, false);
		document.addEventListener("gesturechange", adjustNavigation, false);
	}
	
	// ### jquery.cookie.js ###
	if ($.cookie('to_top_cont')) {
		$.cookie('to_top_cont', null, {expires:-1, path:'/'});
		toTopCont = true;
	}
	
	if ($.cookie('from_sub')) {
		$.cookie('from_sub', null, {expires:-1, path:'/'});
		fromSubCont = true;
	}
	
	if ($.cookie('navi_link')) {
		$.cookie('navi_link', null, {expires:-1, path:'/'});
		naviLink = true;
	}
	
	if ($.cookie('inner_link')) {
		$.cookie('inner_link', null, {expires:-1, path:'/'});
		innerLink = true;
	}
	
	if (toTopCont) { $('#debug').prepend("Cookie toTop ON<br />"); }
	if (fromSubCont) { $('#debug').prepend("Cookie fromSub ON<br />"); }
	if (naviLink) { $('#debug').prepend("Cookie naviLink ON<br />"); }
	if (innerLink) { $('#debug').prepend("Cookie innerLink ON<br />"); }
	
	
	// ### jquery.slidescroll.js ###
	$("a[href*='#']").slideScroll();
	
	// ### IE png opacity ###
	//$(function() {
		if(navigator.userAgent.indexOf("MSIE") != -1) {
			$('img').each(function() {
				if($(this).attr('src').indexOf('.png') != -1) {
					$(this).css({
						'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +
						$(this).attr('src') +
						'", sizingMethod="scale");'
					});
				}
			});
		}
	//});
	
	
	// # inner link #
	$('a.innerLink').click(
		function(e) {
			
			var url = $(this).attr('href');
			$('#debug').prepend(url + "<br />");
			
			onClickInnerLink(url);
			
			return false;
		}
	);
	$('a.innerLinkActive').click(
		function(e) {
			return false;
		}
	);
	
	// # outer link #
	$('a.outerLink').click(
		function(e) {
			
			var url = $(this).attr('href');
			$('#debug').prepend("outerLink! " + url + "<br />");
			
			onClickOuterLink(url);
			
			return false;
		}
	);
	
	// # footer link #
	$('a.footLink').click(
		function(e) {
			var url = $(this).attr('href');
			$('#debug').prepend(url + "<br />");
			
			onClickFootLink(url);
			
			return false;
		}
	);
	$('a.footLinkActive').click(
		function(e) {
			return false;
		}
	);
	
	
	
	
	
	// *** init contents ***
	if (topPage && toTopCont) {
		//alert("ready");
		initSite(!toTopCont);
	}
	else {
		if(topPage) return;
		initPage(naviLink, innerLink);
	}
	
}




// ##################################
//              * Site *
// ##################################

/**
 * initSite
 * 
 */
function initSite(opening) {
	
	if (opening) {
		
		// * Init Navi Line *
		$('#boxLine #boxSubA .boxChildTop').css({height:'0px', marginTop:'400px'});
		$('#boxLine #boxSubA .boxChildBtm').css({height:'0px', marginTop:'0px'});
		$('#boxLine #boxSubB .boxChildTop').css({height:'0px', marginTop:'400px'});
		$('#boxLine #boxSubB .boxChildMid').css({height:'0px', marginTop:'0px'});
		$('#boxLine #boxSubB .boxChildBtm').css({height:'0px', marginTop:'0px'});
		$('#boxLine #boxSubC .boxChildTop').css({height:'0px', marginTop:'400px'});
		$('#boxLine #boxSubC .boxChildBtm').css({height:'0px', marginTop:'0px'});
		$('#boxLine #boxSubD .boxChildTop').css({height:'0px', marginTop:'400px'});
		$('#boxLine #boxSubD .boxChildMid').css({height:'0px', marginTop:'400px'});
		$('#boxLine #boxSubD .boxChildBtm').css({height:'0px', marginTop:'0px'});
		setTimeout(function(){ $('#boxLine #boxSubA .boxChildTop').show().animate({marginTop:'0px', height:naviBarA01+'px'},	800,	'easeInOutCirc'); }, 1200);		// 2000
		setTimeout(function(){ $('#boxLine #boxSubA .boxChildBtm').show().animate({marginTop:'0px', height:'100%'},					800,	'easeInOutCirc'); }, 1250);		// 2050
		setTimeout(function(){ $('#boxLine #boxSubB .boxChildTop').show().animate({marginTop:'0px', height:naviBarB01+'px'},	700,	'easeInOutCirc'); }, 700);		// 1400
		setTimeout(function(){ $('#boxLine #boxSubB .boxChildMid').show().animate({marginTop:'0px', height:naviBarB02+'px'},	800,	'easeInOutCirc'); }, 750);		// 1550
		setTimeout(function(){ $('#boxLine #boxSubB .boxChildBtm').show().animate({marginTop:'0px', height:'100%'},					700,	'easeInOutCirc'); }, 550);		// 1250
		setTimeout(function(){ $('#boxLine #boxSubC .boxChildTop').show().animate({marginTop:'0px', height:naviBarC01+'px'},	800,	'easeInOutCirc'); }, 1000);		// 1800
		setTimeout(function(){ $('#boxLine #boxSubC .boxChildBtm').show().animate({marginTop:'0px', height:'100%'},					800,	'easeInOutCirc'); }, 1050);		// 1850
		setTimeout(function(){ $('#boxLine #boxSubD .boxChildTop').show().animate({marginTop:'0px', height:naviBarD01+'px'},	1500,	'easeInOutCirc'); }, 0);			// 1500
		setTimeout(function(){ $('#boxLine #boxSubD .boxChildMid').show().animate({marginTop:'0px', height:naviBarD02+'px'},	800,	'easeInOutCirc'); }, 600);		// 1400
		setTimeout(function(){ $('#boxLine #boxSubD .boxChildBtm').show().animate({marginTop:'0px', height:'100%'},					800,	'easeInOutCirc'); }, 600);		// 1400
		
		setTimeout(function(){ enableContents = true; }, 2050);
		
		// * Init Navi Main *
		$('#boxNaviMain .boxLogo img').hide();
		$('#boxNaviMain .boxMain a').hide();
		setTimeout(function(){ $("#boxNaviMain .boxLogo img").fadeIn(1000, "easeInOutCirc"); }, 1600);		// 2600
		setTimeout(function(){ $("#boxNaviMain .boxMain a").fadeIn(1000, "easeInOutCirc"); }, 1600);			// 2600
		
		$('#boxNaviMain .boxMain').css({height:'0px', marginTop:'400px', paddingTop:'0px'});
		$('#boxNaviMain .boxSub').css({height:'0px', marginTop:'0px'});
		setTimeout(function(){ $('#boxNaviMain .boxMain').show().animate({marginTop:'0px', height:'230px', paddingTop:'8px'},750,'easeInOutCirc'); }, 1300);		// 2050
		setTimeout(function(){ $('#boxNaviMain .boxSub').show().animate({marginTop:'0px', height:'100%'},750,'easeInOutCirc'); }, 1300);		// 2050
		
		// * Init Navi Sub *
		$('#boxNaviSub').hide();
		setTimeout(function(){ $("#boxNaviSub").fadeIn(2000); }, 1800);		// 3800
		
		// * Init Navi *
		$('#boxNaviMain .boxCont').css('top', NAVI_INIT_MAIN_Y - NAVI_STEP_MAIN_Y);
		$('#navi').show();
		
		
		// * Init Contents *
		setTimeout(function(){ $("#bgImage").fadeIn(2500); }, 1000);				// 3500
		setTimeout(function(){ $("#boxContArea").fadeIn(2800); }, 1000);		// 3800
		
		setNaviEvents();
		
	}
	else {
		
		$('#bgImage').show();
		$('#boxContArea').fadeIn(600);
		initNavigation(true);
		
	}
	
	
}

/**
 * initPage
 * 
 */
function initPage(motion, inner) {
	
	initNavigation(motion);
	
	if (motion) {
		slideInContents(!fromSubCont);
	}
	else {
		if (inner) {
			slideInContents();
		}
		else {
			$('#boxContArea').css({top:'0px'});
			$('#boxContArea').show();
		}
	}
	
}





// ##################################
//            * Navigation *
// ##################################

/**
 * initNavigation
 * 
 */
function initNavigation(motion) {
	
//	motion = false;
	
	var mainY = 0;
	if (idxNaviMain >= 0) {
//		mainY -= NAVI_STEP_MAIN_Y * idxNaviMain;
//		if (idxNaviMain != 4) {
			mainY -= NAVI_STEP_MAIN_Y * (idxNaviMain - 1);
//		}
		activeNaviMain(idxNaviMain);
	}
	$('#boxNaviMain .boxCont').css('top', NAVI_INIT_MAIN_Y - NAVI_STEP_MAIN_Y + mainY);
	
	if (motion) {
		
		var y = NAVI_INIT_Y - NAVI_STEP_MAIN_Y;
//		var y = NAVI_BASE_Y;
		
		if (idxNaviMain == 4) { y += NAVI_STEP_MAIN_Y * idxNaviMain; }
		
		initNaviIndicator(y);
		restoreNaviIndicator(600);
		
		if (fromSubCont) {
			
			var subY = 0;
			if (idxNaviSub >= 0) {
				subY -= NAVI_STEP_SUB_Y * idxNaviSub -1;
				activeNaviSub(idxNaviSub);
			}
			$('#boxNaviSub .boxCont').css('top', NAVI_INIT_SUB_Y + subY);
			
			//slideInContents();
		}
		else {
			slideInNaviSub();
			//slideInContents(true);
		}
		
	}
	else {
		
		var subY = 0;
		if (idxNaviSub >= 0) {
			subY -= NAVI_STEP_SUB_Y * idxNaviSub -1;
			activeNaviSub(idxNaviSub);
		}
		$('#boxNaviSub .boxCont').css('top', NAVI_INIT_SUB_Y + subY);
		
		initNaviIndicator();
		
	}
	
	setNaviEvents();
	enableContents = true;
	
	$('#navi').show();
	
}


/**
 * setNaviEvents
 * 
 */
function setNaviEvents() {
	
	// ## Navi Logo ##
	$('#boxNaviMain .boxLogo a').click(
		function(e) {
			if (!enableContents) { return false; }
//			if (-1 == idxNaviMain) { return false; }
//			if (topPage) { topLogo(); }
//			$('#debug').prepend("onClickNaviLogo <br />");
			onClickNaviLogo();
			return false;
		}
	);
	
	function topLogo() {
		location.href = "index.html";
	}
	
	// ## Navi Main ##
	if (!isSmartPhone) {
		$('#boxNaviMain .boxMain a').hover(
			function(e) {
				if (!enableContents) { return false; }
				if (!$(this).hasClass('active')) {
					$(this).find('img.over').fadeIn(200);
				}
				var idx = $('#boxNaviMain .boxMain a').index(this);
				onOverNaviMain(idx);
			},
			function(e) {
				if (!enableContents) { return false; }
				if (!$(this).hasClass('active')) {
					$(this).find('img.over').stop().fadeOut(200, function(){ $(this).css('opacity', '1'); });
				}
				var idx = $('#boxNaviMain .boxMain a').index(this);
				onOutNaviMain(idx);
			}
		);
	}
	
	$('#boxNaviMain .boxMain a').click(
		function(e) {
			var idx = $('#boxNaviMain .boxMain a').index(this);
			if (!enableContents) { return false; }
			if (idx == idxNaviMain) { return false; }
			$('#debug').prepend("onClickNaviMain : " + idx + "<br />");
			onClickNaviMain(idx);
			return false;
		}
	);
	
	// ## Navi Sub ##
	if (!isSmartPhone) {
		$('#boxNaviSub .boxCont a').hover(
			function(e) {
				if (!enableContents) { return false; }
				var idx = $('#boxNaviSub .boxCont a').index(this);
				onOverNaviSub(idx);
			},
			function(e) {
				if (!enableContents) { return false; }
				var idx = $('#boxNaviSub .boxCont a').index(this);
				onOutNaviSub(idx);
			}
		);
	}
	
	$('#boxNaviSub .boxCont a').click(
		function(e) {
			var idx = $('#boxNaviSub .boxCont a').index(this);
			if (!enableContents) { return false; }
			if (idx == idxNaviSub) { return false; }
			onClickNaviSub(idx);
			return false;
		}
	);
	
}

/**
 * adjustNavigation
 * 
 */
function adjustNavigation() {
	$('#navi').css('left', $(window).scrollLeft() * -1);
	$('#bgImage').css('left', $(window).scrollLeft() * -1);
}




// =============================================== * Navi Logo *

/**
 * onClickNaviLogo
 * 
 */
function onClickNaviLogo() {
	
	$.cookie('navi_link', '1', {expires:1, path:'/'});
	$.cookie('to_top_cont', '1', {expires:1, path:'/'});
	
	var url = $('#boxNaviMain .boxLogo a').attr('href');
	
	enableContents = false;
	
	inactiveNaviMain();
	moveNaviMain();
	
	cahgeNaviIndicator(NAVI_INIT_Y+40, 0);
	
	if (!topPage) {
		slideOutNaviSub();
		slideOutContents(url, true);
	}else {
		setTimeout(function(){ location.href = url; }, 800);
	}
}



// =============================================== * Navi Main *

/**
 * onClickNaviMain
 * 
 */
function onClickNaviMain(idx) {
	
	$.cookie('navi_link', '1', {expires:1, path:'/'});
	
	var url = $('#boxNaviMain .boxMain a').eq(idx).attr('href');
	//$('#debug').prepend(url + "<br />");
	
	enableContents = false;
	
	idxNaviMain = idx;
	
	activeNaviMain(idx);
	
/*	if (idx == 4) {
		moveNaviMain(0);
		cahgeNaviIndicator(NAVI_INIT_Y + (NAVI_STEP_MAIN_Y * idx), 0);
	}
	else {*/
		moveNaviMain(idx);
		cahgeNaviIndicator(NAVI_INIT_Y+40, 0);
//	}
	
	if (!topPage) { slideOutNaviSub(); }
	slideOutContents(url, true);
}

/**
 * onOverNaviMain
 * 
 */
function onOverNaviMain(idx) {
	var y = NAVI_INIT_Y + (NAVI_STEP_MAIN_Y * idx);
	if (idxNaviMain >= 0 /*&& idxNaviMain != 4*/) { y -= (NAVI_STEP_MAIN_Y * idxNaviMain) - NAVI_STEP_MAIN_Y; }
	//var h = idx / ($('#boxNaviMain .boxMain a').size() + 1);
	var h = 0;
	cahgeNaviIndicator(y, h);
}

/**
 * onOutNaviMain
 * 
 */
function onOutNaviMain(idx) {
	restoreNaviIndicator();
}


/**
 * activeNaviMain
 * 
 */
function activeNaviMain(idx) {
	if (idx == undefined) { return false; }
	var t = $('#boxNaviMain .boxMain a:eq(' + idx + ')');
	t.addClass('active');
	t.find('img.over').show();
	inactiveNaviMain(idx);
}

/**
 * inactiveNaviMain
 * 
 */
function inactiveNaviMain(idx) {
	if (idx == undefined) { idx = -1; }
	var t = $('#boxNaviMain .boxMain a');
	for (var i=0; i<t.length; i++) {
		if (i != idx) {
			t.eq(i).removeClass('active');
			t.eq(i).find('img.over').hide();
		}
	}
}

/**
 * moveNaviMain
 * 
 */
function moveNaviMain(idx) {
	if (idx == undefined) {
		$('#boxNaviMain .boxCont').animate({top: NAVI_INIT_MAIN_Y - NAVI_STEP_MAIN_Y + 'px'}, 1000, 'easeInOutQuart');
	}
	else {
		$('#boxNaviMain .boxCont').animate({top: (NAVI_INIT_MAIN_Y - (NAVI_STEP_MAIN_Y * idx)) + 'px'}, 1000, 'easeInOutQuart');
	}
}





// =============================================== * Navi Sub *

/**
 * onClickNaviSub
 * 
 */
function onClickNaviSub(idx) {
	
	if ($('#boxNaviSub .boxCont a').eq(idx).hasClass("naviSab_blank")) {
		var burl = $('#boxNaviSub .boxCont a').eq(idx).attr('href');
		//location.href = burl;
		window.open(burl)
		return;
	}
	
//	$.cookie('motion', '1', {expires:1, path:'/', domain:'www.xxxx.com', secure:true});
	$.cookie('from_sub', '1', {expires:1, path:'/'});
	$.cookie('navi_link', '1', {expires:1, path:'/'});
	
	var url = $('#boxNaviSub .boxCont a').eq(idx).attr('href');
	
	if (url.search("_sample") > -1) { return false; }
	
	enableContents = false;
	
	idxNaviSub = idx;
	
	activeNaviSub(idx);
	moveNaviSub(idx);
	cahgeNaviIndicator(NAVI_INIT_Y+40, 0);
	
	slideOutContents(url);
	
}

/**
 * onOverNaviSub
 * 
 */
function onOverNaviSub(idx) {
	var y = NAVI_INIT_Y + (NAVI_STEP_SUB_Y * idx);
	if (idxNaviSub >= 0) { y -= (NAVI_STEP_SUB_Y * idxNaviSub) - NAVI_STEP_MAIN_Y; }
	var h = idx / ($('#boxNaviSub .boxCont a').size() + 1);
	//var h = 0;
	cahgeNaviIndicator(y, h);
}

/**
 * onOutNaviSub
 * 
 */
function onOutNaviSub(idx) {
	restoreNaviIndicator();
}


/**
 * activeNaviSub
 * 
 */
function activeNaviSub(idx) {
	if (idx == undefined) { return false; }
	var t = $('#boxNaviSub .boxCont a:eq(' + idx + ')');
	t.addClass('active');
	inactiveNaviSub(idx);
}

/**
 * inactiveNaviSub
 * 
 */
function inactiveNaviSub(idx) {
	if (idx == undefined) { idx = -1; }
	var t = $('#boxNaviSub .boxCont a');
	for (var i=0; i<t.length; i++) {
		if (i != idx) {
			t.eq(i).removeClass('active');
		}
	}
}

/**
 * moveNaviSub
 * 
 */
function moveNaviSub(idx) {
	$('#boxNaviSub .boxCont').animate({top: (NAVI_INIT_SUB_Y - (NAVI_STEP_SUB_Y * idx -1)) + 'px'}, 700, 'easeInOutQuart');
}


/**
 * slideInNaviSub
 * 
 */
function slideInNaviSub() {
	$('#boxNaviSub .boxCont').css('top', $('body').outerHeight(true));
	var t = $('#boxNaviSub .boxCont');
//	var y = t.outerHeight(true) * -1;
//	t.animate({top:NAVI_INIT_SUB_Y+'px'}, 300, 'easeInOutSine', function(){ activeNaviSub(0); });
	t.animate({top:NAVI_INIT_SUB_Y-(NAVI_STEP_SUB_Y*idxNaviSub)}, 1000, 'easeInOutQuart', function(){ activeNaviSub(idxNaviSub); });
}

/**
 * slideOutNaviSub
 * 
 */
function slideOutNaviSub() {
	var t = $('#boxNaviSub .boxCont');
	var y = t.outerHeight(true) * -1;
	t.animate({top:y+'px'}, 700, 'easeInOutQuart');
	//$('#debug').prepend(t.outerHeight(true) + "<br />");
}


// =============================================== * Navi Indicator *

/**
 * initNaviIndicator
 * 
 */
function initNaviIndicator(y) {
	if (naviBarA01 == undefined) { naviBarA01 = Math.floor(Math.random() * 512); }
	if (naviBarB01 == undefined) { naviBarB01 = Math.floor(Math.random() * 256); }
	if (naviBarB02 == undefined) { naviBarB02 = Math.floor(Math.random() * 256); }
	if (naviBarC01 == undefined) { naviBarC01 = Math.floor(Math.random() * 512); }
	if (naviBarD01 == undefined) { naviBarD01 = Math.floor(Math.random() * 256); }
	if (naviBarD02 == undefined) { naviBarD02 = Math.floor(Math.random() * 256); }
	if (y == undefined) {
		$('#boxLine #boxSubA .boxChildTop').css('height', naviBarA01 + 'px');
		$('#boxLine #boxSubB .boxChildTop').css('height', naviBarB01 + 'px');
		$('#boxLine #boxSubB .boxChildMid').css('height', naviBarB02 + 'px');
		$('#boxLine #boxSubC .boxChildTop').css('height', naviBarC01 + 'px');
		$('#boxLine #boxSubD .boxChildTop').css('height', naviBarD01 + 'px');
		$('#boxLine #boxSubD .boxChildMid').css('height', naviBarD02 + 'px');
	}
	else {
		$('#boxLine #boxSubA .boxChildTop').css('height', y + 'px');
		$('#boxLine #boxSubB .boxChildTop').css('height', y + 'px');
		$('#boxLine #boxSubB .boxChildMid').css('height', '0px');
		$('#boxLine #boxSubC .boxChildTop').css('height', y + 'px');
		$('#boxLine #boxSubD .boxChildTop').css('height', y + 'px');
		$('#boxLine #boxSubD .boxChildMid').css('height', '0px');
	}
}

/**
 * cahgeNaviIndicator
 * 
 */
function cahgeNaviIndicator(y, h) {
//	if (topPage) { return false;}
	if (y == undefined) { return false; }
	if (h == undefined) { h = 0.5; }
	$('#boxLine #boxSubA .boxChildTop').stop().animate({height: y + 'px'} ,300, 'easeInQuad');
	$('#boxLine #boxSubB .boxChildTop').stop().animate({height: y + 'px'} ,300, 'easeInQuad');
	$('#boxLine #boxSubB .boxChildMid').stop().animate({height: (naviBarB02 * 0.5 * h) + 'px'}, 300, 'easeInQuad');
	$('#boxLine #boxSubC .boxChildTop').stop().animate({height: y + 'px'} ,300, 'easeInQuad');
	$('#boxLine #boxSubD .boxChildTop').stop().animate({height: y + 'px'} ,300, 'easeInQuad');
	$('#boxLine #boxSubD .boxChildMid').stop().animate({height: (naviBarD02 * h) + 'px'}, 300, 'easeInQuad');
}

/**
 * restoreNaviIndicator
 * 
 */
function restoreNaviIndicator(t) {
	if (t == undefined) { t = 185; }
	$('#boxLine #boxSubA .boxChildTop').stop().animate({height: naviBarA01 + 'px'}, t, 'easeOutQuad');
	$('#boxLine #boxSubB .boxChildTop').stop().animate({height: naviBarB01 + 'px'}, t, 'easeOutQuad');
	$('#boxLine #boxSubB .boxChildMid').stop().animate({height: naviBarB02 + 'px'}, t, 'easeOutQuad');
	$('#boxLine #boxSubC .boxChildTop').stop().animate({height: naviBarC01 + 'px'}, t, 'easeOutQuad');
	$('#boxLine #boxSubD .boxChildTop').stop().animate({height: naviBarD01 + 'px'}, t, 'easeOutQuad');
	$('#boxLine #boxSubD .boxChildMid').stop().animate({height: naviBarD02 + 'px'}, t, 'easeOutQuad');
}





// ##################################
//           * Inner Link *
// ##################################

/**
 * onClickInnerLink
 * 
 */
function onClickInnerLink(url) {
	
	$.cookie('inner_link', '1', {expires:1, path:'/'});
	
	slideOutContents(url);
	
}

// ##################################
//           * Outer Link *
// ##################################

/**
 * onClickOuterLink
 * 
 */
function onClickOuterLink(url) {
	var place;
	
	var company = new RegExp('/company/', 'i');
	var service = new RegExp('/service/', 'i');
	var ir = new RegExp('/ir/', 'i');
	var recruit = new RegExp('/recruit/', 'i');
	var contacts = new RegExp('/contacts/', 'i');
	
	if(url.match(company)){
		place = 0;
	}else if(url.match(service)){
		place = 1;
	}else if(url.match(ir)){
		place = 2;
	}else if(url.match(recruit)){
		place = 3;
	}else if(url.match(contacts)){
		place = 4;
	}
	
	$.cookie('navi_link', '1', {expires:1, path:'/'});
	
	enableContents = false;
	
	activeNaviMain(place);
	moveNaviMain(place);
	cahgeNaviIndicator(NAVI_INIT_Y, 0);
	
	slideOutNaviSub();
	slideOutContents(url, true);
}




// ##################################
//           * Footer Link *
// ##################################

/**
 * onClickFootLink
 * 
 */
function onClickFootLink(url) {
	
	$.cookie('navi_link', '1', {expires:1, path:'/'});
	
	enableContents = false;
	
	inactiveNaviMain();
	moveNaviMain();
	cahgeNaviIndicator(NAVI_INIT_Y, 0);
	
	slideOutNaviSub();
	slideOutContents(url, true);
}









// ##################################
//            * Contents *
// ##################################

/**
 * slideInContents
 * 
 */
function slideInContents(main) {
	
	var t = $('#boxContArea');
	var y = $('body').outerHeight(true);
	
	if (isSmartPhone) {
//		t.fadeIn(500);
		t.show();
	}
	else {
		if (main) {
			t.css('top', y * -1);
		}
		else {
			t.css('top', y);
		}
		
		t.css('display', 'block');
		t.css('opacity', '0');
		t.animate({top:'0px', opacity:'1'}, 1200, 'easeInOutQuart');
	}
	
}

/**
 * slideOutContents
 * 
 */
function slideOutContents(url, main) {
	
	var t = $('#boxContArea');
	var y = $('body').outerHeight(true);
	
	if (isSmartPhone) {
		//t.fadeOut(500, function(){ location.href = url; });
		setTimeout(function(){ location.href = url; }, 800);
	}
	else {
		if (!main) { y *= -1; }
		t.animate({top:y+'px', opacity:'0'}, 1000, 'easeInOutQuart', function(){ location.href = url; });
	}
	
}



// ##################################
//            * to top *
// ##################################

function chackToTop() {
	
	var yScroll = 0;
//	var yBody = $('body').outerHeight(true);
	
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	}
	else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	
//	$('#debug').prepend(yScroll + "<br />");
	
	if (showTop) {
		if (yScroll < 200) {
			showTop = false;
			$('a#toTop').animate({bottom:'-30px'}, 200);
		}
	}
	else {
		if (yScroll > 200) {
			showTop = true;
			$('a#toTop').animate({bottom:'60px'}, 200);
		}
	}
	
}



// ##################################
//            * utility *
// ##################################


$(document).ready(function(){
	$(".rollover").hover(
		function(){
			$(this).attr("src", $(this).attr("src").replace("_off", "_on"));
		},
		function(){
			$(this).attr("src", $(this).attr("src").replace("_on", "_off"));
		}
	);
});










