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, QueryString) {

     HTTP.open('get', BasePath + 'addons/ajax/ajax-'+Action+'.php?'+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;
						
						SetAction = 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":

										SetAction = ProcessValue;

									break;
									
									

								}							

							ProcessString = ProcessString.substring(ProcessString.indexOf(' ')+1);

						}

						

						
						
						
						if(SetID.length > 0){					

							if(SetClass != null) document.getElementById(SetID).className = SetClass;

							if(SetValue != null) { 
								//SetValue = unescape(SetValue.substring(SetValue.indexOf('=')+2, SetValue.indexOf(' ')-1));
							
								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;
							
							if(SetAction != null) eval(SetAction);
							
							

						}												

						Response = Response.substring(Response.indexOf('</ajax>')+7);						

					}

			}

}

function str_replace(search, replace, subject) {
	document.title = 'replace';
	t = subject.split(search).join(replace);
	document.title = t;
	return t;
}
