﻿// JScript 파일
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* flash play를 위한 스크립트(투명)
 rcvFile : 실행할 swf 파일
 rcvWidth : 가로크기
 rcvHeight : 세로크기
 rcvMode : 투명? 1이면 투명   
*/

var COMPANYID = 700001;
var CID = 700001;

function WriteSwf(rcvFile, rcvWidth, rcvHeight, rcvMode) 
{
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + rcvWidth + "' height='" + rcvHeight + "'>");
    document.write("<param name='movie' value='" + rcvFile + "'>");
    document.write("<param name='quality' value='high'>");
    document.write("<PARAM NAME='AllowScriptAccess' VALUE='always'>");
    if (rcvMode == '1') {
        document.write("<PARAM NAME=wmode VALUE=transparent>");
    }
    document.write("<embed src='" + rcvFile + "' quality='high' ");
    
    if (rcvMode == '1') {  
        document.write(" wmode='transparent' ");
    }
    
    document.write(" pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + rcvWidth + "' height='" + rcvHeight + "'></embed></object>");
}

//카테고리 배너관리에서 확장자명을 정규식 패턴으로 치환하기때문에 동일한 함수를 다른이름으로 하나더 추가
function writeflash(rcvFile, rcvWidth, rcvHeight, rcvMode) 
{
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + rcvWidth + "' height='" + rcvHeight + "'>");
    document.write("<param name='movie' value='" + rcvFile + "'>");
    document.write("<param name='quality' value='high'>");
    document.write("<PARAM NAME='AllowScriptAccess' VALUE='always'>");
    if (rcvMode == '1') {
        document.write("<PARAM NAME=wmode VALUE=transparent>");
    }
    document.write("<embed src='" + rcvFile + "' quality='high' ");
    
    if (rcvMode == '1') {  
        document.write(" wmode='transparent' ");
    }
    
    document.write(" pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + rcvWidth + "' height='" + rcvHeight + "'></embed></object>");
}

// Flash 스크립트 추가
// 정지용군 : 외부스크립트 사용하기위해서 만듬...
// 플레쉬 즉시 플레이 하기 위해 사용
// param : 파일, 넓이, 높이, 투명도, 외부스크립트사용여부, ID부여
function WriteSwf_V2(rcvFile, rcvWidth, rcvHeight, rcvMode, useScript, MakeId) 
{
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + rcvWidth + "' height='" + rcvHeight + "' id='" + MakeId + "'>");
    document.write("<param name='movie' value='" + rcvFile + "'>");
    document.write("<param name='quality' value='high'>");
	
    
    if (rcvMode == '1') {
        document.write("<PARAM NAME=wmode VALUE=transparent>");
    }
	if (useScript == '1')
	{
		document.write("<param name='allowScriptAccess' value='always'/>");
	}
    document.write("<embed src='" + rcvFile + "' quality='high' ");
    
    if (rcvMode == '1') {  
        document.write(" wmode='transparent' ");
    }
   	if (useScript == '1')
	{
		document.write(" allowScriptAccess='always' ");
	} 
    document.write(" pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + rcvWidth + "' height='" + rcvHeight + "'></embed></object>");
}
	
//로그인 여부 확인 후 로그인 창 오픈
/*
function OpenLoginOn(custId)
{
	if(custId < 1)
	{
		window.open("http://www.elandclub.com/Member/xLogin.aspx?COMPANYID=" + COMPANYID + "&CID=" + CID + "&T=mall" , "loginWindow", "width=400, height=361, scrollbars=0") ;
		return true;
	}
	
	return false;
}
*/

// 마이인포 회원 정보 수정
function goChangeMyInfo2(CID,COMPANYID)
{
	alert("이랜드 회원통합 서비스인 이랜드클럽으로 이동합니다.");
	window.open("https://oneclick.elandclub.com:444/OneClickLogin.aspx?xurl=OneClickMemberUpdate.aspx&CID=" + CID + "&CompanyId=" + COMPANYID, "MyInfo")
}
// 회원 정보 수정
function goChangeMyInfo()
{
	alert("이랜드 회원통합 서비스인 이랜드클럽으로 이동합니다.");
	window.open("https://oneclick.elandclub.com:444/OneClickLogin.aspx?xurl=OneClickMemberUpdate.aspx&CID=" + CID + "&CompanyId=" + COMPANYID, "MyInfo")
}
// 회원 탈퇴
function procMemOut()
{
	var one_win = window.open("https://oneclick.elandclub.com:444/OneClickByeBye_login.aspx?CompanyId=" + COMPANYID + "&CID=" + CID, "memout", "width=647,height=610");
}
///////  돈에 , 를 넣어주데 포커스를 주지 않는다 /////////////////////////////////////////////////////////////////


