// 숫자만 입력
function onlyNumber(){
	if((event.keyCode < 48) || (event.keyCode > 57))
		event.returnValue=false;
}

function isValidEmail(input) {
    /*--
    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    --*/
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(input,format);
}

/****************************************************************
 * isValidFormat(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;
}


/* 기본상수 잡기 */
/* 추후 설정에 맞춰 변경해주세요. */
// -----------------------------------------------------------------------------

var default_image_path = "/company/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;
}


/* 마우스 오버, 아웃시 이미지 변경 */
function imageOver2(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 + "_on." + arr_file[arr_file.length - 1];

	if (mouse_action == "over")
		obj.src = "/company/images/v1/" + folder + over_image_file;
	else if (mouse_action == "out")
		obj.src = "/company/images/v1/" + 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 '';
}



//이미지 크기 조절하여 img 태그 출력 ******************************************
function change_image_size2(imgFile, limit_width, limit_height)
{
	imgFile.style.visibility	= "hidden";

	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_height	= parseInt((real_height * limit_width) / real_width);

			if(result_height > limit_height) result_height = limit_height;

			result_width	= parseInt((real_width * result_height) / real_height);
		}
	}
	else
	{
		if (real_height <= limit_height)
		{
			result_width	= real_width;
			result_height	= real_height;
		}
		else
		{
			result_width	= parseInt((real_width * limit_height) / real_height);

			if(result_width > limit_width) result_width = limit_width;

			result_height	= parseInt((real_height * result_width) / real_width);
		}
	}

	imgFile.width			= result_width;
	imgFile.height			= result_height;
	imgFile.style.visibility	= "visible";
}


/* 플래시 */
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 flash_query(width, height, path, file, query)
{
	var flash_tag = "";
	var flash_path = path+'/'+file+'.swf';
	if (query != "")
		flash_path += "?" + query;

	var url = String(document.location);
	var protocol = url.split(":")[0].toLowerCase();
	if (protocol != "https")
		protocol = "http";

 	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="'+flash_path+'" /> ';
	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="'+flash_path+'" 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);
}

/* FAQ */
function initToggle(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
				}
				this.targetEl.style.display = "block";
				tabContainer.current = this;
			}
			return false;
		};
	}
}



/* 메뉴 링크 */
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) {
		url = "/";
	}

	// Company
	if (b_no == 1)
	{
		switch (m_no)
		{
			case 1 : url = "/company/Front/Company/ceo.jsp"; break;				// CEO 인사말
			case 2 : url = "/company/Front/Company/introduce.jsp"; break;		// 기업소개
			case 3 : url = "/company/Front/Company/history.jsp"; break;			// History
			case 4 : url = "/company/Front/Company/location.jsp"; break;		// Location
			case 5 : url = "/company/Front/Company/contribution.jsp"; break;	// 사회공헌
		}
	}

	// Brand Story
	else if(b_no == 2)
	{
		switch (m_no)
		{
			case 1 : url = "/company/Front/BrandStory/default.jsp?brand_cd=MSW"; break; // Munsingwear
			case 2 : url = "/company/Front/BrandStory/default.jsp?brand_cd=LCG"; break; // Le Coq Golf
			case 3 : url = "/company/Front/BrandStory/default.jsp?brand_cd=LCS"; break; // Le Coq Sportif
			case 4 : url = "/company/Front/BrandStory/default.jsp?brand_cd=DST"; break; // Descente
			case 5 : url = "/company/Front/BrandStory/ShopInfo/list.jsp"; break; // 매장안내
		}
	}

	// PR Center
	else if(b_no == 3)
	{
		switch (m_no)
		{
			case 1 : url = "/company/Front/PR/Notice/list.jsp"; break;	// 뉴스 보도자료
			case 2 : url = "/company/Front/PR/Media_Movie/list.jsp"; break;	// PR자료실
		}
	}

	// Recruit
	else if(b_no == 4)
	{
		switch (m_no)
		{
			case 1 : url = "/company/Front/Recruit/companySystem.jsp"; break;		// 인사제도 및 복리후생
			case 2 : url = "/company/Front/Recruit/person.jsp"; break;				// 인재상
			case 3 : url = "/company/Front/Recruit/Guide/info.jsp"; break;			// 지원가이드
			case 4 : url = "/company/Front/Recruit/Recruit_Notice/list.jsp"; break;	// 채용공고 및 입사지원
			case 5 : url = "/company/Front/Recruit/Guide/checkApplicant.jsp"; break;// 지원서 조회 및 수정
		}
	}

	// 고객센터
	else if(b_no == 5)
	{
		switch (m_no)
		{
			case 1 : url = "/company/Front/Customer/FAQ/list.jsp?bbs_option_cd=FAQ_O1"; break;	// FAQ
			case 2 : url = "/company/Front/Customer/QNA/write.jsp"; break;						// 1:1문의
			case 3 : url = "/company/Front/Customer/AS/Info.jsp"; break;						// AS 안내
			case 4 : url = "/company/Front/Customer/Common_Sense/default.jsp"; break;			// 상품손질지식
		}
	}

	//Media
	else if(b_no == 6)
	{
		switch (m_no)
		{
			case 1	: url = "/Front/Event/Event/list.jsp"; 	break;					//Event 이벤트
			case 2	: url = "/Front/Event/Winner/list.jsp"; 	break;				//Winner 당첨자 게시판
		}
	}

	//-------------------------------------------------------
	// 공통
	//-------------------------------------------------------

	//고객센터
	else if(b_no == 11)
	{
		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/list.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;				//사이트맵
		}
	}



	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 loadLocation(location_no){
	var frm = document.getElementById("form1");
	var brand_cd = frm.brand_cd.value;
	var str_url = "list.jsp?brand_cd=" + brand_cd + "&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;
}

