/* 기본상수 잡기 */
/* 추후 설정에 맞춰 변경해주세요. */
// -----------------------------------------------------------------------------

var default_image_path = "/images/v1/";

// -----------------------------------------------------------------------------



/* 마우스 오버, 아웃시 이미지 변경 */
function imageOver(obj, folder, image_file, mouse_action)
{
	var arr_file = image_file.split(".");
	var file_name = "";

	// 마우스오버 파일명 잡기
	for (i = 0; i < arr_file.length - 1; i++)
	{
		if (file_name == "")
			file_name = arr_file[i];
		else
			file_name += "." + arr_file[i]; 
	}

	// 폴더명이 '/'로 끝나지 않을 경우 예외처리
	if (folder.substring(folder.length - 1, folder.length) != "/")
		folder += "/";

	var over_image_file = file_name + "_ov." + arr_file[arr_file.length - 1];

	if (mouse_action == "over")
		obj.src = default_image_path + folder + over_image_file;
	else if (mouse_action == "out")
		obj.src = default_image_path + folder + image_file;
}


/* div 영역 Toggle Display */
function toggleDisplay(obj_nm)
{
	var obj = document.getElementById(obj_nm);

	if (obj.style.display == "none")
		obj.style.display = "block";
	else
		obj.style.display = "none";
}


/* PNG24 이미지 제대로 보여주기 (IE 6.0 이하 버그 해결) */
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 '';
}



/* 플래시 */
function flash(width, height, path, file)
{
	 var url = String(document.location);
	 var protocol = url.split(":")[0].toLowerCase();
	 if (protocol != "https")	protocol = "http";
	
	 var flash_tag = "";
	 flash_tag =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	 flash_tag += 'id="fla_' + file + '" width="'+width+'" height="'+height+'" ';
	 flash_tag += 'codebase="'+protocol+'://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> ';
	 flash_tag += '<param name="movie" value="'+path+'/'+file+'.swf" /> ';
	 flash_tag += '<param name="quality" value="high" /> ';
	 flash_tag += '<param name="wmode" value="transparent">';
	 flash_tag += '<param name="allowScriptAccess" value="always" /> ';
	 flash_tag += '<embed src="'+path+'/'+file+'.swf" quality="high" wmode="transparent" ';
	 flash_tag += 'width="'+width+'" height="'+height+'" name="fla_'+ file +'" align="middle" ';
	 flash_tag += 'play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" ';
	 flash_tag += 'pluginspage="'+protocol+'://www.adobe.com/go/getflashplayer"> ';
	 flash_tag += '</embed>';
	 flash_tag += '</object>';
	
	 document.write(flash_tag);
}

/* 플래시 */
function flashParam(width, height, path, file, params)
{
	 var url = String(document.location);
	 var protocol = url.split(":")[0].toLowerCase();
	 if (protocol != "https")	protocol = "http";
	
	 
 	var flash_tag = "";
 	flash_tag =  '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	flash_tag += 'id="fla_' + file + '" width="'+width+'" height="'+height+'" ';
	flash_tag += 'codebase="'+protocol+'://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> ';
	flash_tag += '<param name="movie" value="'+path+'/'+file+'.swf'+params+'" /> ';
	flash_tag += '<param name="quality" value="high" /> ';
	flash_tag += '<param name="wmode" value="transparent">';
	flash_tag += '<param name="allowScriptAccess" value="always" /> ';
	flash_tag += '<embed src="'+path+'/'+file+'.swf'+params+'" quality="high" wmode="transparent" ';
	flash_tag += 'width="'+width+'" height="'+height+'" name="fla_'+ file +'" align="middle" ';
	flash_tag += 'play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" ';
	flash_tag += 'pluginspage="'+protocol+'://www.adobe.com/go/getflashplayer"> ';
	flash_tag += '</embed>';
	flash_tag += '</object>';

	document.write(flash_tag);
}


/* 매장정보 플래시 */
function loadLocation(location_no){
	var str_url = "list.jsp?SHOP_AREA=";
	switch (location_no)
	{
		case "01": shop_area = "2"; break;
		case "02": shop_area = "4"; break;
		case "03": shop_area = "1"; break;
		case "04": shop_area = "14"; break;
		case "05": shop_area = "10"; break;
		case "06": shop_area = "12"; break;
		case "07": shop_area = "11"; break;
		case "08": shop_area = "7"; break;
		case "09": shop_area = "15"; break;
		case "10": shop_area = "16"; break;
		case "11": shop_area = "3"; break;
		case "12": shop_area = "13"; break;
		case "13": shop_area = "9"; break;
		case "14": shop_area = "17"; break;
		case "15": shop_area = "8"; break;
		case "16": shop_area = "5"; break;
	}

	location.href = str_url + shop_area;
}

