// Çù·Â¾÷Ã¼ Á¶È¸Ã¢ ¶ç¿ì±â
function se_com(p_url, p_name, w, h)
{
	if ((w=='max') && (h=='max')) {
		winprops = 'scrollbars=yes,status=yes,resizable=yes'	//fullscreen=yes,
	}	else {
  	if (w==null) w = 320
  	else if (w=='max') w = screen.width - 10
  	if (h==null) h = 400
  	else if (h=='max') h = screen.height - 10

  	var winleft = (screen.width - w) / 2
  	var wintop = (screen.height - h) / 2 - 10

		winprops = 'width='+w+',height='+h+',top='+wintop+',left='+winleft+',scrollbars=yes,status=yes,resizable=yes'
//	winprops = 'scrollbars=yes,status=yes,resizable=yes'
	}
	window.open(p_url,p_name,winprops)
}
function new_open(p_url,p_name,w,h)
{
	if (h=='max') h = screen.height - 100

    var winleft = (screen.width - w - 10) / 2

  	winprops = 'width='+w+',height='+h+',top=10,left='+winleft+',scrollbars=none,status=yes,resizable=no'

	window.open(p_url,p_name,winprops)
}

// ¸Þ´º+»õÃ¢ ¶ç¿ì±â
function se_menu(p_url, p_name, w, h)
{
	if (w==null) w = 320
	else if (w=='max') w = screen.width - 50
	if (h==null) h = 400
	else if (h=='max') h = screen.height - 50

	var winleft = (screen.width - w) / 2
	var wintop = (screen.height - h) / 2

	winprops = 'width='+w+',height='+h+',top=10,left='+winleft+',scrollbars,resizable,menubar'
	window.open(p_url,p_name,winprops)
}

