/**
* 	AUTHOR:	Razvan Roncov
	DESC:	This file has functions that deal with the request of data (xml or text) from server
	DATE:	Aug 25, 2005
*/



// request object
var req;


/**
* It creates a request object and it sends the request to the server, it also sets the function to handle the returned data.
*
* @param string - url (is the url of the server site script that will return the data)
* @param string - action (GET, POST, HEADER (to get only the header info about the url))
* @param string - process_function (the javascript function that will handle the data returned from the server)
* 
* @return null
*/
function request_data(url, action, process_function) 
{
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) 
    {
    	try 
    	{
			req = new XMLHttpRequest();
        } 
        catch(e) 
        {
			req = false;
        }    
    } 
    // branch for IE/Windows ActiveX version
    else if(window.ActiveXObject) 
    {
       	try 
       	{
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} 
      	catch(e) 
      	{
        	try 
        	{
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} 
        	catch(e) 
        	{
          		req = false;
        	}
		}
    }
    
    // if object created successfully then send the request
	if(req) 
	{
		req.onreadystatechange = eval(process_function);
		req.open(action, url, true);
		req.send("");
	}
} 
