//=============================================================================
// JSLibrary.js
// ÀÔ·Â°ª Ã¼Å©¿ë ÀÚ¹Ù ½ºÅ©¸³Æ® ¹× ÇÔ¼ö ¶óÀÌºê·¯¸® 
//=============================================================================


//=============================================================================
// ÇÔ¼ö¸í: ValidateData                                                        
// ¼³  ¸í: validateForm¿¡ ÀÇÇØ »ç¿ëµÈ´Ù
// ÀÛ¾÷ÀÏ:                                                                     
// ÀÛ¾÷ÀÚ:                                                                     
//=============================================================================
function validateData(objValue, strValidateStr, strError) 
{
    var epos = strValidateStr.search("="); 
    var command  = ""; 
    var cmdvalue = ""; 
    
    if(epos >= 0) 
    { 
		command  = strValidateStr.substring(0,epos); 
		cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
		command = strValidateStr;
    } 
    switch(command) 
    { 
		case "req": 
        case "required": 
		{
		   var tp = objValue.value.replace(/\s/g,'');
           if(eval(tp.length) == 0) 
           { 
              alert(strError);
              return false; 
           } 
           break;             
        }
        case "maxlen": 
        case "maxlength": 
        { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
				alert(strError);
				return false; 
             }
             break; 
        }
        case "minlen": 
        case "minlength": 
        { 
             if(eval(objValue.value.length) <  eval(cmdvalue) && eval(objValue.value.length) != eval(0)) 
             { 
				alert(strError);
				return false;                 
             }
             break; 
        }        
        case "eng":
        case "english": 
        { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break; 
        }
        case "engnum": 
        case "engnumeric": 
        { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break; 
        }
        case "engnumhyphen":
		{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break;
		} 
        case "num": 
        case "numeric": 
        { 
              var charpos = objValue.value.search("[^0-9\]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break;               
        }
        case "float": 
        { 
			if(objValue != undefined)
			{				
              var charpos = objValue.value.search("[^0-9\-.]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
            }  
            break;           
                
        }
        case "numhyphen": 
        { 
              var charpos = objValue.value.search("[^0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
				alert(strError);
				return false; 
              } 
              break;               
        }
        
        case "han" :
		case "hangul":
		{
              var charpos = objValue.value.search("[^°¡-ÆR]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              }
              break;
		}
		case "hannum" :
		case "hangulnumeric":
		{
              var charpos = objValue.value.search("[^¤¡-¤¾°¡-ÆR0-9]");
              alert(charpos);
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                objValue.select();
				objValue.focus();
                return false; 
              } 			
				break;
		}
		case "hanalpha" :
		case "hangulalphabetic":
		{
              var charpos = objValue.value.search("[^¤¡-¤¾°¡-ÆRA-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false;
              } 			
				break;
		}
		case "hanengnum" :
		case "hangulenglishnumeric":
		{
              var charpos = objValue.value.search("[^¤¡-¤¾°¡-ÆRA-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                alert(strError);
                return false; 
              } 			
				break;
		}
        case "email": 
        { 
               if(!CheckEmail(objValue.value)) 
               { 
                 alert(strError);
                 return false; 
               } 
           break; 
        } 
        case "lt": 
        case "lessthan": 
        { 
            if(isNaN(objValue.value)) 
            { 
              return false; 
            }
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              alert(strError);
              return false;                 
             }             
            break; 
        } 
        case "gt": 
        case "greaterthan": 
        { 
            if(isNaN(objValue.value)) 
            { 
              return false; 
            }
            if(eval(objValue.value) <=  eval(cmdvalue)) 
            { 
               alert(strError); 
               return false;                 
            }             
            break; 
        }        
        case "regexp": 
        { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              alert(strError);
	              return false;                   
	            } 
			}
           break; 
        } 
        case "dontselect": 
        { 
            if(objValue.selectedIndex == null) 
            { 
              return false;
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
              alert(strError);
              return false;                                   
            } 
            break; 
        }
        case "dategreaterthan":
        {
			var startSplit = objValue.value.split("-");
			var endSplit;
			var startDate = new Date(startSplit[0], parseInt(startSplit[1])-1, startSplit[2]);
			var tempDate = new Date();
			var endDate;
			
			if(cmdvalue != "")
			{
				endSplit = document.all[cmdvalue].value.split("-");
				endDate = new Date(endSplit[0], parseInt(endSplit[1])-1, endSplit[2]);
			}
			else
			{
				endDate = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate());
			}
			
			if(startDate <= endDate)
			{
				alert(strError);
				return false;
			}
			break;
        }
    }

    return true; 
}



