
// NOTICE : 이 파일은 UTF-8 로 인코딩되어야 합니다.

// NOTICE : 이 파일은 Eoneo Framework 공용 파일입니다. 
//			개별 제품에 대한 스크립트는 global.js 에 기술하십시오.

var gDebug = false;

Array.prototype.has = function (s)
{
	for (var i = 0; i < this.length ; i++ )
	{
		if (this[i] == s)
		{
			return true;
		}
	}
	return false;
}

String.prototype.trim = function ()
{
	var ret = this.replace (/(^\s*)|(\s*$)/g, "");
	return ret;
}

String.prototype.spaceOptimize = function()
{
	var ret = this.replace (/(\s){2,}/g, " ");
	return ret;
}

String.prototype.cntWord = function()
{
	return this.split(/\w+/).length;
}

Number.max = function (a,b) {
    return a<b?b:a;
}

Number.min = function (a,b) {
    return a>b?b:a;
}

Number.prototype.money = function() {
	return this.toString().money();
}



Math.mod = function(val,mod) {
    if (val < 0) {
        while(val<0) val += mod;
        return val;
    } else {
        return val%mod;
    }
}

window.getInnerWidth = function() {
    if (window.innerWidth) {
        return window.innerWidth;
    } else if (document.body.clientWidth) {
        return document.body.clientWidth;
    } else if (document.documentElement.clientWidth) {
        return document.documentElement.clientWidth;
    }
} 

window.getInnerHeight = function() {
    if (window.innerHeight) {
        return window.innerHeight;
    } else if (document.body.clientHeight) {
        return document.body.clientHeight;
    } else if (document.documentElement.clientHeight) {
        return document.documentElement.clientHeight;
    }
} 

String.prototype.endsWith = function(str) {
    return (this.length-str.length)==this.lastIndexOf(str);
}

String.prototype.reverse = function() {
    var s = "";
    var i = this.length;
    while (i>0) {
        s += this.substring(i-1,i);
        i--;
    }
    return s;
}

String.prototype.money = function() {
	var num = this.trim();

	num = Math.floor(num).toString();

	while((/(-?[0-9]+)([0-9]{3})/).test(num)) {
		num = num.replace((/(-?[0-9]+)([0-9]{3})/), "$1,$2");
	}
	return num;
}

String.prototype.toInt = function() {
    var a = new Array();
    for (var i = 0; i < this.length; i++) {
        a[i] = this.charCodeAt(i);
    }
    return a;
}

String.prototype.toInteger = function() {
	return parseInt(this.replace(/,/g,''));
}


Array.prototype.intArrayToString = function() {
    var a = new String();
    for (var i = 0; i < this.length; i++) {
        if(typeof this[i] != "number") {
            throw new Error("Array must be all numbers");
        } else if (this[i] < 0) {
            throw new Error("Numbers must be 0 and up");
        }
        a += String.fromCharCode(this[i]);
    }
    return a;    
}

Array.prototype.compareArrays = function(arr) {
    if (this.length != arr.length) return false;
    for (var i = 0; i < arr.length; i++) {
        if (this[i].compareArrays) { //likely nested array
            if (!this[i].compareArrays(arr[i])) return false;
            else continue;
        }
        if (this[i] != arr[i]) return false;
    }
    return true;
}

Array.prototype.map = function(fnc) {
    var a = new Array(this.length);
    for (var i = 0; i < this.length; i++) {
        a[i] = fnc(this[i]);
    }
    return a;
}

Array.prototype.foldr = function(fnc,start) {
    var a = start;
    for (var i = this.length-1; i > -1; i--) {
        a = fnc(this[i],a);
    }
    return a;
}

Array.prototype.foldl = function(fnc,start) {
    var a = start;
    for (var i = 0; i < this.length; i++) {
        a = fnc(this[i],a);
    }
    return a;
}

Array.prototype.exists = function (x) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == x) return true;
    }
    return false;
}

