/*
-- ------ 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;
}
//-- ------ #Prototype ------ --
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();
//-- ------ #Function ------ --
netsAjax.prototype.sendRequestSp=function(pURL,pFuncName){
	try{
		this.sHttpRequests[this.sIndex]=new ActiveXObject("microsoft.XMLHTTP");
	}catch(e){
		this.sHttpRequests[this.sIndex]=new XMLHttpRequest();
	}
	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;
}
//-- ------ #Prototype ------ --
netsSingleAjax.prototype.sID="";
netsSingleAjax.prototype.sHttpRequests=Array();
netsSingleAjax.prototype.sPanel="";
netsSingleAjax.prototype.sFlag="";
netsSingleAjax.prototype.sURL="";
netsSingleAjax.prototype.sParameter="";
//-- ------ #Function ------ --
netsSingleAjax.prototype.sendRequestSp=function(pURL,pFuncName){
	try{
		this.sHttpRequests=new ActiveXObject("microsoft.XMLHTTP");
	}catch(e){
		this.sHttpRequests=new XMLHttpRequest();
	}
	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 snetsAjax=new netsAjax();
var snetsSingleAjax=new netsSingleAjax();
//-- ------ #netsAjax Callback demo ------ --
function sendCallback(){
	var tmpCoun0=0;
	while(snetsAjax.sIndex>tmpCoun0){
		var tmpFlag=snetsAjax.sFlag[tmpCoun0];
		var tmpPanel=document.getElementById(snetsAjax.sPanel[tmpCoun0]);
		var tmpHttpRequests=snetsAjax.sHttpRequests[tmpCoun0];
		//alert(tmpHttpRequests.responseText);
		if(tmpHttpRequests.readyState==4 && snetsAjax.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=sysError_Ajax;
		    	//showLoading(1);
		    }
		    snetsAjax.sDone[tmpCoun0]=1;
		}else{
			//showLoading(0);
			tmpPanel.innerHTML="<div>LOADING...<div>";
		}
		tmpCoun0++;
	}
}
//-- ------ #netsSingleAjax Callback demo ------ --
function sendCallback_S(){
	var tmpFlag=snetsSingleAjax.sFlag;
	var tmpPanel=document.getElementById(snetsSingleAjax.sPanel);
	var tmpHttpRequests=snetsSingleAjax.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;
	    	showLoading(1);
	    }else{
	    	tmpPanel.innerHTML=sysError_Ajax;
	    	showLoading(1);
	    }
	}else{
		showLoading(0);
	}
}


