
/* Äü¸Þ´º ½ºÅ©·Ñ */
function scrollquick(name,bottomlimit){
	var topdis=-50;
	if(!document.getElementById(name)){
		return;
	}
	var obj = $("#"+name);
	var btmlimit=parseInt(document.documentElement.scrollHeight-obj.height()-bottomlimit);
	var menuYloc = parseInt(obj.css("top").substring(0, obj.css("top").indexOf("px")));
	$(window).scroll(function() {
		if(menuYloc<$(document).scrollTop()){

		}else{
			topdis = menuYloc;
		}
		offset = topdis+parseInt($(document).scrollTop()) + "px";
		if(parseInt(offset)>btmlimit||menuYloc>btmlimit){
			return;
		}
		obj.animate({ top: offset }, { duration: 500, queue: false });
	});
}


/* ÅÇ¸Þ´º ÀÌ¹ÌÁö Ã¼ÀÎÁö */
function tabImage(index,len){
	for(i=1; i<len+1; i++){
		if(i==index){
			$(".tabM"+i).attr("src",($(".tabM"+i).attr("src")).replace("_off.gif","_on.gif"));
		}else{
			$(".tabM"+i).attr("src",($(".tabM"+i).attr("src")).replace("_on.gif","_off.gif"));
		}
	}
}

/* ÅÇ¸Þ´º ÀÌ¹ÌÁö Ã¼ÀÎÁö2 */
function tabImage(index){
	var clickObj = $(".tabmenu img");
	clickObj.each(function(n){
		$(this).attr("src",($(this).attr("src")).replace("_on.gif","_off.gif"));
		$(this).attr("status","off");
		if(n==index){
			$(this).attr("src",($(this).attr("src")).replace("_off.gif","_on.gif"));
			$(this).attr("status","on");
		}
		$(this).click(function(){
			clickObj.each(function(n){
				$(this).attr("src",($(this).attr("src")).replace("_on.gif","_off.gif"));
				$(this).attr("status","off");
			});
			if($(this).attr("status")=="off"){
				$(this).attr("src",($(this).attr("src")).replace("_off.gif","_on.gif"));
				$(this).attr("status","on");
			}
		});
	});
}

/* ÅÇ¸Þ´º */
function tabChange(index,name,total){
	for(i=1; i<total+1; i++){
		if(i==index){
			$(".tabM"+i).attr("src",($(".tabM"+i).attr("src")).replace("_off.gif","_on.gif"));
			$(name+i).show();
		}else{
			$(name+i).hide();
			$(".tabM"+i).attr("src",($(".tabM"+i).attr("src")).replace("_on.gif","_off.gif"));
		}
	}
}


/* Biz ¼Ö·ç¼Ç ¼­ºê¸ÞÀÎ ¸Þ´ºÆ®¸® */
function menuTreeEvent(){
	var clickObj = $("#lnb li ul a");
	var clickObj2 = $("#lnb li > a");

	$("#lnb li ul").each(function(){
		$(this).find("li:last").addClass("end");
	});

	clickObj.each(function(n){
		$(this).removeClass("on");
		$(this).attr("status","off");
		if(n==0){
			$(this).addClass("on");
			$(this).attr("status","on");
		}
		$(this).click(function(){
			clickObj.each(function(n){
				$(this).removeClass("on");
				$(this).attr("status","off");
			});
			if($(this).attr("status")=="off"){
				$(this).addClass("on");
				$(this).attr("status","on");
			}
		});
	})

	clickObj2.click(function(){
		if($(this).next("ul").css("display")!="none"){
			$(this).next("ul").css("display","none");
			$(this).removeClass("hover");
		}else{
			$(this).next("ul").css("display","block");
			$(this).removeClass("hover");
			$(this).addClass("hover");
		}
	});

	$("#lnb li:eq(0) > a").click();
}


/* ·¹ÀÌ¾îº¸ÀÌ°í´Ý±â */
function layerShow(target){
	if($(target).css("display") != "block"){
		$(target).show();
	}else{
		$(target).hide();
	}
}


