/*- Function binding the ajax call to the php script performing the processing for getRecommendation
    Input parameters are :
    - user_id : user id
    - node_id : node id of wanted album
    Return : none
-*/
function bd_getRecommandation(user_id, object_id) 
{
	if (user_id==10)
	{
	}
	else
	{
		var http_request=new_http_request();
		if (!http_request) 
		{
			//alert('Abandon :( Impossible de créer une instance XMLHTTP');
			return false;
		}
		http_request.onreadystatechange = function() { bd_getRecommandationResponse(http_request); };
		var url_to_call='http://www.bedeo.fr/index.php/bedeo/bd_criteo/bd_getRecommandation/(user_id)/'+user_id+'/(object_id)/'+object_id;

		http_request.open('GET', url_to_call, true);
		http_request.send(null);
	}
}

/*- Function waiting for the script's response for getRecommandation
    Input parameters are :
    - http_request : http_request created by the setRating function
    Return :
    - http_request.responseText
-*/
function bd_getRecommandationResponse(http_request) 
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{
			alert(http_request.responseText);

			var reco = http_request.responseText;
			  // Extract the required information from the module content stuff

			  alert (reco);
			var tab1 = reco.split("|CRITEO_BEGIN|");
			var tab2 = tab1[1].split("|CRITEO_END|");
			var response=tab2[0].split("|");
			var estimate=response[0];
			var reliability=response[1];
			alert("Reco criteo = |"+estimate+"|"+reliability+"|");
			document.getElementById('recommandation').innerHTML = response;
			  // turn on the recommandation stars
			turn_on( 'reco_', parseInt(response) );
			
			return response;
		} 
	}
}
