String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/gi, "");
}

function objectTrim(v)
{
	return v.value.trim();
}

function objectFalse(msg, v)
{
	alert (msg + "     ");
	v.value = "";
	v.focus();
	return false;
}

function moveFocus(src, len, trg)
{
	if (objectTrim(src).length == len)
		trg.focus();
}

function zipcode(f, zn1, zn2, an1, an2)
{
	w = 500;
	h = 300;
	url = "/zipcode/zipcode.asp?form_name=" + f + "&zipcode1_name=" + zn1 + "&zipcode2_name=" + zn2 + "&address1_name=" + an1 + "&address2_name=" + an2;

	window.open(url, "zipcode", "width=" + w + ", height=" + h + ", top=" + (screen.height - (screen.availHeight / 2) - (h / 2)) + "px, left=" + (screen.width - (screen.availWidth / 2) - (w / 2)) + "px, scrollbars=yes");
}

function isEmail(s)
{
	return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~w-]+)+\s*$/g) >= 0;
}

function isNumber(f)
{
	if (f != 13 && (f < 48 || f > 57))
		return false;
}

function isDotNumber(f)
{
	if (f != 13 && (f < 46 || f > 57))
		return false;
}

function isImage(f)
{
	if (f.length > 0)
	{
		img_type = f.substring(f.lastIndexOf(".") + 1, f.length);

//		if (img_type.length > 0 && img_type.toLowerCase() != "gif" && img_type.toLowerCase() != "jpg" && img_type.toLowerCase() != "tif" && img_type.toLowerCase() != "png" && img_type.toLowerCase() != "bmp")
		if (img_type.length > 0 && img_type.toLowerCase() != "gif" && img_type.toLowerCase() != "jpg")
			return false;
		else
			return true;
	}
}

function isHun(f)
{
	if (f.length > 0)
	{
		img_type = f.substring(f.lastIndexOf(".") + 1, f.length);

		if (img_type.length > 0 && img_type.toLowerCase() != "gul")
			return false;
		else
			return true;
	}
}

function viewImg(f, title, width, height, origin_width, origin_height)
{
	w = width;
	h = height;
	ow = origin_width;
	oh = origin_height;

	if (w <= screen.availWidth && h <= screen.availHeight)
		window.open("/inc/viewImg.asp?img=" + f + "&title=" + title + "&w=" + w + "&h=" + h + "&origin_w=" + ow + "&origin_h=" + oh, w + h, "top=" + (screen.height - (screen.availHeight / 2) - (h / 2)) + "px, left=" + (screen.width - (screen.availWidth / 2) - (w / 2)) + "px, toolbar=no, location=0, directory=no, status=no, scrollbars=no, resizable=no, width=" + w + ", height=" + h);
	else
	{
		if (w >= screen.availWidth && h <= screen.availHeight)
			window.open("/inc/viewImg.asp?img=" + f + "&title=" + title + "&w=" + w + "&h=" + h + "&origin_w=" + ow + "&origin_h=" + oh, w + h, "top=" + (screen.height - (screen.availHeight / 2) - (h / 2)) + "px, left=" + (screen.width - (screen.availWidth / 2) - (screen.availWidth / 2)) + "px, scrollbars=yes, width=" + screen.availWidth + ", height=" + h);
		else if (w <= screen.availWidth && h >= screen.availHeight)
			window.open("/inc/viewImg.asp?img=" + f + "&title=" + title + "&w=" + w + "&h=" + h + "&origin_w=" + ow + "&origin_h=" + oh, w + h, "top=" + (screen.height - (screen.availHeight / 2) - (screen.availHeight / 2)) + "px, left=" + (screen.width - (w / 2) - (screen.availHeight / 2)) + "px, scrollbars=yes, width=" + w + ", height=" + screen.availHeight);
		else
			window.open("/inc/viewImg.asp?img=" + f + "&title=" + title + "&w=" + w + "&h=" + h + "&origin_w=" + ow + "&origin_h=" + oh, w + h, "top=0px, left=0px, scrollbars=yes, width=" + screen.availWidth + ", height=" + screen.availHeight);
	}
}

function viewHunLiteXP(tenderIdx, fileCount, childTF)
{
	w = 983;
	h = 680;


	if (fileCount < 1)
		h = h - 100;

	wTop = (screen.height - (screen.availHeight / 2) - (h / 2) - 50);
	wTop = 0;
	wLeft = (screen.width - (screen.availWidth / 2) - (w / 2));

	if (!childTF)
		wLeft = 0;

	window.open("http://hms.nhtra.co.kr/hunLiteXP/?tenderIdx=" + tenderIdx, "", "top=" + wTop + "px, left=" + wLeft + "px, scrollbars=no, width=" + w + ", height=" + h);
}