function commaSplitAndNumberOnlyNotFocus(ob)
{

        var txtNumber = '' + ob.value;
        
        
        
        if (isNaN(txtNumber) )   // 소수점 사용 가능
        {
                ob.value = ob.value.substring(0, ob.value.length-1 );
                //alert('숫자 혹은 \'.\' 만 입력하십시오.');
                return ob.value;
        }
        else
        {
                var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
                var arrNumber = txtNumber.split('.');
                arrNumber[0] += '.';
                do
                {
                        arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
                }
                while (rxSplit.test(arrNumber[0]));

                if (arrNumber.length > 1)
                {
                        return arrNumber.join('');
                }
                else {
                        return arrNumber[0].split('.')[0];
                }
   }
}


///////  commaSplitAndNumberOnlyNotFocus 이 함수는 value를 받는데 value를 쓸수 없을때 금액에 콤마 넣기 /////////////////////////////////////////////////////////////////
function setComma(str)
{
        str = ""+str+"";
        var retValue = "";
        for(j=0; j<str.length; j++)
        {
                if(j > 0 && (j%3)==0) {
                        retValue = str.charAt(str.length - j -1) + "," + retValue;
                 } else {
                        retValue = str.charAt(str.length - j -1) + retValue;
                }
        }
        return retValue ;
}

function showAlert(CTIME, MSG){
			var parameter = new Array();

			parameter[0] = MSG;
			parameter[1] = CTIME * 1000;	
			
			var url = "/neoalert.htm";
			var feature = "status:no;dialogWidth:305px;dialogHeight:145px;help:no;unadorned:yes;scroll:no;edge:raised";
			var RtnVal = window.showModalDialog(url,parameter,feature);
	}


//숫자여부 확인
//숫자가 아니면 true 리턴
function ChkNum(str) { 
    var flag=false; 
    if (str.length > 0) { 
        for (i = 0; i < str.length; i++) {  
            if (str.charAt(i) < '0' || str.charAt (i) > '9') { 
                flag=true; 
            } 
        } 
    } 
    return flag; 
} 


// Trim 함수들 

function trim (strSource) {
	re = /^[\s　]+|[\s　]+$/g;

	return strSource.replace(re, '');
}

function ltrim (strSource) {
	re = /^[\s　]+/g;

	return strSource.replace(re, '');
}

function rtrim (strSource) {
	re = /[\s　]+$/g;

	return strSource.replace(re, '');
}

//////// 로그인 하지 않았을 경우 alert ///////
function Not_login(){
    alert("로그인 후 이용 가능합니다.");
}
//////////////////////////////////////////////

// 로그인 팝업 

function Login_PopWindow(){
	//★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
	//One Click을 위한 경로 통합마일지지 오프전 까지 올리기 전에 변경해야함
	//alert("이랜드 회원통합 서비스인 이랜드클럽으로 이동합니다.");
	//window.open("http://www.elandclub.com/Member/xLogin.aspx?COMPANYID=" + COMPANYID + "&CID=" + CID + "&T=mall", "loginWindow", "width=400, height=361, top=30 ,left=100, scrollbars=0") ;
	window.open("/myOutlet/Cust/mLogin.aspx?T=mall", "loginWindow", "width=400, height=361, top=30 ,left=100, scrollbars=0") ;

	//★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
	///return false ;
	
}


/////////// 제목 클릭시 제목 굵게
var SIdName = ''; //저장한 변수를 초기화
function change_title_bold(IdName){
	if( SIdName != IdName ) { // 저장되어 있는 변수와 새로운 변수가 같은지 비교
		if( SIdName !='' ) { //이미 클릭한 메뉴가 있을경우
			document.getElementById(SIdName).style.fontWeight = 'normal'; //스타일을 초기화
		}
		document.getElementById(IdName).style.fontWeight="bold"; //강조하려는 메뉴에 스타일을 준다
		SIdName = IdName; //변수에 현재 내용을 저장해 놓는다.
	}
}
///////////////////////////////////



//--------------------------------------------------
//----- 날짜 //

