function getOId(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function getOStyle(o) { return((typeof(o)=='object'?o:getOId(o)).style); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function abPos(o) { var o=(typeof(o)=='object'?o:$(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); }
function XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }

star={};

star.mouse=function(e,o) { 

	if(star.stop || isNaN(star.stop)) { 
	
		star.stop=0;
		document.onmousemove=function(e) {		
			var n=star.num;
			var p=abPos(getOId('star'+n)), x=XY(e), oX=x.X-p.X, oY=x.Y-p.Y; star.num=o.id.substr(4);
	
			if(oX<1 || oX>84 || oY<0 || oY>19) { star.stop=1; star.revert(); }
			
			else {
				var score = Math.round(oX/84*100);
				var color = '#00CC00';
				if(score < 50) color= '#FF0000';
	
				getOStyle('starCur'+n).width=oX+'px';
				getOStyle('starUser'+n).color=color;
				getOId('starUser'+n).innerHTML=score+'%';
			}
    	};
	}
	
};

star.update=function(e,o) { 
	
	var n=star.num, v=parseInt(getOId('starUser'+n).innerHTML);
	getOId('starCur'+n).title = v;
	document.reviewform.score.value = v;

};

star.revert=function() { 
	
	var n=star.num, v=parseInt(getOId('starCur'+n).title);
    getOStyle('starCur'+n).width=Math.round(v*84/100)+'px';
    getOId('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'');
    getOId('starUser'+n).style.color='#ccc';
	
	if(v==0) getOId('starUser'+n).innerHTML='no ratings';
    
    document.onmousemove='';

};

star.num=0;
