//정수입력(마이너스포함)
function keyInteger(el){
	var cquantity, cunit, cr_money;
	el.value=stripCommas(el.value);
     if(!el.value.match(/^(\-){0,1}[1-9]{1}\d*$/g)){//현재 포커스 텍스트에서 정수인지 체크
	 	el.value='';//정수가 아니면 삭제
	 }

	}
function addCommas(strValue){
var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
   while(objRegExp.test(strValue)) {
   strValue = strValue.replace(objRegExp, '$1,$2');
   }
return strValue;
}

function stripCommas(strValue){
var objRegExp = new RegExp('(-?[0-9]+)(\,+)([0-9]{3})');
   while(objRegExp.test(strValue)) {
   strValue = strValue.replace(objRegExp, '$1$3');
   }
return strValue;
}


function doBlink(){
	var blink = document.all.tags("BLINK");
	for(i=0;i<blink.length;i++)
		blink[i].style.visibility= blink[i].style.visibility=="" ? "hidden" : "";
}
function startBlink(){

	if(document.all){
	setInterval("doBlink()",500);
	}
}
window.onload = startBlink;
//확장자 체크하기.. 있으면 true 리턴
function extCheck(filename) {
  if (filename.match(/\.(php|jsp|html|htm|cgi|php3|php4|inc)$/i)) return true;
  return false;
}
// token  인자1:문자열, 인자2: 자를 기준문자 (특수문자), 인자3: 잘려진 문자에서 처음, 이나 두번째 (예1, 2)
// 재우 추가 2003.03.12 나중에 수정요망..

function token(str_source, token_str, fs_sel)
{
	var strlen = str_source.length;
	var rcvToken = "";
	var rcvToken1 = "";
	var flag=0;
	for ( i=0; i < strlen ; i++){
	  chr = str_source.substring(i,i+1);
	  if (chr == token_str) {
	    flag=1;
	  } else {
	    if(flag==1)  { rcvToken1 = rcvToken1 + chr;} else {rcvToken = rcvToken + chr;}
	  }
	}
	if(fs_sel=="2") return rcvToken1; else return rcvToken;
}

function trim(strTrim)
{
	strlen = strTrim.length;
	rcvTrim = "";

	for ( i=0; i < strlen ; i++){
	  chr = strTrim.substring(i,i+1);
	  if (chr == " ") {
	    rcvTrim = rcvTrim;
	  } else {
	    rcvTrim = rcvTrim + chr;
	  }
	}

	return rcvTrim;
}
// 달력입니다..
function search_calendar(v_from_cal_gubun){

	var thref;
	thref = "/calendar/calendar.php";
	thref = thref + "?" + "v_from_cal_gubun=" + v_from_cal_gubun;
	var myWin = window.open(thref,"calendar","width=300,height=200,left=100,top=100,resizable=no,scrollbars=no");
	myWin.focus();

}

// 상품 상세에서 그림 바꿔보여주기 2002.11.28일 재우
function show_layer(tlayer)
{
 if(tlayer=='layer1'){
 	layer1.style.display='block';
 	layer2.style.display='none';
 	layer3.style.display='none';
 	layer4.style.display='none';
 	layer5.style.display='block';
 	layer6.style.display='none';
 	layer7.style.display='none';
 	layer8.style.display='none';
 }
 if(tlayer=='layer2'){
 	layer1.style.display='none';
 	layer2.style.display='block';
 	layer3.style.display='none';
 	layer4.style.display='none';
 	layer5.style.display='none';
 	layer6.style.display='block';
 	layer7.style.display='none';
 	layer8.style.display='none';
 }
 if(tlayer=='layer3'){
 	layer1.style.display='none';
 	layer2.style.display='none';
 	layer3.style.display='block';
 	layer4.style.display='none';
 	layer5.style.display='none';
 	layer6.style.display='none';
 	layer7.style.display='block';
 	layer8.style.display='none';
 }
 if(tlayer=='layer4'){
 	layer1.style.display='none';
 	layer2.style.display='none';
 	layer3.style.display='none';
 	layer4.style.display='block';
 	layer5.style.display='none';
 	layer6.style.display='none';
 	layer7.style.display='none';
 	layer8.style.display='block';

 }
}
// 상품평하기 창 2002.11.29 재우
function cust_qna(pro_code)
	{
		var theURL = "/admin/cust/cust_qna_new.php?pro_code="+pro_code;
		var winName = "cust_review";
		var features = "width=500,height=450";
		window.open(theURL,winName,features);
	}