/* FAQ 리스트 */
function toggleFaqDisplay(obj_id)
{
	var td_nm = "title" + obj_id;
	var div_nm = "line" + obj_id;

	if (document.getElementById(td_nm).className == "title")
		document.getElementById(td_nm).className = "title_select";
	else
		document.getElementById(td_nm).className = "title";
	toggleDisplay(div_nm);
}




//이미지 크기 조절하여 img 태그 출력 ******************************************
function change_image_size2(imgFile, limit_width, limit_height)
{
	var real_width			= imgFile.width;
	var real_height			= imgFile.height;

	if (limit_width == 0)
		limit_width			= real_width;
	if (limit_height == 0)
		limit_height		= real_height;

	if (real_width >= real_height)
	{
		if (real_width <= limit_width)
		{
			result_width	= real_width;
			result_height	= real_height;
		}
		else
		{
			result_width	= limit_width;
			result_height	= parseInt((real_height * limit_width) / real_width);
		}
	}
	else
	{
		if (real_height <= limit_height)
		{
			result_width	= real_width;
			result_height	= real_height;
		}
		else
		{
			result_width	= parseInt((real_width * limit_height) / real_height);
			result_height	= limit_height;
		}
	}

	imgFile.width			= result_width;
	imgFile.height			= result_height;
	imgFile.style.visibility	= "visible";
}



// MENU 플래쉬 링크 ******************************************************************
function ClickMenu(b_no, m_no, s_no)
{
	b_no = Number(b_no);
	m_no = Number(m_no);
	s_no = Number(s_no);

	var url = "";
	if (m_no == 0) m_no = 1;

	// 먼싱웨어
	if (b_no == 0)
	{
		url = "/Front/Brand/Intro/default.jsp";
	}
	else if (b_no == 1)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Brand/Intro/default.jsp"; break;
			case 2	: url = "/Front/Brand/History/history01.jsp"; break;
			case 3	: url = "/Front/Brand/Concept/concept01.jsp"; break;
			
		}
	}

	// 콜렉션
	else if (b_no == 2)
	{
		if (s_no == 0) s_no = 1;
		switch (m_no)
		{
			case 1  : url = "/Front/Collection/sport.jsp"; break;
			case 2  : url = "/Front/Collection/duex.jsp"; break;
			case 3  : url = "/Front/Collection/catalog.jsp"; break;
		}
	}

	// 레볼루션
	else if (b_no == 3)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Revolution/revolution01.jsp"; break;
			case 2	: url = "/Front/Revolution/revolution02.jsp"; break;
			case 3	: url = "/Front/Revolution/revolution03.jsp"; break;
			case 4	: url = "/Front/Revolution/revolution04.jsp"; break;
			case 5	: url = "/Front/Revolution/revolution05.jsp"; break;
		}
	}

	// MAIN 먼싱웨어 챔피온쉽
	else if (b_no == 4)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Championship/Introduce/introduce01.jsp";	break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
			case 2	: url = "/Front/Championship/Player/player01.jsp"; break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
			case 3	: url = "/Front/Championship/Media/media_plan.jsp";break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
			case 4	: url = "/Front/Championship/News/list.jsp?bbs_option_cd=CHAMPION"; break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
		}
	}

	// main 스폰서쉽
	else if (b_no == 5)
	{
		switch (m_no)
		{
//			case 1	: url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Bae/profile.jsp";	
			case 1	: url = "/Front/Sponsor/Bae/profile.jsp"; break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
//			case 2	: url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Andrew/profile.jsp";	
			case 2	: url = "/Front/Sponsor/Andrew/profile.jsp";	 break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
//			case 3	: url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Hur/profile.jsp";	
			case 3	: url = "/Front/Sponsor/Hur/profile.jsp";	 break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
//			case 4	: url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Yoon/profile.jsp";	
			case 4	: url = "/Front/Sponsor/Yoon/profile.jsp"; break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
//			case 5	: url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Chung/profile.jsp";	
			case 5	: url = "/Front/Sponsor/Chung/profile.jsp"; break; 
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
		}
	}

	// 스타
	else if (b_no == 6)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Star/default.jsp"; break;
		}
	}

	// 이벤트
	else if (b_no == 7)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Event/Event/list.jsp"; break;
			case 2	: url = "/Front/Event/Winner/list.jsp"; break;
		}
	}

	// 이벤트
	else if (b_no == 8)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Customer/Notice/list.jsp"; break;
			case 2	: url = "/Front/Customer/FAQ/list.jsp"; break;
			case 3	: url = "/Front/Customer/QNA/write.jsp"; break;
			case 4	: url = "/Front/Customer/ShopInfo/list.jsp"; break;
		}
	}

	


	if (url == "")
		alert("페이지를 준비중입니다.");
	else
		location.href = url;
}





