﻿var ReAjax = function()
{}
ReAjax.prototype.GetHttpRequest = function()
{
	var reObj="";
	if ( window.XMLHttpRequest ){
		reObj= new XMLHttpRequest() ;
	}
	else if ( window.ActiveXObject ){	
		try{
			reObj=new ActiveXObject("MsXml2.XmlHttp") ;
		}
		catch(e){
			reObj=new 	ActiveXObject("microsoft.XmlHttp")
		}
	}
	return reObj;
}
ReAjax.prototype.LoadUrl = function( urlToCall,altDiv)
{	
	var oReAjax = this ;
	var oAjaxHttp = this.GetHttpRequest() ;
	oAjaxHttp.open( "GET", urlToCall, true) ;
	oAjaxHttp.onreadystatechange=function()
	{
		if(oAjaxHttp.readyState==4)
		{
			document.getElementById(altDiv).style.display="none";
			document.getElementById(altDiv).innerHTML=oAjaxHttp.responseText;
		}
	}
	oAjaxHttp.send( null ) ;
}
ReAjax.prototype.LoadUrlToSelect = function( urlToCall,altDiv)
{	
	var oReAjax = this ;
	var oAjaxHttp = this.GetHttpRequest() ;
	oAjaxHttp.open( "GET", urlToCall, true) ;
	oAjaxHttp.onreadystatechange=function(){
			var ServerNameListID=$(altDiv);
			while(ServerNameListID.options.length>0)
			{
				ServerNameListID.remove(0)
			}
			ServerNameListID.selectedIndex=-1;
			var opt=document.createElement("OPTION");
			opt.text="---Loading...---";
			opt.value="0";
			ServerNameListID.options.add(opt);
			opt.selected=true;
			
			if (oAjaxHttp.readyState == 4) 
			{
						var str=oAjaxHttp.responseText;
						if(str==""||str.indexOf("$$$")==-1){
								ServerNameListID.options[0].text="-- All Server --";
								ServerNameListID.options[0].value=-100;
								ServerNameListID.disabled=true;
								return;
						}
						ServerNameListID.disabled=false;
						while(ServerNameListID.options.length>0)
						{
							ServerNameListID.remove(0)
						}
						ServerNameListID.selectedIndex=-1;
						var rightstr=str.split("$$$");
						var arrayStr=rightstr[0].split("|");
						var i;
						
						if(arrayStr.length-1>0)
						{
							for(i=0;i<arrayStr.length-1;i++)
							{
								var arrayName=new Array(1);
								arrayName=arrayStr[i].split("@");
								var opt=document.createElement("OPTION");
								opt.text=arrayName[1];
								opt.value=arrayName[0];
								ServerNameListID.options.add(opt);
							}
							ServerNameListID.options[0].selected=true;
						}
			}
		};
	oAjaxHttp.send( null ) ;
}
ReAjax.prototype.LoadUrl2 = function( urlToCall)
{	
	var oReAjax = this ;
	var oAjaxHttp = this.GetHttpRequest() ;
	oAjaxHttp.open( "GET", urlToCall, false) ;
	oAjaxHttp.send( null );
	var result=oAjaxHttp.responseText;
	return result;
}