// Ç°¸í Á¶È¸Ã¢ ¶ç¿ì±â
function se_mat(p_url, p_name, w, h)
{
	if (w==null) w = 320
	else if (w=='max') w = screen.width - 50
	if (h==null) h = 400
	else if (h=='max') w = screen.height - 50
	var winleft = (screen.width - w) / 2
	var wintop = (screen.height - h) / 2

	if (fo.vendor.value == "") {
		alert("Çù·Â¾÷Ã¼ÄÚµå¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	p_url = p_url + "&vendor=" + fo.vendor.value
	winprops = 'width='+w+',height='+h+',top='+wintop+',left='+winleft+',scrollbars=yes,status=yes,resizable=yes'
//	winprops = 'scrollbars=yes,status=yes,resizable=yes'
	window.open(p_url,p_name,winprops)
}

// ³³ÀÔÀü¼ÛÃ³¸®Ã¢ ¶ç¿ì±â
function open_inbound(fm)
{
	p_url = '/edi02/edi02005/edi02005_ok.asp'
	w = 320
	h = 240
	l = (screen.width - w) / 2
	t = (screen.height - h) / 2
	winprops = 'scrollbars=yes,status=yes,resizable=yes,' + 'width=' + w + ',height=' + h + ',top=' + t + ',left=' + l
	if (fm.DDATE.value == "") {
		alert("³³Ç°ÀÏÀÚ¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (fm.NAPNUM.value == "") {
		alert("³³Ç°·®À» ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (parseInt(fm.NAPNUM.value) == 0) {
		alert("³³Ç°·® 1°³ ÀÌ»óÀ» ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (fm.LOTNO.value == "") {
		alert("Lot No¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}

	if (parseInt(fm.NAPNUM.value) > parseInt(fm.HASU.value)) {
		alert("ÀÔ°í°¡´É¼ö·®À» ÃÊ°úÇÏ¿´½À´Ï´Ù")
		return
	}
	window.open('about:blank','inbound',winprops)
	fm.submit()
}

// ³³ÀÔÀü¼Ûº¯°æÃ¢ ¶ç¿ì±â
function open_inbound_modify(fm)
{
	p_url = '/edi02/edi02005/edi02005a_modify.asp'
	w = 320
	h = 240
	l = (screen.width - w) / 2
	t = (screen.height - h) / 2
	winprops = 'scrollbars=yes,status=yes,resizable=yes,' + 'width=' + w + ',height=' + h + ',top=' + t + ',left=' + l
	if (fm.DDATE.value == "") {
		alert("³³Ç°ÀÏÀÚ¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (fm.NAPNUM.value == "") {
		alert("³³Ç°·®À» ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (parseInt(fm.NAPNUM.value) == 0) {
		alert("³³Ç°·® 1°³ ÀÌ»óÀ» ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}
	if (fm.LOTNO.value == "") {
		alert("Lot No¸¦ ÀÔ·ÂÇÏ¼¼¿ä")
		return
	}

	if (parseInt(fm.NAPNUM.value) > parseInt(fm.HASU.value)) {
		alert("ÀÔ°í°¡´É¼ö·®À» ÃÊ°úÇÏ¿´½À´Ï´Ù")
		return
	}
	window.open('about:blank','inbound_modify',winprops)
	fm.submit()
}

// »õÃ¢ À§Ä¡,Å©±â º¯°æ
function InitWin(w,h)
{
	window.moveTo((screen.width - w) / 2, (screen.height - h) / 2)
	window.resizeTo(w, h)
}

/*
// ´ÜÀ§ÀÌ¸§º¯°æ
Function ConvUnitName(Unit, Toggle)
{
	if (Toggle = "on") {
		if (Unit = "PC") {
			return("BOX")
		{
		else {
			return("TON")
		}
	}
	else {
		return(Unit)
	}
}

// ´ÜÀ§º¯°æ
Function ConvUnit(Unit, su, Toggle, box)
{
	if (Toggle = "on") {
		if (Unit = "PC") {
			if ((su mod box) > 0) {
				return( int((su / box)+1) )
			}
			else {
				return( int(su / box) )
			}
		else {
			return(su / 1000)
		}
	}
	else {
		return(su)
	}
}
*/
/*
// Ã¼Å©¹Ú½º ¼±ÅÃ,ºñ¼±ÅÃ
var chk = false
function chkall(frm)
{
	for (var i=0;i<frm.elements.length;i++) {
		var e = frm.elements[i]
		if (e.type=='checkbox')	{
			e.checked = chk
		}
	}
	chk = not chk
}
*/

function setCookie(name, val, Days) {
  var expDays = Days
  var exp = new Date()
  var cookieTimeToLive = exp.getTime() + (expDays * 24 * 60 * 60 * 1000)
  exp.setTime(cookieTimeToLive)
  document.cookie = name + "=" + val + ";expires=" + exp.toGMTString()
//  document.cookie = name + "=" + escape(val) + ";expires=" + exp.toGMTString()
}

function getCookie(name) {
  var cookieNameLen = name.length;
  var cLen = document.cookie.length;
  var i = 0;
  var cEnd;
  var myStringToReturn;
  var myStringToReturnLen;
  while (i < cLen) {
    var j = i + cookieNameLen;
    if (document.cookie.substring(i,j) == name) {
      cEnd = document.cookie.indexOf(";",j);
      if (cEnd == -1) {
	      cEnd = document.cookie.length;
      }
//      myStringToReturn = unescape(document.cookie.substring(j,cEnd));
      myStringToReturn = document.cookie.substring(j,cEnd);
      myStringToReturnLen = myStringToReturn.length;
      myStringToReturn = myStringToReturn.substring(1,myStringToReturnLen+1);
      return myStringToReturn;
    }
    i++;
  }
  return "";
}

function delCookie( name )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate()-1 );
	document.cookie = name+"=; path=/; expires="+todayDate.toGMTString()+";";
}

function numscomma(idd)
{
/*
 var d, s;                      //Declare variables.
   d = 1234523423423423412321;
   s = d.toLocaleString();       //Convert to current locale.
s=s.substring(0,s.length-3)
*/
	msg = "";
	fdd = idd+"";
	len = fdd.length;
	if (len <= 3) return fdd;
	st = fdd.length%3;
	ste = (fdd.length-st)/3;
	if (st > 0) {
		msg = fdd.substr(0,st)+",";
		fdd = fdd.substr(st,len-st)
	}
	for (j=0;j<ste;j++) {
		msg = msg + fdd.substr(j*3,3);
		if (j<ste-1) msg=msg+",";
	}
	return msg;
}

function ConvUnitName(Unit)
{
	if (Unit == "PC") return "BOX";
	else if (Unit == "BOX") return "PC";
	else if (Unit == "KG") return "TON";
	else if (Unit == "TON") return "KG";
	return Unit;
}

function ConvUnit(Unit,box,org_su,org_Unit)
{
	var ret;
	ret = "";
	if (Unit == org_Unit) {
		ret = org_su;
	} else if (Unit == "BOX") {
		if ((org_su%box)>0) {
			ret = (Math.floor(org_su / box))+1;
		} else {
			ret = (Math.floor(org_su / box));
		}
	} else if (Unit == "TON") {
		ret = org_su / 1000;
	}
	return ret;
}

function CVT(p_num)
{
//	SMessage("´ÜÀ§ º¯È¯ ÁßÀÔ´Ï´Ù.\nÀÚ·á ¼ö¿¡ µû¶ó¼­ ¸¹Àº ½Ã°£ÀÌ °É¸± ¼öµµ ÀÖ½À´Ï´Ù.");
	var coll1 = document.all.item("dan");

	if (coll1 == null) return;
	for (i=0; i<coll1.length; i++) {
		dan[i].innerText = ConvUnitName(dan[i].innerText);
	}

	var coll2 = document.all.item("D1");
//alert(coll2.length)
	for (i=0; i<coll2.length; i++) {
		if (Math.floor(i/p_num) >= coll1.length) continue;
		D1[i].innerText = ConvUnit(dan[Math.floor(i/p_num)].innerText,org_box[Math.floor(i/p_num)].value,D1[i].org,dan[Math.floor(i/p_num)].org);
//		D1[i].innerText = ConvUnit(dan[Math.floor(i/p_num)].innerText,org_box[Math.floor(i/p_num)].value,D1[i].value,org_dan[Math.floor(i/p_num)].value);
//		D1[i].innerHTML = numscomma(D1[i].innerHTML);
	}
//	HMessage();
}
function chgstat(p_id,p_html)
{
	if ((p_html != "RED") && (p_html != "CYAN"))
	 	p_id.innerHTML = "<font color=BLACK>OK</font>";
	else
  	p_id.innerHTML = "<font color=" + p_html + ">Check</font>";
}

// ÇÁ·¹ÀÓ »ç¿ë½Ã ÇÊ¿ä.
var TLWriter="";
var TRWriter="";
var BLWriter="";
var BRWriter="";
function loadclient(thi) {
	if (thi.name == "TL") { thi.document.body.innerHTML = TLWriter; }
	if (thi.name == "TR") { thi.document.body.innerHTML = TRWriter; }
	if (thi.name == "BL") { thi.document.body.innerHTML = BLWriter; }
	if (thi.name == "BR") { thi.document.body.innerHTML = BRWriter; }
}

// ÀÔ·ÂÅØ½ºÆ® ÃÊ°úÃ¼Å©
function chklen(p_name,p_maxlen)
{
	if (p_name.value.length >= p_maxlen) {
		alert(p_maxlen+"ÀÌ³» ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù")
		p_name.value = p_name.value.substring(0, p_maxlen-2); 
	}
}

// RFQ
function send_form()
{
	if (confirm("¹ß¼ÛÇÏ½Ã°Ú½À´Ï±î?")==true) {
		form1.mode.value="send";
		if (DoSubmit(form1))
			form1.submit();
		else
			form1.mode.value="m";
	}
}

function InputAlert(p_name,p_value)
{
	if (p_name.scrollHeight>p_value)
		alert("Ãâ·ÂÈ­¸éÀ» ÃÊ°úÇÕ´Ï´Ù.");
}

function chkDate(p_name)
{
	var p_value = p_name.value;
	var exstr = "¿¹:2002-12-12";
	if ((p_value=="")||(p_value==null)) return true;
	if ((p_value.length < 10)||(p_value.substring(4,5)!="-")||(p_value.substring(7,8)!="-")) {
		alert("Çü½ÄÀÌ Æ²¸³´Ï´Ù. \n"+exstr);
		p_name.value = "";
		p_name.focus();
		return false;
	}
	return true;
}

function chkDate2(p_name)
{
	var p_value = p_name.value;
	var exstr = "¿¹:2002-12-12";
	if ((p_value=="")||(p_value==null)) return true;
	if ((p_value.length < 10)||(p_value.substring(4,5)!="-")||(p_value.substring(7,8)!="-")) {
		alert("Çü½ÄÀÌ Æ²¸³´Ï´Ù. \n"+exstr);
		p_name.focus();
		return false;
	}
	return true;
}

function search_vendor(p_obj) {
	var keyCode = window.event.keyCode;
	if ((keyCode==13)&&(p_obj!=null)) {
		p_obj.click();
	}
}

function search_button(p_obj) {
	var keyCode = window.event.keyCode;
	if ((keyCode==13)&&(p_obj!=null)) {
		p_obj.click();
	}
}

function escape() {
	var keyCode = window.event.keyCode;
	if (keyCode==27) {
		window.close();
	}
}

function togglecheckbox(ckbox, chk)
{ 
	if (ckbox) {
    ckbox.checked = chk;
		for (iCount=0;iCount<ckbox.length;iCount++) {
			ckbox[iCount].checked = chk;
		}
	}
}

function existcheckbox(ckbox, errmsg)
{
	if (ckbox) {
    if (ckbox.checked) {
      return true;
    }
		for (iCount=0;iCount<ckbox.length;iCount++) {
			if (ckbox[iCount].checked) {

				return true;
			}
		}
	}
	alert(errmsg);
	return false;
}

function existitem(item, errmsg)
{
	if (item) {
    return true;
	}
	alert(errmsg);
	return false;
}

