﻿function TryThese() {
	for (i = 0; i < arguments.length; i++) {
		try {
			return arguments[i]();
		} catch(a) {}
	}
	return false;
}

function CreateXMLHTTP() {
	return TryThese(function() {
		return new ActiveXObject("Msxml2.XMLHTTP");
	},
	function() {
		return new ActiveXObject("Microsoft.XMLHTTP");
	},
	function() {
		return new XMLHttpRequest();
	}) || false;
}

function SendRequest(a, d, e, b) {
	var c = CreateXMLHTTP();
	if (c) {
		c.onreadystatechange = function() {
			if (c.readyState == 4 && c.status == 200) {
				if (b != null) {
					b(c.responseText.replace(/&amp;/g, "&"));
				}
			}
		};
		c.open(e, a, true);
		c.setRequestHeader("Content-Length", d.length);
		c.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
		c.send(encodeURI(d));
	} else {
		NoXMLHTTP();
	}
}

function NoXMLHTTP() {
	alert("Sorry, your browser doesn't support XMLHTTP");
}

function ajax_post(b, a, d, e) {
	var c = "../ajax_response.php";
	if (e.length == 0) {
		e = "json";
	}
	d._ajax_func_ = b;
	$.post(c, d, function(f) {
		a(d, f);
	},
	e);
}