// 상품평하기 창 2002.11.23 재우
function cust_review(pro_code)
	{
		var theURL = "/admin/cust/cust_review_new.php?pro_code="+pro_code;
		var winName = "cust_review";
		var features = "width=500,height=450";
		window.open(theURL,winName,features);
	}
// 주문수량 +1-1 하기 2002.11.23 재우
function upamt(objform)
	{
		eval(objform).value = parseInt(eval(objform).value) + 1;
	}

// 주문수량 +1-1 하기 2002.11.23
function downamt(objform)
	{
		var tmpCnt = parseInt(eval(objform).value);
		if(tmpCnt>1) {
			eval(objform).value = tmpCnt - 1;
		}
	}
function  go_url(gourl)
{
 location.href=(gourl);
}
function  open_win( url, name, w, h )
{
    var winname = window.open( url, name, "scrollbars=no,resizable=no,width="+w+",height="+h+"top=100,left=100");
}
//재우 수정
function  open_win2( url, name, w, h, t, l )
{
    var winname = window.open( url, name, "menubar=yes,scrollbars=yes,resizable=yes,width="+w+",height="+h+",top="+t+",left="+l);
}
function view(name,num) {
	for(i=0;i<document.all[name].length;i++)	{
		if(i==parseInt(num-1))
		document.all[name][i].style.visibility="visible";
	else
		document.all[name][i].style.visibility="hidden";
		}
}
function init() {
	if(document.all["layer"]!=null)	{
	for(i=1;i<document.all["layer"].length;i++)
		document.all["layer"][i].style.visibility="hidden";
	}
}

function pwd_keypress()
{
	if(event.keyCode==13)
	{
		login();
	}
}
function goPop(gourl,wid,hei)
{
	window.open(gourl,'','width=' + wid + ',height=' + hei + ',scrollbars=no');
}
//----------------------------------- 필드(String) 내용 관련 함수  -----------------------------------

/******************************
*  기능 :  문자열 Valid 검사처리 *
*  수정일 : 2002-01-25              *
*  parameter : string, space  *
*******************************/
function CheckChar(String, space)
{

   var retvalue = false;

   for (var i=0; i<String.length; i++)
   {		//String이 0("" 이나 null)이면 무조건 false
      if (space == true)
      {
         if (String.charAt(i) == ' ')
         {			//String이 0이 아닐때 space가 있어야만 true(valid)
            retvalue = true;
            break;
         }
      } else {
         if (String.charAt(i) != ' ')
         {			//string이 0이 아닐때 space가 아닌 글자가 있어야만 true(valid)
            retvalue = true;
            break;
         }
      }
   }
   return retvalue;
}

function isNoSelect(Field, error_msg)
{
	if(error_msg == "") {
		if(!CheckChar(field.value, false)) 	{
			return true;
		} else {
			return false;
		}
	}else {
		if(Field.selectedIndex==0) {
			alert(error_msg);
			Field.focus() ;
			return true;
		} else {
			return false;
		}
	}
}
// 공백인가 검사
function isEmpty(field, error_msg)
{

	// error_msg가 ""이면 alert와 focusing을 하지 않는다
	if(error_msg == "") {
		if(!CheckChar(field.value, false)) 	{
			return true;
		} else {
			return false;
		}
	} else {
		if(!CheckChar(field.value, false)) {
			alert(error_msg);
			field.focus() ;
			return true;
		} else {
			return false;
		}
	}
}
// 공백인가 검사
function isEmptyNofocus(field, error_msg)
{

	// error_msg가 ""이면 alert와 focusing을 하지 않는다
	if(error_msg == "") {
		if(!CheckChar(field.value, false)) 	{
			return true;
		} else {
			return false;
		}
	} else {
		if(!CheckChar(field.value, false)) {
			alert(error_msg);
			return true;
		} else {
			return false;
		}
	}
}

function isNotSet(field, error_msg)
{
	//for hidden field....
	if(field.value == "")
	{
		alert(error_msg);
		return true;
	} else
	{
		return false;
	}
}

