/**
 * 김무건 || Elkha (elkha1914@hotmail.com)
 * http://elkha.kr
 * 2010-08-27
 **/

menu_ani = "default";

(function($){

	// 애니메이션 정의
	var menu = {
		"default" : { width:"show", height:"show" },
		"slideDown" : { height:"show", opacity:"show" },
		"slideRight" : { width:"show", opacity:"show" },
		"false" : { opacity:"show" }
	};

	// 상단 레이어 포커스
	var login_input = {
		"default" : { "blur":"#333", "focus":"#222" },
		"t2" : { "blur":"#fff", "focus":"#eff5e1" },
		"t3" : { "blur":"#fff", "focus":"#eff5e1" },
		"t4" : { "blur":"#fff", "focus":"#eff5e1" },
		"t5" : { "blur":"#fff", "focus":"#eff5e1" }
	};

	// 서브메뉴 배경색
	var lnb_bg = {
		"default" : { "out":"#eee", "hover":"#ddd" },
		"t2" : { "out":"#f7f7f7", "hover":"#e9e9e9" },
		"t3" : { "out":"#fff", "hover":"#f6f6f6" },
		"t4" : { "out":"#f4f4f4", "hover":"#e6e6e6" },
		"t5" : { "out":"#f4f4f4", "hover":"#f4f4f4" }
	};
	$(document).ready(function(){

		$("#gnb").navi({
			show : menu[menu_ani], // 메뉴를 보이는 애니메이션
			hide : { opacity: "hide" }, // 메뉴를 숨기는 애니메이션
			delay : 50 // 메뉴가 사라지기까지 대기시간
		});

		// 검색창 focus/blur
		$("#header .search .inputText").focus(function(){
			$(this).parents("form").addClass("focus");
		})
		.blur(function(){
			$(this).parents("form").removeClass("focus");
		});

		// 상단 레이어 열기
		$("#header .hLayer .open").click(function(){
			if( $(this).attr("href").match("#") ) { // 본문내 URL일 경우 레이어 펼침
				$("#header .bg-out").removeClass("on");
				$(this).next(".bg-out").addClass("on");
				$("#header .bg-out:not('.on')").slideUp("fast");
				$(this).next(".bg-out").slideToggle("fast", function(){
					$("#uid, #hSearch", this).focus();
				});
				return false;
			}
		});

		// 상단레이어 닫기
		$("#header .hLayer .close").click(function(){
			$(this).parents(".bg-out").slideUp("fast");
		});

		// 로그인 메시지 여닫기
		$("#keepA").click(function(){
			if( $(this).attr("checked") == true ) {
				$("#header .hLayer .keep_caution").animate({
					"opacity":"show",
					"right":"93%"
				}, "fast");
			} else {
				$("#header .hLayer .keep_caution").animate({
					"opacity":"hide",
					"right":"100%"
				}, "fast");
			}
		});

		// 상단 레이어 포커스 애니메이션
		$("#header .hLayer .inputText").focus(function(){
			$(this).stop().animate({
				"backgroundColor":login_input[Design].focus
			}, "fast");
		})
		.blur(function(){
			$(this).stop().animate({
				"backgroundColor":login_input[Design].blur
			}, "fast");
		});

		// 위젯 하위메뉴 펼치고 닫기
		$("#column .lnb .more button").click(function(){
			$(this).parents(".li2").toggleClass("on");
			if( $(this).parents(".li2").attr("class").match("on") ) $(this).parent(".more").next("ul").show("fast");
			else $(this).parent(".more").next("ul").hide("fast");
		});

		// 위젯 메뉴 배경 애니메이션
		$("#column .lnb .sec a").hover(function(){
			if(lnb_bg[Design].out != lnb_bg[Design].hover) $(this).stop().animate({"backgroundColor":lnb_bg[Design].hover}, "fast");
		}, function(){
			if(lnb_bg[Design].out != lnb_bg[Design].hover) $(this).stop().animate({"backgroundColor":lnb_bg[Design].out}, "fast");
		});

		// 확장메뉴 펼침
		$("#column .lnb .expandY").addClass("on")
			.children(".ul3").show("fast");
	});
})(jQuery);