//=============================================================================
// ÇÔ¼ö¸í: validateForm
// ¼³  ¸í: ÄÁÆ®·ÑÀÇ À¯È¿¼ºÀ» °Ë»ç validateData()¸¦ È£ÃâÇÏ¿© °Ë»çÇÑ´Ù.
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function validateForm(arrObjDesc) 
{ 

	for(var i=0; i < arrObjDesc.length; i++) 
	{
		for(var j=0; j < arrObjDesc[i].length ;j++) 
		{
			var objForm = document.all[arrObjDesc[i][j][0]];
			
			if(validateData(objForm, arrObjDesc[i][j][1], arrObjDesc[i][j][2]) == false) 
			{
				objForm.focus();
				event.returnValue = false;
				return false;				 
			}
		} 
	}
	return true;
}

//=============================================================================
// ÇÔ¼ö¸í: Popup 
// ¼³  ¸í: PopUp Ã¢ È£Ãâ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================

function PopUp(intStyle, intWidth, intHeight, strUrl) {
   var intLeft = 0, intTop = 0;
   var winstyle;            

   //Áß¾ÓÁ¤·Ä (½ºÅ©·Ñ¹Ù ¹«, »óÅÂÇ¥½ÃÁÙ ¹«)
   if (intStyle == 0) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      return window.open(strUrl, null, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }    
   //showModelessDialog
   else if (intStyle == 1) {
      winstyle = "dialogWidth=" + intWidth + "px; dialogHeight=" + intHeight + "px; center:yes; status=no; help:no; ";      
      return window.showModelessDialog(strUrl, window, winstyle); 
   }
   //showModalDialog
   else if (intStyle == 2) {
      winstyle = "dialogWidth=" + intWidth + "px; dialogHeight=" + intHeight + "px; center:yes; status=no; help:no; ";      
      return window.showModalDialog(strUrl, window, winstyle); 
   }
   //excel
   else if (intStyle == 3) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      return window.open(strUrl, null, 'menubar =1,resizable=1,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   //Áß¾ÓÁ¤·Ä (½ºÅ©·Ñ¹Ù À¯, »óÅÂÇ¥½ÃÁÙ ¹«)
   else if (intStyle == 4) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      return window.open(strUrl, null, 'menubar =0,resizable=0,scrollbars=1,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }
   //ÁÂÃø»ó´ÜÁ¤·Ä (½ºÅ©·Ñ¹Ù ¹«, »óÅÂÇ¥½ÃÁÙ ¹«)
   else if (intStyle == 5) {      
      
      return window.open(strUrl, null, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }   
   //Å×½ºÆ®¿ë (½ºÅ©·Ñ¹Ù À¯, »óÅÂÇ¥½ÃÁÙ À¯)   
   else if (intStyle == 99) {      
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      return window.open(strUrl, null, 'menubar =0,resizable=0,scrollbars=1,status=yes,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      
   }      
   
}  


//=============================================================================
// ÇÔ¼ö¸í: EnterProcOnKeyDown
// ¼³  ¸í: Enter Key Event¸¦ Tab Key Event·Î ÀüÈ¯
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function EnterProcOnKeyDown() { 
   if (event.keyCode == 13) {
      event.keyCode = 9;
   } 
}


//=============================================================================
// ÇÔ¼ö¸í: MM_preloadImages
// ¼³  ¸í: Mouse Over¿¡ ÀÇÇÑ ÀÌ¹ÌÁö ÀüÈ¯
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
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];}}
}


//=============================================================================
// ÇÔ¼ö¸í: MM_swapImgRestore
// ¼³  ¸í: Mouse Over¿¡ ÀÇÇÑ ÀÌ¹ÌÁö ÀüÈ¯
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
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;
}


//=============================================================================
// ÇÔ¼ö¸í: MM_findObj
// ¼³  ¸í: Mouse Over¿¡ ÀÇÇÑ ÀÌ¹ÌÁö ÀüÈ¯
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
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;
}


//=============================================================================
// ÇÔ¼ö¸í: MM_swapImage
// ¼³  ¸í: Mouse Over¿¡ ÀÇÇÑ ÀÌ¹ÌÁö ÀüÈ¯
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
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];}
}


