/*
-- ------ netsAjax class 1.40 ------ --
unionNets.com
2009
*/
function netsAjax(){
	var sID;
	var sIndex;
	var sDone;
	var sHttpRequests;
	var sPanel;
	var sFlag;
	var sURL;
	var sParameter;
}
//-- ------ #Parameters ------ --
netsAjax.prototype.sName="tmpAjax";
netsAjax.prototype.sID='';
netsAjax.prototype.sIndex=0;
netsAjax.prototype.sDone=Array();
netsAjax.prototype.sHttpRequests=Array();
netsAjax.prototype.sPanel=Array();
netsAjax.prototype.sFlag=Array();
netsAjax.prototype.sURL=Array();
netsAjax.prototype.sParameter=Array();
//-- ------ #Methods ------ --
netsAjax.prototype.Initial=function(){
	try{
		if (window.XMLHttpRequest){
			//code for Firefox, Opera, IE7, etc.
			this.sHttpRequests[this.sIndex]=new XMLHttpRequest();
		}else if (window.ActiveXObject){
			//code for IE6, IE5
			this.sHttpRequests[this.sIndex]=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}catch(Exp){}

	return 0;
}
netsAjax.prototype.sendRequestSp=function(pURL,pFuncName){
	try{
		if (window.XMLHttpRequest){
			//code for Firefox, Opera, IE7, etc.
			this.sHttpRequests[this.sIndex]=new XMLHttpRequest();
		}else if (window.ActiveXObject){
			//code for IE6, IE5
			this.sHttpRequests[this.sIndex]=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}catch(Exp){}

	this.sDone[this.sIndex]=0;
	this.sURL[this.sIndex]=pURL;
	this.sHttpRequests[this.sIndex].open("GET",pURL);
	this.sHttpRequests[this.sIndex].onreadystatechange=new Function(pFuncName);
	this.sHttpRequests[this.sIndex].send(null);
	this.sIndex++;
}

/*-- ------ netsSingleAjax ------ --*/
function netsSingleAjax(){
	var sID;
	var sHttpRequests;
	var sPanel;
	var sFlag;
	var sURL;
	var sParameter;
}
//-- ------ #Parameters ------ --
netsSingleAjax.prototype.sName="tmpSingleAjax";
netsSingleAjax.prototype.sID="";
netsSingleAjax.prototype.sHttpRequests=Array();
netsSingleAjax.prototype.sPanel="";
netsSingleAjax.prototype.sFlag="";
netsSingleAjax.prototype.sURL="";
netsSingleAjax.prototype.sParameter="";
//-- ------ #Methods ------ --
netsAjax.prototype.Initial=function(){
	try{
		if (window.XMLHttpRequest){
			//code for Firefox, Opera, IE7, etc.
			this.sHttpRequests=new XMLHttpRequest();
		}else if (window.ActiveXObject){
			//code for IE6, IE5
			this.sHttpRequests=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}catch(Exp){}

	return 0;
}
netsSingleAjax.prototype.sendRequestSp=function(pURL,pFuncName){
	try{
		if (window.XMLHttpRequest){
			//code for Firefox, Opera, IE7, etc.
			this.sHttpRequests=new XMLHttpRequest();
		}else if (window.ActiveXObject){
			//code for IE6, IE5
			this.sHttpRequests=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}catch(Exp){}

	this.sURL=pURL;
	this.sHttpRequests.open("GET",pURL);
	this.sHttpRequests.onreadystatechange=new Function(pFuncName);
	this.sHttpRequests.send(null);
}
//-- ------ #Function ------ --
function getDataByFlag(pSource,pFlag){
	/*
	Get data from request by flag , single find - find by flag
	<!--S."+pDisp+"-->
	<!--E."+pDisp+"-->
	*/
	var tmpData="";
	var startFlag="<!--S."+pFlag+"-->";
	var endFlag="<!--E."+pFlag+"-->";
	var startIndex=0;
	var endIndex=0;
	
	startIndex=pSource.indexOf(startFlag)+startFlag.length;
	endIndex=pSource.indexOf(endFlag);
	tmpData=pSource.substr(startIndex,endIndex-startIndex);
	return tmpData;
}
//-- ------ #Instance ------ --
var tmpAjax=new netsAjax();
var tmpSingleAjax=new netsSingleAjax();
//-- ------ #netsAjax Callback demo ------ --
function sendCallback(){
	var tmpCoun0=0;
	while(tmpAjax.sIndex>tmpCoun0){
		var tmpFlag=tmpAjax.sFlag[tmpCoun0];
		var tmpPanel=document.getElementById(tmpAjax.sPanel[tmpCoun0]);
		var tmpURL=tmpAjax.sURL[tmpCoun0];
		var tmpHttpRequests=tmpAjax.sHttpRequests[tmpCoun0];
		//alert(tmpHttpRequests.responseText);
		if(tmpHttpRequests.readyState==4 && tmpAjax.sDone[tmpCoun0]==0){
			//alert(tmpHttpRequests.responseText);
			var tmpData=getDataByFlag(tmpHttpRequest.responseText,tmpFlag);
			//alert(tmpData);
			if(tmpData.indexOf("sendRequestBase")>=0 && tmpData!="<!--sendRequestBase-->"){
				tmpPanel.innerHTML=tmpData;
		    	//showLoading(1);
		    }else{
		    	tmpPanel.innerHTML=tmpCommon.sysError_Ajax.replace(/\{Nets.Response}/g,tmpURL);
		    	//showLoading(1);
		    }
		    tmpAjax.sDone[tmpCoun0]=1;
		}else{
			//showLoading(0);
			tmpPanel.innerHTML=tmpCommon.sysError_Ajax.replace(/\{Nets.Response}/g,tmpURL);
		}
		tmpCoun0++;
	}
}
//-- ------ #netsSingleAjax Callback demo ------ --
function sendCallback_S(){
	var tmpFlag=tmpSingleAjax.sFlag;
	var tmpPanel=document.getElementById(tmpSingleAjax.sPanel);
	var tmpURL=tmpSingleAjax.sURL;
	var tmpHttpRequests=tmpSingleAjax.sHttpRequests;
	//alert(tmpHttpRequests.responseText);
	if(tmpHttpRequests.readyState==4){
		//alert(tmpHttpRequests.responseText);
		var tmpData=getDataByFlag(tmpHttpRequests.responseText,tmpFlag);
		//alert(tmpData);
		if(tmpData.indexOf("sendRequest")>=0 && tmpData!="<!--sendRequest-->"){
			tmpPanel.innerHTML=tmpData;
	    	tmpFrames.showLoading(1);
	    }else{
	    	tmpPanel.innerHTML=tmpCommon.sysError_Ajax.replace(/\{Nets.Response}/g,tmpURL);
	    	tmpFrames.showLoading(1);
	    }
	}else{
		tmpFrames.showLoading(0);
		tmpPanel.innerHTML=tmpCommon.sysError_Ajax.replace(/\{Nets.Response}/g,tmpURL);
	}
}
