﻿function InitAssessFace(commentid,objectid1,objectid2,imgid,projectid,templateid,newsid)
{
   
     var zipCode=Math.random();
     var zipCode1=Math.random();
     var url1 = "/commentsolution/InitAssessInfo.aspx?projectid="+projectid + "&templateid=" + templateid +"&objectid="+newsid + "&type=upcount"+"&CommentID="+commentid+ "&zipcode="+zipCode ;    
    
     $.get(url1,function(data){
       
         $("#"+objectid1).html(data);
         getdowncount(commentid,objectid1,objectid2,imgid,projectid,templateid,newsid);
      }); 


      
}

function getdowncount(commentid,objectid1,objectid2,imgid,projectid,templateid,newsid)
{
      var zipCode1=Math.random();   
      var url2 = "/commentsolution/InitAssessInfo.aspx?projectid="+projectid + "&templateid=" + templateid +"&objectid="+newsid + "&type=downcount"+"&CommentID="+commentid+ "&zipcode="+zipCode1 ;          

       $.get(url2,function(data1){
         $("#"+objectid2).html(data1);
         getFace(objectid1,objectid2,imgid);
      }); 
    

}
function getFace(objectid1,objectid2,imgid)
{
 
      var upsum = parseInt($("#"+objectid1).html()); 
 
     var downsum = parseInt($("#"+objectid2).html());

     var result = downsum/(upsum+downsum);
     var imageurl = "";

    if(result<=0.25)
        imageurl = "http://stock.788111.com/images/icon_laugh.gif";
    else if(result <= 0.45 &&   result>0.25)
        imageurl = "http://stock.788111.com/images/icon_smile.gif";
    else if(result <= 0.65 &&   result>0.45)
        imageurl = "http://stock.788111.com/images/icon_normal.gif";
    else if(result <= 0.85 &&   result>0.65)
        imageurl = "http://stock.788111.com/images/icon_sad.gif";
    else if(result > 0.85 )
        imageurl = "http://stock.788111.com/images/icon_cry.gif";


/*
      if(result > 2)
         imgurl = "http://stock.788111.com/images/icon_laugh.gif";
      else if(result < 2 && result > 1)
         imgurl = "http://stock.788111.com/images/icon_smile.gif";
      else if(result == 1)
         imgurl = "http://stock.788111.com/images/icon_normal.gif";
      else if(result > 0.5 && result < 1)
         imgurl = "http://stock.788111.com/images/icon_sad.gif";
      else if(result < 0.5)
         imgurl = "http://stock.788111.com/images/icon_cry.gif"; 

*/
      var imglink = document.getElementById(imgid); 
      imglink.src = imageurl;
  
}