Array.prototype.filter = function(fnc) {
    var a = new Array();
    for (var i = 0; i < this.length; i++) {
        if (fnc(this[i])) {
            a.push(this[i]);
        }
    }
    return a;
}

Array.prototype.random = function() {
    return this[Math.floor((Math.random()*this.length))];
}

Array.prototype.shuffle = function()
{
	var arr = this.slice(0);
	for(i=0;i<arr.length;i++)
	{
     	var t = arr[i];
      	var r = Math.round(Math.random()*arr.length)+1;
      	arr[i] = arr[r];
      	arr[r] = t;
   }
   return arr;
}

Array.prototype.shuffleList = function()
{
	var arr = this;
	for(i=0;i<arr.length;i++)
	{
     	var t = arr[i];
      	var r = Math.round(Math.random()*arr.length);

		if (r >= arr.length)
			r--;

      	arr[i] = arr[r];
      	arr[r] = t;
   }
   return arr;
}

function EoneoObject() { }

EoneoObject.prototype = {};

EoneoObject.prototype.toQueryString = function() {
	var arr = [];

	for (var k in this)
	{
		if (k == "" || typeof this[k] == "function" || typeof this[k] == "object" || typeof this[k] == "array")
			continue;

		arr.push(k + "=" + escape(this[k]));
	}

	return arr.join('&');
}

function g(s)
{
	return (document.getElementById) ? document.getElementById(s) : document.all[s];
}

Function.prototype.extend = function(obj)
{
	var _this = this;
	
	for (var k in obj.prototype)
	{
		_this.prototype[k] = obj[k];
	}

	return _this;
}

function formSubmit(formName, oElement)
{
	var oForm = document.forms[formName];

	if (oElement != undefined)
	{
		for (var k in oElement)
		{
			if (k == "" || typeof oElement[k] == "function" || typeof oElement[k] == "object" || typeof oElement[k] == "array")
				continue;
			
			oForm[k].value = oElement[k];
		}
	}

	oForm.submit();
}

function getFormValue(obj)
{
	// 이럴 땐.. 폼이 중복일 가능성이 있음
	if (obj.tagName == undefined)
		return null;

	switch (obj.tagName.toString().toLowerCase())
	{
		case "input":
			switch (obj.type.toString().toLowerCase())
			{
				case "text":
				case "hidden":
				case "password":
				case "file":
					return obj.value;
					break;
				case "radio":
					return getRadioValue(obj);
					break;
				case "checkbox":
					alert('클라이언트 폼 경고: 체크박스는 getFormValue() 를 통해 값을 획득 할 수 없습니다.');
					return '';
					break;			
			}
			break;
		case "textarea":
			return obj.value;
			break;
		case "select":
			return selectedValue(obj);
			break;
	}
}

function getRadioValue(obj)
{
	if (typeof obj == "string")
	{
		var strElName = obj;
		var oInput = document.getElementsByTagName('input');

		for (var i = 0; i < oInput.length ; i++ )
		{
			if (oInput[i].type == "radio" && oInput[i].name == strElName && 
				oInput[i].checked)
				return oInput[i].value;
		}
	}

	if (obj.length == undefined)
		return obj.value;

	for (var i = 0; i < obj.length ; i++ )
	{
		if (obj[i].checked)
			return obj[i].value;
	}

	return null;
}

function setRadioValue(obj, value)
{
	if (obj.length == undefined)
		return ;

	for (var i = 0; i < obj.length ; i++ )
	{
		if (obj[i].value == value)
		{
			obj[i].checked = true;
			return ;
		}
	}

	return ;
}

function selectedValue(obj)
{
	if (obj.selectedIndex < 0)
		return '';

	return obj.options[obj.selectedIndex].value;
}

function selectedText(obj)
{
	if (obj.selectedIndex < 0)
		return '';

	return obj.options[obj.selectedIndex].text;
}

function isChecked(obj)
{
	return obj.checked;	
}

function isKorean(sTarget)
{
	return /^[가-힣]+$/.test(sTarget);
}

