
//check browser
var isie=(/msie/i).test(navigator.userAgent); //ie
var isie6=(/msie 6/i).test(navigator.userAgent); //ie 6
var isie7=(/msie 7/i).test(navigator.userAgent); //ie 7
var isie8=(/msie 8/i).test(navigator.userAgent); //ie 8
var isie9=(/msie 9/i).test(navigator.userAgent); //ie 9
var isfirefox=(/firefox/i).test(navigator.userAgent); //firefox
var isapple=(/applewebkit/i).test(navigator.userAgent); //safari,chrome
var isopera=(/opera/i).test(navigator.userAgent); //opera
var isios=(/(ipod|iphone|ipad)/i).test(navigator.userAgent);//ios
var isipad=(/(ipad)/i).test(navigator.userAgent);//ipad
var isandroid=(/android/i).test(navigator.userAgent);//android
if(isie7 || isie8 || isie9) isie6=false;
if(isie9) isie=false;


// png setting
function setPng24(obj) {
	 obj.width=obj.height="1";
	 obj.className=obj.className.replace(/\bpng24\b/i,"");
	 obj.style.filter= "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	 obj.src=""; 
	 return "";
}

// RollOver
function imageOver(imgs) {
	imgs.src = imgs.src.replace("off.gif", "on.gif");
}
function imageOut(imgs) {
	imgs.src = imgs.src.replace("on.gif", "off.gif");
//  onmouseover="imageOver(this);" onmouseout="imageOut(this);"
}
// IE6 background fix
try{
	document.execCommand('BackgroundImageCache',false,true);
}
catch(e){}

// popup
function popupOpen(url,w,h,type){
	window.open(url ,  "openWin", "width="+w+",height="+h+",top=30,left=100,resizable=no,scrollbars="+type) ;
}


//max-width, max-height
function maxSize(obj,w,h){
    if(obj.readyState != "complete") return "auto";
    real_w=obj.offsetWidth;
    real_h=obj.offsetHeight;
    virt_w=obj.offsetWidth;
    virt_h=obj.offsetHeight;
    if(w>0 && virt_w>w){
        virt_w = w;
        virt_h = real_h * (virt_w/real_w);
    }
    if(h>0 && virt_h>h){
        virt_h = h;
        virt_w = real_w * (virt_h/real_h);
    }

    obj.style.width="0";
    obj.style.height="0";
    obj.style.width=virt_w+"px";
    obj.style.height=virt_h+"px";
}

//min-height
function min_height(obj,h){
    if(obj.readyState != "complete") return "auto";
    if(obj.offsetHeight<h){
        obj.style.height="0";
        obj.style.height=h+"px";
    }
}


// flash Laod
function flashX(src, w, h, swfid) {
	swf_html = '';
	swf_html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + w + '" height="' + h + '" id="' + swfid + '">';
	swf_html += '<param name="allowScriptAccess" value="sameDomain">';
	swf_html += '<param name="movie" value="' + src + '">';
	swf_html += '<param name="quality" value="high">';
	swf_html += '<param name="bgcolor" value="#FFFFFF">';
	swf_html += '<PARAM NAME="wmode" VALUE="transparent">';
	swf_html += '<PARAM NAME="base" VALUE=".">';
	swf_html += '<embed base="." src="' + src + '" quality="high" bgcolor="#FFFFFF" width="' + w + '" height="' + h + '" name="' + swfid + '" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	swf_html += '</object>';
	document.write(swf_html);
}

/* 로고롤링 */
function goPageaa(_url, _seq, _target){
		var url = _url;
		var seq = _seq>0?'?seq='+_seq:'';
		var target = _target;

		window.open(url+seq, target);
	}
	function goPage(_url, _seq, _target){
		var url = _url;
		var seq = _seq>0?'?seq='+_seq:'';
		var target = '_blank';
		var option = "";

		if(_target=='move'){
			target = '_self';
		}else if(_target=='ebook'){
			option = 'top=0,left=0,width='+(screen.availWidth-10)+',height='+(screen.availHeight-48)+',fullscreen=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrolling=0';
			target = "fullscreen";
		}else if(_target == "_self"){
			target = "_self";
		}else{
			target = '_blank';
		}
		
		var _screen = window.open(url+seq, target, option );
		_screen.focus();
	}
	function buttonClick(element,index){
		$(element).cycle(index);
	}
	function buttonmouseover(element,index){
		$(element).cycle(index);
	}
	function stopImageH(command){
		$("#h_img").cycle(command);
	}

