function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}


function vote(idproduct, vote){
	
    var xmlHttp = GetXmlHttpObject();
    var params = "idproduct=" + idproduct + "&vote=" + vote;
    xmlHttp.open("POST", "/browse/rating/", true);

    //Send the proper header information along with the request
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var response = new String(xmlHttp.responseText);
            var resp=response.split("|");
            
            // document.getElementById(idproduct).innerHTML = response;
            if(vote=='1'){
                document.getElementById('current-rating').style.width = '18px';  
            }else if(vote=='2'){
                document.getElementById('current-rating').style.width = '36px';  
            }else if(vote=='3'){
                document.getElementById('current-rating').style.width = '54px';  
            }else if(vote=='4'){
                document.getElementById('current-rating').style.width = '72px';  
            }else if(vote=='5'){
                document.getElementById('current-rating').style.width = '90px';  
            }
            
            document.getElementById('all_vote').innerHTML = resp[2];
            document.getElementById('count_vote').innerHTML = resp[1];
            document.getElementById('current-rating-result').innerHTML = resp[4];
            
        }
    }
    xmlHttp.send(params);
         
  
}