function hunView(fileName, path)
{
	w = 983;
	h = 630;

	windowOpen("http://hms.nhtra.co.kr/hunLiteXP/hunFileView.asp?fileName=" + fileName + "&path=" + path, "", w, h);
}

function objectFocus(f)
{
	objectTrim(f);
	f.select();
	f.style.backgroundColor = "#0000C0";
	f.style.color = "yellow";
}

function objectBlur(f)
{
	objectTrim(f);
	f.style.backgroundColor = "#FFFFFF";
	f.style.color = "navy";
}

function windowOpen(url, name, width, height)
{
	var wTop = (screen.height - (screen.availHeight / 2) - (height / 2)) - 50;
	var wLeft = (screen.width - (screen.availWidth / 2) - (width / 2));

	if (width >= 900)
		wTop = 0;

	window.open(url, name, "width=" + width + ", height=" + height + ", top=" + wTop + "px, left=" + wLeft + "px, channelmode=0, directories=0, location=0, menubar=0, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0");
}

function openWins(url, name, width, height)
{
	window.open(url, name, "width=" + width + ", height=" + height + ", top=" + (screen.height - (screen.availHeight / 2) - (height / 2)) + "px, left=" + (screen.width - (screen.availWidth / 2) - (width / 2)) + "px, channelmode=0, directories=0, location=0, menubar=0, resizable=0, scrollbars=yes, status=0, titlebar=0, toolbar=0");
}

function dialogOpen(url, name, width, height)
{
	winOpt = "dialogWidth:" + width + "px; dialogHeight:" + height + "px; leftmargin:30px; marginwidth:30px; dialogTop:" + (screen.height - (screen.availHeight / 2) - (height / 2)) + "px; dialogLeft:" + (screen.width - (screen.availWidth / 2) - (width / 2)) + "px; center:yes; help:no; resizable:no; scroll:no; status:no;";
	return showModalDialog(url, name, winOpt);
}

function openDialog(url, name, width, height)
{
	winOpt = "dialogWidth:" + width + "px; dialogHeight:" + height + "px; leftmargin:30px; marginwidth:30px; dialogTop:" + (screen.height - (screen.availHeight / 2) - (height / 2)) + "px; dialogLeft:" + (screen.width - (screen.availWidth / 2) - (width / 2)) + "px; center:yes; help:no; resizable:no; scroll:yes; status:no;";
	return showModalDialog(url, name, winOpt);
}

function chkIt(EL)
{
	if (EL.checked)
		setStyle(EL);
	else
		resStyle(EL);
}

function chkAll(f)
{
	var frm = f;

	for (i=0; i<frm.elements.length; ++i)
	{
		var ele = frm.elements[i];

		if ((ele.type == "checkbox" || ele.type == "radio"))
		{
			if (!ele.checked)
				resStyle(ele);
			else
				setStyle(ele);
		}
	}
}

function setStyle(E)
{
	while (E.tagName != "TR")
		E = E.parentElement;

	with (E.style)
		backgroundColor = "#FFF3E7";
}

function resStyle(E)
{
	while (E.tagName != "TR")
		E = E.parentElement;

	with (E.style)
		backgroundColor = "";
}

function comma(f)
{
	var sub_number = 0;
	var origin_number;
	deComma(f);
	number = '' + f.value;
	origin_number = f.value;
	plus_minus = number.substring(0, 1);

	if (plus_minus == "-")
	{
		startPos = 1;
		number = number.substring(1, number.length);
	}
	else
		startPos = 0;

	if (number.indexOf(".") > 0)
	{
		sub_number = number.substring(number.indexOf(".") + 1, number.length);
		number = number.substring(startPos, number.indexOf("."));
	}

	if (number.length > 3)
	{
		var mod = number.length % 3;
		var output = (mod > 0 ? (number.substring(0, mod)) : '');

		for (i=0; i < Math.floor(number.length / 3); i++)
		{
			if ((mod == 0) && (i == 0))
				output += number.substring(mod + 3 * i, mod + 3 * i + 3);
			else
				output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
		}

		f.value = output;

		if (plus_minus == "-")
			f.value = "-" + f.value;

		if (origin_number.indexOf(".") > 0)
			f.value = f.value + "." + sub_number;
	}
}