/* ÀüÃ¼¸Þ´ºº¸±â */
function allMenuShow(){
	var target = $(".allMenuLayer");
	var obj = $("a.allmenu_view");

	if(target.css("display") != "block"){
		target.show();
		obj.addClass("on");
	}else{
		target.hide();
		obj.removeClass("on");
	}
}

/* ºê¶ó¿ìÀú Ã¼Å© */
function browser_chk()
{
	appname = navigator.appName;
	useragent = navigator.userAgent;
	 if(appname == "Microsoft Internet Explorer") appname = "IE";
	 IE55 = (useragent.indexOf('MSIE 5.5')>0);  //5.5 ¹öÀü
	 IE6 = (useragent.indexOf('MSIE 6')>0);     //6.0 ¹öÀü
	 IE7 = (useragent.indexOf('MSIE 7')>0);     //7.0 ¹öÀü
}

/* ÆË¾÷Ã¢(»õÃ¢) °¡¿îµ¥·Î ¶ç¿ì±â(°øÅë) */
function openWinCenter(url,winName,Width,Hight) {
	var useragent = navigator.userAgent;
	var winObject = null;
	var w= Width; //wid
	if(useragent.indexOf('Safari') != -1){
		h = Hight - 60;
	}else{
		h= Hight;
	}
	winToTop = (screen.height) ? (screen.height-h)/2 : 0;
	winToLeft = (screen.width) ? (screen.width-w)/2 : 0;
	var settings ='toolbar=0,directories=0,status=no,menubar=0,scrollbars=yes,resizable=no,height='+h+',width='+w+',left='+winToLeft+',top='+winToTop+',location=no';
	winObject = window.open(url, winName, settings);
}

/* µ¿¿µ»ó»óÇ°¼³¸í ÆË¾÷ */
function openPopupPost(url, frm, solution_id, solution_nm) {
	var useragent = navigator.userAgent;
	var winObject = null;
	var Width =730;
	var Hight =600;
	var w= Width; //wid

	//¾ÆÀÌÆù,¾ÆÀÌÆÐµå¿¡¼­ ¾ó·µ°øÁö
	if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPad') != -1) {
		alert("ÁË¼ÛÇÕ´Ï´Ù. ÇØ´ç ºê¶ó¿ìÀú¿¡¼­ Áö¿øÇÏÁö ¾Ê´Â ¼­ºñ½ºÀÔ´Ï´Ù.\n´Ù¸¥ ºê¶ó¿ìÀú¸¦ ÀÌ¿ëÇÏ¿© ÁÖ¼¼¿ä.");
		return;
	}else{
		if(useragent.indexOf('Safari') != -1){
			h = Hight - 60;
		}else{
			h= Hight;
		}
		winToTop = (screen.height) ? (screen.height-h)/2 : 0;
		winToLeft = (screen.width) ? (screen.width-w)/2 : 0;
		var settings ='toolbar=0,directories=0,status=no,menubar=0,scrollbars=yes,resizable=no,height='+h+',width='+w+',left='+winToLeft+',top='+winToTop+'';

		if (frm.solution_id != null) {
			frm.solution_id.value = solution_id;
			frm.solution_nm.value = solution_nm;
		} else {
			frm.board_seqx.value = solution_id;
			frm.title.value = solution_nm;
		}

		window.open('', 'popup_post',settings);

		frm.target = 'popup_post';
		frm.action = url;

		frm.submit();
	}
}


/* ¼­ºê¿¡¼­ ¼Ö·ç¼Ç»óÇ°ÀüÃ¼º¸±â ·¹ÀÌ¾î ¶ç¿ì±â */
function SubPrAllOpen(){
	if($('.SubPrAllArea').css("display") != "block"){
		$('.SubPrAllArea').show();
	}else{
		$('.SubPrAllArea').hide();
	}
}



/* ¼­ºê¿¡¼­ ½º¸¶Æ®°Ë»ö ·¹ÀÌ¾î ¶ç¿ì±â */
function subSmrtShow(){
	if($(".SubSearchResultArea").css("display") != "block"){
		$(".SubSearchResultArea").show();
		$(".categoryWrap .categoryMore").click();
		$(".categoryWrap .categoryMore").attr("status","sub");
		$(".smrtResultWrap .resultLayerClose").attr("status","sub");
		$(".indexSmrtSearch .all_view_btn").hide();
	}
}