/* 탭 클릭시 보이기 숨기기 */
function showHideElem1(_objId, _param_split){
	var showObj = document.getElementById(_objId);
	if(!showObj) return false;
	//나타낼 객체가 있고 숨길 객체가 다수인경우
	if(_param_split){
		//숨길 객체들 문자열(언더바를 구분자로 파라메터를 받는다)
		var hideObjId_arr = _param_split.split("_");
		//숨길 객체 배열
		var hideObj_arr = Array();
		for(i=0; i<hideObjId_arr.length; i++){
			hideObj_arr[i] = document.getElementById(hideObjId_arr[i]);
		}
		//숨길 객체 숨기기
		for(i=0; i<hideObj_arr.length; i++){
			if(hideObj_arr[i].style){
				hideObj_arr[i].style.display = "none";
			}else{
				return false;
			}
		}
		//나타낼 객체 나타내기
		showObj.style.display = "block";
	}
	//나타내거나 숨길 객체가 한개인 경우 
	else{
		if(showObj.style.display == "block"){
			showObj.style.display = "none";
		}else{
			showObj.style.display = "block";
		}
	}
}
function showHideElem2(_objId, _param_split){
	var showObj = document.getElementById(_objId);
	if(!showObj) return false;
	//나타낼 객체가 있고 숨길 객체가 다수인경우
	if(_param_split){
		//숨길 객체들 문자열(언더바를 구분자로 파라메터를 받는다)
		var hideObjId_arr = _param_split.split("_");
		//숨길 객체 배열
		var hideObj_arr = Array();
		for(i=0; i<hideObjId_arr.length; i++){
			hideObj_arr[i] = document.getElementById(hideObjId_arr[i]);
		}
		//숨길 객체 숨기기
		for(i=0; i<hideObj_arr.length; i++){
			if(hideObj_arr[i].style){
				hideObj_arr[i].style.visibility = "hidden";
			}else{
				return false;
			}
		}
		//나타낼 객체 나타내기
		showObj.style.visibility = "visible";
	}
	//나타내거나 숨길 객체가 한개인 경우 
	else{
		if(showObj.style.visibility == "visible"){
			showObj.style.visibility = "hidden";
		}else{
			showObj.style.visibility = "visible";
		}
	}
}
// jQuery Load
(function($){
	$(document).ready(function(){
		// leyout dom setting for ie6
		if(isie6){$('#contents, #leftmenu').css('height','350px');}
		
		/* 로고롤링 */
		if($("#h_img").length > 0){
			$("#h_img").cycle({
				fx:"fade",
				timeout: 5000
			});
		};
		/* select */
		$('.tabMenu1 ol li:first-child').css('background','none');
		$('.tbDataType2 tr:first-child th').css('border-top','none');
		$('.tbDataType2 tr:first-child td').css('border-top','none');
		$('#applyArea div:last').css('margin-right','0');
		$('.tbDataType3 tr:first-child td').css('padding-top','10px');
		$('.tbDataType3 tr:last-child td').css('padding-bottom','10px');
		$('.defineType1 li:first').css('background','none');
		$('.main_menuList li:last').css('margin-right','0');
		$('.favoriteBox ul li:last').css('margin-right','0');
		$('.itemBox:first').css('border-top','none');
		$('.category li:first').css('border-left','none');
		$('.advieLink li:odd').css('margin-right','0');
		$('.sbjBox li:first-child').css({background: '0', paddingLeft: '0'});

		/* sub gnb */
		if($('#mainNavigation > ul > li.on').length > 0){
			var onli = $('#mainNavigation > ul > li.on > a > img').attr('src');
			$('#mainNavigation > ul > li.on > a > img').attr('src',onli.replace('off.gif','on.gif'));
		}
		$('#mainNavigation ul li:not(.on) img').mouseover(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('off.gif','on.gif'));
		});
		$('#mainNavigation ul li:not(.on) img').mouseout(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('on.gif','off.gif'));
		});
		$('#mainNavigation ul li').mouseover(function(){
			$('#mainNavigation ul li ul').css('display','none');
			$(this).find('ul').css('display','block');
		});
		$('#mainNavigation').mouseleave(function(){
			$('#mainNavigation ul li ul').css('display','none');
			$('#mainNavigation ul li.on ul').css('display','block');
			
		});



		/* main rollover */
		$('.main_menuList li img').mouseover(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('off.gif','on.gif'));
		});
		$('.main_menuList li img').mouseleave(function(){
			var filename = $(this).attr('src');
			$(this).attr('src',filename.replace('on.gif','off.gif'));
		});

		/* main highlight */
		var itemWidth = 996;
		var itemLength = $('#mainSlider > ul > li').length;
		var ulWidth = itemWidth * itemLength;
		$('#mainSlider > ul').css('width', ulWidth);

		$('#next').click(function(){
			if($('#mainSlider > ul').is(':not(:animated)')){
				var marginLeft = $('#mainSlider > ul').css('marginLeft');
				
				if (-ulWidth + itemWidth < parseInt(marginLeft)) {
					$('#prev').attr('src', '/images/main/btn_hightlight1_off.gif');
					$('#next').attr('src', '/images/main/btn_hightlight2_on.gif');
					$('.loading').show();
					
					$('#mainSlider > ul').animate({
						marginLeft: parseInt(marginLeft) - itemWidth
					}, 700, function(){
						$('#mainSlider').css('height', 'auto');
						$('.loading').hide();
					});
				}
			}
		});

		$('#prev').click(function(){
			if($('#mainSlider > ul').is(':not(:animated)')){
				var marginLeft = $('#mainSlider > ul').css('marginLeft');

				if (0 > parseInt(marginLeft)) {
					$('#prev').attr('src','/images/main/btn_hightlight1_on.gif');
					$('#next').attr('src','/images/main/btn_hightlight2_off.gif');
					$('#mainSlider').css('height', '390');
					$('.loading').show();

					$('#mainSlider > ul').animate({
						marginLeft: parseInt(marginLeft) + itemWidth
					}, 700, function(){
						$('.loading').hide();
					});
					
				}
			}
		});
		

		/* mypage lnb */
		$('#myAside .mainLnb li a').bind({
			mouseover: function(){
				$(this).css({color:'#fff'});
				$(this).parents('li').addClass('on');
			},
			mouseleave: function(){
				$(this).css({color:'#e2e3e8'});
				$(this).parents('li').removeClass('on');
			}
		});
		
		/*$('#myAside .subLnb').bind({
			mouseover: function(){
				$('#myAside .subLnb dt.on').show();
			},
			mouseleave: function(){
				$('#myAside .subLnb dd').hide();
				$('#myAside .subLnb dd.on').show();
				$('#myAside .subLnb dt').css({background:'#8d8eac'});
				$('#myAside .subLnb dt.on').css({background:'#565780'});
			}
		});
		$('#myAside .subLnb dt').bind({
			mouseover: function(){
				$(this).siblings('dd').hide();
				$(this).css({background:'#565780'});
				$(this).next('dd').show();
			},
			mouseleave: function(){
				$(this).css({background:'#8d8eac'});
			}
		});
		$('#myAside .subLnb dt.on').bind({
			mouseover: function(){
				$(this).css({background:'#565780'});
			},
			mouseleave: function(){
				$(this).css({background:'#565780'});
				$('#myAside .subLnb dd').hide();
				$('#myAside .subLnb dd.on').show();
			}
		});*/


		/* 마이페이지 탭 */
		$('#tabs').each(function(){
			$('#tabs .tab_list2 li').click(function(){
				$(this).addClass('on');
				$(this).siblings().removeClass('on');
				$('.messageType').hide();
				$('.messageType').next().show();
				return false;
			});
		});


		/* 즐겨찾기 레이어 */
		$('.myFavoriteView').click(function(){
			$('#favoriteLayer').slideDown();
		});
		$('.setArea .close').click(function(){
			$('#favoriteLayer').slideUp();
		});

		/* 통합검색 임시 */
		$('.funcOff').click(function(){
			$('.kitaSearchLayer').slideUp();
		});


		/* sitemap */
		$('.fullMenu').each(function(){
			$(this).click(function(){
				$('.fullMenuLayer').slideDown('slow');
			});
			$('.fullMenuLayer').mouseout(function(){
				$(this).slideUp('fast');
			});
		});

		/* main toggle */
		$('.poplight').click(function(){
			$('#mainPopup1').fadeIn('slow');
		});
		$('.closePop').click(function(){
			$('#mainPopup1').fadeOut('slow');
		});

		//FAQ
		//$('.alwaysFaq dd:first').css('display','block');
		$('.alwaysFaq dt').click(function(){
			$(this).siblings('dd').hide();
			$('.alwaysFaq dt').removeClass('on');
			$(this).next('dd').show();
			$(this).addClass("on");
		});
		$('.alwaysFaq dt').bind( {
			mouseover: function() {
				$(this).addClass("hover");
				$(this).css('text-decoration','underline');
			},
			mouseleave: function() {
				$(this).removeClass("hover");
			}
		});

		// search
		$('#searchLnb ul li').bind( {
			mouseover: function() {
				$(this).find('a').css({color: '#404b68'});
			},
			mouseleave: function() {
				$(this).find('a').css({color: '#666666'});
			}
		});
		$('#searchLnb ul li.on').bind( {
			mouseover: function() {
				$(this).find('a').css({color: '#fff'});
			},
			mouseleave: function() {
				$(this).find('a').css({color: '#fff'});
			}
		});


		// Footer
		$('.footerUtil li').each(function(){
			$(this).click(function(){
				$(this).find('ul').slideDown('slow');
			});
			$(this).mouseleave(function(){
				$(this).find('ul').slideUp('fast');
			});
		});
	});
})(jQuery);//회원사
function infoCompany() {	window.open('http://cmember.kita.net/jsp/front/KFTraComE_Login.jsp', 'infocom', 'toolbar=no,width=800,height=500,location=no,status=no,scrollbars=yes,directories=no,menubar=no,resizable=yes');			}function NewWindowCard_new() {	New_WinCard=window.open("http://cmember.kita.net/jsp/fee/KFeeMemS.jsp", "NewWinCard", "toolbar=no,width=300,height=340,location=no,status=no,scrollbars=no,directories=no,menubar=no,resizable=yes");	New_WinCard.focus();}function go_id() { window.open('http://cmember.kita.net/jsp/front/KFNormalIdApprovalS.jsp?left_bold=general', 'id', 'top=100, left=100, scrollbars=yes, width=450, height=250, resizable=yes ');}function openPopupMemmerJ() { var oWin = window.open ( "http://cmember.kita.net/jsp/front/KFRejoinMemberChkI.jsp", "_blank",  "toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=yes,width=450,height=200,top=100,left=100" ); oWin.focus();}function openPopupKFMID() { var oWin = window.open ( "http://cmember.kita.net/jsp/front/KFMnIdAppU.jsp?idmode=idapply", "_blank",  "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=900,height=350,top=100,left=100" ); oWin.focus();}function goAlim() {	alert("이미 회원사 대표 ID 입니다.\n\n문의 사항이 있으시면 트레이드 콜센터(1566-5114)로 문의 하시기 바랍니다.")}function goAlim2() {	alert("이미 검색 권한이 있습니다. \n\n문의 사항이 있으시면 트레이드 콜센터(1566-5114)로 문의 하시기 바랍니다.")}



//사업신청목록팝업링크
function bizAppPopup() {
 var sUrl="http://cmember.kita.net/jsp/marketing/MT002040.jsp";// 운영

 //var sUrl="http://cmember.kita.net/jsp/marketing/MT002040.jsp";// 운영 
  window.open(sUrl,'bizApp','status=yes,scrollbars=yes,resizable=yes,width=640,height=320,left=50,top=50');
}

function bizAppPopupNum(pageNum) {
	
	var sUrl = "http://cmember.kita.net/jsp/marketing/MT002040.jsp";// 운영

	sUrl += "#" + pageNum;

	window.open(sUrl,'bizApp','status=yes,scrollbars=yes,resizable=yes,width=640,height=320,left=50,top=50');
}