function deComma(f)
{
	f.value = objectTrim(f).replace(/,/gi, "");
}

function hide_div()
{
	var name  = "idControls";
	var layer = document.all[name];
	layer.style.visibility = "hidden";
}

function show_div()
{
	var name  = "idControls";
	var layer = document.all[name];
	layer.style.visibility = "visible";
}

function view_page(landscape)
{
	IEPrint.left = 10;
	IEPrint.right = 10;
	IEPrint.top = 20;
	IEPrint.bottom = 6;
	IEPrint.header = "";
	IEPrint.footer = "";
	IEPrint.printbg = true;
	IEPrint.landscape = landscape;
	IEPrint.paper = "A4";

	hide_div();
	IEPrint.Preview();
	show_div();
}

function print_page(landscape)
{
	IEPrint.left = 10;
	IEPrint.right = 10;
	IEPrint.top = 20;
	IEPrint.bottom = 6;
	IEPrint.header = "";
	IEPrint.footer = "";
	IEPrint.printbg = true;
	IEPrint.landscape = landscape;
	IEPrint.paper = "A4";

	hide_div();
	IEPrint.SilentPrint();
	show_div();
}

function printer_view_page(landscape)
{
	IEPrint.left = 10;
	IEPrint.right = 10;
	IEPrint.top = 20;
	IEPrint.bottom = 6;
	IEPrint.header = "";
	IEPrint.footer = "";
	IEPrint.printbg = true;
	IEPrint.landscape = landscape;
	IEPrint.paper = "A4";

	hide_div();
	IEPrint.Print();
	show_div();
}

function isBusinessNumber(f1, f2, f3)
{
	var checkID = new Array(1, 3, 7, 1, 3, 7, 1, 3, 5, 1);
	var i, sum = 0, c2, remander;

	bizID = objectTrim(f1) + "" + objectTrim(f2) + "" + objectTrim(f3);

	for (i=0; i<8; i++)
		sum += checkID[i] * bizID.charAt(i);

	c2 = "0" + (checkID[8] * bizID.charAt(8));
	c2 = c2.substring(c2.length - 2, c2.length);

	sum += Math.floor(c2.charAt(0)) + Math.floor(c2.charAt(1));

	remander = (10 - (sum % 10)) % 10;

	if (bizID.length != 10 || Math.floor(bizID.charAt(9)) != remander)
		return false;
	else
		return true;
}

function processKey() 
{
	if((event.ctrlKey == true && (event.keyCode == 67 || event.keyCode == 78 || event.keyCode == 82)) || (event.keyCode >= 112 && event.keyCode <= 123))
	{
		event.keyCode = 0;
		event.cancelBubble = true;
		event.returnValue = false;
	}
}

function mouseRightButtonDisabled()
{
	if (event.button == 2 || event.button == 3)
		return false;
}

function sourceDisabled()
{
	return false;
}

function selectStartDisabled()
{
	return false;
}

function dragStartDisabled()
{
	return false;
}

function download(name)
{
	window.location.href = "/inc/download.asp?filename=" + name;
}

function numberKey(keyCode)
{
	if (keyCode != 13 && (keyCode < 48 || keyCode > 57))
		return false;
}

function toHex(dec)
{
	var hexCharacters = "0123456789ABCDEF"

	if (dec < 0)
		return "00";

	if (dec > 255)
		return "FF";

	var i = Math.floor(dec / 16)

	var j = dec % 16

	return hexCharacters.charAt(i) + hexCharacters.charAt(j)
}

function setbgColor(red, green, blue)
{
	document.bgColor = "#" + toHex(red) + toHex(green) + toHex(blue);
}

function fade(sred, sgreen, sblue, ered, egreen, eblue, step)
{
	for(var i=0; i<=step; ++i)
	{
		var red = Math.floor(sred * ((step - i) / step) + ered * (i / step))
		var green = Math.floor(sgreen * ((step - i) / step) + egreen * (i / step))
		var blue = Math.floor(sblue * ((step - i) / step) + eblue * (i / step))
		setbgColor(red, green, blue)
	}
}

self.status = "(ÁÖ)NH¹«¿ª";
document.oncontextmenu = sourceDisabled;
document.onkeydown = processKey;
document.onselectstart = selectStartDisabled;
document.ondragstart = dragStartDisabled;