/*
	xmlHttp.readyState options:
	State	Description
	0		The request is not initialized
	1		The request has been set up
	2		The request has been sent
	3		The request is in process
	4		The request is complete
*/

// callback funtcion to use, default 'ajax_handle'


// function sends ajax request to destination
function sendAjaxReq( destination, sendAjaxReq_callback ){
	
	var xmlHttp=makeAjaxReq();

	if( !sendAjaxReq_callback || sendAjaxReq_callback == 'undefined' || typeof(sendAjaxReq_callback) != 'function' ){
		sendAjaxReq_callback = 'ajax_handle';
	}

	if(xmlHttp){
		// ajax_handle() should reside in your module
		xmlHttp.onreadystatechange = function(){ 
				if(xmlHttp.readyState==4){ 
					window[sendAjaxReq_callback](xmlHttp.responseText);
				} 
			}
		try{xmlHttp.open("GET",destination,true);}
		catch(err){alert(err);}
		try{xmlHttp.send(null);}
		catch(err){alert(err);}
	}
}

// function returns ajax object
function makeAjaxReq(){
	var xmlHttp;
	try{xmlHttp=new XMLHttpRequest();} // Firefox, Opera 8.0+, Safari
	catch(e){
		try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} // Internet Explorer 6+
		catch(e){
			try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}// Internet Explorer 5.5
			catch(e){xmlHttp=false;}
		}
	}
	return xmlHttp;
}
