/* AJAX Star Rating : v1.0.3 : 2008/05/06 */
/* http://www.nofunc.com/AJAX_Star_Rating/ */
 
function formatToShow(num) {
	if (num==100) {return 100}
	else if (num>94) {return 95}
	else if (num>89) {return 90}
	else if (num>84) {return 85}
	else if (num>79) {return 80}
	else if (num>74) {return 75}
	else if (num>69) {return 70}
	else if (num>64) {return 65}
	else if (num>59) {return 60}
	else if (num>54) {return 55}
	else if (num>49) {return 50}
	else if (num>44) {return 45}
	else if (num>39) {return 40}
	else if (num>34) {return 35}
	else if (num>29) {return 30}
	else if (num>24) {return 25}
	else if (num>19) {return 20}
	else if (num>14) {return 15}
	else if (num>9) {return 10}
	else if (num>4) {return 5}
	else {return 0}
}
function $(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function $S(o) { return((typeof(o)=='object'?o:$(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($('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 {
 
			$S('starCur'+n).width=oX+'px';
			$S('starUser'+n).color='#111';
			$('starUser'+n).innerHTML=Math.round(oX/84*100)+'%';
			//$('starUser'+n).innerHTML=formatToShow(Math.round(oX/84*100));
		}
		show_tw();
		//document.getElementById('comment').value=oX+" "+oY+"---"+x.X+" "+x.Y;
		//document.getElementById('comment').value=e.pageY;
	};
} };
 
star.update=function(e,o) { var n=star.num, v=parseInt($('starUser'+n).innerHTML);
 
// 	rating[n] = v;
 	
	n=o.id.substr(4); $('starCur'+n).title=v;
	show_tw();
 
};
 
star.revert=function() { var n=star.num, v=parseInt($('starCur'+n).title);
 
	$S('starCur'+n).width=Math.round(v*84/100)+'px';
	$('starUser'+n).innerHTML=(v>0?Math.round(v)+'%':'');
	$('starUser'+n).style.color='#888';
	
	document.onmousemove='';
 
};
 
star.num=0;
