/* DAPA jQuery by EZ1
 * Created : 2008. 12. 3.
 */
$(function(){
	/* ¸ÞÀÎ ³»ºñ°ÔÀÌ¼Ç */
	$("#mainNavi  > ul >  li").bind("mouseover keyup",function(e){
			$(this).siblings().find(".over").removeClass("over").end().find(".subMenu").hide();
			$(this).children("a").addClass("over").end().find(".subMenu").show();
	});

	/* ¸ÞÀÎ ´º½º */
	$("#main_news  > ul >  li").bind("click keyup",function(e){
			$(this).siblings().find(".over").removeClass("over").end().find(".newsContents").hide();
			$(this).siblings().find(".over").removeClass("over").end().find(".more").hide();
			$(this).children("a").addClass("over").end().find(".newsContents").show();
			$(this).children("a").addClass("over").end().find(".more").show();
	});

	/* ÆË¾÷Á¸ */
	var popupZoneLen =  $("#popupzone ul li").length;
	var popupTimer;
	var thisOrder =0;
	var mar;

	$("#popupzone ul").css("width", (popupZoneLen*245)+"px");

	popupScrollAuto();
	
	$("#popupzone dl dd a").bind("mouseover keyup", function(){
			clearTimeout(popupTimer);
			thisOrder = $("#popupzone dl dd a").index(this);
			popupScroll(thisOrder);
			}).bind("mouseout blur", popupScrollAuto);
	$("#popupzone ul li a").focus(function(e){
		clearTimeout(popupTimer);
				thisOrder = $("#popupzone ul li a").index(this);
		$(this).parent().parent().css("marginLeft",-(thisOrder*245)+"px");
					$("#popupzone dl dd a").removeClass("on");
					$("#popupzone dl dd a").eq(thisOrder).addClass("on");
	});
		/* ÄÁÆ®·Ñ·¯ */
		$("#popupzone .control a.stop").bind("click", function(){
				clearTimeout(popupTimer);
		});
		$("#popupzone .control a.play").bind("click", function(){
				popupScrollAuto();
		});

		$("#popupzone ul li").hover(function(){
			clearTimeout(popupTimer); 
			},
				function(){
					thisOrder=$("#popupzone ul li").index(this);
					popupScrollAuto();
			});
	function popupScroll(o) {
				$("#popupZoneWrap").css("overflow", "hidden");
				$("#popupzone dl dd a").removeClass("on");
				$("#popupzone dl dd a").eq(o).addClass("on");
				mar = (o*245);
				$("#popupzone ul").stop().animate({marginLeft: -(mar) +"px"},500,"easeOutQuad");
	}
	
	function popupScrollAuto(){
		$("#popupZoneWrap").css("overflow", "hidden");
		if (thisOrder < popupZoneLen-1) thisOrder += 1;
		else thisOrder = 0;
		popupTimer = setTimeout(function(){
												popupScroll(thisOrder); popupScrollAuto();
		}, 5000);
	}

	/* ºí·Î±× Ã¢ */
	$("#koreaBlog").dialog({autoOpen:false, width:502, height:226, resizable:false, title:"¹æÀ§»ç¾÷Ã» ºí·Î±×" });

	$(".blogToggle").click(function(e){
		e.preventDefault();
		if ($("#koreaBlog").dialog("isOpen")) {
			$("#koreaBlog").dialog("close"); return false;
		} else { $("#koreaBlog").dialog("open"); return false; }
	});

		
	// »õÃ¢¿¡¼­ ¿­¸®´Â ¸µÅ©¿¡ '»õÃ¢¿¡¼­ ¿­¸²' Å¸ÀÌÆ² ºÙÀÓ
	$("a[rel='external'], a[target='_blank']").each(function(){
		var text = $(this).text()+"(»õÃ¢¿¡¼­¿­¸²)";
		$(this).attr("title", text);
		});

	/* ½Ç°ú/Á÷¼Ó±â°ü ¿©´Ý±â */
	$(".customer1 h3").toggle(function(){
		$(this).toggleClass("closed").next().fadeIn(500,"easeInQuad");
		}, function(){
			$(this).toggleClass("closed").next().fadeOut(500,"easeOutQuad");
	});

	/* ½Ã±º±¸/Áß¾Ó,Áö¹æ ¿©´Ý±â */
	$(".customer2 h3").toggle(function(){
		$(this).toggleClass("closed").next().fadeIn(500,"easeInQuad");
		}, function(){
			$(this).toggleClass("closed").next().fadeOut(500,"easeOutQuad");
	});

	/* ÁÖ¹Î/ÁÖ¹ÎÀÚÄ¡¼¾ÅÍ ¿©´Ý±â */
	$(".customer3 h3").toggle(function(){
		$(this).toggleClass("closed").next().fadeIn(500,"easeInQuad");
		}, function(){
			$(this).toggleClass("closed").next().fadeOut(500,"easeOutQuad");
	});

	/* °ü³» À¯°ü±â°ü ¿©´Ý±â */
	$(".customer4 h3").toggle(function(){
		$(this).toggleClass("closed").next().fadeIn(500,"easeInQuad");
		}, function(){
			$(this).toggleClass("closed").next().fadeOut(500,"easeOutQuad");
	});

	/* ÆÐ¹Ð¸®»çÀÌÆ® ¿©´Ý±â */
	$(".customer5 h3").toggle(function(){
		$(this).toggleClass("closed").next().fadeIn(500,"easeInQuad");
		}, function(){
			$(this).toggleClass("closed").next().fadeOut(500,"easeOutQuad");
	});

	/* °ü·Ã »çÀÌÆ® ¼¿·ºÆ® ¹Ú½º Á¦¾î */
	$(".relatedSite li input").click(function(){
		var selectedVal = $(this).prev().val();
		if (selectedVal == "" || selectedVal =="#")
		{ return false;}
		else if (this.id) { window.open(selectedVal); return false; }
		else { location.href=selectedVal; }
	});

	// file Çü½Ä¿¡ µû¶ó Å¬·¡½º ÁöÁ¤
	
	$("a[href$=pdf]").each(function(){
		var text = $(this).text()+"pdfÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)";
		$(this).attr("title", text);
		});
	//$("a[href$=pdf]").addClass("pdfFile somefiles").attr("title", "pdfÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");
	//$("a[href*=hwp]").addClass("hwpFile somefiles").attr("title", "hwpÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");
	//$("a[onclick*=hwp]").addClass("hwpFile somefiles").attr("title", "hwpÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");
	//$("a[href*=xls]").addClass("xlsFile somefiles").attr("title", "xlsÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");
	//$("a[href*=ppt]").addClass("pptFile somefiles").attr("title", "pptÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");
	//$("a[href*=doc]").addClass("wordFile somefiles").attr("title", "docÆÄÀÏ(»õÃ¢¿¡¼­¿­¸²)");

}); // end of jQuery