/* ½º¸¶Æ®°Ë»ö ·¹ÀÌ¾î */
function categoryMore(){
	var clickObj = $(".categoryWrap .categoryMore");//Ä«Å×°í¸®(¾÷¹«À¯Çü) º¸ÀÌ±â ¹öÆ°
	var checkObj = $(".categoryWrap .category03");//Ä«Å×°í¸®(¾÷¹«À¯Çü) Ã¼Å©
	var clickObj2 = $(".smrtResultWrap .resultLayerClose");//°Ë»ö°á°ú ´Ý±â ¹öÆ°

	clickObj.click(function(){
		if(checkObj.css("display") != "block"){
			checkObj.show();
			clickObj.addClass("closeBtn");
		}else{
			checkObj.hide();
			clickObj.removeClass("closeBtn");
		}

		if($(this).attr("status") == "sub"){
			$(".SubSearchResultArea").hide();
			$(this).attr("status","");
		}
	});

	clickObj2.click(function(){
		$(this).hide();
		$(".smrtResultFrame").hide();
		if($(this).attr("status") == "sub"){
			$(".categoryMore").show();
			clickObj.click();
		}
	});
}

/* ½º¸¶Æ®°Ë»ö Ä«Å×°í¸® Å¬¸¯½Ã °á°ú Ç¥½Ã */
function smrtCategoryClick(){
	var clickObj = $(".indexSmrtSearch .categoryWrap input[type=checkbox]");
	var clickObj2 = $(".smrtResultWrap .resultLayerClose");//°Ë»ö°á°ú ´Ý±â ¹öÆ°

	clickObj.click(function(){
		$(".categoryWrap .category03").show();
		$(".categoryWrap .categoryMore").addClass("closeBtn");
		$(".indexSmrtSearch .smrtResultFrame").show();
		clickObj2.show();
	});
}


/* ajax ÄÁÅÙÃ÷ ·Îµù */
function contentLoading(url, target) {
	$.ajax({
		type: "POST",
		url: url,
		async: false,
		cache: false,
		dataType: "html",
		error: function(XMLHttpRequest, textStatus, errorThrown) {
		},
		success: function(data){
			if(!(target==undefined || target==null || target=="")){ $(target).html("").append(data.toString()); }
		}
	});
};


/* ºñÁî¼Ö·ç¼Ç - ¼º°øµµÀÔ»ç·Ê ÅÇ // ¼Ö·ç¼Ç»ó´ã¼¾ÅÍ - ´ëÇ¥ºê·£µå¼Ò°³ ÅÇ °øÅë */
function bizSolTab03(){
	var clickObj = $(".tabList a");
	clickObj.each(function(n){
		$(this).removeClass("on");
		$(this).attr("status","off");
		if(n==0){
			$(this).addClass("on");
			$(this).attr("status","on");
		}
		$(this).click(function(){
			clickObj.each(function(n){
				$(this).removeClass("on");
				$(this).attr("status","off");
			});
			if($(this).attr("status")=="off"){
				$(this).addClass("on");
				$(this).attr("status","on");
			}
		});
	})
}


/* iframe ¸®»çÀÌÁî ÇÔ¼ö */
function init(conId,frameId){
	var doc = document.getElementById(conId);
	if(doc.offsetHeight == 0){

	}else{
		pageheight = doc.offsetHeight;
		parent.document.getElementById(frameId).height = pageheight+"px";
	}
}

function init2(conId,frameId){
	var doc = parent.document.getElementById(conId);
	if(doc.offsetHeight == 0){

	}else{
		pageheight = doc.offsetHeight;
		parent.parent.document.getElementById(frameId).height = pageheight+"px";
	}
}


/* ¸ÞÀÎ °øÁö»çÇ× ·Ñ¸µ */
function mainNoticeClick(index){
	var clickObj = $(".indexNewsNotice .nextBtn");
	var target = $(".indexNewsNotice .listWrap");
	var targetLen = target.length;

	target.each(function(n){
		$(this).hide();
		if(n==index){
			$(this).show();
		}
	});

	clickObj.click(function(){
		target.each(function(n){
			$(this).hide();
		});
		if(index < (targetLen-1)){
			$(".indexNewsNotice .listWrap:eq("+(index+1)+")").show();
			index++;
		}else{
			index = 0;
			$(".indexNewsNotice .listWrap:eq("+index+")").show();
		}
	});
}


