var AjaxStatusDescription = new Array();
AjaxStatusDescription[100] = "Continue";
AjaxStatusDescription[101] = "Switching Protocols";
AjaxStatusDescription[200] = "OK";
AjaxStatusDescription[201] = "Created";
AjaxStatusDescription[202] = "Accepted";
AjaxStatusDescription[203] = "Non-Authoritative Information";
AjaxStatusDescription[204] = "No Content";
AjaxStatusDescription[205] = "Reset Content";
AjaxStatusDescription[206] = "Partial Content";
AjaxStatusDescription[300] = "Multiple Choices";
AjaxStatusDescription[301] = "Moved Permanently";
AjaxStatusDescription[302] = "Found";
AjaxStatusDescription[303] = "See Other";
AjaxStatusDescription[304] = "Not Modified";
AjaxStatusDescription[305] = "Use Proxy";
AjaxStatusDescription[306] = "(unused, but reserved)";
AjaxStatusDescription[307] = "Temporary Redirect";
AjaxStatusDescription[400] = "Bad Request";
AjaxStatusDescription[401] = "Unauthorized";
AjaxStatusDescription[402] = "Payment Required";
AjaxStatusDescription[403] = "Forbidden";
AjaxStatusDescription[404] = "Not Found";
AjaxStatusDescription[405] = "Method Not Allowed";
AjaxStatusDescription[406] = "Not Acceptable";
AjaxStatusDescription[407] = "Proxy Authentication Required";
AjaxStatusDescription[408] = "Request Timeout";
AjaxStatusDescription[409] = "Conflict";
AjaxStatusDescription[410] = "Gone";
AjaxStatusDescription[411] = "Length Required";
AjaxStatusDescription[412] = "Precondition Failed";
AjaxStatusDescription[413] = "Request Entity Too Large";
AjaxStatusDescription[414] = "Request-URI Too Long";
AjaxStatusDescription[415] = "Unsupported Media Type";
AjaxStatusDescription[416] = "Requested Range Not Satisfiable";
AjaxStatusDescription[417] = "Expectation Failed";
AjaxStatusDescription[500] = "Internal Server Error";
AjaxStatusDescription[501] = "Not Implemented";
AjaxStatusDescription[502] = "Bad Gateway";
AjaxStatusDescription[503] = "Service Unavailable";
AjaxStatusDescription[504] = "Gateway Timeout";
AjaxStatusDescription[505] = "HTTP Version Not Supported";
AjaxStatusDescription[509] = "Bandwidth Limit Exceeded";

var AjaxReadyState = new Array();
AjaxReadyState[0] = "Uninitialized";
AjaxReadyState[1] = "Open";
AjaxReadyState[2] = "Sent";
AjaxReadyState[3] = "Receiving";
AjaxReadyState[4] = "Loaded";

// Carica oggetto HttpRequest
function Get_HttpRequest() {
	var AjaxObj = null;
	var CurrentBrowser = navigator.userAgent.toUpperCase();

	if (typeof(XMLHttpRequest) == "function" || typeof(XMLHttpRequest) == "object") {
		AjaxObj = new XMLHttpRequest();
		return AjaxObj;
	}
	if(window.ActiveXObject && CurrentBrowser.indexOf("MSIE 4") < 0) {
		if(CurrentBrowser.indexOf("MSIE 5") < 0) {
			AjaxObj = new ActiveXObject("Msxml2.XMLHTTP");
		} else {
			AjaxObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return AjaxObj;
}

function NtwLogin_SendAjaxRequest(RetFunc, QueryForm, sUrlRequest) {
	var r=Get_HttpRequest();
	var sUrl = '/inc/ntw_login/DsLoginAjax.asp';
	if (sUrlRequest != '') { sUrl = sUrlRequest; }
 	r.open('POST', sUrl, true);
	r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	r.setRequestHeader('Content-length', QueryForm.lenght);
	//r.setRequestHeader('Connection', 'close');
	r.onreadystatechange = function() {	
		if(r.readyState==4 || r.readyState=='complete') {
			if (AjaxStatusDescription[r.status] == 'OK') {
				eval(RetFunc+"('"+r.responseText+"')");
			} else {	
				if (sUrlRequest == '') { NtwLogin_SendAjaxRequest(RetFunc, QueryForm, 'inc/ntw_login/DsLoginAjax.asp'); } else { alert(AjaxStatusDescription[r.status]); }
			}
		}
	}
	r.send(QueryForm);
}

function DsLogin_getRequestValue(qString, pName) {
	qString=qString.split('&');
	for(var h=0;h<qString.length;h++){
		if(qString[h].toLowerCase().substring(0,pName.length)==pName.toLowerCase()) {
			return qString[h].substring(qString[h].indexOf('=')+1,qString[h].length);
		}
	}
	return '';
}