//// JScript source code
//var ajax = {};
//ajax.xhr = {};
//
//// XMLHttpRequest »ý¼ºÇÏ±â À§ÇÑ Request Å¬·¡½ºÀÇ »ý¼ºÀÚ ÇÔ¼ö.
//// url : ¼­¹ö url
//// params :
//// callback : callback ÇÔ¼ö¸í
//// method : È£Ãâ¹æ½Ä (GET, POST - Default GET¹æ½Ä)
//ajax.xhr.Request = function(url, params, callback, method)
//{
//    this.url = url;
//    this.params = params;
//    this.callback = callback;
//    this.method = method;
//
//    this.send();
//}
//
//
//// ºê¶ó¿ìÀú¿¡ µû¶ó XMLHttpRequest °´Ã¼¸¦ »ý¼ºÇØ ÁÖ´Â ÇÔ¼ö getXMLHttpRequest ¸â¹öÇÔ¼ö¿Í send ¸â¹öÇÔ¼ö Á¤ÀÇ
//ajax.xhr.Request.prototype = {
//    getXMLHttpRequest : function()
//    {
//        if (window.ActiveXObject)
//        {
//            try
//            {
//                return new ActiveXObject("MSXML2.XMLHTTP");
//            }
//            catch (e)
//            {
//                try
//                {
//                    return new ActiveXObject("Microsoft.XMLHTTP");
//                } catch (e1)
//                {
//                    return null;
//                }
//            }
//        }
//        else if (window.XMLHttpRequest) {
//            return new XMLHttpRequest;
//        }
//        return null;
//    },
//
//	// XMLHttpRequest¸¦ »ç¿ëÇØ¼­ ÁöÁ¤µÈ URL·Î ÁöÁ¤µÈ ¿äÃ»ÀÎÀÚ¸¦
//	// Àü¼Û ¹æ½Ä(GET/POST)¿¡ µû¶ó¼­ À¥¼­¹ö¿¡ ¿äÃ»À» Àü¼ÛÇÑ´Ù.
//	// ¼­¹öÀÇ ÀÀ´ä °á°ú´Â callbackÀ¸·Î ÁöÁ¤µÈ ÄÝ¹é ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.
//	send : function () {
//		this.httpRequest = this.getXMLHttpRequest();
//
//		// Àü¼Û ¹æ½ÄÀÌ »ý·«µÈ °æ¿ì ±âº»À¸·Î GET ¹æ½ÄÀ¸·Î ¼³Á¤ÇÑ´Ù.
//		var httpMethod = this.method ? this.method : 'GET'
//
//		// Àü¼Û ¹æ¹ýÀÌ GET/POST ÀÌ¿Ü´Â ¹«Á¶°Ç GET ¹æ½ÄÀ¸·Î ¼³Á¤ÇÑ´Ù.
//		if (httpMethod != 'GET' && httpMethod != 'POST')
//		{
//			httpMethod = 'GET'
//		}
//
//		// ¿äÃ» ÀÎÀÚÀÇ ±âº»°ªÀ» ¼³Á¤ÇÑ´Ù.
//		var httpParams = "";
//		if (this.params != null && this.params != '') {
//			for (var key in this.params) {
//				if (httpParams == "") {
//					httpParams = key + '=' + encodeURIComponent(this.params[key]);
//				}
//				else {
//					httpParams += '&' + key + '=' + encodeURIComponent(this.params[key]);
//				}
//			}
//		}
//
//		var httpUrl = this.url;
//		// Àü¼Û ¹æ½ÄÀÌ GET ÀÌ¸é¼­ ¿äÃ» ÀÎÀÚ°¡ Á¸ÀçÇÒ °æ¿ì URL µÚ¿¡ ¿äÃ»ÀÎÀÚ¸¦ Ãß°¡.
//		if (httpMethod == 'GET' && httpParams == '')
//		{
//			httpUrl = httpUrl + "?" + httpParams;
//		}
//
//		// Àü¼Û ¹æ½Ä°ú URLÀ» ¼³Á¤ÇÑ´Ù.
//		this.httpRequest.open(httpMethod, httpUrl, true);
//
//		// Àü¼Û ¹æ½ÄÀÌ POSTÀÌ¸é Àü¼ÛÇÒ ÄÁÅÙÃ÷ÀÇ Å¸ÀÔÀ» ÁöÁ¤ÇÑ´Ù.
//		if (httpMethod == 'POST')
//		{
//			this.httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//		}
//
//		// readyState ¼Ó¼ºÀÌ º¯°æµÉ ¶§¸¶´Ù È£ÃâµÉ ÄÝ¹é ÇÔ¼ö¸¦ ÁöÁ¤ÇÑ´Ù.
//		var localThis = this;
//
//		this.httpRequest.onreadystatechange = function () {
//			// »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ ÄÝ¹é ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.
//			localThis.callback(localThis.httpRequest);
//		}
//
//		// Àü¼Û ¹æ½ÄÀÌ POSTÀÌ¸é ¿äÃ» ÀÎÀÚ¸¦ send() ÀÇ ÀÎÀÚ·Î Àü´ÞÇÑ´Ù.
//		this.httpRequest.send(httpMethod == 'POST' ? httpParams : null);
//	}
//}
//
//
var ajax = {};
ajax.xhr = {};

