/* ------------------------------------------------------------
 * Name      : /common/js/jquery_common.js
 * Desc       : PentaBreed jQuery
 * Created   : 2010-07-14 PentaBreed by Myungwol
 ------------------------------------------------------------ */

/* png_ pngFix È£Ãâ Ã³¸® */
// ÀÌ¸§ÀÇ ±ÔÄ¢À¸·Î ¸¸µç rollover  _on.gif
$(document).ready(function(){
	$(".rollover").hover(
		function() {
			if ($(this).attr("src").substring($(this).attr("src").length-6,$(this).attr("src").length)=="on.gif"){
				$(this).addClass ("over");
			}else{
				var currentImg = $(this).attr("src").replace(".gif", "on.gif");
				$(this).attr("src", currentImg);
			}
		}, function() {
			if($(this).hasClass("over")!=true){
				var currentImg = $(this).attr("src").replace("on.gif", ".gif");
				$(this).attr("src", currentImg);
			}
	});
});

/* navigation */
$(document).ready(function() {
	$("#topArea .navigation >li").hover(function(){
			$(this).contents("ul").show();
			$(this).contents("ul").css("z-index", "10");
			$(this).addClass("on");
		},
		function(){
			$(this).contents("ul").hide();
			$(this).contents("ul").css("z-index", "");
			$(this).removeClass("on");
		}
	);

	$("#topArea .naviWrap").hover(function(){
		$(".topWrap .stock").hide();
		},
		function(){
		$(".topWrap .stock").show();
		}
	);

	$(".navigation li a").hover(
		function() {
			if ($(this).contents("img").attr("src").substring($(this).contents("img").attr("src").length-6,$(this).contents("img").attr("src").length)=="on.gif"){
				$(this).contents("img").addClass ("over");
			}else{
				var currentImg = $(this).contents("img").attr("src").replace(".gif", "on.gif");
				$(this).contents("img").attr("src", currentImg);
			}

		}, function() {
			if($(this).contents("img").hasClass("over")!=true){
				var currentImg = $(this).contents("img").attr("src").replace("on.gif", ".gif");
				$(this).contents("img").attr("src", currentImg);
			}
		}
	)

	$("#secondNav > ul > li > a").each(function(index){
		var $subDep = $("#secondNav ul li li a");

		$(this).addClass("num"+(index+1));
		$(this).hover(
			function(){$(this).parents("li").addClass("on");},
			function(){
				if($(this).contents("img").attr("src").substring($(this).contents("img").attr("src").length-6,$(this).contents("img").attr("src").length)!="on.gif"){
					$(this).parents("li").removeClass("on");
				}
			}
		);

		$subDep.hover(
			function(){$(this).addClass("on")},
			function(){
				if($(this).contents("img").attr("src").substring($(this).contents("img").attr("src").length-6,$(this).contents("img").attr("src").length)!="on.gif"){
					$(this).removeClass("on")
				}
			}
		)
	})

});

function getSecNavi(pageCode){
	$("#secondNav > ul > li ul").hide();
	$("#secondNav > ul > li ul ul").hide();//for IE6.0
	var $thisPage = $("#secondNav > ul").find("[id='"+pageCode+"']");

	if($thisPage.contents("ul").length >0 ){
		$thisPage.parent("ul").show("slow");
		$thisPage.contents("ul").show();
	}else{
		$thisPage.parent("ul").show("slow");
	}
}

$(document).ready(function() {
	var $viewTit = $(".footerIn .family > a");
	$(".footerIn .familyCNT").hide();
	$viewTit.click(
		function(){
			$(".footerIn .familyCNT").slideDown();
			$(".footerIn > .familyCNT").mouseout(function(){closeFamily();return false;})
			$(this).contents("img").attr("src","/image/common/family_on.gif");
		}
	);
	$(".footerIn .familyCNT .close a").click(function(){closeFamily();return false;});
	$(".familyCNT").hover(
		function(){
			$(".footerIn .familyCNT").slideDown();
		},function(){
			closeFamily();return false;
		}
	);

});

function closeFamily(){
	$(".footerIn .familyCNT").slideUp();
	$(".footerIn .family > a").contents("img").attr("src","/image/common/family.gif");
}

$(document).ready(function(){
	$("#topArea .language ul").hide();
	$("#topArea .language a:first-child").click(function(){
		$("#topArea .language ul").slideToggle("fast");
	});
});

/* SNS °øÀ¯ÇÏ±â */
$(document).ready(function(){
	$(".snsArea ul").hide();
	$(".snsArea a:first-child").click(function(){
		$(".snsArea ul").slideToggle("fast");
	});
});

/* ÁÖ°¡ ·Ñ¸µ_100719Ãß°¡*/
$(document).ready(function() {
	$('.roll').css({
		'display': 'block',
		'overflow': 'hidden'
	});
	$('.roll ul').append('<li></li>'); //<li> ÀÚµ¿ »ý¼º
	$('.roll ul li:last').html($('.roll ul li:first').html());

	var i = 0;
	var max = $('.roll ul li').length;  //¸®½ºÆ® ÀüÃ¼°¹¼ö
	var listH = $('.roll ul li').height(); //ÀÌµ¿°ª

	function roll() {
		if (i == max) {
			$('.roll ul').css('top', '0');
			i = 0; //ÃÊ±âÈ­
		}

		$('.roll ul').animate({top: -(i++)*listH}, 600);
		time=setTimeout(roll,1500);
	}
	roll();
});

