function ajax_check_rates(artwork_id)
{

	var xmlHttpD=GetXmlHttpObject();
	var thishost = window.location.hostname;
				
	if (xmlHttpD==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

   	xmlHttpD.onreadystatechange=function()
	{
		if(xmlHttpD.readyState==4)
		{
			var chk_r_response = eval( xmlHttpD.responseText ); // produces an array
			document.getElementById('total_rates_counts_info').innerHTML =  chk_r_response[0]; // total count rates for this artwork
			document.getElementById('average_rates_info').innerHTML =  "<img src='http://"+thishost+"/images/stars_"+Math.round(chk_r_response[2])+"_voted.png' alt='Average rate' title='Average rate'>"; // average rates for this artwork
		}      
	}
    smrnd = (Math.round((Math.random()*110000)+1));
	xmlHttpD.open("GET","/fetch_rates_info.php?artwork_id="+artwork_id+"&"+smrnd,true);
	xmlHttpD.send(null);

}


function ajax_check_rates_user(artwork_id,user_id)
{

	var xmlHttpEF=GetXmlHttpObject();
	var thishost = window.location.hostname;
			
	if (xmlHttpEF==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

   	xmlHttpEF.onreadystatechange=function()
	{
		if(xmlHttpEF.readyState==4)
		{
			var chk_r_response = xmlHttpEF.responseText;			
			if (chk_r_response > 0)
			{				
				document.getElementById("user_hidden_rates_info").innerHTML = chk_r_response;
				document['rates_stars_im'].src="http://"+thishost+"/images/stars_"+chk_r_response+"_yours_gray.png";
			}
		}      
	}
    smrnd = (Math.round((Math.random()*110000)+1));
	xmlHttpEF.open("GET","/fetch_rates_info.php?user_id="+user_id+"&artwork_id="+artwork_id+"&"+smrnd,true);
	xmlHttpEF.send(null);

}

//setInterval('ajaxFunction()',15000);