function isEnglish(sTarget)
{
	return /^[a-zA-Z0-9\.,~!\?\$%@&'\"\\\- ]+$/.test(sTarget);
}

function isEnglish2(sTarget)
{
	var temp = sTarget.replace (/[가-힣]+/g, "");
	return (temp.length == sTarget.length);
}

function isPureEnglishWord(sTarget)
{
	return /^[a-zA-Z0-9\.,~!\?\$%@&'\"\\\-]+$/.test(sTarget);
}

function isEmail(sTarget)
{ 
	return /^[0-9a-z]([-_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,4}$/i.test(sTarget); 
}

function isDomain(sTarget)
{
	return /^[0-9a-zA-Z-]+(\.)+([0-9a-zA-Z-]+)([\.0-9a-zA-Z-])*$/.test(sTarget);
}

function isNumber(sTarget)
{
	return /^[0-9]+$/.test(sTarget);
}

function $(s)
{
	return (document.getElementById ) ? document.getElementById(s) : document.all[s];
}

function __get(varName)
{
	return eval(varName);
}

function checkedValue(name)
{
	var obj = null;

	for (var i = 0; i < 10 ; i++ )
	{
		var obj = g(name + "[" + i + "]");

		if (obj == undefined)
			break;
		
		if (isChecked(obj))
			return g(name + "[" + i + "]").value;
	}

	return null;
}

function setFocus(objName, interval)
{
	if (interval != undefined)
	{
		setTimeout('g("' + objName + '").focus();', interval * 1000);
	}
	else
	{
		g(objName).focus();
	}
}

function getCheckboxValue(s)
{
	var inputs = document.getElementsByTagName("input");

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'checkbox' &&
			dat.id.indexOf(s + "[") > -1 &&
			dat.checked == true)
		{
			return dat.value;
		}
	}

	return -1;
}

function getCheckboxValues(s, bOnlyChecked)
{
	if (bOnlyChecked == undefined)
		bOnlyChecked = true;

	var inputs = document.getElementsByTagName("input");
	var arr = [];

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'checkbox' &&
			dat.id.indexOf(s + "[") > -1 &&
			( (bOnlyChecked && dat.checked == true) || !bOnlyChecked ))
		{
			arr.push(dat.value);
		}
	}

	return arr;
}

function getCheckboxObjects(s, bOnlyChecked)
{
	if (bOnlyChecked == undefined)
		bOnlyChecked = true;

	var inputs = document.getElementsByTagName("input");
	var arr = [];

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'checkbox' &&
			dat.id.indexOf(s + "[") > -1 &&
			( (bOnlyChecked && dat.checked == true) || !bOnlyChecked ))
		{
			arr.push(dat);
		}
	}

	return arr;
}

function getInputValues(s)
{
	var inputs = document.getElementsByTagName("input");
	var arr = [];

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'text' &&
			dat.id.indexOf(s + "[") > -1 &&
			dat.value.toString().trim() != "")
		{
			arr.push(dat.value);
		}
	}

	return arr;
}

function setCheckboxValue(s, v)
{
	var inputs = document.getElementsByTagName("input");

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'checkbox' &&
			dat.id.indexOf(s + "[") > -1)
		{
			dat.checked = dat.value == v ? true : false;
		}
	}
}

function multipleChecked(prefix, arrData, startIdx, endIdx)
{
	for (var i = startIdx; i <= endIdx; i++ )
	{
		var obj = g(prefix + i);
		if (obj != undefined && obj.type == "checkbox")
		{
			obj.checked = in_array(i, arrData);
		}
	}
}

function selectTagLock()
{
	var inputs = document.getElementsByTagName("select");

	for (var i = 0; i < inputs.length; i++)
	{
		var obj = inputs[i];
		obj.style.visibility = "hidden";	
	}
}

function selectTagUnlock()
{
	var inputs = document.getElementsByTagName("select");

	for (var i = 0; i < inputs.length; i++)
	{
		var obj = inputs[i];
		obj.style.visibility = "visible";	
	}
}