function printDates(sObj, eObj, format) {
	
	
	var pSObjName = 'document.' + sObj.form.name + '.' + sObj.name; // 시작날짜핃드
	var pEObjName = 'document.' + eObj.form.name + '.' + eObj.name; // 끝날짜필드

	

  //--- 오늘 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,0,0,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/2.gif' align='absmiddle' border='0'></a>&nbsp;");

  //--- 어제 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,0,-1,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/1.gif' align='absmiddle' border='0'></a>&nbsp;");

  //--- 3일 이전 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,0,-3,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/btn_s_3d.gif' align='absmiddle' border='0'></a>&nbsp;");

  //--- 일주일 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,0,-7,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/btn_s_7d.gif' align='absmiddle' border='0'></a>&nbsp;");
  
  //--- 한달이전 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,-1,0,\"yyyy-mm-dd\")'>" 
	           + "<img src='/Images/button/btn_s_1m.gif' align='absmiddle' border='0'></a>&nbsp;");
  
  //--- 3개월이전 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,-3,0,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/btn_s_3m.gif' align='absmiddle' border='0'></a>&nbsp;");

  //--- 6개월이전 ---//
  document.write("<a href='javascript:moveDates(" + pEObjName + "," + pSObjName + ",0,-6,0,\"yyyy-mm-dd\")'>"
               + "<img src='/Images/button/btn_s_6m.jpg' align='absmiddle' border='0'></a>&nbsp;");

}


function moveDates(sObj,eObj,year,month,day,format) {
    
      /*----------------------------------------------
       시간계산 시작 ^^
	  ------------------------------------------------*/
	  
	  var nowDate = new Date();
    
	  var now_year  = nowDate.getFullYear();
      var now_month = nowDate.getMonth(); 
      var now_day   = nowDate.getDate();
     
	  var newDate = new Date(now_year + year, now_month +  month, now_day + day);
	
	  var procYear = newDate.getFullYear(); 
      var procMonth = newDate.getMonth() + 1; 
	  var procDay = newDate.getDate();
	  
	  //----------------------------------------------
	  //----- 오늘 날짜
	  //-----------------------------------------------
	  
	  now_month += 1;
	  if (("" + now_month).length == 1) { now_month = "0" + now_month; }
      if (("" + now_day).length   == 1) { now_day   = "0" + now_day;   }
      

	  //----------------------------------------------
	  //----- 변형된 날짜 
	  //----------------------------------------------

      if (("" + procMonth).length == 1) { procMonth = "0" + procMonth; }
      if (("" + procDay).length   == 1) { procDay   = "0" + procDay;   }
      
	  sObj.value = now_year + "-" + now_month + "-" + now_day; // 값을 넘겨주기 
 	  eObj.value = procYear + "-" + procMonth + "-" + procDay; 
    
}

function moveDates(sObjY,sObjM, sObjD, eObjY, eObjM, eObjD, year, month, day) {
    
      /*----------------------------------------------
       시간계산 시작 ^^
	  ------------------------------------------------*/
	  
	  var nowDate = new Date();
    
	  var now_year  = nowDate.getFullYear();
      var now_month = nowDate.getMonth(); 
      var now_day   = nowDate.getDate();
     
	  var newDate = new Date(now_year + year, now_month +  month, now_day + day);
	
	  var procYear = newDate.getFullYear(); 
      var procMonth = newDate.getMonth() + 1; 
	  var procDay = newDate.getDate();
	  
	  //----------------------------------------------
	  //----- 오늘 날짜
	  //-----------------------------------------------
	  
	  now_month += 1;
	  if (("" + now_month).length == 1) { now_month = "0" + now_month; }
      if (("" + now_day).length   == 1) { now_day   = "0" + now_day;   }
      

	  //----------------------------------------------
	  //----- 변형된 날짜 
	  //----------------------------------------------

      if (("" + procMonth).length == 1) { procMonth = "0" + procMonth; }
      if (("" + procDay).length   == 1) { procDay   = "0" + procDay;   }

      // 값을 넘겨주기 
	  eObjY.value = now_year;
	  eObjM.value = now_month;
	  eObjD.value = now_day; 

	  sObjY.value = procYear;
	  sObjM.value = procMonth;
	  sObjD.value = procDay; 

    
}

function EditorContents(EditorName) {
	var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
	return oEditor.GetXHTML( false );
}


/*-------------------------------------------------------------
  Iframe 용 달력 호출함수 
  조낸 중요한거당 
--------------------------------------------------------------*/