ajax.xhr.Request = function(url, params, callback, method) {
	this.onTimeout = function (obj) {
		setTimeout(function() {
			if (obj.req.readyState!="4") {
				obj.req.abort();
				obj.send();
			}
		}, 3000);
	}
	this.onTimeout(this);
	this.url = url;
	this.params = params;
	this.callback = callback;
	this.method = method;
	this.send();
}
ajax.xhr.Request.prototype = {
	getXMLHttpRequest: function() {
		if (window.ActiveXObject) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e1) { return null; }
			}
		} else if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else {
			return null;
		}
	},
	send: function() {
		this.req = this.getXMLHttpRequest();

		var httpMethod = this.method ? this.method : 'GET';
		if (httpMethod != 'GET' && httpMethod != 'POST') {
			httpMethod = 'GET';
		}
		var httpParams = (this.params == null || this.params == '') ?
		                 'timestamp=' + (new Date()).getTime() : this.params + '&timestamp=' + (new Date()).getTime();
		var httpUrl = this.url;
		if (httpMethod == 'GET' && httpParams != null) {
			httpUrl = httpUrl + "?" + httpParams;
		}

		this.req.open(httpMethod, httpUrl, true);
		this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		var request = this;
		this.req.onreadystatechange = function() {
			request.onStateChange.call(request);
		}
		this.req.send(httpMethod == 'POST' ? httpParams : null);
	},
	onStateChange: function() {
		this.callback(this.req);
	}
}

ajax.Event = {};
ajax.Event.addListener = function(element, name, observer, useCapture) {
    useCapture = useCapture || false;

	if (element.addEventListener) {
		element.addEventListener(name, observer, useCapture);
	} else if (element.attachEvent) {
		element.attachEvent('on' + name, observer);
	}
}
ajax.Event.removeListener = function(element, name, observer, useCapture) {
	useCapture = useCapture || false;

	if (element.removeEventListener) {
		element.removeEventListener(name, observer, useCapture);
	} else if (element.detachEvent) {
		element.detachEvent('on' + name, observer);
	}
}
ajax.Event.getTarget = function(event) {
	if (event == null) return null;
	if (event.target) return event.target;
	else if (event.srcElement) return event.srcElement;
	return null;
}
ajax.Event.getMouseXY = function(event) {
	var mouseX = event.clientX;
	var mouseY = event.clientY;

	var dd = document.body;
	var db = document.documentElement;
	if (dd) {
		mouseX += dd.scrollLeft;
		mouseY += dd.scrollTop;
	} else if (db) {
		mouseX += db.scrollLeft;
		mouseY += db.scrollTop;
	}
	return {x: mouseX, y: mouseY};
}
ajax.Event.isLeftButton= function(event) {
	return (event.which) ?
	       event.which == 1 && event.button == 0 :
	       (event.type == 'click') ? event.button == 0 : event.button == 1;
}
ajax.Event.isRightButton = function(event) {
	return event.button == 2;
}
ajax.Event.stopPropagation = function(event) {
	if (event.stopPropagation) {
	    event.stopPropagation();
	} else {
	    event.cancelBubble = true;
	}
}
ajax.Event.preventDefault = function(event) {
	if (event.preventDefault) {
	    event.preventDefault();
	} else {
	    event.returnValue = false;
	}
}
ajax.Event.stopEvent = function(event) {
	ajax.Event.stopPropagation(event);
	ajax.Event.preventDefault(event);
}
ajax.Event.bindAsListener = function(func, obj) {
	return function() {
		return func.apply(obj, arguments);
	}
}

