/*PARAMS
URL=Url of the page to display the result.
ajax_result=Div ID where you wish the result to be displayed.
params=Send the params if you wish to post some data into the desired url
ajax_loading=if you wish to display another image other then the default image. Send the sec of that image in this parameter.

*/
function send_request(url,ajax_result,params,ajax_loading)
{
	var ajaxRequest;  // The variable that makes Ajax possible!
	var img2=ajax_loading;	
	var img1=ajax_result;
	var method;	
	var send_val;
	var send_header;
	ajaxRequest = new XMLHttpRequest();
	
	rand=Math.random();
	if(params !=null)
	{
		method="POST";
		send_val=params;
		send_header="application/x-www-form-urlencoded";
	}
	else
	{
		method="GET";
		send_val=null;
		send_header="application/x-javascript;"
	}	
	ajaxRequest.open(method, url+"&nocache="+rand, true);	
	//ajaxRequest.open(method, url, true);		

	ajaxRequest.setRequestHeader("Content-Type",send_header);
	
	
	if(params !=null)
	{
		ajaxRequest.setRequestHeader("Content-length", params.length);
      	ajaxRequest.setRequestHeader("Connection", "close");
	}
	
	
	
	
	// Create a function that will receive data sent from the server	
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4 ){
			//document.myForm.time.value = ajaxRequest.responseText;
			if(ajaxRequest.status == 200)
			{
				document.getElementById(img1).innerHTML=ajaxRequest.responseText;		
				/*if(img2 !=null)
				{	
					//document.getElementById(img2).innerHTML='';
				}*/
			}
			
			
		}

		
	}
	ajaxRequest.send(send_val); 
	if(img2 !=null)
	{
		document.getElementById(img1).innerHTML="<div align=\"center\" style=\"vertical-align:middle\"><img src='"+img2+"' /></div>"; //Display "loading image"
	}
	else
	{
		document.getElementById(img1).innerHTML="<div align=\"center\" style=\"vertical-align:middle\"><img src='images/loading.gif' /></div>"; //Display "loading image"
	}
}


