try {
	MessageB.style.width = MessageB.style.width;
	MB = true;
} catch (Exception) {
	MB = false;
}

if(!MB) {
	var MMMM1;
	MMMM1 = "<div id=\"MessageB\" name=\"MessageB\" style=\"position:absolute; left:-500px; top:0px; width:200px; height:50px; z-index:99 visibility: hidden; \">"+
					"<table width=200 height=50  border=1 cellpadding=0 cellspacing=0 bordercolorlight=#000000 bordercolordark=#FFFFFF bgcolor=#CC9933><tr><td id=ttx align=center>&nbsp;</td></tr></table>"+
					"</div>";
	document.write (MMMM1);
}

function SMessage(msg)
{
	x = (document.body.offsetWidth/2)-(200/2);
	y = (document.body.offsetHeight/2)-(50/2);
	MessageB.style.left = x;
	MessageB.style.top = y;
	ttx.innerHTML = msg;
	MessageB.style.visibility = "visible";

}

function MSMessage(msg,p)
{
	x = event.x + 3;
	y = event.y + 2;
	MessageB.style.left = x;
	MessageB.style.top = y;
	ttx.innerHTML = msg;
	MessageB.style.visibility = "visible";
}

function HMessage()
{
	try	{
		MessageB.style.visibility = "hidden";
	} catch (Exception) {}
}

function ShowCalander(rt1,rt2)
{
	Lleft=(screen.width - 270) / 2;
	Ltop=(screen.height - 200) / 2;
	window.open('/common/calendar.asp?rt1='+rt1+'&rt2='+rt2,'_cal','Width=270,Height=200,Left='+Lleft+',Top='+Ltop+'');
}

function ShowMat(rt1,rt2)
{
	window.open('/common/search_mat2.asp?rt1='+rt1+'&rt2='+rt2,'_mat','width=250 height=300 scrollbars=yes');
}

function ShowPost(rt1,rt2)
{
	window.open('/common/search_post.asp?return1='+rt1+'&return2='+rt2,'post_search','width=440,height=400,scrollbars=yes,status=yes');
}

function ShowImage(dir)
{
	window.open(dir,'Show_image','width=440,height=400,scrollbars=yes');
}

function FindString(target,keyword,UpperCase)
{
	var tg,kw;
	if(UpperCase) {
		tg = target.toUpperCase();
		kw = keyword.toUpperCase();
	} else {
		tg = target;
		kw = keyword;
	}
	return (tg.indexOf(kw));
}

function checkdate(val)
{
	if (val.value.length == 0) return true;
	if(val.value.match(/[0-9-]+/g)!=val.value) {
        alert("³¯Â¥´Â ¼ýÀÚ ±×¸®°í - ¸¸ µË´Ï´Ù.");
        return false;
	} else if (val.value.length < 8) {
		alert("³¯Â¥´Â ÃÖ¼Ò 8ÀÚ ÀÔ´Ï´Ù. ¿¹) 20020101 or 2002-01-01");
		return false;
	} else if (val.value.length == 8) {
		val.value = val.value.substr(0,4)+"-"+val.value.substr(4,2)+"-"+val.value.substr(6,2);
	}
	if((FindString(val.value.substr(0,4),"-",false) > -1) || (FindString(val.value.substr(5,2),"-",false) > -1) || (FindString(val.value.substr(8,2),"-",false) > -1)) {
		alert("³¯Â¥°¡ Àß¸ø µÇ¾ú½À´Ï´Ù. ¿¹) 20020101 or 2002-01-01");
		return false;
	}
	return true;
}

function checkemail(str)
{
  if(str.length == 0) return true;
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  tf = (!r1.test(str) && r2.test(str));
  if(!tf) {
		alert("EmailÁÖ¼Ò°¡ Àß¸ø µÇ¾ú½À´Ï´Ù.");
		return false;
	}
  return true;
}

