function CreateRequestObject() {
     var myObject;
     var browser = navigator.appName;
     if(browser == "Microsoft Internet Explorer"){
          myObject = new ActiveXObject("Microsoft.XMLHTTP");
     }else{
          myObject = new XMLHttpRequest();
     }
     return myObject;
}
var HTTP = CreateRequestObject();

function SendRequest(Action, Do, QueryString) {
     HTTP.open('get', BasePath + 'backend/action.php?Action='+Action+'&Do='+Do+'&'+QueryString);
     HTTP.onreadystatechange = HandleResponse;
     HTTP.send(null);
}

function HandleResponse() {
			// SPLIT AJAX STRING
			SetID = null;
			SetClass = null;
			SetValue = null;
			SetFieldValue = null;
			SetFocusField = null;
			
			if(HTTP.readyState == 4){
					var Response = new String(HTTP.responseText);
					var Update = new Array();
					
																													
					while(Response.indexOf('</ajax>') != -1){
						ProcessString = Response.substring(6, Response.indexOf('</ajax>')-1);
						ProcessString += ' ';
						
						SetID = null;
						SetClass = null;
						SetValue = null;
						SetFieldValue = null;
						SetFocusField = null;
						SetNewID = null;
						SetSRC = null;
						
						while(ProcessString.indexOf(' ') != -1){
							ProcessElement = ProcessString.substring(0, ProcessString.indexOf('='));
							ProcessValue = unescape(ProcessString.substring(ProcessString.indexOf('=')+2, ProcessString.indexOf(' ')-1));
								switch(ProcessElement){
									case "id":
										SetID = ProcessValue;
									break;
									case "class":
										SetClass = ProcessValue;
									break;
									case "content":
										SetValue = ProcessValue;
									break;
									case "value":
										SetFieldValue = ProcessValue;
									break;
									case "newid":
										SetNewID = ProcessValue;
									break;
									case "src":
										SetSRC = ProcessValue;
									break;
									case "action":
										SetFocusField = ProcessValue;
									break;
								}							
							ProcessString = ProcessString.substring(ProcessString.indexOf(' ')+1);
						}
						
						
						if(SetID.length > 0){
							if(SetClass != null) document.getElementById(SetID).className = SetClass;
							if(SetValue != null) document.getElementById(SetID).innerHTML = DoReplace('+', ' ', SetValue);
							if(SetSRC != null) document.getElementById(SetID).src = DoReplace('+', ' ', SetSRC);
							if(SetFieldValue != null) document.getElementById(SetID).value = DoReplace('+', ' ', SetFieldValue);
							if(SetNewID != null) document.getElementById(SetID).id = SetNewID;
						}												
						Response = Response.substring(Response.indexOf('</ajax>')+7);						
					}
			}
}

function DoReplace(FindString, SetString, MyString){
		while(MyString.indexOf(FindString) != -1){
			MyString = MyString.substring(0, MyString.indexOf(FindString)) + SetString + MyString.substring(MyString.indexOf(FindString) + FindString.length);
		}
		return MyString;
}