/* 메뉴 링크 */
function LeftmenuLink(b_no, m_no, s_no)
{
	b_no = Number(b_no);
	m_no = Number(m_no);
	s_no = Number(s_no);
	var url = "";

	//if (b_no == 0) b_no = 1;
	if (m_no == 0) m_no = 1;
	if (s_no == 0) s_no = 1;
	
	// 메인페이지
	if (b_no == 0)
	{
		url = "/Front/Main/main.jsp"; 
	}
	// 브렌드 소개
	else if (b_no == 1)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Brand/Intro/default.jsp"; break;			//소개 
			case 2	: url = "/Front/Brand/History/history01.jsp"; break;		//연혁
			case 3	: url = "/Front/Brand/Concept/concept01.jsp"; break;		//컨셉
		}
	}
	//Collection
	else if(b_no == 2)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Collection/sport.jsp"; break;		//Sports 
			case 2	: url = "/Front/Collection/duex.jsp"; break;		//Duex
			//case 3	: url = "/Front/Collection/codi.jsp"; break;		//Codi
			case 3	: url = "/Front/Collection/catalog.jsp"; break;		//Catalog
		}

	}
	//Revolution
	else if(b_no == 3)
	{
		url = "/Front/Revolution/revolution01.jsp";
	}

	//siebar - championship
	else if(b_no == 4)
	{

		switch (m_no)
		{
			case 1	: url = "/Front/Championship/Introduce/introduce01.jsp";	break;
			case 2	: url = "/Front/Championship/Player/player01.jsp"; break;
			case 3	: url = "/Front/Championship/Media/media_plan.jsp";break;
			case 4	: url = "/Front/Championship/News/list.jsp?bbs_option_cd=CHAMPION"; break; 
		}

//			url = "/Front/Championship/Introduce/introduce01.jsp";
//			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//			return;
	}

	// Sponsor
	else if(b_no == 5)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Sponsor/Bae/profile.jsp";	break;
			case 2	: url = "/Front/Sponsor/Andrew/profile.jsp"; break;
			case 3	: url = "/Front/Sponsor/Hur/profile.jsp";break;
			case 4	: url = "/Front/Sponsor/Yoon/profile.jsp"; break; 
			case 5	: url = "/Front/Sponsor/Chung/profile.jsp"; break; 
		}

//		url = "/Front/Sponsor/Bae/profile.jsp";	
//		url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/default.jsp";	
//		window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
//		return;
		
	}
	//Star
	else if(b_no == 6)
	{
		url = "/Front/Star/default.jsp";
	}

	//Event
	else if(b_no == 7)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Event/Event/list.jsp"; break;	 //Event	 
			case 2	: url = "/Front/Event/Winner/list.jsp"; break;		//Winner
		}
	}

	//Sponsor ship
	else if(b_no == 9)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Event/Event/list.jsp"; break;		 
			case 2	: url = "/Front/Event/Winner/list.jsp"; break;		//Duex
		}
	}

	//-------------------------------------------------------
	// 공통 
	//------------------------------------------------------- 
	
	//고객센터 
	else if(b_no == 8)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Customer/Notice/list.jsp"; break;			//공지사항 
			case 2	: url = "/Front/Customer/FAQ/list.jsp"; break;				//FAQ
			case 3	: url = "/Front/Customer/QNA/write.jsp"; break;				//1:1문의
			case 4	: url = "/Front/Customer/ShopInfo/list.jsp"; break;			//매장 정보 
			
		}

	}
	
	//로그인 / Join
	else if(b_no == 12)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/User/login.jsp"; break;			//로그인  
			case 2	: url = "/Front/User/idSearch.jsp"; break;		//아이디 찾기 
			case 3	: url = "/Front/User/pwSearch.jsp"; break;		//비번 찾기
			case 4	: url = "/Front/Join/join.jsp"; break;			//회원가입 
			
		}
	}
	
	//MyPage
	else if(b_no == 13)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Mypage/Info/modify.jsp"; break;					//회원정보수정  
			case 2	: url = "/Front/Mypage/MyQNA/list.jsp"; break;					//1:1문의 현황 
			case 3	: url = "/Front/Mypage/MyEvent/list.jsp"; break;				//이벤트참여현황
		}
	}

	//ETC
	else if(b_no == 14)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Etc/PersonPolicy/default.jsp"; break;						//개인정보 보호정책  
			case 2	: url = "/Front/Etc/Pervision/default.jsp"; break;				//이용약관
			case 3	: url = "/Front/Etc/SiteMap/default.jsp"; break;				//사이트맵 
		}
	}
	
	

	//alert("b_no : " + b_no +" / m_no : " + m_no + " / s_no : " + s_no);

	if (url == "")
	{
		//alert("b_no : " + b_no +" / m_no : " + m_no + " / s_no : " + s_no);
		alert("페이지를 준비중입니다");
	}
	else
	{
		//alert("b_no : " + b_no +" / m_no : " + m_no + " / s_no : " + s_no);
		location.href = url;
	}
}

/* Flash Xml 경로 선언 */
function getFlashXmlPath()
{
 return "/common/flash/xml/";
}