//=============================================================================
// ÇÔ¼ö¸í: CheckSumIdnNo
// ¼³  ¸í: ÁÖ¹Î¹øÈ£ CheckSum È®ÀÎ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function CheckSumIdnNo(pStrIdnNo){
	var tmp = 0 
	var pStrIdnNo1 = pStrIdnNo.substring(0,6);
	var pStrIdnNo2 = pStrIdnNo.substring(6,13);
	
	if (pStrIdnNo2.substring(0, 1) == 5 || pStrIdnNo2.substring(0, 1) == 6)
	{
		return true;  
	}
	else
	{
		for (i = 0; i <=5 ; i++) { 
			tmp = tmp + ((i%8+2) * parseInt(pStrIdnNo1.substring(i,i+1))) 
		}     
		
		for (i = 6; i <=11 ; i++) { 
			tmp = tmp + ((i%8+2) * parseInt(pStrIdnNo2.substring(i-6,i-5))) 
		}     
		
		tmp = 11 - (tmp %11) 
		tmp = tmp % 10 	
		
		if (tmp != pStrIdnNo2.substring(6,7)) { 
			return false;  
		}else{
			return true;  
		}
	}	
}


//=============================================================================
// ÇÔ¼ö¸í: CheckIdnNo
// ¼³  ¸í: ÁÖ¹Î¹øÈ£ È®ÀÎ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function CheckIdnNo(pStrIdnNoObj1, pStrIdnNoObj2, pStrIdnNo1, pStrIdnNo2) {

	var arrFormValidationIdnNo =
	[
		[
			[pStrIdnNoObj1, "req", "ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä."],
			[pStrIdnNoObj1, "num", "ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®¸¦ È®ÀÎÇÏ¼¼¿ä."],
			[pStrIdnNoObj1, "maxlen=6", "ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â 6ÀÚ¸® ÀÔ´Ï´Ù."],
			[pStrIdnNoObj1, "minlen=6", "ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â 6ÀÚ¸® ÀÔ´Ï´Ù."],
			[pStrIdnNoObj2, "req", "ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®¸¦ ÀÔ·ÂÇÏ¼¼¿ä."],
			[pStrIdnNoObj2, "num", "ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®¸¦ È®ÀÎÇÏ¼¼¿ä."],										
			[pStrIdnNoObj2, "maxlen=7", "ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®´Â 7ÀÚ¸® ÀÔ´Ï´Ù."],
			[pStrIdnNoObj2, "minlen=7", "ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®´Â 7ÀÚ¸® ÀÔ´Ï´Ù."]

		]
	];
	
	if (validateForm(arrFormValidationIdnNo) == false)
	{
		return false;
	}
	if (CheckSumIdnNo(pStrIdnNo1+pStrIdnNo2) == false)
	{
		alert("ÁÖ¹Î¹øÈ£°¡ À¯È¿ÇÏÁö ¾Ê½À´Ï´Ù.");
		return false;
	}
	return true;
}


//=============================================================================
// ÇÔ¼ö¸í: ScrapFood
// ¼³  ¸í: ¸Þ´º ½ºÅ©·¦
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function ScrapFood(pstrFoodCd) {                               
	var url;

	if ((pstrFoodCd != "")) {
		url = "Food0000DetailPopupScrap.aspx?FOOD_CD=" + pstrFoodCd ;

		var temp;
		temp = PopUp(0, 350, 150, url);
		temp.focus();
	} 			   
}		


//=============================================================================
// ÇÔ¼ö¸í: SendMailFood
// ¼³  ¸í: ¸Þ´º ¸ÞÀÏ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function SendMailFood(pstrFoodCd, pstrGb) {                               
	if ((pstrFoodCd != "")) {
	
		if (pstrGb == "0") {	
			url = "../food/Food0000DetailPopupSendMailL.aspx?FOOD_CD=" + pstrFoodCd ;
		}
		if (pstrGb == "1") {	
			url = "../food/Food0000DetailPopupSendMailS.aspx?FOOD_CD=" + pstrFoodCd ;
		}

		var temp;
		temp = PopUp(4, 705, 600, url);
		temp.focus();
	} 			   
}