/* 메인페이지 배너 링크 */
function mainFlashBannerLink(link_no)
{
	link_no = Number(link_no);
	var url = "";
	var target = "_blank";

	switch (link_no)
	{
	}

	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 : alert("준비중입니다."); break;
		case 2 : url = "http://www.descentekorea.co.kr"; break;
		case 3 : url = "/Front/Customer/ShopInfo/list.jsp"; target="_self"; break;
		case 4 : break;
		case 5 : break;
		case 6 : url = "/Front/Customer/Notice/list.jsp"; target="_self"; break;
		case 7 : url = "/Front/Etc/SiteMap/default.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 link_cc(){
	location.href = "/company/Front/Customer/FAQ/list.jsp";
}
function link_contact(){
	location.href = "/company/Front/Company/location.jsp";
}
function link_sitemap(){
	location.href = "/company/Front/Etc/SiteMap/default.jsp";
}


//쿠키 찾기 *******************************************************************
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 returnCookie;
}
 
//File Upload 창 띄우기 *******************************************************
function popup_upload(formName, inputName, uploadType, bbs_section_cd, brand_cd)
{
	var win; 
	win = "/company/Front/Components/FileUploader/fileSelector.jsp";
	win = win + "?formName="+ formName +"&inputName="+ inputName +"&uploadType="+ uploadType 
	win = win + "&bbs_section_cd="+ bbs_section_cd + "&brand_cd=" + brand_cd;
	window.open(win, 'popup', 'width=376, height=200');
}



//큰이미지 보기
function imgResize(img, left, top)
{
	img1 = new Image();
	img1.src = (img);
	imgControll(img, left, top);
}

function imgControll(img, left, top)
{
	if((img1.width!=0)&&(img1.height!=0))
	{
		viewImage(img, left, top);
	}
	else
	{
		controller="imgControll('"+img+"')";
		intervalID=setTimeout(controller, 20);
	}
}

function viewImage(img, left, top)
{
	var scroll = "yes";
	var W = img1.width;
	var H = img1.height;
	var AW = screen.availWidth;
	var AH = screen.availHeight;

	if (H > AH && W <= AW)
		W += 17;
	if (W > AW && H <= AH)
		H += 17;

	if (W <= AW && H <= AH)
		scroll = "no";

	var O = "width=" + W + ",height=" + H + ",scrollbars=" + scroll + ",left=" + left + ",top=" + top;
	imgWin=window.open("","",O);
	imgWin.document.write("<html><head><title>Image View</title></head>");
	imgWin.document.write("<body style='margin:0'>");
	imgWin.document.write("<img src='"+img+"' onclick='self.close()' style='cursor:hand;'>");
	imgWin.document.write("</body></html>");
	imgWin.document.close();
}
