//document.write('<div id="xttpMsg" style="display:none"></div>');
//document.write('<iframe id="xttpFrame" width="0" height="0" frameborder="0"></iframe>');

if (typeof(e) != "function") function e(id) { return document.getElementById(id); }

var _xttp = function (name) {
	this.xmlHttp = null;
	this.name = name;
	this.msg = "";
	this.method = "get";
	this.url = "";
	this.data = "";
	this.func = "";
	this.init = function () {
		if (window.XMLHttpRequest)
			this.xmlHttp = new XMLHttpRequest();
		else if (window.ActiveXObject) {
			try {
				this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (error) {
				try {
					this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(error) {}
			}
		}
	};
	this.send = function (url, data, func) {
		this.showMsg();
		this.method = "post";
		this.url = url;
		this.data = data;
		this.func = func;
		setTimeout(this.name+".request()", 0);
	};
	this.request = function () {
		this.init();
		this.xmlHttp.open(this.method, this.url, false);
		if (this.method.toLowerCase() == "post")
			this.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		this.xmlHttp.send(this.data);
		if(this.func.indexOf("(") < 0) {
			var obj = e(this.func);
			obj.innerHTML = this.xmlHttp.responseText;
			if (obj.style.display == "none") obj.style.display = "";
		}
		else
			eval(this.func.replace(/\%s/g, this.name + ".xmlHttp.responseText"));
		//this.hideMsg();
	};
	this.showMsg = function (msg) {
		if (this.msg == "" && msg == undefined) return;
		var msgLayer = e("xttpMsg");
		msgLayer.innerHTML = msg != undefined ? msg : this.msg;
		msgLayer.style.display = "";
	};
	this.hideMsg = function () {
		e("xttpMsg").style.display = "none";
	};
};

function getfv(form) {
	var values = new Array(), vIndex = 0, type = "";
	for (var i = 0; i < form.elements.length; i++) {
		var obj = form.elements[i];
		if (obj.name) {
			if (((type = obj.type.toLowerCase()) == "checkbox" || type == "radio") && !obj.checked)
				continue;
		values[vIndex++] = obj.name + "=" + encodeURIComponent(obj.value);
		}
	}
	return values.join("&");
}