
function addvote(entryid,option,votes){
        //     alert(entryid);
		var serviceurl = "http://www.royalchallengers.com/ee/index.php/misc/votes/" + entryid + "/" + option + "/";
          //  alert(serviceurl);          
           var params = "";	
		postData(serviceurl,params,getvote);

                entry_id=entryid;
                optionid=option;
                nvotes=votes;
}

function getvote(data){
      //  alert(data);
         var divid = "like_" + entry_id +"_" + optionid;


     if(data.indexOf('You voted +1')!=-1){
      //   alert(divid);

         nvotes++;
         document.getElementById(divid).innerHTML=nvotes;
     }
     else if(data.indexOf('You voted -1')!=-1){
    //     alert(divid);

         nvotes++;
         document.getElementById(divid).innerHTML=nvotes;
     }
     else{
     }
}

function addfavorite(entryid,option){
//alert(entryid);
                var inhtml='';
		var serviceurl = "http://www.royalchallengers.com/ee/index.php/misc/favorite_add/" + entryid + "/";
                
                 if(option=='delete'){
                    serviceurl +="delete/"
                    inhtml='<a href="javascript:addfavorite(\''+ entryid+'\',\'add\')" >Add as a favorites</a>';
                 }
                else{
                  inhtml='<a href="javascript:addfavorite(\''+ entryid+'\',\'delete\')" >Remove from favorites</a>';
                }
           //    alert(serviceurl);	
	
                var params = "";	
		postData(serviceurl,params,getfavorite);

               var divid = "fav_" + entryid;
               document.getElementById(divid).innerHTML=inhtml;
                
}
function getfavorite(data){
  // alert(data);
}