//=============================================================================
// ÇÔ¼ö¸í: ViewMailFood
// ¼³  ¸í: ¸Þ´º ¸ÞÀÏ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function ViewMailFood(pstrMailNo, pstrGb) {                               
	if ((pstrMailNo != "")) {
	
		if (pstrGb == "0") {	
			url = "../food/Food0000DetailPopupViewMailL.aspx?MAIL_NO=" + pstrMailNo ;
		}
		if (pstrGb == "1") {	
			url = "../food/Food0000DetailPopupViewMailS.aspx?MAIL_NO=" + pstrMailNo ;
		}

		var temp;
		temp = PopUp(4, 705, 600, url);
		temp.focus();
	} 			   
}

//=============================================================================
// ÇÔ¼ö¸í: PopupAgreement
// ¼³  ¸í: ÀÌ¿ë¾à°ü Popup
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupAgreement() {

	var strAgreement;
	
	strAgreement = window.open("../common/PopupAgreement.aspx","popupApplTip","width=490,height=710,scrollbars=no,resizable=no,top=0,left=0");	        	
	strAgreement.focus();

}

//=============================================================================
// ÇÔ¼ö¸í: PopupPersonal
// ¼³  ¸í: °³ÀÎº¸È£Á¤Ã¥ Popup
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupPersonal() {

	var strPersonal;
	
	strPersonal = window.open("../common/PopupPersonal.aspx","popupApplTip","width=490,height=710,scrollbars=no,resizable=no,top=0,left=0");	        	
	strPersonal.focus();

}

//=============================================================================
// ÇÔ¼ö¸í: PopupViewApplTip
// ¼³  ¸í: Áö¿ø¼­ÀÛ¼º¿ä·É Popup
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupViewApplTip() {

	var strApplTip;
	
	strApplTip = window.open("","popupApplTip","width=604,height=407,scrollbars=no,resizable=no,top=0,left=0");	        
	strApplTip.document.write("<title>T.G.I. FRiDAY'S!</title><body leftmargin=0 topmargin=0><img src='../../image/company_4050_popup_010.gif' border=0 style=cursor:hand; onClick=self.close();></body>");		
	
	strApplTip.focus();

}


//=============================================================================
// ÇÔ¼ö¸í: 
// ¼³  ¸í: ·¹ÀÌ¾î ÀÛ¾÷
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


//=============================================================================
// ÇÔ¼ö¸í: PopupEvent
// ¼³  ¸í: ÀÌº¥Æ®, °øÁö Popup
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupEvent(pstrUrl, pstrNm, pstrWindowType, pstrPublicYn) {
	var objWindow;	
	
	if (pstrPublicYn == "0")
	{
		if (document.all.txtLoginYn.value != "1")
		{
			alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
			return;						
		}
	}			
	
	objWindow = window.open(pstrUrl + "?CD=" + pstrNm, pstrNm, pstrWindowType);	        	
	objWindow.focus();
}


//=============================================================================
// ÇÔ¼ö¸í: CheckEmail
// ¼³  ¸í: ÀÌ¸ÞÀÏ ÁÖ¼Ò °Ë»ç
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function CheckEmail( strValue )
{

	if ( strValue.search(/(\S+)@(\S+)\.(\S+)/) == -1 ) {
	    return false;    
	}

	return true;

} 


//=============================================================================
// ÇÔ¼ö¸í: Trim
// ¼³  ¸í: ³Ñ¾î¿Â ¹®ÀÚ¿­µéÁß¿¡ Æ÷ÇÔµÈ °ø¹éÀ» ¸ðµÎ ¾ø¾Ø ¹®ÀÚ¿­À» ¸®ÅÏ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function Trim(strings)
{
    var retString = "";
    var c;
    var i;
    for(i=0;i<strings.length;i++) {
        c = strings.charAt(i);
        if(c != ' '){
           retString += c;
        }
    }
    return(retString);
}

//=============================================================================
// ÇÔ¼ö¸í: ReplaceStr
// ¼³  ¸í: ¹®ÀÚ¿­ Ä¡È¯ Popup
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================

function ReplaceStr(strOriginal, strFind, strChange)
{
  return strOriginal.split(strFind).join(strChange);
}


//=============================================================================
// ÇÔ¼ö¸í: isDate
// ¼³  ¸í: ³¯Â¥ À¯È¿¼º
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function isDate(yyyy,mm,dd)
{
   if (yyyy.length != 4)
      return false;
   else {   
      yyyy=parseInt(yyyy,10);
      mm=parseInt(mm,10);
      dd=parseInt(dd,10);
      d = new Date(yyyy,mm-1,dd);
      if (d=="NaN") return false;
      if (yyyy == d.getFullYear() &&
         mm == d.getMonth()+1 &&
         dd == d.getDate() ) return true;
      return false;
   }   
}


