function getHTTPObject()
{
	var oXmlHttp;
	/*@cc_on
	@if(@_jscript_version>=5)
	try
	{
		oXmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e)
	{
		try
		{
			oXmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e)
		{
			oXmlHttp=false;
		}
	}
	@else
	oXmlHttp=false;
	@end@*/
	if(!oXmlHttp&&typeof XMLHttpRequest!='undefined')
	{
		try
		{
			oXmlHttp=new XMLHttpRequest();
		}
		catch(e)
		{
			oXmlHttp=false;
		}
	}
	return oXmlHttp;
}
var _oHttpS=getHTTPObject(); 
function ajaxSyncGet(sURL)
{
	with(_oHttpS)
	{
		open('GET',sURL,false);
		send(null);
		return responseText;
	}
}
function ajaxSyncPost(sURL,sVars)
{
	with(_oHttpS)
	{
		open('POST',sURL,false);
		setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		send(sVars);
		return responseText;
	}
}
var _oHttp=new Array();
var _inProcess=new Array();
function createAJAXInstance()
{
	var nLastIndex=_oHttp.length;
	_oHttp[nLastIndex]=getHTTPObject();
	_inProcess[nLastIndex]=false;
	return nLastIndex;
}
function asyncAJAXGet(sURL,sFunction,nIndex)
{
	if(!_inProcess[nIndex]&&_oHttp[nIndex])
	{
		_inProcess[nIndex]=true;
		with(_oHttp[nIndex])
		{
			open('GET',sURL,true);
			onreadystatechange=function(){responseAsyncAJAXGet(sFunction,nIndex);}
			send(null);
		}
	}
}
function responseAsyncAJAXGet(sFunction,nIndex)
{
	AJAXDebug(nIndex);
	if(_oHttp[nIndex].readyState==4)
	{
		if(_oHttp[nIndex].status==200)
		{
			_oHttp[nIndex].onreadystatechange=function(){};
			_inProcess[nIndex]=false;
			eval(sFunction);
		}
	}
}
function asyncAJAXPost(sURL,sVars,sFunction,nIndex)
{
	if(!_inProcess[nIndex]&&_oHttp[nIndex])
	{
		_inProcess[nIndex]=true;
		with(_oHttp[nIndex])
		{
			open('POST',sURL,true);
			setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			onreadystatechange=function(){responseAsyncAJAXPost(sFunction,nIndex);}
			send(sVars);
		}
	}
}
function responseAsyncAJAXPost(sFunction,nIndex)
{
	AJAXDebug(nIndex);
	if(_oHttp[nIndex].readyState==4)
	{
		if(_oHttp[nIndex].status==200)
		{
			_oHttp[nIndex].onreadystatechange=function(){};
			_inProcess[nIndex]=false;
			eval(sFunction);
		}
	}
}
function responseAJAX(nIndex)
{
	return _oHttp[nIndex].responseText;
}
function formAJAX(oForm)
{
	var sGenericInput='',sRadios='',sChecks='',sSelects='';
	var aChecks=new Array(oForm.length);
	var nChecks=-1;

	for(x=0;x<oForm.length;x++)
	{
		var chkOpciones='',selOpciones='';
		var bReady=false;

		with(oForm.elements[x])
		{
			if(type=='text'||type=='password'||type=='hidden'||type=='hidden'||type=='file'||type=='select-one'||type=='textarea')
			{
				sGenericInput+=name+'='+stringUTF8(value)+'&';
			}
			if(type=='radio')
			{
				if(checked) sRadios+=name+'='+stringUTF8(value)+'&';
			}
			if(type=='checkbox')
			{
				for(i=0;i<aChecks.length;i++)
				{
					if(aChecks[i]==name)
					{
						bReady=true;
					}
				}
				if(!bReady)
				{
					nChecks++;
					aChecks[nChecks]=name;
					for(y=0;y<n(name).length;y++)
					{
						if(n(name)[y].checked)
						{
							chkOpciones+=stringUTF8(n(name)[y].value)+',';
						}
					}
					if(chkOpciones.length>0) chkOpciones=chkOpciones.substring(0,chkOpciones.length-1);
					sChecks+=name+'='+chkOpciones+'&';
				}
			}
			if(type=='select-multiple')
			{
				for(y=0;y<options.length;y++)
				{
					if(options[y].selected) selOpciones=selOpciones+stringUTF8(options[y].value)+',';
				}
				if(selOpciones.length>0) selOpciones=selOpciones.substring(0,selOpciones.length-1);
				sSelects+=name+'='+selOpciones+'&';
			}
		}
	}
	return sGenericInput+sRadios+sChecks+sSelects;
}
var _aFunctionsAJAX=new Array();
function evalHTMLAJAX(sText)
{
	var sPattern=eval('/<scr'+'ipt((.|\\r|\\n)*?)>((.|\\r|\\n)*?)<\\/scr'+'ipt>/gi');
	_aFunctionsAJAX.splice(0,_aFunctionsAJAX.length);
	_aFunctionsAJAX=sText.match(sPattern);
	return sText.replace(sPattern,'');
}
function evalScriptsAJAX()
{
	var sPattern=eval('/<scr'+'ipt((.|\\r|\\n)*?)>((.|\\r|\\n)*?)<\\/scr'+'ipt>/gi');
	for(x=0;x<_aFunctionsAJAX.length;x++)
	{
		var sFunction=_aFunctionsAJAX[x].replace(sPattern,'$3');
		sFunction=sFunction.replace(/\/\/(.*?)\r\n/g,'');
		sFunction=sFunction.replace(/\r\n\t/gi,'');
		sFunction=sFunction.replace(/\/\*(.*?)\*\//gi,'');
		if(getEngine()==0)
		{
			window.execScript(sFunction,'javascript');
		}
		else
		{
			//window.eval(sFunction);
			setTimeout('eval(\''+sFunction.replace(/'/g,'\\\'')+'\')',0);
		}
	}
}
var _sAJAXDebug;
var _bAJAXDebug=false;
function setAJAXDebugMode(sDebug,nIndex)
{
	_sAJAXDebug=sDebug;
	_bAJAXDebug=true;
	nDebugObject=nIndex;
}
function AJAXDebug(nIndex)
{
	if(_bAJAXDebug&&nIndex==nDebugObject) dNTR(_sAJAXDebug).innerHTML=_oHttp[nIndex].responseText;
}
