﻿var xmlHttp;

var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; 
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; 
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;

function _AjaxRequest(url){
	xmlHttp = GetXmlHttpObject(_XmlHttpHandler); 
	xmlHttp_Get(xmlHttp, url); 
}

function _XmlHttpHandler() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){ 
		onTransferComplete(xmlHttp.responseText);
	}
}

function xmlHttp_Get(xmlhttp, url) { 
	xmlhttp.open('GET', url, true); 
	xmlhttp.send(null); 
} 

function GetXmlHttpObject(handler) { 
	var objXmlHttp = null;
	if (is_ie){ 
		var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
		try{ 
			objXmlHttp = new ActiveXObject(strObjName); 
			objXmlHttp.onreadystatechange = handler; 
		}catch(e){ 
			alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); 
			return;
		} 
	} 
	else if (is_opera){ 
		alert('Opera detected. The page may not behave as expected.'); 
		return; 
	} 
	else{ 
		objXmlHttp = new XMLHttpRequest(); 
		objXmlHttp.onload = handler; 
		objXmlHttp.onerror = handler; 
	} 
	return objXmlHttp; 
} 