//=============================================================================
// ÇÔ¼ö¸í: isDate_yyyy_m_d
// ¼³  ¸í: yyyy-mm-dd ÇüÅÂ À¯È¿¼º
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function isDate_yyyy_m_d(s)// yyyy-mm-dd ÇüÅÂ
{
   s=s.replace(/\s/g,""); // °ø¹éÁ¦°Å
   if (s.match(/\d+\-\d+\-\d+/g)!=s) 
      return false; // 1111-11-11 Æ÷¸ËÀÌ ¾Æ´Ô
   var d = s.split(/\-/g);
   return isDate(d[0],d[1],d[2]);
}


//=============================================================================
// ÇÔ¼ö¸í: checkDate
// ¼³  ¸í: yyyy-mm-dd ÇüÅÂ ³¯Â¥ À¯È¿¼º
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function checkDate(s)
{
   var isD

   isD=isDate_yyyy_m_d(s);
   if (isD) 
      return true;
   else
      return false;
}


//=============================================================================
// ÇÔ¼ö¸í: correctDate
// ¼³  ¸í: yyyy-mm-dd ÇüÅÂ ³¯Â¥
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function correctDate(s)// yyyy-mm-dd ÇüÅÂ
{
   s=s.replace(/\s/g,""); // °ø¹éÁ¦°Å
   var d = s.split(/\-/g);
   if (d[1].length == 1)
      d[1] = "0" + d[1];
   if (d[2].length == 1)
      d[2] = "0" + d[2];  
   return d[0] + "-"  + d[1] + "-" + d[2];
}



//=============================================================================
// ÇÔ¼ö¸í: PopupViewCompanyLink
// ¼³  ¸í: °ü°è»ç¸µÅ© ÆË¾÷
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupViewCompanyLink() {

	var strUrl;
	var temp;
					
	strUrl = "../common/PopupCompanyLink.aspx";
	temp = PopUp(0, 530, 422, strUrl);
	temp.focus();
	
}


//=============================================================================
// ÇÔ¼ö¸í: GoHome
// ¼³  ¸í: È¨ÆäÀÌÁö ÃÊ±âÈ­¸éÀ¸·Î ÀÌµ¿
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function GoHome() {
	
	parent.location = "../common/index.aspx" ;
	
}

//=============================================================================
// ÇÔ¼ö¸í: GoStart
// ¼³  ¸í: ÁÂÃø¸Þ´ºÀÇ ÃÊ±âÈ­¸éÀ¸·Î ÀÌµ¿
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function GoStart(pStrGroup, pStrNo) {
	
	var strUrl;
	
	// COMPANY : È¸»ç¼Ò°³
	if (pStrGroup == "COMPANY")
	{
		if  (pStrNo == "1")
			strUrl = "../company/Company1010.aspx" ;
		else if (pStrNo == "2")
			strUrl = "../company/Company2000.aspx" ;
		else if (pStrNo == "3")
			strUrl = "../company/Company3000.aspx" ;
		else if (pStrNo == "4")
			strUrl = "../company/Company4010.aspx" ;
	
	}
	
	// FOOD : ¸Þ´º
	else if (pStrGroup == "FOOD")
	{
		if  (pStrNo == "1")
			strUrl = "../food/Food1000.aspx" ;
		else if (pStrNo == "2")
			strUrl = "../food/Food1000.aspx" ;
		else if (pStrNo == "3")
			strUrl = "../food/Food1000.aspx" ;
		
	}
	
	// STORE : ¸ÅÀå
	else if (pStrGroup == "STORE")
	{
		if  (pStrNo == "1")
			strUrl = "../store/Store1010.aspx" ;	
	}
	
	// MEMBERSHIP : ¸â¹ö½±
	else if (pStrGroup == "MEMBERSHIP")
	{
		if  (pStrNo == "1")
			strUrl = "../membership/Membership1000.aspx" ;
		else if (pStrNo == "2")
			strUrl = "../need_login/Membership2010.aspx" ;
		else if (pStrNo == "3")
			strUrl = "../membership/Membership3010.aspx" ;
		else if (pStrNo == "4")
			strUrl = "../membership/Membership4010.aspx" ;	
		else if (pStrNo == "5")
			strUrl = "../membership/Membership5010.aspx" ;	
	}
	
	// EVENTS : ÀÌº¥Æ®
	else if (pStrGroup == "EVENTS")
	{
		if  (pStrNo == "1")
			strUrl = "../events/Events1000.aspx" ;
		else if (pStrNo == "2")
			strUrl = "../events/Events2000.aspx" ;
		else if (pStrNo == "3")
			strUrl = "../events/Events3000.aspx" ;
		else if (pStrNo == "4")
			strUrl = "../events/Events4000.aspx" ;	
		else if (pStrNo == "5")
			strUrl = "../events/Events5010.aspx" ;	
		else if (pStrNo == "6")
			strUrl = "../customer/Customer4000.aspx" ;	
	
	}
	
	// CUSTOMER : °í°´ÀÇ¼Ò¸®
	else if (pStrGroup == "CUSTOMER")
	{
		if  (pStrNo == "1")
			strUrl = "../customer/Customer1000.aspx" ;
		else if (pStrNo == "2")
			strUrl = "../customer/Customer2000.aspx" ;
		else if (pStrNo == "3")
			strUrl = "../customer/Customer3000.aspx" ;
		else if (pStrNo == "4")
			strUrl = "../customer/Customer6000.aspx" ;			
	}
	
	
	else if (pStrGroup == "COMMON")
	{
	
	
	}
	
	else 
	{
		strUrl = "about:blank";
	}	
	
	parent.location = strUrl ;
	
}