/* 메인페이지 배너 링크 */
function mainFlashBannerLink(link_no)
{
	link_no = Number(link_no);
	var url = "";
	var target = "_blank";
	
	switch (link_no)
	{
		case 1 : 
			url = "/Front/Championship/Introduce/introduce01.jsp";	
			window.open(url,"championship","status=no, resizable=no,scrollbars=no,width=960,height=720");
			return; break;
		case 2 :
			url = "http://www.descentekorea.co.kr/sponsor/Munsingwear/Yoon/profile.jsp";	
			window.open(url,"sponsorship","status=no, resizable=no,scrollbars=no,width=960,height=720");
			return; break;
		case 3 :
			url = "/Front/PCampaign/campaign01.jsp";
			target = "_self";
			break;
		case 4 :
			url = "/Front/PMunsing/introduce.jsp";
			target="_self";
			break;
	}
	
	if (url != "")
	{
		if (target == "_self")
			location.href = url;
		else
			window.open(url, target);
	}	
}

/* 글로벌사이트 링크 */
function globalLink(link_no)
{
	link_no = Number(link_no);
	var url = "";
	var target = "_blank";
	
	switch (link_no)
	{
		case 1 : url = "http://www.lecoqsportif.com"; break;
		case 2 : url = "http://www.lecoqgolf.com"; break;
		case 3 : url = "http://www.munsingwear-jp.com"; break;
		case 4 : url = "http://www.descente.co.jp"; break;
		case 5 : url = "http://www.ridedna.com"; break;
		case 6 : url = "http://www.descente.com"; break;
		case 7 : url = "http://www.descenteathletic.com"; break;
	}
	
	if (url != "")
	{
		if (target == "_self")
			location.href = url;
		else
			window.open(url, target);
	}
}




/* 풋터 링크 */
function footerLink(link_no)
{
	link_no = Number(link_no);
	var url = "";
	var target = "_blank";
	
	switch (link_no)
	{
		case 1 : url = "http://www.descentekorea.co.kr"; break;
		case 2 : url = "/Front/Customer/ShopInfo/list.jsp"; target = "_self"; break;
		case 3 : window.open("/Front/Etc/privacy.jsp", "agree", "width=450, height=355"); break;
		case 4 : window.open("/Front/Etc/agreement.jsp", "agree", "width=450, height=355"); break;
		case 5 : url = "/Front/Customer/Notice/list.jsp"; target="_self"; break;
		case 6 : url = "/Front/Etc/SiteMap/default.jsp"; target="_self";break;
	}
	 
	if (url != "")
	{
		if (target == "_self")
			location.href = url;
		else
			window.open(url, target);
	}	
}


/* 글로벌사이트 링크 */
function bottomFlashLink(link_no)
{
	link_no = Number(link_no);
	var url = "";
	var target = "_blank";
	
	switch (link_no)
	{
		case 0 : url = "http://www.lecoqsportif.com"; break;
		case 1 : url = "http://www.lecoqgolf.com"; break;
		case 2 : url = "http://www.munsingwear-jp.com"; break;
		case 3 : url = "http://www.descente.co.jp"; break;
		case 4 : url = "http://www.ridedna.com"; break;
		case 5 : url = "http://www.descente.com"; break;
		case 6 : url = "http://www.descenteathletic.com"; break;
	}
	
	if (url != "")
	{
		if (target == "_self")
			location.href = url;
		else
			window.open(url, target);
	}
}


/* 챔피온십(골프대회) 링크 */
function ChampionshipLink(b_no, m_no, s_no)
{
	b_no = Number(b_no);
	var url = "";
	var target = "_self";

	switch (b_no)
	{
		case 1 : url = "/Front/Championship/Introduce/introduce01.jsp"; break;
		case 2 : url = "/Front/Championship/Player/player01.jsp"; break;
		case 3 : url = "/Front/Championship/Media/media_plan.jsp"; break;
		case 4 : url = "/Front/Championship/News/list.jsp?bbs_option_cd=CHAMPION"; break;
	}
	
	if (url != "")
	{
		if (target == "_self")
			location.href = url;
		else
			window.open(url, target);
	}
}



//쿠키 찾기 *******************************************************************
function getCookie(name)
{
	var returnCookie		= "";
	var thisCookie			= document.cookie.split("; ") ;
	for (i = 0; i < thisCookie.length; i++)
	{
		// 쿠키가 발견될때까지 찾기
		if(thisCookie[i].split("=")[0] == name)
			returnCookie	= thisCookie[i].split("=")[1]; // 쿠키를 찾아서"=" 로 분리한후 변수로 저장
	}
	return unescape(returnCookie);
}


//쿠키 설정 *********************************************************************
function setCookie( name, value )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() +1);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

