/**
 * wizcom 패키지 공통 자바스크립트
 *
 * @author 도장민(stampmin@hotmail.com)
 *
 * @version 1.000, 2006/10/16
 */

//document.oncontextmenu= function() { return false; };
//document.ondragstart= function() { return false; };
//document.onselectstart= function() { return false; };

function reloadPage()
{
	if ( document.forms[0] == null )
		self.location.reload();
	else
	{
		document.forms[0].target="_self";
		document.forms[0].action=self.location;
		document.forms[0].submit();
	}
}

function forcedClose()
{
	if ( /MSIE/.test(navigator.userAgent) )
	{
		if ( navigator.appVersion.indexOf("MSIE 7") > -1 )
			window.open("about:blank", "_self").close();
		else
		{
			window.opener = self;
			self.close();
		}
	}
	else
	{

		window.name = "___temp___";
		var w = window.open("about:blank");
		w.document.open();
		w.document.write("<html><body><script type='text/javascript'>function _temp_close(){var w=window.open.('about:blank', '" + window.name + "'); w.close(); self.close();}</" + "script></body></html>");
		w.document.close();
		w._temp_close();
	}
}

function log(msg)
{
	var console = document.getElementById("DIV_LOG");
	if ( console == null )
		alert("디버그 콘솔 ID는 DIV_LOG 입니다.");
	else
		console.innerHTML =+ msg + "<br/>";
}

// 값 입력여부 체크
function isEmpty(elem, title)
{
	try {
		if (elem.value) {
			for (index = 0; index < elem.value.length; index++) {
				// 공백 문자(13), 수평탭(HT-9), 엔터(CR-13, LF-10)가 아닌게 하나라도 있으면...
				if (elem.value.charCodeAt(index) != 32 && elem.value.charCodeAt(index) != 9
				&& elem.value.charCodeAt(index) != 13 && elem.value.charCodeAt(index) != 10)
					return false;
			}
		}
		if ( title != null ) alert(title + " 입력은 필수입니다.");
		elem.focus();
		return true;
	}
	catch(e) {
		return true;
	}
}

function isNoE(elem)
{
	try
	{
		if ( isNull(elem) ) true;
		if (elem.value) {
			for (index = 0; index < elem.value.length; index++) {
				// 공백 문자(13), 수평탭(HT-9), 엔터(CR-13, LF-10)가 아닌게 하나라도 있으면...
				if (elem.value.charCodeAt(index) != 32 && elem.value.charCodeAt(index) != 9
				&& elem.value.charCodeAt(index) != 13 && elem.value.charCodeAt(index) != 10)
					return false;
			}
		}
		return true;
	}
	catch(e) {
		return true;
	}
}

function appendStrParam(frmId, strParam)
{
	with ( frmId )
	{
		for ( n=0; n < elements.length; n++ )
		{
			if ( elements[n].name.substr(0, 3) == "$D_" )
			{
				if (( elements[n].type == "checkbox" || elements[n].type == "radio" ) && !elements[n].checked ) continue;
				if ( elements[n].type == "select-multiple" )
				{
					for ( m=0;m < elements[n].options.length;m++ )
					{
						if ( elements[n].options[m].selected )
							strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].options[m].value);
					}
				}
				else
					strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].value);
			}
		}

		for ( n=0; n < elements.length; n++ )
		{
			if ( elements[n].name.substr(0, 3) == "$N_" )
			{
				if (( elements[n].type == "checkbox" || elements[n].type == "radio" ) && !elements[n].checked ) continue;
				if ( elements[n].type == "select-multiple" )
				{
					for ( m=0;m < elements[n].options.length;m++ )
					{
						if ( elements[n].options[m].selected )
							strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].options[m].value);
					}
				}
				else
					strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].value);
			}
		}
	}
	return strParam;
}

function appendStrParamByPrefix(strParam, prefix, formId)
{
	if ( formId == null ) formId = form1;
	with ( formId )
	{
		for ( n=0; n < elements.length; n++ )
		{
			if ( elements[n].name.indexOf(prefix) == 0 )
			{
				if (( elements[n].type == "checkbox" || elements[n].type == "radio" ) && !elements[n].checked ) continue;
				if ( elements[n].type == "select-multiple" )
				{
					for ( m=0;m < elements[n].options.length;m++ )
					{
						if ( elements[n].options[m].selected )
							strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].options[m].value);
					}
				}
				else
					strParam += "&" + elements[n].name + "=" + encodeURIComponent(elements[n].value);
			}
		}
	}
	return strParam;
}

// typeof(a)
//	Though the typeof operator can be used to find the type of objects, it has got some problems. so we can use the following global functions to wrap the typeof operator.

// This function returns true if a is an object, array, or function. It returns false if a is a string, number, Boolean, null, or undefined.
function isObject(a)
{
	return (typeof a == 'object' && !!a) || isFunction(a);
}

// This function returns true if a is a function. Beware that some native functions in IE were made to look like objects instead of functions. This function does not detect that.Netscape is better behaved in this regard.
function isFunction(a)
{
	return typeof a == 'function';
}

// Internet Explorer holds references to objects that are not actually javascript objects. So if we use the objects in javascript it will give error. But the typeof operator identifies them as javascript objects( problem!!!). Here we can use the isIEObject() function to identify those objects.
function isIEObject(a)
{
	return isObject(a) && typeof a.constructor != 'function';
}

// This function returns true if a is an array, meaning that it was produced by the Array constructor or by the [ ] array literal notation.
function isArray(a)
{
	return isObject(a) && a.constructor == Array;
}

// This function returns true if a is one of the Boolean values, true or false.
function isBoolean(a)
{
	return typeof a == 'boolean';
}


// This function returns true if a is the null value.
function isNull(a)
{
	return typeof a == 'object' && !a;
}

// This function returns true if a is a finite number. It returns false if a is NaN or Infinite. It also returns false if a is a string that could be converted to a number.
function isNumber(a)
{
	return typeof a == 'number' && isFinite(a);
}


// This function returns true if a is a string.
function isString(a)
{
	return typeof a == 'string';
}

// This function returns true if a is the undefined value. You can get the undefined value from an uninitialized variable or from an object's missing member.
function isUndefined(a)
{
	return typeof a == 'undefined';
}

