var BasePath = 'http://www.devcon5.cc/';


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();


var Requesting = false;

function SendRequest(Action, Do, QueryString,LoadBar) {
	var zeit = new Date();
	if (Requesting != true) {
		if (LoadBar == true && LoadBar != undefined) {
			Get('MainLoader').className = 'Show';
		} 
		Requesting = true;	
		HTTP.open('get', BasePath + 'action.php?Action='+  Action  +'&Do='+Do+'&'+QueryString+'&Bust=' + zeit.getTime());
     	HTTP.onreadystatechange = HandleResponse;
 		HTTP.send(null);
	} else {
		
		window.setTimeout("SendRequest('"+ Action +"','"+ Do +"','"+ QueryString +"')",100);	
	}
}




function HandleResponse() {
		
		
			// SPLIT AJAX STRING

			SetID = null;

			SetClass = null;

			SetValue = null;

			SetFieldValue = null;

			SetFocusField = null;
			
			SetAction = null;
			

			

			if(HTTP.readyState == 4){ 
					Requesting = false;
					Get('MainLoader').className = 'Hide';
			
					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":

										SetAction = ProcessValue;

									break;
									
									

								}							

							ProcessString = ProcessString.substring(ProcessString.indexOf(' ')+1);

						}

						

						

						if(SetID.length > 0){					
							
							c = document.getElementById(SetID);
							if (c) {
								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;
							}
							if(SetAction != null) eval(SetAction);

							

						}												

						Response = Response.substring(Response.indexOf('</ajax>')+7);						

					}

			}

}
