/*
* This module contains io - ajax functions for fetching data
*/

var waiting_img="media/images/loading.gif";

/*
 * This function uses the JQuery ajax  - functions
 * and is the main function for ajax functionality
 * The Param variable has to be formulated like this : Var1:"Value", Var2:"Value2" ...
 * The Url is the  url to a serverside file which will generate the output
 * The Obj is the object which will receive the response of the server file
 */
function snd_req(Param,Url,Obj)
{
	$.ajax({  
        type: "POST",  
        url: Url,  
        data: Param,  
        success: function(data){
		req_handler(data,Obj);
        }  
    });
	
	//Showing the loading - image which is defined in the variable waiting_img
	//document.getElementById(Obj).innerHTML="<img src='" + waiting_img + "#/>";
	/*$.post(Url, Param ,
			   function(data){
			     req_handler(data,Obj);
		  	   });*/
}


/*
 * This is the request handler which handles the ajax  -responses
 * javascript - code sections will be executed with the eval  - command
 */
function req_handler(Response,Obj)
{
	document.getElementById(Obj).innerHTML=Response;
	
	$("#"+Obj).find("script").each(function(index){
	 eval($(this).text());	
	});
}


