// requires JSON.js

Ajax={ 
	getXMLHttpRequest : function () {
	
		if ((typeof XMLHttpRequest) == "undefined") {
			XMLHttpRequest=function() {
				return new ActiveXObject(navigator.userAgent.indexOf("MSIE 5") >= 0 ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
			}
		} 	
		return (new XMLHttpRequest());
	},
	
	isSuccess : function (xmlHttpRequestObj) {
		try {
			return (!xmlHttpRequestObj.status && location.protocol=="file:") || (xmlHttpRequestObj.status >=200 && xmlHttpRequestObj.status < 300) || xmlHttpRequestObj.status==304 || (navigator.userAgent.indexOf("Safari") >= 0 && typeof xmlHttpRequestObj.status == "undefined");
		} catch(e){};
		return false;		
	},
	
	/* dataType is string, values: xml, html, json */
	
	getResponseData : function (xmlHttpRequestObj,dataType) {
		var ct=xmlHttpRequestObj.getResponseHeader("content-type");
		var xmlData= !dataType && ct && ct.indexOf("xml")>=0;
		var data= (dataType == "xml" || xmlData)? xmlHttpRequestObj.responseXML: xmlHttpRequestObj.responseText;
		if (dataType=="json") {
			data=JSON.unserialize(data);
		}
		return data;
	}
}