function haveSpace(field, error_msg)
{
	if(CheckChar(field.value, true))
	{
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}


function isNotNumber(field, error_msg)
{
	var val = field.value;

	if(isNaN(val) ) {
		if(error_msg.length > 0) {
			alert(error_msg);
			field.focus();
			field.select();
		}
		return true;
	} else {
		return false;
	}
}

/******************************
*  기능 :  NumberCheck And Empty Check
*  수정일 : 2002-04-02(denial)
*  parameter : field, error_msg
*******************************/
function isNotNumberOrEmpty(field, error_msg)
{
	var val = field.value;

	if(val.length == 0 || isNaN(val) ) {
		if(error_msg.length > 0) {
			alert(error_msg);
			field.focus();
			field.select();
		}
		return true;
	} else {
		return false;
	}
}

function alertAndFocus(field, error_msg)
{
	alert(error_msg);
	field.focus();
	field.select();
}

/***************************************
*  기능 : String 알파벳과 숫자만~ Check  *
*  수정일 : 2002-01-25                           *
*  parameter : Form                              *
****************************************/
function isNotAlphaNumeric(field,error_msg)
{

   for (var i=0; i < field.value.length; i++)
   {
      if ( ( (field.value.charAt(i) < "0") || (field.value.charAt(i) > "9") ) &&
           ( ( (field.value.charAt(i) < "A") || (field.value.charAt(i) > "Z") ) &&
             ( (field.value.charAt(i) < "a") || (field.value.charAt(i) > "z") ) ) )
	  {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
	   }
   }

   return false;
}



// 필드(String) 길이 관련
function strLength(field)
{

   var Length = 0;

   var Nav = navigator.appName;
   var Ver = navigator.appVersion;

   var IsExplorer = false;

   var ch;

   if ( (Nav == 'Microsoft Internet Explorer') && (Ver.charAt(0) >= 4) )
   {
      IsExplorer = true;
   }

   if(IsExplorer)
   {

      for(var i = 0 ; i < field.value.length; i++)
      {

         ch = field.value.charAt(i);

         if ((ch == "\n") || ((ch >= "ㅏ") && (ch <= "히")) ||
             ((ch >="ㄱ") && (ch <="ㅎ")))
		{
	    	Length += 2;
		} else
		{
	    	Length += 1;
       	}

	  }

   }else {
      Length = field.value.length ;
   }

   return Length;
}

/****************************************
*  기능 : 문자열 길이제한                          *
*  수정일 : 2002-01-25                              *
*  parameter : field, min, max, error_msg  *
*****************************************/
function isOutOfRange(field, min, max, error_msg)
{
	if(strLength(field) < min || strLength(field) > max)
	{
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}

function isNotExactLength(field, len, error_msg) {
	if(strLength(field) != len) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}

function isOutOfNumericRange(field, min, max, error_msg) {
	if(field.value < min || field.value > max) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}
//---------------//



/****************************************
 Select Box 선택여부 검사            *
*****************************************/

function isNotSelected(field, error_msg) {
	if(field.selectedIndex == 0) {
		alert(error_msg);
		field.focus() ;
		return true;
	} else {
		return false;
	}
}

/******************************
*  Radio Button Check    *
*******************************/
function isNotCheckedRadio(field, error_msg) {
	if ( field == null ) {
		alert(error_msg);
		return true;
	}

	if ( field.length == null ) {
		if ( field.checked == true ) {
			return false;
		} else {
			alert(error_msg);
			return true;
		}
	}

	for(i = 0; i < field.length; i++) {
		if(field[i].checked == true) {
			return false;
		}
	}
	alert(error_msg);
	return true;
}
//---------------//

/**
 * Radio Button을 선택해제한다
 */
function uncheckRadio(field) {
	for(i = 0; i < field.length; i++) {
		field[i].checked = false;
	}
}

/**
 * Radio Button의 선택된 값을 가져온다
 */
function getRadioVal(field) {
	for(i = 0; i < field.length; i++) {
		if(field[i].checked == true)
			return field[i].value;
	}
	return "";
}

//------------------------------------- 특정 필드 관련 함수 ---
function checkDujumin(id)
{
	if(isEmpty(id, "ID를 기입해 주세요!")) return true;
	if(isNotAlphaNumeric(id,"ID는 4~10자 사이의 숫자 및 영문 대소문자로만 기입해 주세요!")) return true;
	//if(isOutOfRange(id,4, 10, "ID는 한글 2자~5자, 영문 4~10자 이내로 기입해 주세요!")) return true;
}

function checkName(name)
{
	if(isEmpty(name, "사용자명을 기입해 주세요!")) return true;
}

/*******************************
*  기능 : 비밀번호 Check            *
*  수정일 : 2002-01-25                *
*  parameter : Form                  *
*******************************/
function isNotValidPassword(form) {

	if(isEmpty(form.password,"패스워드를 입력해 주세요!")) return true;
	if(isEmpty(form.password2,"패스워드를 재입력해 주세요!")) return true;
	if(isNotAlphaNumeric(form.password,"비밀번호는 4~10자 사이의 숫자 및 영문 대소문자로만 기입해 주세요!")) return true;
	if(isNotAlphaNumeric(form.password2,"비밀번호는 4~10자 사이의 숫자 및 영문 대소문자로만 기입해 주세요!")) return true;
	if(isOutOfRange(form.password, 4, 10, "비밀번호는 4~10자 사이의 숫자 및 영문 대소문자로만 기입해 주세요!")) return true;
	if(isOutOfRange(form.password2, 4, 10, "비밀번호는 4~10자 사이의 숫자 및 영문 대소문자로만 기입해 주세요!")) return true;
	if(form.password.value != form.password2.value) {
		alert("비밀번호가 서로 일치하지 않습니다.\n 다시 입력해 주세요!");
		form.password.value="";
		form.password2.value="";
		form.password.focus();
		form.password.select();
		return true;
	}
	return false;
}

/******************************
*  기능 : 주민등록번호 Check     *
*  수정일 : 2002-01-25               *
*  parameter : Form                  *
*******************************/
function isNotValidjumin(form) {

	if(isEmpty(form.regNum1,"주민등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.regNum2,"주민등록번호를 입력해 주세요!")) return true;
	if(isNotNumber(form.regNum1,"주민등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.regNum2,"주민등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(form.regNum1, 6, "주민등록번호 앞자리는 6자리입니다!")) return true;
	if(isNotExactLength(form.regNum2, 7, "주민등록번호 뒷자리는 7자리입니다!")) return true;
	strchr = form.regNum1.value.concat(form.regNum2.value);
	if (strchr.length == 13	) {
		nlength = strchr.length;

		num1 = strchr.charAt(0);
		num2 = strchr.charAt(1);
		num3 = strchr.charAt(2);
		num4 = strchr.charAt(3);
		num5= strchr.charAt(4);
		num6 = strchr.charAt(5);
		num7 = strchr.charAt(6);
		num8 = strchr.charAt(7);
		num9 = strchr.charAt(8);
		num10 = strchr.charAt(9);
		num11 = strchr.charAt(10);
		num12 = strchr.charAt(11);

		var total = (num1*2)+(num2*3)+(num3*4)+(num4*5)+(num5*6)+(num6*7)+(num7*8)+(num8*9)+(num9*2)+(num10*3)+(num11*4)+(num12*5);
		total = (11-(total%11)) % 10;
	//	if (total == 11) total = 1;
	//	if (total == 10) total = 0;

		if(total != strchr.charAt(12)) {
			alert("주민등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
			form.regNum1.value="";
			form.regNum2.value="";
			form.regNum1.focus();
			return true;
		}
		return false;
	}	else
		alert("주민등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		form.regNum1.value="";
		form.regNum2.value="";
		form.regNum1.focus();
		return true;
}
/******************************
*  기능 : 사업자등록번호 Check  *
*  수정일 : 2002-01-25               *
*  parameter : Form                  *
*******************************/
function isNotValidBID(form) {

	if(isEmpty(form.bid1,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.bid2,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.bid3,"사업자등록번호를 입력해 주세요!")) return true;
	if(isNotNumber(form.bid1,"사업자등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.bid2,"사업자등록번호 가운데자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.bid3,"사업자등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(form.bid1, 3, "사업자등록번호 앞자리는 3자리입니다!")) return true;
	if(isNotExactLength(form.bid2, 2, "사업자등록번호 뒷자리는 2자리입니다!")) return true;
	if(isNotExactLength(form.bid3, 5, "사업자등록번호 뒷자리는 5자리입니다!")) return true;
	//strchr = form.bid1.value.concat(form.bid2.value.concat(form.bid3.value));

	//num1 = strchr.charAt(0);
	//num2 = strchr.charAt(1);
	//num3 = strchr.charAt(2);
	//num4 = strchr.charAt(3);
	//num5= strchr.charAt(4);
	//num6 = strchr.charAt(5);
	//num7 = strchr.charAt(6);
	//num8 = strchr.charAt(7);
	//num9 = strchr.charAt(8);
	//num10 = strchr.charAt(9);

	//var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	//total = total + ((num9 * 5) / 10);
	//var tmp = total % 10;
	//if(tmp == 0) {
	//	var num_chk = 0;
	//} else {
	//	var num_chk = 10 - tmp;
	//}

	//if(num_chk != num10) {
	//	alert("사업자등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		//form.bid1.value="";
		//form.bid2.value="";
		//form.bid3.value="";
		//form.bid1.focus();
		//return true;
	//}
	return false;
}
/******************************
*  기능 :  E-Mail Check            *
*  수정일 : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/
function isNotValidEmail(field)
{
   var checkflag = true;
   var retvalue;

   if(field.value == "") {
	   retvalue = true;
   } else {

	   if (window.RegExp) {
		  var tempstring = "a";
		  var exam = new RegExp(tempstring);
		  if (tempstring.match(exam)) {
			 var ret1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			 var ret2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			 retvalue = (!ret1.test(field.value) && ret2.test(field.value));
		  } else {
			 checkflag = false;
		  }
	   } else {
		  checkflag = false;
	   }

	   if (!checkflag) {
		  retvalue = ( (field.value != "") && (field.value.indexOf("@")) > 0 && (field.value.index.Of(".") > 0) );
	   }

   }
   if(retvalue) { return false;
   } else {
		alert("이메일 주소가 정확하지 않습니다. \n다시 입력해 주세요!");
		field.focus();
		field.select();
		return true;
   }
}

function isNotValidEmailNofocus(field)
{
   var checkflag = true;
   var retvalue;

   if(field.value == "") {
	   retvalue = true;
   } else {

	   if (window.RegExp) {
		  var tempstring = "a";
		  var exam = new RegExp(tempstring);
		  if (tempstring.match(exam)) {
			 var ret1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			 var ret2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			 retvalue = (!ret1.test(field.value) && ret2.test(field.value));
		  } else {
			 checkflag = false;
		  }
	   } else {
		  checkflag = false;
	   }

	   if (!checkflag) {
		  retvalue = ( (field.value != "") && (field.value.indexOf("@")) > 0 && (field.value.index.Of(".") > 0) );
	   }

   }
   if(retvalue) { return false;
   } else {
		alert("이메일 주소가 정확하지 않습니다. \n다시 입력해 주세요!");
		return true;
   }
}

/******************************
*  기능 :  TelNumber Check      *
*  수정일 : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/
function isNotValidTel(field) {

   var Count;
   var PermitChar =
         "0123456789-";

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert("전화번호가 정확하지 않습니다. \n다시 입력해 주세요!")
		 field.focus();
		 return true;
         break;
      }
   }
   return false;
}
//---------------//


function isNotValidChar(field,error_msg) {

   var Count;
   var PermitChar = "0123456789-";  // 허용가능한 문자들을 모두 기록한다.

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
         break;
      }
   }
   return false;
}

function isNotValidChar2(field,error_msg) {

   var NotPermitChar = "\"";  //허용되어서는 안되는 문자들을 모두 기록한다.
//   var NotPermitChar = "<>\"^&|'\\ ";  //허용되어서는 안되는 문자들을 모두 기록한다.

   if(field.value == "") return false;
   for (var i = 0; i < field.value.length; i++) {
      for (var j = 0; j < NotPermitChar.length; j++) {
         if(field.value.charAt(i) == NotPermitChar.charAt(j)) {
            ans = confirm(error_msg);
			if(ans == true) {
				return false;
			} else {
				field.focus();
				field.select();
				return true;
			}
         }
      }
   }
   return false;
}

function auto_fill_birth(jumin1) {

	var year = jumin1.value.substr(0,2);
	var month = jumin1.value.substr(2,2);
	var date = jumin1.value.substr(4,2);
	document.forms[0].year.value = year;
	document.forms[0].month.value = month;
	document.forms[0].date.value = date;

}

function hide_in(field) {
	if(field.value == field.defaultValue) field.value = "";
}
function show_out(field) {
	if(field.value == "") field.value = field.defaultValue;
}

function checkNumber(objname)
{
	var intErr = 1;
	var strValue = objname.value;
	var retCode = 0;

	for(i = 0; i < strValue.length; i++)
	{
		var retCode = strValue.charCodeAt(i);
		var retChar = strValue.substr(i, 1).toUpperCase();

		retCode = parseInt(retCode);

		// "3.4"도 숫자이다.
		if(!((retChar >= "0" && retChar <= "9") || retChar == "."))
		{
			intErr = 0; // break;
		}
	}

	var periodCnt = 0;

	while(strValue.indexOf(".") != -1)
	{
		periodCnt++;

		strValue = strValue.substr(strValue.indexOf(".") + 1, strValue.length - (strValue.indexOf(".") + 1));
	}

	// "3..4"는 숫자가 아니다.
	if(periodCnt > 1)
		intErr = 0;

	if (intErr!=1)
	{
		return true;
	}
	else return false;
}


function openNoScrollWin(theURL, winName, winTitle, width, height, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param, winName, "menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height);
}

/**
 * <PRE>
 * Scroll 이 없는 새 창을 띄운다
 * </PRE>
 * @param   theURL : 새로 띄울 파일 이름이다
 * @param   winName : 새창 이름
 * @param   winTitle : 새창 title
 * @param	width : 새창 가로 크기
 * @param	height : 새창 세로 크기
 * @param   param : 추가적인 화면 argument
 */
function openScrollWin(theURL, winName, winTitle, width, height, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param, winName, "menubar=no, scrollbars=yes, resizable=no, width="+width+", height="+height) ;
}

/**
 * <PRE>
 * 제약이 없는 새 창 띄우기를 하자
 * </PRE>
 * @param   theURL : 새로 띄울 파일 이름이다
 * @param   winName : 새창 이름
 * @param   winTitle : 새창 title
 * @param	width : 새창 가로 크기
 * @param	features : 다양한 모양을 직접 준다
 * @param   param : 추가적인 화면 argument
 */
function openFlexWin(theURL,winName,winTitle, width, features, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param,winName,features);
}






/**
 * <PRE>
 * 특정 필드에 대한 수정을 막는 행위
 * </PRE>
 * @param   objectName : 수정을 중지시킬 필드객체.(주로 input type)
 */
function editStop(objectName) {
	objectName.blur();
}

/**
 * 숫자나 문자열을 통화(Money) 형식으로 만든다.( 쉼표(,) 찍는다는 소리.. )
 * @param	amount	"1234567"
 * @return	currencyString "1,234,567"
 */
function formatCurrency(amount)
{
	amount = new String(amount);
	var amountLength = amount.length;
	var modulus = amountLength % 3;
	var currencyString = amount.substr(0,modulus);
	for(i=modulus; i<amountLength; i=i+3) {
		if(currencyString != "")
			currencyString += ",";
		currencyString += amount.substr(i, 3);
	}
	return currencyString;
}

///////////////////// LotteMRO Specific Functions ///////////////////////////
/**
 * 아이템 수량별 할인가를 반환한다(수량별 할인가 정보가 없을 경우 기본가 반환)
 *
 * @param	arrDiscount	수량별 할인가 배열
 * @param	qty	수량
 * @param	defaultSellPrice	기본 가격
 * @return	discountPrice	할인가
 */
function calcDiscountPrice(arrDiscount, qty, defaultSellPrice)
{
	var discountPrice = defaultSellPrice;
	var prevQty = 0;

	for( i=0; i<arrDiscount.length; i++ ) {
		if(qty >= prevQty && qty < arrDiscount[i][0]) {
			break;
		} else {
			discountPrice = arrDiscount[i][1];
			prevQty = arrDiscount[i][0];
		}
	}

	return discountPrice;
}

/*
 * 사업자 등록 번호를 검사한다.
 */
function isNotValidBIZ(form) {

	if(isEmpty(form.bizregno1,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.bizregno2,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.bizregno3,"사업자등록번호를 입력해 주세요!")) return true;
	if(isNotNumber(form.bizregno1,"사업자등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.bizregno2,"사업자등록번호 가운데자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.bizregno3,"사업자등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(form.bizregno1, 3, "사업자등록번호 앞자리는 3자리입니다!")) return true;
	if(isNotExactLength(form.bizregno2, 2, "사업자등록번호 뒷자리는 2자리입니다!")) return true;
	if(isNotExactLength(form.bizregno3, 5, "사업자등록번호 뒷자리는 5자리입니다!")) return true;
	strchr = form.bizregno1.value.concat(form.bizregno2.value.concat(form.bizregno3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5 = strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + ((num9 * 5) / 10);
	var tmp = total % 10;
	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("사업자등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		form.bizregno1.value="";
		form.bizregno2.value="";
		form.bizregno3.value="";
		form.bizregno1.focus();
		return true;
	}
	return false;
}


/******************************
*  기능 :  Positive NumberCheck           *
*  수정일 : 2002-04-10(withsun)              *
*  parameter : field, error_msg  *
*******************************/
function isNotPositiveNumber(field, error_msg)
{
   for (var i=0; i < field.value.length; i++)
   {
      if ( field.value.charAt(i) < "1" || field.value.charAt(i) > "9" )
	  {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
	   }
   }
}


/**
 * ENTER키 다운 되었을때 넘겨받은 Function실행
 *
 * @param	func	실행할 Function명
 */
function enterKeyDown(func)
{
	enter = event.keyCode;
	if(enter == 13)
	{
		eval(func);
	}

}



/**
 * 주언진 8자리 문자열을 날짜포맷(YYYY-MM-DD or YYYY/MM/DD)로 바꾸어준다.
 *
 * @param	source		변환할 8자리 날짜문자열
 * @param	format		날짜형식
 * @return	ret			변환된 날짜 문자열
 **/
function dateFormat(source, format)
{
	ret = "";
	delimiter = "";

	if (format.indexOf("-") != -1)
		delimiter = "-";
	else if (format.indexOf("/") != -1)
		delimiter = "/";
	else
	{
		alert("입력된 날짜포맷이 잘못되었습니다.");
		return;
	}

	if (source.length == 8)
	{
		ret = source.substring(0, 4) + delimiter + source.substring(4, 6) + delimiter + source.substring(6, 8);
	} else if (source.length == 10)
	{
		ret = source.substring(0, 4) + delimiter + source.substring(5, 7) + delimiter + source.substring(8, 10);
	} else
	{
		alert("입력된 날짜형식이 잘못되었습니다.");
		return;
	}
	return ret;
}

/**
 * 날짜형식이 올바른지 검사
 *
 * @param	astrValue	날짜포맷(yyyymmdd, yyyy/mm/dd, yyyy-mm-dd)
 * @param	astrNotNull:	nn:not null, "": null 허용
 * @return	true/false
 **/
function blnOkDate(astrValue, astrNotNull)
{
	var arrDate;

	if (astrValue=='')
	{
		if (astrNotNull == "nn")
			return false;
		else
			return true;
	}else{
		if (astrValue.indexOf("-") != -1)
			arrDate = astrValue.split("-");
		else if (astrValue.indexOf("/") != -1)
			arrDate = astrValue.split("/");
		else
		{
			if (astrValue.length != 8) return false;
			astrValue = astrValue.substring(0,4)+"/"+astrValue.substring(4,6)+"/" +astrValue.substring(6,8);
			arrDate = astrValue.split("/");
		}

		if (arrDate.length != 3) return false;

		var chkDate = new Date(arrDate[0] + "/" + arrDate[1] + "/" + arrDate[2]);
		if (isNaN(chkDate) == true ||
			(arrDate[1] != chkDate.getMonth() + 1 || arrDate[2] != chkDate.getDate()))
		{
			return false;
		}
	}
	return true;
}


/**
 * 그리드 날짜 셀에서 날짜를 입력받고서 유효한지 체크(yyyymmdd or yyyy-mm-dd or yyyy/mm/dd)후 틀리면 Calendar Popup
 *
 * @param	fgName	그리드객체명
 * @param	row		행수
 * @param	col		열수
 **/
function openCalendarInGrid(fgName, row, col)
{
	var fg = document.all(fgName);
	if (!blnOkDate(fg.TextMatrix(row, col), "nn"))
	{
		fg.TextMatrix(row, col) = "";
		showDateCalendarGrid(fgName + ", " + row + ", " + col);
	}
	else
		fg.TextMatrix(row, col) = dateFormat(fg.TextMatrix(row, col), "YYYY-MM-DD");

}

/**
 * INPUT field에서 날짜를 입력받고서 유효한지 체크(yyyymmdd or yyyy-mm-dd or yyyy/mm/dd)후 틀리면 Calendar Popup
 *
 * @param field INPUT 객체
 **/
function openCalendar(dateField)
{
 var obj = eval("document." + dateField);

 if (obj.value == "")
  return;
 if (!blnOkDate(obj.value, "nn"))
 {
  obj.value = "";
  showDateCalendar(dateField);
 }
 else
  obj.value = dateFormat(obj.value, "YYYY-MM-DD");

}

/**
 * 문자열내에 있는 ', "를 \', \" 로변환한다.
 *
 * @param	str	변환할 문자열
 **/
function toValidStr(str)
{
/*	alert(str);
	var ret = "";
	for (i = 0; i < str.length; i++)
	{
		if (str.charAt(i) == '\'')
			ret += '\\\'';
		else if (str.charAt(i) == '"')
			ret += '\\\"';
		else
			ret += str.charAt(i);
	}
*/

	re1 = /\'/gi;
	re2 = /\"/gi;
	str = str.replace(re1, "\\\'");
	str = str.replace(re2, "\\\"");
	return str;


}

function encChar(str)
{
	var temp1 = "@@@@@";
	re1 = /\'/g;
	re2 = /\"/g;
	str = str.replace(re1, temp1);
	return str;
}

function decChar(str)
{
	re3 = /@@@@@/g;
	str = str.replace(re3, "'");
	return str;
}


// system의 현재날짜를 return: yyyymmdd
function strGetToDay()
{
 	 var today=new Date();

 	 var strToDay = today.getYear();

 	 if (today.getMonth()+1 < 10)
 	 	strToDay += "-0"+(today.getMonth()+1);
 	 else
 	 	strToDay += "-" + today.getMonth()+1;

 	 if (today.getDate() < 10)
 	 	strToDay += "-0"+today.getDate();
 	 else
 	 	strToDay += "-" + today.getDate();

 	 return strToDay;
}

//주어진 값(val)을 소수점이하 num자리수에서 반올림한값을 리턴한다.
function round(val, num)
{
	val = val * Math.pow(10, num - 1);
	val = Math.round(val);
	val = val / Math.pow(10, num - 1);
	return val;
}


function isVaildMail(email)
{
     var result = false;

     if( email.indexOf("@") != -1 )
     {
          result = true;

          if( email.indexOf(".") != -1 )
          {
               result = true;
          }
          else
          {
               result = false;
          }
     }
     return result;
}



function isLoginname(obj) {
    len = obj.value.length;
    ret = true;

    if (len < 4)
		return false;
    if(!((obj.value.charAt(0) >= "a" && obj.value.charAt(0) <= "z") ||
       (obj.value.charAt(0) >= "A" && obj.value.charAt(0) <= "Z")))
		ret = false;
    for (i = 1; i < len; i++) {
		if((obj.value.charAt(i) >= "0" && obj.value.charAt(i) <="9") ||
		   (obj.value.charAt(i) >= "a" && obj.value.charAt(i) <= "z") ||
		   (obj.value.charAt(i) >= "A" && obj.value.charAt(i) <= "Z"))
		    ;
		else
		    ret = false;
    }
    return ret;

}



/*
 * 사업자 등록 번호를 검사한다.
 */
function isNotValidBIZNo(form) {

	if(isEmpty(form.site_serial1,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.site_serial2,"사업자등록번호를 입력해 주세요!")) return true;
	if(isEmpty(form.site_serial3,"사업자등록번호를 입력해 주세요!")) return true;
	if(isNotNumber(form.site_serial1,"사업자등록번호 앞자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.site_serial2,"사업자등록번호 가운데자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotNumber(form.site_serial3,"사업자등록번호 뒷자리는 숫자로만 기입해 주세요!")) return true;
	if(isNotExactLength(form.site_serial1, 3, "사업자등록번호 앞자리는 3자리입니다!")) return true;
	if(isNotExactLength(form.site_serial2, 2, "사업자등록번호 뒷자리는 2자리입니다!")) return true;
	if(isNotExactLength(form.site_serial3, 5, "사업자등록번호 뒷자리는 5자리입니다!")) return true;
	strchr = form.site_serial1.value.concat(form.site_serial2.value.concat(form.site_serial3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5 = strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + parseInt((num9 * 5) / 10);
	var tmp = total % 10;

	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("사업자등록번호가 올바르지 않습니다. \n다시 입력해 주세요!");
		form.site_serial1.value="";
		form.site_serial2.value="";
		form.site_serial3.value="";
		form.site_serial1.focus();
		return true;
	}
	return false;
}

/**
 * TAB키 다운 되었을때 넘겨받은 Function실행
 *
 * @param	func	실행할 Function명
 */
function tabKeyDown(func)
{
	enter = event.keyCode;
	if(enter == 09)
	{
		eval(func);
	}

}

// 쿠기저장
function setCookie(name, value, expires) {
	document.cookie = name + "=" + escape (value) + "; path=/; expires="
		+ expires.toGMTString();
}

// 쿠키조회
function getCookie(name) {
	var search = name + "=";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return "";
}
