/***********************************************************************************************************************
 * 이 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.lecoqgolf.co.kr','르꼬끄골프');
}




/* 기본상수 잡기 */
/* 추후 설정에 맞춰 변경해주세요. */
// -----------------------------------------------------------------------------

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 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);
}

/* 매장정보 플래시 */
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;
}

/* GNB 플래시 링크 */
function LeftmenuLink(b_no, m_no, s_no)
{
	var comb = b_no + "," + m_no + "," + s_no;
	var url = "";

	switch (comb)
	{
		case "0,0,0" : url = "/Front/Main/main.jsp"; break;

		case "1,1,0" : url = "/Front/Brand/intro.jsp"; break;
		case "1,2,0" : url = "/Front/Brand/history.jsp"; break;
		case "1,3,0" : url = "/Front/Brand/concept01.jsp"; break;

		/*
		case "2,1,0" : url = "/Front/Product/sports.jsp"; break;
		case "2,2,0" : url = "/Front/Product/libre.jsp"; break;
		*/
		case "2,1,0" : url = "/Front/Product/collection.jsp"; break;
		case "2,2,0" : url = "/Front/Product/collection.jsp"; break;
		
		case "3,1,0" : url = "/Front/Catalog/default.jsp"; break;
		
		case "4,1,0" : url = "/Front/Yang/realDesign01.jsp"; break;
		case "4,2,0" : url = "/Front/Yang/profile.jsp"; break;
		case "4,3,0" : url = "/Front/SpecialLine/duals.jsp"; break;
		case "4,4,0" : url = "/Front/SpecialLine/playdown.jsp"; break;

		case "5,1,0" : url = "/Front/Sponsor/Kim/profile.jsp"; break;
//		case "5,1,0" : window.open("http://www.descentekorea.co.kr/sponsor/Lecoqgolf/default.jsp","_blank", "width=960, height=720"); break;
		
		case "6,1,0" : url = "/Front/PR/Media_Movie/list.jsp"; break;
		case "6,2,0" : url = "/Front/MediaRoom/Media_PR/list.jsp"; break;
		case "6,3,0" : url = "/Front/MediaRoom/Media_Column/list.jsp"; break;

		case "7,1,0" : url = "/Front/Event/Event/list.jsp"; break;
		case "7,2,0" : url = "/Front/Event/Winner/list.jsp"; break;
		
		case "8,1,0" : url = "/Front/Customer/Notice/list.jsp"; break;
		case "8,2,0" : url = "/Front/Customer/FAQ/list.jsp"; break;
		case "8,3,0" : url = "/Front/Customer/QNA/write.jsp"; break;
		case "8,4,0" : url = "/Front/Customer/ShopInfo/list.jsp"; break;
}
	
	if (url != "")
		location.href = url;
}

/* 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);
}


/* Flash Xml 경로 선언 */
function getFlashXmlPath()
{
	return "/common/flash/xml/";
}

//이미지 크기 조절하여 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);
		}
		
		if (result_height > limit_height)
		{
			result_width	= parseInt((result_width * limit_height) / result_height); 
			result_height	= limit_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);
			result_height	= limit_height;
		}
		
		if (result_width > limit_width)
		{
			result_height	= parseInt((result_height * limit_width) / result_width); 
			result_width	= limit_width;
		}
	}
	
	imgFile.width			= result_width;
	imgFile.height			= result_height;
	imgFile.style.visibility	= "visible";
}



/* 메인페이지 배너 링크 */
function mainFlashBannerLink(link_no)
{
	link_no = Number(link_no);

	var url = "";
	var target = "_blank";
	
	switch (link_no)
	{
		case 1 : 
			//url = "http://www.descentekorea.co.kr/mall/display/plan.do?method=plancategory&plan_code=2010020004&template_code=002";
			window.open("/Front/MiniSite/Big3/default.html","big3","width=1000,height=670,top=0,left=0, scrollbars=no");
			break; 
		case 2 :
			url = "http://www.descentekorea.co.kr/mall/display/plan.do?method=plancategory&plan_code=2010020003&template_code=002";
			break;
		case 3 :
			url = "http://www.descentekorea.co.kr/mall/display/plan.do?method=plancategory&plan_code=2010020007&template_code=002";
			break;
		case 4 :
			url = "/Front/Yang/realDesign01.jsp";
			target = "_self";
			break;
		case 5 :	// 남성 로고자수 티셔츠
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100242&style_code=G011KG1502";
			break;
		case 6 :	// 여성 이너 티셔츠
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100242&style_code=G011KG1502";
			break;
		case 7 :	// 남성 캐디백
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100310&style_code=G012KG1070";
			break;
		case 8 :	// 남성 방풍자켓
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100315&style_code=G012KG4502";
			break;
		case 9 :	// 남성 바람막이
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100318&style_code=G012KG6001";
			break;
		case 10 :	// 남성 양피 골프 장갑
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100251&style_code=G011QQ8016";
			break;
		case 11 :	// 여성 우븐 모자
			url = "http://www.descentekorea.co.kr/mall/display/goods.do?method=goods&goods_code=100348&style_code=G012KL0301";
			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.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 setCookie(name, value, expiredays)
{
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

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;
}

//마이크로 사이트 이벤트 팝업  
function microEvent(eventNo)
{   
	switch(eventNo) 
	{
		case 1: 
			//window.open("/Front/Event/Micro/201004_YEYang.jsp", "golfMicroEvent01", "status=no, resizable=no,scrollbars=yes,width=920,height=700,left=0, top=0")
			window.open("/Front/Event/Micro/201004_YEYang.jsp");
			break;
	}
}

// catalog layer popup 
function changeDivDisplay(divName, display)
{
	var div = document.getElementById(divName);
	div.style.display = display;
}


