
function VotingStar(objName,ajaxPHPScript,divEl,itemId,itemType,isSmall)
{if(arguments.length>0)
{this.init(objName,ajaxPHPScript,divEl,itemId,itemType,isSmall);}}
VotingStar.prototype.init=function(objName,ajaxPHPScript,divEl,itemId,itemType,isSmall)
{this.objName=objName;this.ajaxPHPScript=ajaxPHPScript;this.divObj=null;this.divEl=divEl;this.itemId=itemId;this.itemType=itemType;this.isSmall=isSmall;this.createVoting();}
VotingStar.prototype.clear=function()
{this.data=null;this.responseText=null;}
VotingStar.prototype.loadData=function(estimation)
{this.clear();estimation=(estimation?estimation:0);var referenceThis=this;var url=this.ajaxPHPScript+'?event=GetDataVoting&type='+this.itemType+'&id='+this.itemId+'&estimate='+estimation;new Ajax.Request(url,{method:'get',onSuccess:function(transport)
{try
{referenceThis.data=transport.responseText.evalJSON();referenceThis.responseText=transport.responseText;}catch(e){}
referenceThis.answerOnLoadData()},onFailue:function(transport)
{alert('Please, check you connection!');}});}
VotingStar.prototype.answerOnLoadData=function()
{if(this.data!=null)
{var html=this.getVotingHTML();setDivContent(this.divEl,html);}
else
{}}
VotingStar.prototype.getVotingHTML=function()
{if(this.data.isVote==true)
{html_disallow=(!(this.isSmall>0)?'<ul class="star-rating">':'<ul class="star-rating-60">');html_disallow+='<li class="current-rating" style="width: '+this.data.estimate*20+'%;">&nbsp;</li>';html_disallow+='<li></li><li></li><li></li><li></li><li></li>';html_disallow+='</ul>';return html_disallow;}
else
{html_allow=(this.isSmall!=1?'<ul class="star-rating">':'<ul class="star-rating-60">');html_allow+='<li class="current-rating" style="width: '+this.data.estimate*20+'%;">&nbsp;</li>';html_allow+='<li><a class="one-star" href="one" onclick="'+this.objName+'.loadData(1); return false;">&nbsp;</a></li>';html_allow+='<li><a class="two-stars" href="two" onclick="'+this.objName+'.loadData(2); return false;">&nbsp;</a></li>';html_allow+='<li><a class="three-stars" href="three" onclick="'+this.objName+'.loadData(3); return false;">&nbsp;</a></li>';html_allow+='<li><a class="four-stars" href="four" onclick="'+this.objName+'.loadData(4); return false;">&nbsp;</a></li>';html_allow+='<li><a class="five-stars" href="five" onclick="'+this.objName+'.loadData(5); return false;">&nbsp;</a></li>';html_allow+='</ul>';return html_allow;}}
VotingStar.prototype.createVoting=function()
{this.divObj=document.getElementById(this.divEl)
if(!this.divObj)
{return;}
this.loadData();}