function printFlash(objParm, parm, output)
{
//	var flaVer = '10,1,53,64';
	var flaVer = '9,0,124,0';
	var htmls = [];

	// IE 사용자 이거나, SSL 환경이 아닌 경우에만 <object> 태그로
	if (window.navigator.appVersion.indexOf("MSIE") > -1 || location.protocol.indexOf("http:") > -1)	
	{
		htmls.push('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		htmls.push(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flaVer + '"');
		for (var key in objParm)
		{
			if(key == "name") continue;
			
			htmls.push(' ' + key + '="' + objParm[key] + '"');
		}
		htmls.push('>');
		htmls.push('<PARAM name="quality" value="high">');
		for (var key in parm)
		{
			htmls.push('<PARAM name="' + key + '" value="' + parm[key] + '">');
		}

		htmls.push('</OBJECT>');
	}
	else
	{
		htmls.push('<embed');
		for (var key in objParm)
		{
			if (key == "movie")
			{
				continue;
			}
			htmls.push(' ' + key + '="' + objParm[key] + '"');
		}
		for (var key in parm)
		{
			htmls.push(' ' + key + '="' + parm[key] + '"');
		}
		htmls.push(' quality="high"');
		htmls.push(' pluginspage="http://www.macromedia.com/go/getflashplayer"');
		htmls.push(' type="application/x-shockwave-flash" />');
	}


	if (typeof(output) == "undefined" || output == "")
		document.write(htmls.join(''));
	else
		return htmls.join('');
}

function showFlash(id, width, height, movie, flashvars, style, wmode, bgColor)
{
	if (wmode == undefined)
		wmode = "transparent";

	if (bgColor == undefined)
		bgColor = "#FFFFFF";

	var objParm = {id:null,width:null,height:null,movie:null,style:null};
	var parm = {flashvars:null};

	objParm.id = id;
	objParm.name = id;
	objParm.width = width;
	objParm.height = height;
	objParm.movie = movie;
	objParm.style = style;
	parm.menu = "false";
	parm.allowScriptAccess = "sameDomain";
	parm.swLiveConnect = "true";
	parm.wmode = wmode;
	parm.bgcolor = bgColor;
	parm.scale = "exactfit";
	parm.src = movie;
	parm.flashvars = flashvars;
	parm.allowfullscreen = 'true';
	printFlash(objParm, parm);
}

function outputFlash(id, width, height, movie, flashvars, style)
{
	var objParm = {id:null,width:null,height:null,movie:null,style:null};
	var parm = {flashvars:null};

	objParm.id = id;
	objParm.name = id;
	objParm.width = width;
	objParm.height = height;
	objParm.movie = movie;
	objParm.style = style;
	parm.menu = "false";
	parm.allowScriptAccess = "sameDomain";
	parm.swLiveConnect = "true";
	parm.wmode = "transparent";
	parm.bgcolor = "#FFFFFF";
	parm.scale = "exactfit";
	parm.src = movie;
	parm.flashvars = flashvars;
	return printFlash(objParm, parm, "output");
}

function toggle(obj)
{
	if (obj==null)
		return;

	if (obj.style.display != 'none')
		hide(obj);
	else
		show(obj);
}

function show(obj, bShow)
{
	if(bShow == undefined || bShow == true)
	{
		try
		{
			if(obj.style.display == '') return;
			obj.style.display = "";
		}
		catch(e){}
	}
	else
	{
		hide(obj);
	}
}

function hide(obj)
{
	try
	{
		if(obj.style.display == 'none') return;
		obj.style.display = "none";
	}
	catch(e){}
}

function showFullScreen(id)
{
	var obj = g(id);
	show(obj);
}

showFullScreen.prototype = {};

function fx(nNewPadding,el)
{
	try
	{
		while (el.tagName!="TD")
			el = el.parentNode;
		var nPadding = parseInt(el.getAttribute("nPadding"));
		if (!nPadding)
		{
			var nPadding = parseInt(el.currentStyle.paddingTop);
			el.setAttribute("nPadding",nPadding);
		}

		el.style.paddingTop=nPadding+nNewPadding;
	}
	catch(e){}
}

function defx(el)
{
	try
	{
		while (el.tagName!="TD")
			el = el.parentNode;
		var nPadding = parseInt(el.getAttribute("nPadding"));
		el.style.paddingTop = nPadding;
	}
	catch(e){}
}

function addSelectOptionList(object, text, value)
{
	lObjLength=object.length;
	object.options[lObjLength] = new Option(text,value);
}

function in_array(needle, haystack)
{
	for (var i in haystack)
	{
		if (haystack[i] == needle)
		{
			return true;
		}
	}

	return false;
}

function index_search(needle, haystack)
{
	for (var i in haystack)
	{
		if (haystack[i] == needle)
		{
			return i;
		}
	}

	return -1;
}

function array_search_delete(needle, haystack)
{
	for (var i in haystack)
	{
		if (haystack[i] == needle)
		{
			delete haystack[i];
		}
	}

	return haystack;
}

function attachEvent_(obj, evt, fuc, useCapture)
{	
	if(!useCapture) 
	{
		useCapture=false;
	}

	if(obj.addEventListener) // W3C DOM 지원 브라우저
	{ 
		return obj.addEventListener(evt,fuc,useCapture);
	} 
	else if(obj.attachEvent) // MSDOM 지원 브라우저
	{
		return obj.attachEvent(evt, fuc);
	} 
	else // NN4 나 IE5mac 등 비 호환 브라우저
	{ 
		//MyAttachEvent(obj, evt, fuc);
		//obj[evt]=function() { MyFireEvent(obj,evt) };
	}
}

function detachEvent_(obj, evt, fuc, useCapture) 
{
	if(!useCapture) 
	{
		useCapture=false;
	}

	if(obj.removeEventListener) 
	{
		return obj.removeEventListener(evt,fuc,useCapture);
	} 
	else if(obj.detachEvent) 
	{
		return obj.detachEvent(evt, fuc);
	} 
	else 
	{
		MyDetachEvent(obj, evt, fuc);
		obj[evt]=function() { MyFireEvent(obj,evt) };
	}
}

// ***** //

function isValidLoginID(s, minLen, maxLen)
{
	if (minLen == undefined)
		minLen = 4;

	if (maxLen == undefined)
		maxLen = 20;

	if (s.trim() == "")
	{
		return false;
	}

	if (s.length < minLen || s.length > maxLen)
	{
		return false;
	}

	var pattern = eval("/[a-zA-Z0-9\-_]+/g");

	if (s.replace(pattern,"") != "")
	{
		return false;
	}

	return true;
}

function isValidPassword(s, minLen, maxLen)
{
	if (minLen == undefined)
		minLen = 4;

	if (maxLen == undefined)
		maxLen = 20;

	if (s.trim() == "")
	{
		return false;
	}

	return (s.length >= minLen && s.length <= maxLen);
}

function setPng24(obj)
{
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');

	obj.style.filter =

	"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
	obj.src=''; 
	return '';
}

function autoNext(formObj, obj, prevFormName, nextFormName, len)
{
	if (nextFormName != "" && obj.value.length >= len && event.keyCode != 8 && event.keyCode != 46)
	{
		formObj[nextFormName].focus();
	}
	else if (prevFormName != "" && obj.value == "" && event.keyCode == 8)
	{
		formObj[prevFormName].focus();
	}
	else if (event.keyCode == 8)
	{
		obj.value = obj.value;
	}
}

// 오프너를 끝까지 추척하여 제일 처음 창을 열어준 창의 핸들을 반환합니다.
function getParentWindow(hWnd)
{
	if (hWnd == undefined)
		return {location:{href:""},focus:function(){},_child:function(){return null;}};

	while (hWnd != null)
	{
		if (hWnd.opener)
			return getParentWindow(hWnd.opener);
		else
			return hWnd;
	}
}

// 전체 선택/해제
function checkAll(prefix)
{
	var inputs = document.getElementsByTagName("input");

	checkAll[prefix] = !checkAll[prefix];

	for (var i = 0; i < inputs.length; i++)
	{
		var dat = inputs[i];
		if (dat.type.toLowerCase() == 'checkbox' &&
			dat.id.indexOf(prefix + '[') > -1)
		{
			dat.checked = checkAll[prefix];

			if (typeof dat.onclick == "function")
				dat.onclick();
		}
	}
}

checkAll.prototype = {};


function incrementCnt(id, max, fCallbackFunc)
{
	var obj = g(id);
	var cnt = parseInt(obj.value);

	if (max == undefined)
		max = 1;

	if (cnt >= max)
	{
		obj.value = max;
	}
	else
	{
		obj.value = cnt + 1;
		if (fCallbackFunc != undefined)
			fCallbackFunc();
	}
}

function decrementCnt(id, min, fCallbackFunc)
{
	var obj = g(id);
	var cnt = parseInt(obj.value);
	
	if (min == undefined)
		min = 1;

	if (cnt <= min)
	{
		obj.value = min;
	}
	else
	{
		obj.value = cnt - 1;
		if (fCallbackFunc != undefined)
			fCallbackFunc();
	}
}

function insertRow(oTable, arr, trId, idx)
{
	var oRow	= oTable.insertRow(idx || oTable.rows.length);

	if (trId)
		oRow.id = trId;
	
	for (var i = 0; i < arr.length ; i++ )
	{
		var oCell	= oRow.insertCell(i);

		if (trId)
			oCell.id = trId + '[' + i + ']';

		if (typeof arr[i] == "object")
		{
			bind(arr[i], oCell);
		}
		else
		{
			oCell.innerHTML = arr[i];
		}
	}
}

function bind(oBind, oTar)
{
	for (var k in oBind)
	{
		if (typeof oBind[k] == "object")
		{
			bind(oBind[k], oTar[k]);
			return ;
		}

		oTar[k] = oBind[k];
	}
}

function showCal(objName)
{
	g(objName).orgValue = g(objName).value;

	window.showModalDialog(gURL_root + gSitePath + "/calendar.html", g(objName), "dialogWidth=290px;dialogHeight=262px;resizable=no;status=no;scroll=no");

	if (g(objName).onchange != undefined)
		g(objName).onchange();
}

function showCal2(objName0, objName1)
{
	g(objName0).orgValue = g(objName0).value;
	g(objName1).orgValue = g(objName1).value;

	window.showModalDialog(gURL_root + gSitePath + "/calendar2.html", [g(objName0), g(objName1)], "dialogWidth=580px;dialogHeight=262px;resizable=no;status=no;scroll=no");

	if (g(objName0).onchange != undefined)
		g(objName0).onchange();

	if (g(objName1).onchange != undefined)
		g(objName1).onchange();

}

function getCookie(name)
{
	
	var nameOfCookie = name + "=";
	var x = 0;
	
	while (x <= document.cookie.length)
	{
		
		var y = (x+nameOfCookie.length);
		
		if (document.cookie.substring(x,y) == nameOfCookie)
		{
		
			if ((endOfCookie=document.cookie.indexOf(";",y)) == -1)
				endOfCookie = document.cookie.length;
				return unescape(document.cookie.substring(y,endOfCookie));
		}
	
		x = document.cookie.indexOf(" ",x) + 1;
		
		if (x == 0)
		break;
	}
	return "";
}

function setCookie(name, value, expiredays)
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}