/* ¸ÞÀÎ HOT NEWS ÀÌ¹ÌÁö */
function bannerChange(index){
	var left = $(".productInfoWrap .prod04 .prevnext_btn a:eq(0)");
	var right = $(".productInfoWrap .prod04 .prevnext_btn a:eq(1)");
	var targetImg = $(".productInfoWrap .prod04 .imgArea");
	var imgLen = targetImg.length;

	targetImg.each(function(n){
		$(this).hide();
		if(n==index){
			$(this).show();
		}
	});

	left.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index > 0){
			$(".productInfoWrap .prod04 .imgArea:eq("+(index-1)+")").show();
			index--;
		}else{
			index = imgLen-1;
			$(".productInfoWrap .prod04 .imgArea:eq("+index+")").show();
		}
	});

	right.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index < (imgLen-1)){
			$(".productInfoWrap .prod04 .imgArea:eq("+(index+1)+")").show();
			index++;
		}else{
			index = 0;
			$(".productInfoWrap .prod04 .imgArea:eq("+index+")").show();
		}
	});
}

/* ºñÁî¼Ö·ç¼Ç ¼­ºê¸ÞÀÎ HOT NEWS ÀÌ¹ÌÁö */
function bannerChange2(index){
	var left = $(".hotnews .prevnext_btn a:eq(0)");
	var right = $(".hotnews .prevnext_btn a:eq(1)");
	var targetImg = $(".hotnews .imgArea");
	var imgLen = targetImg.length;

	targetImg.each(function(n){
		$(this).hide();
		if(n==index){
			$(this).show();
		}
	});

	left.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index > 0){
			$(".hotnews .imgArea:eq("+(index-1)+")").show();
			index--;
		}else{
			index = imgLen-1;
			$(".hotnews .imgArea:eq("+index+")").show();
		}
	});

	right.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index < (imgLen-1)){
			$(".hotnews .imgArea:eq("+(index+1)+")").show();
			index++;
		}else{
			index = 0;
			$(".hotnews .imgArea:eq("+index+")").show();
		}
	});
}

/* Äü¸Þ´º ÀÌ¹ÌÁö */
function quickImgChange(index){
	var left = $("#quick .btn_prev");
	var right = $("#quick .btn_next");
	var targetImg = $("#quick .imgArea");
	var imgLen = targetImg.length;

	if(targetImg.find("img").length !=0 ){
		$("#quick .today_sol").show();
	}

	targetImg.each(function(n){
		$(this).hide();
		if(n==index){
			$(this).show();
		}
	});

	left.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index > 0){
			$("#quick .imgArea:eq("+(index-1)+")").show();
			index--;
		}else{
			index = imgLen-1;
			$("#quick .imgArea:eq("+index+")").show();
		}
	});

	right.click(function(){
		targetImg.each(function(n){
			$(this).hide();
		});
		if(index < (imgLen-1)){
			$("#quick .imgArea:eq("+(index+1)+")").show();
			index++;
		}else{
			index = 0;
			$("#quick .imgArea:eq("+index+")").show();
		}
	});
}

/* ÆÐ¹Ð¸®»çÀÌÆ® */
function slideFamilySite(){
	var clickObj = $(".family .familyBtn");
	var target = $(".family .familySiteList");
	if(target.css("display") != "block"){
		target.slideDown("fast");
	}else{
		target.slideUp("fast");
	}
}


$(document).ready(function(){
	categoryMore();//½º¸¶Æ®°Ë»ö ·¹ÀÌ¾î Á¦¾î(ÀüÃ¼°øÅëÀ¸·Î Àû¿ë)
	smrtCategoryClick();//½º¸¶Æ®°Ë»ö Ä«Å×°í¸® Å¬¸¯ÀÌº¥Æ®
	quickImgChange(0);//Äü¸Þ´º ÀÌ¹ÌÁö ·Ñ¸µ
});

