
function getPosition(e){var left=0;var top=0;while(e.offsetParent){left+=e.offsetLeft;top+=e.offsetTop;e=e.offsetParent;}
left+=e.offsetLeft;top+=e.offsetTop;return{x:left,y:top};}
function hx_gb_rater(){this.rating=0;this.tmpRating=0;}
hx_gb_rater.prototype={create:function(_element,_read_only){var offsets={'1':3,'37':0,'6':1,'14':4,'15':2}
var offset=0;if(_element.tagName=='SELECT')this.rating=_element.selectedIndex;else this.rating=gt(_element);var cn=_element.className;var s=cn.indexOf('type');if(type>=0&&type<offsets.length){if(s>0){s+=4;var e=cn.indexOf('off',s);var type=cn.substr(s,e-s);offset=offsets[type]*14;}}
var el=_element.parentNode;el.removeChild(_element);this.div=document.createElement('div');this.div.style.display='block';this.div.style.width='80px';this.div.style.height='14px';if(cn.indexOf('inline')>=0){this.div.style.position='absolute';this.div.style.top='0px';this.div.style.right='0px';}
this.div.style.backgroundColor='white';this.div.style.backgroundImage='url( images/vsclover.gif )';this.div.style.backgroundRepeat='repeat-x';this.div.style.backgroundPosition='0 -70px';this.readOnly=_read_only;if(!this.readOnly){this.div.style.cursor='pointer';var thisPtr=this;this.div.onmousemove=function(_e){thisPtr.onHover(_e,thisPtr);};this.div.onmouseout=function(_e){thisPtr.onMouseOut(_e,thisPtr);};this.div.onclick=function(_e){thisPtr.onClick(_e,thisPtr);};this.input=document.createElement('input');this.input.type='hidden';this.input.name='rating';el.appendChild(this.input);}
this.line=document.createElement('div');this.line.style.height='100%';this.line.style.backgroundColor='transparent';this.line.style.backgroundImage='url( images/vsclover.gif )';this.line.style.backgroundRepeat='repeat-x';this.line.style.backgroundPosition='0 -'+offset+'px';this.div.appendChild(this.line);el.appendChild(this.div);this.set(this.rating);},onHover:function(_e,_this){if(!_e)_e=window.event;var pos=getPosition(_this.div);_this.tmpRating=Math.floor((_e.clientX-pos.x)*5/_this.div.clientWidth)+1;if(_this.tmpRating>5)_this.tmpRating=5;_this.draw(_this.tmpRating);if(!_e.stopPropagation)window.event.cancelBubble=true;else _e.stopPropagation();},onMouseOut:function(_e,_this){_this.draw(_this.rating);},onClick:function(_e,_this){_this.rating=_this.tmpRating;if(!_this.readOnly)sv(_this.input,_this.rating);},draw:function(_rating){this.line.style.width=(_rating*100/5)+'%';},get:function(){return this.rating;},set:function(_rating){this.rating=Math.ceil(_rating);this.draw(this.rating);this.div.title=loc_js.rating+this.rating+'/5';}}
var raters=[];function convertRatings(){var spans=document.getElementsByTagName('span');for(var j=0;j<spans.length;j++){if(spans[j].className.indexOf('rating')>=0){var r=new hx_gb_rater();r.create(spans[j],true);j--;raters.push(r);}}}