//----------------------------------------------------------------------------------
//
//외부 
//
//-----------------------------------------------------------------------------------
/***********************************************************************************************************************
* 이 function을 사용하기 위해선 form의 elements에 대해서 몇가지 특별한 마킹을 해야합니다.
*
* required="*" : 필수 여부 체크
*
* num="3.2" : 3 - 정수부 길이, 2 - 소수부 길이
*
* len="4-12" : 문자 길이 (4 - 최소 길이, 12 - 최대 길이)
*
* txtMsg : 필드에 값을 입력 안했을 경우 출력하는 메시지
*
* numMsg : 숫자 체크 시 출력하는 메시지
*
* lenMsg : 문자 길이 체크 시 출력하는 메시지
*
* 예시는 다음과 같다.
* ex: <input type="text" name="tmp_name" value="" required="*" num="3.2" len="4-12" txtMsg="임시필드를 입력해주세요." numMsg="임시필드는 정수 3자리 실수 2자리입니다." lenMsg="임시필드는 최소크기 4, 최대크기 12입니다.">
*
* 이 스크립트는 submit 시점에 전체 필드에 대한 체크를 하도록 사용하고 그 체크 순서는 객체의 순서임.
***********************************************************************************************************************/
function validateFrm(which){
  with(which){
      for(x = 0; x < length; x++){
          if(elements[x].getAttribute("required") == "*"){
              var fieldName = elements[x].name;
              if(!eval(fieldName).length){
                  if(elements[x].disabled == false && trimField(elements[x]) == ""){
                      eval(fieldName).focus();
                      alert(elements[x].getAttribute("txtMsg"));
                      return false;
                  }
                  if(elements[x].disabled == false && elements[x].getAttribute("num") != null && elements[x].num != ""){
                      var numVal = elements[x].getAttribute("num").split(".");
                      if(!numVal[1]){
                          if(checkInteger(eval(fieldName).value, numVal[0], 0) == false){
                              eval(fieldName).focus();
                              alert(elements[x].getAttribute("numMsg"));
                              return false;
                          }
                      }
                      else{
                          if(checkInteger(eval(fieldName).value, numVal[0], numVal[1]) == false){
                              eval(fieldName).focus();
                              alert(elements[x].getAttribute("numMsg"));
                              return false;
                          }
                      }
                  }
                  if(elements[x].disabled == false && elements[x].getAttribute("len") != null && elements[x].getAttribute("len") != ""){
                      var lenVal = elements[x].getAttribute("len").split("-");
                      if(!lenVal[1]){
                          if(checkLength(eval(fieldName).value, lenVal[0], lenVal[0]) == false){
                              eval(fieldName).focus();
                              alert(elements[x].getAttribute("lenMsg"));
                              return false;
                          }
                      }
                      else{
                          if(checkLength(eval(fieldName).value, lenVal[0], lenVal[1]) == false){
                              eval(fieldName).focus();
                              alert(elements[x].getAttribute("lenMsg"));
                              return false;
                          }
                      }
                  }
              }
              else{
                  if(!eval(fieldName)[0].length){
                      for(y = 0; y < eval(fieldName).length; y++){
                          if(eval(fieldName)[y].selected && trimField(eval(fieldName)[y]) == ""){
                              eval(fieldName).focus();
                              alert(eval(fieldName).getAttribute("txtMsg"));
                              return false;
                          }
                      }
                  }
                  else{
                      for(y = 0; y < eval(fieldName).length; y++){
                          if(eval(fieldName)[y].disabled == false && trimField(eval(fieldName)[y]) == ""){
                              eval(fieldName)[y].focus();
                              alert(eval(fieldName)[y].getAttribute("txtMsg"));
                              return false;
                          }
                          if(eval(fieldName)[y].disabled == false && eval(fieldName)[y].getAttribute("num") != null && eval(fieldName)[y].getAttribute("num") != ""){
                              var numVal = eval(fieldName)[y].getAttribute("num").split(".");
                              if(!numVal[1]){
                                  if(checkInteger(eval(fieldName)[y].value, numVal[0], 0) == false){
                                      eval(fieldName)[y].focus();
                                      alert(eval(fieldName)[y].getAttribute("numMsg"));
                                      return false;
                                  }
                              }
                              else{
                                  if(checkInteger(eval(fieldName)[y].value, numVal[0], numVal[1]) == false){
                                      eval(fieldName)[y].focus();
                                      alert(eval(fieldName)[y].getAttribute("numMsg"));
                                      return false;
                                  }
                              }
                          }
                          if(eval(fieldName)[y].disabled == false && eval(fieldName)[y].getAttribute("len") != null && eval(fieldName)[y].getAttribute("len") != ""){
                              var lenVal = eval(fieldName)[y].getAttribute("len").split("-");
                              if(!lenVal[1]){
                                  if(checkLength(eval(fieldName)[y].value, lenVal[0], lenVal[0]) == false){
                                      eval(fieldName)[y].focus();
                                      alert(eval(fieldName)[y].getAttribute("lenMsg"));
                                      return false;
                                  }
                              }
                              else{
                                  if(checkLength(eval(fieldName)[y].value, lenVal[0], lenVal[1]) == false){
                                      eval(fieldName)[y].focus();
                                      alert(eval(fieldName)[y].getAttribute("lenMsg"));
                                      return false;
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }

      return true;
  }
}

/*****************************************************
* 실수 자리수를 체크하는 함수
*
* val : 체크를 하는 실수
*
* intLen : 정수부 길이
*
* realLen : 실수부 길이
****************************************************/
function checkInteger(val, intLen, realLen){
  var valNum = val.split(".");

  if(isFloat(val)== false)
      return false
  else if(!valNum[0])
      return false;
  else if(realLen == 0){
      if(valNum[0].length > intLen)
          return false;
      else if(typeof(valNum[1]) != "undefined")
          return false;
      else
          return true;
  }
  else{
      if(valNum[0].length > intLen)
          return false;
      else if(typeof(valNum[1]) != "undefined" && valNum[1].length > realLen)
          return false;
      else
          return true;
  }
}

/*****************************************************
* 실수를 체크하는 함수
*
* val : 체크를 하는 실수
****************************************************/
function isFloat(val) {
  var count = 0;
  var ch;

  for(idx = 0; idx < val.length; idx++){
      ch = val.charAt(idx);

      if(isNaN(ch)){
          if(ch == ".")
              count ++;
          else
              return false;
      }
  }

  if(count > 1)
      return false;
  else
      return true;
}

/*****************************************************
* 문자 길이를 체크하는 함수
*
* val : 체크를 하는 문자
*
* minLen : 최소 길이
*
* maxLen : 최대 길이
****************************************************/
function checkLength(val, minLen, maxLen){
  var len = byteNum(val);

  if(len < minLen)
      return false;
  else if(len > maxLen)
      return false;
  else
      return true;
}

/*****************************************************
* trimField(form.field)
*  : 문자열 앞뒤의 공백을 지움 (' ', '\r', '\n', '\t')
* examples  :
*
* form.field = ' ha한글 '일 경우....
* trimField(form.field) -> 'ha한글'
*
* return : 대체된 새로운 문자열
* date   : 2007-01-05
****************************************************/
function trimField(input) {
  if (input == "") {
      return;
  }
  var str     = input.value;
  var len     = str.length;
  var iFrom   = 0;
  var iTo     = len;

  for(var i=0 ; i < len ; i++) {
      if( str.charAt(i) == ' ' || str.charAt(i) == '\r' || str.charAt(i) == '\n' || str.charAt(i) == '\t' )
          iFrom = i+1;
      else break;
  }
  for(var i=len-1 ; i > iFrom ; i--) {
      if( str.charAt(i) == ' ' || str.charAt(i) == '\r' || str.charAt(i) == '\n' || str.charAt(i) == '\t' )
          iTo = i;
      else break;
  }
  return str.substring(iFrom, iTo);
}

/*****************************************************
* ltrim(val)
*  : 문자열 왼쪽 공백 삭제
* examples  : ltrim(' abc')
*
* val    : 요청된 문자열
* return : 대체된 새로운 문자열
* date   : 2007-01-05
****************************************************/
function ltrim(val){
  var s = new String(val);
  if (s.substr(0,1) == " ") return ltrim(s.substr(1));
  else return s;
}

/*****************************************************
* rtrim(val)
*  : 문자열 오른쪽 공백 삭제
* examples  : rtrim('abc ')
*
* val    : 요청된 문자열
* return : 대체된 새로운 문자열
* date   : 2007-01-05
****************************************************/
function rtrim(val){
  var s = new String(val);
  if(s.substr(s.length-1,1) == " ") return rtrim(s.substring(0, s.length-1));
  else return s;
}

/*****************************************************
* trim(val)
*  : 문자열 오른쪽,왼쪽 공백 삭제
* examples  : trim(' abc ')
*
* val    : 요청된 문자열
* return : 대체된 새로운 문자열
* date   : 2007-01-05
****************************************************/
function trim(val){
  return ltrim(rtrim(val));
}

/*****************************************************
* 문자의 길이를 구하는 함수
*
* val : 길이를 구하는 문자
* date   : 2007-01-05
****************************************************/
function byteNum(val){
  var byteLength = 0;

  for(inx = 0; inx < val.length; inx++){
      var oneChar = escape(val.charAt(inx));
      if(oneChar.length == 1)
          byteLength ++;
      else if(oneChar.indexOf("%u") != -1)
          byteLength += 2;
      else if(oneChar.indexOf("%") != -1)
          byteLength += oneChar.length/3;
  }

  return byteLength;
}

/*********************************************************************
* alertMsg(form.field) : 주어진 문자열로 경고창을 띄운 뒤 입력객체에 포커스 됨.
* examples  :
*
* if (isValidPhone(form.field)) {
*      alertMsg(form.field, '입력값이 전화번호 형식이네요.');
* }
*
* return : 항상 False. -> 의미 없음.
* date   : 2007-01-05
*********************************************************************/
function alertMsg( input, msg ) {
  alert( msg );
  if (!isNullObj(input)) {
	    var preStat = input.disabled;
	    input.disabled = false;
	    input.focus();
	    input.select();
	    input.disabled = preStat;
  }
  return false;
}

/*****************************************************
* isNullObj(form.field) : 해당 오브젝트가 NULL인지 체크
* return : 해당오브젝트가 Null 이면 true
* date   : 2007-01-05
****************************************************/
function isNullObj( obj ) {
  if (obj == null || obj == "undefined") {
      return true;
  }
  return false;
}

/*****************************************************
* isNumber(form.field) : 입력값이 숫자로만 되어 있는지 체크
* 본 함수가 자주 호출될 경우에는 숫자 지역변수를 전역변수로
* 사용해도 좋다.
* examples  :
*
* if( isNumber(form.field) ) {
*   alert('입력값이 숫자로만 구성되어 있네요.');
* }
*
* return : 입력값이 숫자로만 이루어져 있으면 TRUE
* date   : 2007-01-05
****************************************************/
function isNumber(input) {
  var chars = "0123456789";
  return containsCharsOnly(input,chars);
}

/****************************************************************
* containsCharsOnly(form.field, chars) :
* 입력값이 특정 문자만으로 되어있는지 체크
* examples  :
*
* if( containsCharsOnly(form.field, "ABO") ) {
*   alert('입력값이 A or B or O 문자로만 구성되어 있네요.');
* }
*
* return : 입력값이 지정한 특정문자로만 되어 잇으면 TRUE
* date   : 2007-01-05
****************************************************************/
function containsCharsOnly(input,chars) {
  for (var inx = 0; inx < input.value.length; inx++) {
     if (chars.indexOf(input.value.charAt(inx)) == -1)
         return false;
  }
  return true;
}

/****************************************************************
* isNumComma(form.field, format) :
* 입력값이 사용자가 정의한 포맷 형식인지 체크
* 자세한 format 형식은 자바스크립트의 'regular expression(정규식)'을 참조
* 정규식에 대한 내용은 검색엔진을 통해 찾아보면 나옴.
* examples  :
*
* if (isValidFormat(form.field, "[xyz]")) {
*      alert('x-z 까지의 문자가 존재하네요.');
* }
*
* return : 입력값이 지정한 올바른 포맷으로 되어 있으면 TRUE
* date   : 2002-10-28
****************************************************************/
function isValidFormat(input, format) {
  if (input.value.search(format) != -1) {
      return true;
  }
  return false;
}

/****************************************************************
* isValidEmail(form.field) : 입력값이 이메일 형식인지 체크
* examples  :
*
* if (isValidEmail(form.field)) {
*      alert('입력값이 이메일 형식이네요.');
* }
*
* return : 입력값이 이메일 형식으로 되어있으면 TRUE
* date   : 2002-10-28
****************************************************************/
function isValidEmail(input) {
  /*--
  var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
  --*/
  var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
  return isValidFormat(input,format);
}


function goUrl(argUrl){
	location.href=argUrl;
}

function multiSelectCheck(input, msg){
	var multiSelectCount = 0;
	for(var multiSelectCheckVar = 0 ; multiSelectCheckVar < input.length ; multiSelectCheckVar++){
		if(input[multiSelectCheckVar].checked == true){
			multiSelectCount++;
		}
	}
	if(multiSelectCount == 0){
		alert( msg );
		return false;
	}else{
		return true;
	}
}

/**
* <pre>
* </pre>
* @param str
* @param true, false)
* @return boolean
* ex)  jsp
*      function ue_retrieve(){
*          if (!isDate(document.searchForm.fromDate.value)) return;
*          if (!isDate(document.searchForm.toDate.value)) return;
*/
function isDate(str) {
  var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  var ymd = str.split("/");

  if(str.length != 10 || ymd.length != 3 || ymd[0].length != 4 || ymd[1].length != 2 || ymd[2].length != 2 ){
		alert("The date is incorrect.");
      return false;
  }

  if (ymd[0]%1000 != 0 && ymd[0]%4 == 0) days[1] = 29;
  if ((ymd[2] > days[ymd[1]-1] || ymd[2] < 1)
       ||(ymd[1] < 1 || ymd[1] > 12)
       ||(ymd[1]%1 != 0 || ymd[0]%1 != 0 || ymd[2]%1 != 0) ){
		alert("The date is incorrect.");
      return false;
  }else   return true;
}

/**
* <pre>
* </pre>
* @return boolean
* ex) if (!chkFromTo(document.searchForm.fromDate.value,document.searchFrom.toDate.value,'field name')) {
*         document.searchForm.fromDate.focus();
*         return;
*     }
*/
function chkFromTo(fromDate, toDate, FName) {
	var fDate = fromDate.split('/');
	var tDate = toDate.split('/');
	fDate = fDate[0]+fDate[1]+fDate[2];
	tDate = tDate[0]+tDate[1]+tDate[2];
  if ( fDate > tDate ) {
      alert("날짜를 바르게 입력해주세요. "+FName+"");
      return false;
  }

  return true;
}


/**
* <PRE>
* Scroll 이 없는 새 창을 띄운다
* </PRE>
* @param   theURL 새로 띄울 파일 이름이다
* @param   winName 새창 이름
* @param   winTitle 새창 title
* @param	width 새창 가로 크기
* @param	height 새창 세로 크기
* @param   param 추가적인 화면 argument
*/
function openNoScrollWin(theURL, winName, winTitle, width, height, param)
{
	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param, winName, "menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();
}

function openNoScrollWin_2(theURL,  winName, winTitle, width, height)
{
	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;
	var win = window.open(theURL ,winName ,"menubar=no, scrollbars=yes, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();
}

function openNoScrollWinPost(theURL, winName, winTitle, width, height, param)
{
	var wid = (screen.width)/2 - width/2 ;
	var hei = (screen.height)/2 - height/2;
	var win = window.open("about:blank", winName, "menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height+ ",top=" + hei + ",left=" + wid + "");
	win.focus();
}

/**
* 간단 상품 검색(ENTER KEY)
*/
function semiGoodsSearchGo(e,path_root){
	if(e.keyCode == '13'){
		semiGoodsSearch(path_root);
	}
}

/**
* 간단 상품 검색
*/
function semiGoodsSearch(path_root){
	var form = document.semiSearchFrm;
	if(validateFrm(form) == true){
		if(isNumber(form.searchValue) == true){
			form.searchMethod.value="code";
		}
		form.action = path_root+"/display/search.do";
		form.submit();
	}else{
		return false;
	}
}

function writeFlash(strSrc, strWid, strHei){
var str = "";
str += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'";
str += " codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'";
str += " width='"+strWid+"' height='"+strHei+"'>";
str += "    <param name='movie' value='"+strSrc+"'>";
str += "    <param name='quality' value='high'>";
str += "    <param name='wmode' value='transparent'>";
str += "    <embed src='"+strSrc+"' quality='high'";
str += "     pluginspage='http://www.macromedia.com/go/getflashplayer'";
str += "     type='application/x-shockwave-flash' width='"+strWid+"' height='"+strHei+"'></embed>";
str += "</object>";

document.writeln(str);
}

/**
* <pre>
* 숫자나 문자열을 통화(Money) 형식으로 만든다.( 쉼표(,) 찍는다는 소리.. )
* &lt;input type="text" name="test" value="" onkeyup="this.value=toCurrency(this.value);"&gt;
* or
* var num = toCurrency(document.form[0].text.value);
* </pre>
* @param	amount	"1234567"
* @return	currencyString "1,234,567"
*/
function toCurrency(amount){
  var data = amount.split(".");
	var sign = "";
	var firstChar = data[0].substr(0,1);
	if(firstChar == "-"){
		sign = firstChar;
		data[0] = data[0].substring(1, data[0].length);
	}
	data[0] = data[0].replace(/\D/g,"");
	if(data.length > 1){
		data[1] = data[1].replace(/\D/g,"");
	}
	firstChar = data[0].substr(0,1);
	//0으로 시작하는 숫자들 처리
	if(firstChar == "0"){
		if(data.length == 1){
			return sign + parseFloat(data[0]);
		}
	}
	var comma = new RegExp("([0-9])([0-9][0-9][0-9][,.])");
	data[0] += ".";
	do {
		data[0] = data[0].replace(comma, "$1,$2");
	} while (comma.test(data[0]));

	if (data.length > 1) {
		//= 소수점  .00 붙이기
//	    if(data[1].length == 1) data[1] = data[1] + "0";
//		return sign + data.join("");
		//= 소수점 없애기
		return sign + data[0].split(".")[0];
	} else {
		return sign + data[0].split(".")[0];
	}
}

/**
* ,이 있는 숫자를 순수한 숫자로 바꿔준다. (+), (-) 허용
*
* @param num
* @return number
*/
function toNormalNum( num ) {
  num = num.replace(/,/g, "");
  var args = Number(num);
	return args;
}



//인터넷 익스플로러 버전에 다른 모달창 사이즈 조절을 위한 flag
var useragent = navigator.userAgent;
var IE_version = '';
//IE7이 아니고 IE6일때는
if ((useragent.indexOf('MSIE 6') > 0) && (useragent.indexOf('MSIE 7') == -1) && (useragent.indexOf('MSIE 8') == -1)) {
	IE_version = '6';
} else {
	IE_version = '7';
}

function myFavorite() 
{
 window.external.AddFavorite('http://www.munsingwear.co.kr','먼싱웨어');
}

