//date: ama feb.13, 2008
//
//usage: include this script in your page
//
//<script src="mxajax.js" type="text/javascript" language="javascript"></script>
//
//parameters: 
//		psRFuncName = remote function name
//		psRParams = remote function parameters, delimited by ;
//		psLFuncName = local js function on the page
//
//two functions required
//ajaxReponse(psRFuncName,psLFuncName) - handle response from ajax server
//ajaxRequest(psRFuncName,psLFuncName) - handle request to ajax server, ajaxFunction will be called in this function
//
var xmlHttp;
var flag_calling_ajax = false;
function ajaxFunction(psRFuncName,psRParams,psLFuncName){
    try	{  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  }
		catch (e){
			// Internet Explorer  
			try	{
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				}
  			catch (e){    
	    		try	{      
	      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
	      		}
    			catch (e){      
					alert("Your browser does not support AJAX!");      
					return false;
				}    
			}
		}
  
	debug_print('called ajaxFunction(' + psRFuncName + ',' + psRParams + ',' + psLFuncName + ')');
	
	xmlHttp.onreadystatechange=function() {
		debug_print("xmlHttp.readyState = "+xmlHttp.readyState);
	if(xmlHttp.readyState==4)
    	//action when returns back from server
      	{
	      	ajaxResponse(psLFuncName);
		}
    }
    var url = '/_scripts_ajax_/mxajax.asp?f=' + psRFuncName + '&p=' + psRParams;
    debug_print('calling url='+url);

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);  
	return false;
}