var xmlMegaDivx

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest){
	objXMLHttp=new XMLHttpRequest()
}
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp
}

function rateProduct(rating,productID)
 {
 xmlMegaDivx=GetXmlHttpObject()
 if (xmlMegaDivx==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  }
xmlMegaDivx.onreadystatechange=function (){
changement(rating,productID)
}
xmlMegaDivx.open("GET", "/update.php?productID="+ productID +"&rating="+rating ,true)
xmlMegaDivx.send(null)
}

function change() 
{ 

document.getElementById('ratingtext').innerHTML = 'Thank you for your vote!';

}
function changement(rating,productID)
{ 
if (xmlMegaDivx.readyState==4 || xmlMegaDivx.readyState=="complete"){
 xmlDoc=xmlMegaDivx.responseText;
if (xmlDoc==''){
document.getElementById('ratingtext' + productID).innerHTML = 'erreur inconnu!';
rating = (rating * 12) ;
document.getElementById('current-rating' + productID).style.width = rating+'px';
document.getElementById('ratelinks' + productID).style.display = 'none';
}
else if (xmlDoc==6){
document.getElementById('ratingtext' + productID).innerHTML = 'erreur dans le vote!';
rating = (rating * 12) ;
document.getElementById('current-rating' + productID).style.width = rating+'px';
document.getElementById('ratelinks' + productID ).style.display = 'none';
}
else if (xmlDoc==99){
document.getElementById('ratingtext' + productID).innerHTML = 'vous avez deja voté!';
rating = (rating * 12) ;
document.getElementById('current-rating' + productID).style.width = rating+'px';
document.getElementById('ratelinks' + productID).style.display = 'none';
}
else{

rating = (rating * 12) ;
document.getElementById('current-rating' + productID ).style.width = rating+'px';
document.getElementById('ratelinks' + productID ).style.display = 'none';
document.getElementById('ratingtext' + productID ).innerHTML = 'Merci pour avoir voté!';
//document.getElementById('ratingtext').innerHTML =xmlDoc;
}

}
}

function ratePuct3(rating,productID)  {
		remotos = new datosServidor;
		nt = remotos.enviar('update.php?rating='+rating+'&productID='+productID);
		rating = (rating * 25) - 8;
		document.getElementById('current-rating').style.width = rating+'px';
		document.getElementById('ratelinks').style.display = 'none';
		document.getElementById('ratingtext').innerHTML = 'Thank you for your vote!';
}