function ch_check(TF)
{
	oError = 0; mName="";
	var focu;
	for (i = 0; i < TF.tags("INPUT").length; i++)
	{
		obj = TF.tags("INPUT")[i];
		if ((obj.type.toUpperCase() != "TEXT")&&(obj.type.toUpperCase() != "HIDDEN")) continue;
		try	{
			if(obj.ch == null) continue;
			else {
				if(FindString(obj.ch,"SPACE",true) > -1) {
					if(!isSpace(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"MNUM",true) > -1) {
					if(!isMNum(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"NUM",true) > -1) {
					if(!isNum(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"HAN",true) > -1) {
					if(!isHan(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"ENG",true) > -1) {
					if(!isEng(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"NUMENG",true) > -1) {
					if(!isEngNum(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"DT",true) > -1) {
					if(!checkdate(obj.value)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"JUMIN",true) > -1) {
					if(!checkjumin(obj)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
				if(FindString(obj.ch,"EMAIL",true) > -1) {
					if(!checkemail(obj.value)) {
						if(focu==null) {
							if(obj.ret!=null) focu = eval(obj.ret);
							else focu = obj;
						}
					}
				}
			}
		} catch(exception) {}
		if(focu!=null) break;
	}
	if(focu==null) return true;
	else {
		if(focu.type.toUpperCase() != "HIDDEN") focu.focus();
		return false;
	}
}

function DoSubmit(TF)
{
	SMessage("Please wait! Now Running...");
	oError = 0; mName="";
	var focu;
	for (i = 0; i < TF.tags("INPUT").length; i++)
	{
		obj = TF.tags("INPUT")[i];
		if ((obj.type.toUpperCase() != "TEXT") && (obj.type.toUpperCase() != "PASSWORD")) continue;
		if(FindString(obj.className,"PK",true) > -1) {
			if(obj.value.length < 1) {
				if(focu==null) {
						if(obj.ret!=null)  focu = eval(obj.ret);
						else 	focu = obj;
				}
				oError = oError + 1;
				try {
					if(obj.tx != null) mName=mName+"["+obj.tx+"]";
				} catch(exception) {}
			}
		}
	}
	if (oError>0) {
	  alert("Please confirm again!");
//		if(mName.length > 0) {
//			alert (oError+"°³ÀÇ ÇÊ¼ö Ç×¸ñ( "+mName+" )ÀÌ ÀÔ·ÂµÇÁö ¾Ê¾Ò½À´Ï´Ù.\nPlease confirm again!");
//		} else {
//			alert (oError+"°³ÀÇ ÇÊ¼ö Ç×¸ñÀÌ ÀÔ·ÂµÇÁö ¾Ê¾Ò½À´Ï´Ù.\nPlease confirm again!");
//		}
		focu.focus();
		HMessage();
		return false;
	} else {
		if(ch_check(TF)) {
			for (i = 0; i < TF.tags("INPUT").length; i++)
			{
				obj = TF.tags("INPUT")[i];
				if (obj.type.toUpperCase() == "BUTTON")
						obj.disabled = true;
			}
			TF.submit();
			return true;
		} else {
			HMessage();
			return false;
		}
	}
}

function getIndex(input)
{
	var index = -1, i = 0;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input) index = i;
		else i++;
	return index;
}

function movetab(input)
{
	event.returnValue=false;
	obj = input.form[(getIndex(input)+1)%input.form.length];
	while((obj.readOnly==true)||(obj.disabled==true)||(obj.type.toUpperCase()=="HIDDEN")) {
		obj = input.form[(getIndex(obj)+1)%input.form.length];
	}
	obj.focus();
}

function number_check(obj) {
	var keyCode = window.event.keyCode;
	if ((keyCode < 48) || (keyCode > 57)){
		switch(keyCode) {
			case 8		:				// ¹é½ºÆäÀÌ½º
			case 46 	: break;		// Del Key
			case 13		: movetab(obj); break;  // ENTER
			default 	: event.returnValue=false;
		}
	}
	return;
}

function number_minus_check(obj) {
	var keyCode = window.event.keyCode;

	if ((keyCode < 48) || (keyCode > 57)){
		switch(keyCode) {
			case 45  	:						// -
			case 189	:						// -
			case 8		:						// ¹é½ºÆäÀÌ½º
			case 46 	: break;				// Del Key
			case 13		: movetab(obj); break;  // ENTER
			default 	: event.returnValue=false;
		}
	}
	return;
}

function lend(ifr) {
	ifr.document.close();
	return;
}

function setDataType(cValue) { 
	var isDate = new Date(cValue); 
	if (isDate == "NaN") { 
		if (isNaN(cValue)) { 
			cValue = cValue.toUpperCase(); 
			return cValue; 
		} else { 
			var myNum; 
			myNum = String.fromCharCode(48 + cValue.length) + cValue; 
			return myNum; 
		} 
	} else { 
		var myDate = new String(); 
		myDate = isDate.getFullYear() + " " ; 
		myDate = myDate + isDate.getMonth() + " "; 
		myDate = myDate + isDate.getDate(); + " "; 
		myDate = myDate + isDate.getHours(); + " "; 
		myDate = myDate + isDate.getMinutes(); + " "; 
		myDate = myDate + isDate.getSeconds(); 
		return myDate ; 
	} 
}

function sortTable(col, tableToSort) 
{ 
	var iCurCell = col + tableToSort.cols; 
	var totalRows = tableToSort.rows.length; 
	var bSort = 0; 
	var colArray = new Array(); 
	var oldIndex = new Array(); 
	var indexArray = new Array(); 
	var bArray = new Array(); 
	var newRow; 
	var newCell; 
	var i; 
	var c; 
	var j; 
	for (i=1; i < tableToSort.rows.length; i++) {
		colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
		iCurCell = iCurCell + tableToSort.cols;
	}
	for (i=0; i < colArray.length; i++) { 
		bArray[i] = colArray[i]; 
	} 
	colArray.sort(); 
	for (i=0; i < colArray.length; i++) {
		indexArray[i] = (i+1); 
		for(j=0; j < bArray.length; j++) { 
			if (colArray[i] == bArray[j]) { 
				for (c=0; c<i; c++) { 
					if ( oldIndex[c] == (j+1) ) { 
						bSort = 1; 
					} 
				} 
				if (bSort == 0) { 
					oldIndex[i] = (j+1); 
				} 
				bSort = 0; 
			} 
		} 
	} 
	for (i=0; i<oldIndex.length; i++) { 
		newRow = tableToSort.insertRow(); 
		for (c=0; c<tableToSort.cols; c++) { 
			newCell = newRow.insertCell(); 
			newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML; 
		} 
	} 
	for (i=1; i<totalRows; i++) { 
		tableToSort.moveRow((tableToSort.rows.length -1),1); 
	}
	for (i=1; i<totalRows; i++) {
		tableToSort.deleteRow();
	}
} 

function WaitMsg()
{
	SMessage("Please wait! Now Running...");
}

