

//ÀÎÅ¬·çµå jsÆÄÀÏ - ajax ¸®Äù½ºÆ®	

var ajax = {};
ajax.xhr = {};

ajax.xhr.Request = function(url, params, callback, method) {
	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 == '') ? 
		                 '' : this.params;
		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);
	}
}

function findPosX(obj){
var curleft = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
		curleft += obj.offsetLeft;
		obj = obj.offsetParent;
		}
	}
	else if(obj.x) curleft += obj.x;

	return curleft;
}

function findPosY(obj){
var curtop = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
		curtop += obj.offsetTop;
		obj = obj.offsetParent;
		}
	}
	else if(obj.y) curtop += obj.y;

	return curtop;
}


function _(obj) {
	if (typeof obj == 'string')
    obj = document.getElementById(obj);
	obj.show = function() {
						obj.style.display = "block";
					}
	obj.hide = function() {
						obj.style.display = "none";
					}
	obj.status = function() {
						return (obj.style.display);
					}
	obj.html = function(html) {
						obj.innerHTML = html;
					}
	obj.setparameter = function(_obj) {
						 obj.parameter = _obj;
					}
	obj.getparameter = function() {
						 return obj.parameter;
					}
	return obj;
}