// 마우스 위치 반환
function Mouse(e)
{
	try
	{
		Mouse._x = document.layers || (document.getElementById && !document.all) ? e.pageX : event.x + document.body.scrollLeft;
		Mouse._y = document.layers || (document.getElementById && !document.all) ? e.pageY : event.y + document.body.scrollTop;	
	}
	catch (e)
	{
		Mouse._x = null;
		Mouse._y = null;
	}
}

function isValidSSN(ssn)
{
	var weight = '234567892345'; // 자리수 weight 지정
	var len = ssn.length;
	var sum = 0;

	if (len != 13)
		return false;

	for (var i = 0; i < 12; i++) {
		sum = sum + (ssn.substr(i,1)*weight.substr(i,1));
	}

	var rst = sum%11;
	var result = 11 - rst;

	if (result == 10)
		result = 0;
	else if (result == 11)
		result = 1;

	var ju13 = ssn.substr(12,1);

	return (result == ju13);
}

function toggleChecked(objName)
{
	g(objName).checked = !g(objName).checked;
}

function setChecked(objName, objAtt)
{
	g(objName).checked = true;

	if (objAtt != undefined)
	{
		for (var k in objAtt)
		{
			g(objName)[k] = objAtt[k];
		}
	}
}

function doBlink(bPlay)
{
	if (!document.all)
		return ;

	if (bPlay == undefined)
		var bPlay = true;

	if (!bPlay)
	{
		clearTimeout(this.timeoutId);
		return true;
	}

	var blink = document.all.tags("blink");
					 
	for (var i=0; i<blink.length; i++)
	{
		blink[i].style.visibility = (blink[i].style.visibility == "") ? "hidden" : "";
	}

	
	this.timeoutId = setTimeout("doBlink()", 500);
}

