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 + 'ajax/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;
						
						SetFunction = 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;
									
									
									case "function":

										SetFunction = ProcessValue;

									break;
								}							

							ProcessString = ProcessString.substring(ProcessString.indexOf(' ')+1);

						}

						

						

						if(SetFunction != null) eval(SetFunction.replace(/\+/g, ' '));
						else if(SetID.length > 0){						

							if(SetClass != null) document.getElementById(SetID).className = SetClass;

							if(SetValue != null)document.getElementById(SetID).innerHTML = SetValue.replace(/\+/g, ' ');

							if(SetSRC != null) document.getElementById(SetID).src = SetSRC.replace(/\+/g, ' ');

							if(SetFieldValue != null) document.getElementById(SetID).value = SetFieldValue.replace(/\+/g, ' ');

							if(SetNewID != null) document.getElementById(SetID).id = SetNewID;

						}												

						Response = Response.substring(Response.indexOf('</ajax>')+7);						

					}

			}

}