//=============================================================================
// ÇÔ¼ö¸í: GoPage
// ¼³  ¸í: Page ÀÌµ¿
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function GoPage(pStrPageNm) {
	
	parent.location = pStrPageNm ;
	
}

//=============================================================================
// ÇÔ¼ö¸í: SetIframeHeight
// ¼³  ¸í: Iframe ³ôÀÌ ¼³Á¤
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function SetIframeHeight() {
		
	parent.document.all.Iframe1.height = document.body.scrollHeight; 
	
}

//=============================================================================
// ÇÔ¼ö¸í: cmbSubCompanyLink_Onchange
// ¼³  ¸í: Sub Page ÇÏ´ÜÀÇ ·Ôµ¥ °è¿­»ç ¸µÅ© 
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================

function cmbSubCompanyLink_Onchange() {	
	window.open(document.all.BottomCopyright1_cmbCompanyLink.value);
}			 						

//=============================================================================
// ÇÔ¼ö¸í: CheckLogin
// ¼³  ¸í: ·Î±×ÀÎ Ã¼Å©
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function CheckLogin() {
	if (document.all.txtLoginYn.value != "1")
	{
		alert("·Î±×ÀÎÀ» ÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
		return false;						
	}
	else
	{
		return true;
	}	
}


//=============================================================================
// ÇÔ¼ö¸í: getCookie
// ¼³  ¸í: ÄíÅ°°ªÀ» °¡Á®¿À´Â ÇÔ¼ö 
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function getCookie(name) { 
   var from_idx = document.cookie.indexOf(name+'='); 
   if (from_idx != -1) { 
      from_idx += name.length + 1 
      to_idx = document.cookie.indexOf(';', from_idx) 

      if (to_idx == -1) { 
            to_idx = document.cookie.length 
      } 
      return unescape(document.cookie.substring(from_idx, to_idx)) 
   } 
} 


//=============================================================================
// ÇÔ¼ö¸í: setCookie
// ¼³  ¸í: ÄíÅ° »ý¼º ÇÔ¼ö
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function setCookie(name, value, expire) { 
    var expire_date = new Date(expire) 
    document.cookie = name + "=" + escape(value) + "; expires=" + expire_date.toGMTString(); 
} 


//=============================================================================
// ÇÔ¼ö¸í: clearCookie
// ¼³  ¸í: ÄíÅ° ¼Ò¸ê ÇÔ¼ö
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function clearCookie(name) { 
    var today = new Date() 
    //¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù. 
    var expire_date = new Date(today.getTime() - 60*60*24*1000) 
    document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() 
} 


//=============================================================================
// ÇÔ¼ö¸í: controlCookie
// ¼³  ¸í: Ã¼Å© »óÅÂ¿¡ µû¶ó ÄíÅ° »ý¼º°ú ¼Ò¸êÀ» Á¦¾îÇÏ´Â ÇÔ¼ö 
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function controlCookie(elemnt, name) { 
        if (elemnt.checked) { 
            var today = new Date() 
    		var expire_date = new Date(today.getTime() + 60*60*24*1000) 
            
            //Ã¼Å© ¹Ú½º¸¦ ¼±ÅÃÇßÀ» °æ¿ì ÄíÅ° »ý¼º ÇÔ¼ö È£Ãâ 
        	setCookie(name, "true", expire_date) 
        } 
        else { 
        	//Ã¼Å© ¹Ú½º¸¦ ÇØÁ¦ÇßÀ» °æ¿ì ÄíÅ° ¼Ò¸ê ÇÔ¼ö È£Ãâ 
            clearCookie(name) 
        } 
        return 
} 


//=============================================================================
// ÇÔ¼ö¸í: PopupViewPlaceStore
// ¼³  ¸í: Á¡Æ÷¼Ò°³ ¾È³» ÆË¾÷
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function PopupViewPlaceStore() {

	var strUrl;
	var temp;
					
	strUrl = "../common/PopupPlaceStore.aspx";
	temp = PopUp(0, 641, 505, strUrl);
	temp.focus();
	
}

//=============================================================================
// ÇÔ¼ö¸í: PopupViewFridaysCardForm
// ¼³  ¸í: ÇÁ¶óÀÌµ¥ÀÌÁîÄ«µå½ÅÃ»¼­ ÆË¾÷
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================

function PopupViewFridaysCardForm() {

	var strUrl;
	var temp;
					
	strUrl = "../common/PopupContract.aspx";
	temp = PopUp(0, 560, 680, strUrl);
	temp.focus();
	
}


//=============================================================================
// ÇÔ¼ö¸í: PopupViewFridaysCardForm
// ¼³  ¸í: È¸¿øÃ¼Å© Æ÷Ä¿½º ÀÌµ¿
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function moveFocus(num,fromform,toform){
	var str = fromform.value.length;
	if(str == num)
		toform.focus();
}



//=============================================================================
// ÇÔ¼ö¸í: GetFormatDate(strDate)
// ¼³  ¸í: ³¯ÀÚÇü½ÄÆ÷¸ä
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function GetFormatDate(strDate) { 
   var strFormatDt;

   if (strDate)
      strFormatDt = strDate.substring(0, 4) + '-' + strDate.substring(4, 6) + '-' + strDate.substring(6, 8);
   else   
      strFormatDt = "";
   return strFormatDt;
}


//=============================================================================
// ÇÔ¼ö¸í: DeleteSpace(string)
// ¼³  ¸í: °ø¹éÁ¦°Å
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function DeleteSpace(source) {
   var i = 0;
   var str_temp = "";

   for (i = 0; i < source.length; i++)
      if (source.substring(i, i + 1) != " ")
         str_temp += source.substring(i , i + 1) 
   return str_temp ;
}

//--------------------------------------------------------------------------------------//
// Description  : a function for MS IE ActiveX Rollup Patch                             //
// Parameter    : id                                                                    //
// Example  :                                                                           //
// Etc      :                                                                           //
//--------------------------------------------------------------------------------------//
function __WS__(id)
{
 document.write(id.text); id.id="";
} 




/* ¾÷·Îµå ÆË¾÷ È£Ãâ */
function PopUpUpload(intWidth, intHeight, strUrl) {
      var intLeft = 0, intTop = 0;
    
      intLeft = screen.width/2-intWidth/2;
      intTop = screen.height/2-intHeight/2;
      
      return window.open(strUrl, null, 'menubar =0,resizable=0,scrollbars=0,status=no,titlebar=0,toolbar=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop);      

}


//=============================================================================
// ÇÔ¼ö¸í: 
// ¼³  ¸í: 
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ: 
//=============================================================================
function newpages(sel)
			{
			  var URL = sel.options[sel.selectedIndex].value;
				if (URL != "" && URL != null){
					popup = window.open(URL,'');
				}
			}
			
			
			
//=============================================================================
// ÇÔ¼ö¸í: scroll
// ¼³  ¸í: ¿À¸¥ÂÊ µû¶ó´Ù´Ï´Â ½ºÅ©·Ñ
// ÀÛ¾÷ÀÏ: 
// ÀÛ¾÷ÀÚ:
//=============================================================================


function scroll(){
    var a=document.body.scrollTop+340
    menu.style.top=a;
}