function changeInnerHtml(id, strHTML)
{
	g(id).innerHTML = strHTML;
}


function getBytes(str)
{
	var l = 0;
	for (var i=0; i<str.length; i++)
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
	return l;
}


if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){
	HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) 
				this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}
}

if (typeof window.document.attachEvent != "undefined")
	window.document.attachEvent("onmousemove",Mouse);

function S4()
{
   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

function guid()
{
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}

function checkChangedValue(oTxt, elementId)
{
	if (oTxt.value.toString().trim() != oTxt.orgValue.toString().trim())
		show(g(elementId));
	else
		hide(g(elementId));
}

function createXmlHttpRequest()
{
	var xmlHttp = null;

	if(window.ActiveXObject)
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if(window.XMLHttpRequest)
		xmlHttp = new XMLHttpRequest();

	return xmlHttp;
}

function sendXmlHttpRequest(url, oForm, fnCallBack, oArg)
{
    var xmlHttp = createXmlHttpRequest();

	if (fnCallBack != undefined)
	{
		xmlHttp.onreadystatechange = function()
									{
										if(xmlHttp.readyState == 4)
										{
											if(xmlHttp.status == 200)
											{
												eval(fnCallBack)(xmlHttp, oArg);
											}
										}
									};
	}

	var arrQrt = [];

	for (var name in oForm )
	{
		arrQrt.push(name + '=' + escape(oForm[name]));
	}

	var strQrt = arrQrt.join('&');

    xmlHttp.open("POST", url, fnCallBack == undefined ? false : true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
    xmlHttp.send(strQrt);

	if (fnCallBack == undefined)
		return xmlHttp;
}

function form2obj(formName)
{
	if (typeof formName == "string")
		var oForm = document.forms[formName];
	else
		var oForm = formName;

	var elems = oForm.elements;
	var oRadioForm = {};
	var dat = {};

	for (var i=0;i<elems.length;i++)
	{
		var elem = elems[i];

		if (elem.tagName.toUpperCase() == "INPUT")
		{
			switch (elem.type)
			{
				case "hidden":
				case "password":
				case "text":
					dat[elem.name] = elem.value;
					break;
				case "radio":
					if (elem.checked)
						dat[elem.name] = elem.value;
					break;
			}
		}
		else if (elem.tagName.toUpperCase() == "TEXTAREA")
		{
			dat[elem.name] = elem.value;
		}
		else if (elem.tagName.toUpperCase() == "SELECT")
		{
			if (elem.selectedIndex < 0)
				return null;

			dat[elem.name] = elem.options[elem.selectedIndex].value;
		}
	}

	return dat;
};

function parse_str(queryStr)
{
	var arr = queryStr.split("&");
	var temp = '';
	var obj = new EoneoObject;
	
	for (var i = 0; i < arr.length ; i++ )
	{
		temp = arr[i].split("=",2);
		obj[temp[0]] = temp[1];
	}

	return obj;	
}