ajax.GUI = {};
ajax.GUI.setOpacity = function(el, opacity) {
	if (el.filters) {
		el.style.filter = 'alpha(opacity=' + opacity * 100 + ')';
	} else {
		el.style.opacity = opacity;
	}
}
ajax.GUI.getStyle = function(el, property) {
	var value = null;
	var dv = document.defaultView;

	if (property == 'opacity' && el.filters) {// IE opacity
		value = 1;
		try {
			value = el.filters.item('alpha').opacity / 100;
		} catch(e) {}
	} else if (el.style[property]) {
		value = el.style[property];
	} else if (el.currentStyle && el.currentStyle[property]) {
		value = el.currentStyle[property];
	} else if ( dv && dv.getComputedStyle ) {
		// ´ë¹®ÀÚ¸¦ ¼Ò¹®ÀÚ·Î º¯È¯ÇÏ°í ±× ¾Õ¿¡ '-'¸¦ ºÙÀÎ´Ù.
		var converted = '';
		for(i = 0, len = property.length;i < len; ++i) {
			if (property.charAt(i) == property.charAt(i).toUpperCase()) {
				converted = converted + '-' +
				            property.charAt(i).toLowerCase();
			} else {
				converted = converted + property.charAt(i);
			}
		}
		if (dv.getComputedStyle(el, '').getPropertyValue(converted)) {
			value = dv.getComputedStyle(el, '').getPropertyValue(converted);
		}
	}
	return value;
}

ajax.GUI.getXY = function(el) {
	// elÀº ¹®¼­¿¡ Æ÷ÇÔµÇ¾î ÀÖ¾î¾ß ÇÏ°í, È­¸é¿¡ º¸¿©¾ß ÇÑ´Ù.
	if (el.parentNode === null || el.style.display == 'none') {
		return false;
	}

	var parent = null;
	var pos = [];
	var box;

	if (document.getBoxObjectFor) { // gecko ¿£Áø ±â¹Ý
		box = document.getBoxObjectFor(el);
		pos = [box.x, box.y];
	} else { // ±âÅ¸ ºê¶ó¿ìÀú
		pos = [el.offsetLeft, el.offsetTop];
		parent = el.offsetParent;
		if (parent != el) {
			while (parent) {
				pos[0] += parent.offsetLeft;
				pos[1] += parent.offsetTop;
				parent = parent.offsetParent;
			}
		}
		// ¿ÀÆä¶ó¿Í »çÆÄ¸®ÀÇ 'absolute' postionÀÇ °æ¿ì
		// bodyÀÇ offsetTopÀ» Àß¸ø °è»êÇÏ¹Ç·Î º¸Á¤ÇØ¾ß ÇÑ´Ù.
		var ua = navigator.userAgent.toLowerCase();
		if (
			ua.indexOf('opera') != -1
			|| ( ua.indexOf('safari') != -1 && this.getStyle(el, 'position') == 'absolute' )
		) {
			pos[1] -= document.body.offsetTop;
		}
	}

	if (el.parentNode) { parent = el.parentNode; }
	else { parent = null; }

	// body ¶Ç´Â html ÀÌ¿ÜÀÇ ºÎ¸ð ³ëµå Áß¿¡ ½ºÅ©·ÑµÇ¾î ÀÖ´Â
	// ¿µ¿ªÀÌ ÀÖ´Ù¸é ¾Ë¸Â°Ô Ã³¸®ÇÑ´Ù.
	while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') {
		pos[0] -= parent.scrollLeft;
		pos[1] -= parent.scrollTop;

		if (parent.parentNode) { parent = parent.parentNode; }
		else { parent = null; }
	}
	return {x: pos[0], y: pos[1]};
}
ajax.GUI.getX = function(el) {
	return ajax.GUI.getXY(el).x;
}
ajax.GUI.getY = function(el) {
	return ajax.GUI.getXY(el).y;
}
ajax.GUI.getBounds = function(el) {
	var xy = ajax.GUI.getXY(el);
	return {
		x: xy.x,
		y: xy.y,
		width: el.offsetWidth,
		height: el.offsetHeight
	};
}
ajax.GUI.setXY = function(el, x, y) {
	var pageXY = ajax.GUI.getXY(el);
	if (pageXY === false) { return false; }
	var position = ajax.GUI.getStyle(el, 'position');
	if (!position || position == 'static') {
		el.style.position = 'absolute';
	}
	var delta = {
		x: parseInt( ajax.GUI.getStyle(el, 'left')),
		y: parseInt( ajax.GUI.getStyle(el, 'top'))
	};

	if ( isNaN(delta.x) ) { delta.x = 0; }
	if ( isNaN(delta.y) ) { delta.y = 0; }

	if (x != null) {
		el.style.left = (x - pageXY.x + delta.x) + 'px';
	}
	if (y != null) {
		el.style.top = (y - pageXY.y + delta.y) + 'px';
	}

	return true;
}


//xml Ã¹¹øÂ°³ëµå °ª °¡Á®¿À±â
function xtxt(obj){
	if (obj==null)
		return '';
	else
	{
		if (obj.firstChild==null)
			return '';
		else
			return obj.firstChild.nodeValue;
	}
}