function createCalendar() {

document.write("<div id='calDIV' style='z-index:+999;position:absolute;visibility:hidden;top:0;left:0'>");
document.write("<iframe align='center' valign='middle' name='frmCal' id='frmCal' frameborder='0' width='210' height='190' src='/Common/js/blank.html'></iframe>")
document.write("</div>");

}

var objPrev; // 현재 보여주는 obj 

function popUpCalendar(ob,ob2,types,formats){
   


   var posTop, posLeft, leftPos, topPos;
   var aTag;
   
   posTop = 0;
   posLeft = 0;
   leftPos = 0;
   topPos = 0;
   
	aTag = ob;
	var posTop, posLeft;
    
	do {
		aTag = aTag.offsetParent;
		leftPos	+= aTag.offsetLeft;
		topPos += aTag.offsetTop;
		
	} while(aTag.tagName != "BODY");

    
   posTop =  ob.offsetTop + 20 + topPos ;
   posLeft = ob.offsetLeft + leftPos;
   
   calDIV.style.top = posTop;
   calDIV.style.left = posLeft;

 
   calDIV.style.visibility = "visible";
   frmCal.window.callCalandar(ob,ob2,types,formats);
   
   objPrev = ob;
}

// 스프레드용 달력
function popUpCalendarSpread(sparedid, ob,ob2,types,formats){
   
   var posTop, posLeft, leftPos, topPos;
   var aTag;
   var spread = document.getElementById(sparedid + "_view");
   
   posTop = 0;
   posLeft = 0;
   leftPos = 0;
   topPos = 0;
   
	aTag = ob;
	var posTop, posLeft;
    
	do {
		aTag = aTag.offsetParent;
		leftPos	+= aTag.offsetLeft;
		topPos += aTag.offsetTop;
	} while(aTag.tagName != "HTML" && aTag.tagName != "BODY");
   
   posTop =  (ob.offsetTop - spread.scrollTop) + 20 + topPos ;
   posLeft = (ob.offsetLeft - spread.scrollLeft) + leftPos;
   
   calDIV.style.top = posTop + "px";
   calDIV.style.left = posLeft + "px";
 
   calDIV.style.visibility = "visible";
   frmCal.window.callCalandar(ob,ob2,types,formats);
   
   objPrev = ob;
}

function hideCalLayer(ob)	{
    
	if (objPrev == ob) {
	
		 if(calDIV.style.visibility == "visible" || calDIV.style.visibility == "") {
			calDIV.style.visibility = "hidden";
		} 
    }
	
	objPrev = null;

}

/*-------------------------------------------------------------
  즐겨찾기 추가
  myFavorite('http://www.2001outlet.com','백화점을 할인한다 - 2001아울렛');   
--------------------------------------------------------------*/
function myFavorite(rcvURL, rcvTitle){
window.external.AddFavorite(rcvURL,rcvTitle)
}


//특수문자 입력 확인
//특수문자가 있으면 false를 리턴한다.
function checkSpecialChar(pText)
{
	//reg = /[`~!@#$%^&*()_+|\;\\/:=-<>.'\"]/;
	regPattern = /`|~|!|@|#|\$|%|\^|&|\*|\(|\)|\\|\||'|"|;|:|<|>|\/|\?|\[|\]|\{|\}/g
	
	if (pText.match(regPattern) != null)
	{
		return false;
	}
	else
		return true;
	
}

function getByteLength(s){
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}

function checkLength(obj, maxlen, preMsg) {
    var len = 0;
    var s = obj.value;
    var cutStr = '';
    
    if ( s == null ) return 0;
    for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
      
      if (len > maxlen) {
        break;
      }
      
      cutStr += unescape(c);
    }
    
    if (len > maxlen) {
        alert(preMsg + ' 한글 ' + maxlen/2 +'자(영문' + maxlen + '자) 이상 입력 할 수 없습니다.');
        obj.value = cutStr;
        obj.focus();
    }
}

function isSpecialChar(val) {
    var chars = '!,*&^%$#@~;=+|\\`:"\'?/.';
    return containsChars2(val, chars);
}

function containsChars2(val, chars) {
    var cnt = 0;
	for (var inx = 0; inx < val.length; inx++) {
		if (chars.indexOf(val.charAt(inx)) > -1)
			cnt++;
	}
	
	if (cnt > 0) {
	    return true;
	} else {
	    return false;
	}
}

function checkKeyCode()
{
    if((event.keyCode<48)||(event.keyCode>57)) 
    {
    event.returnValue=false; 
    }

}

