$.fn.rating=function(url,guesturl,width,height){var items=10;return this.each(function(){var div=$("<div/>").attr({title:this.title,className:this.className}).insertAfter(this);$(this).find("select option").each(function(){div.append("<div class='star'><a href='#"+this.value+"' title='Give it a "+this.value+"/10 Rating'>"+this.value+"</a></div>");items=this.value;});div.css("width",(width*items)+"px").css("height",height+"px");var averageRating=this.title.split(/:\s*/)[1].split("."),sitearea=$("input[name=sitearea]",this).val(),siteareaid=$("input[name=siteareaid]",this).val(),averageIndex=averageRating[0],averagePercent=averageRating[1];var stars=div.find("div.star").mouseover(drainFill).focus(drainFill).mouseout(drainReset).blur(drainReset).click(click).css("width",width+"px").css("height",height+"px");reset();function drainFill(){drain();fill(this);}function drainReset(){drain();reset();}function click(){averageIndex=stars.index(this)+1;averagePercent=0;if(averageIndex===0){drain();}if(guesturl){$('.yourate').html("Only members can rate. <a href='"+guesturl+"'>Join now</a>.");}else
{$.post(url,{rating:$(this).text(),sitearea:sitearea,siteareaid:siteareaid},function(response){$('.yourate').html(response);});}return false;}function fill(elem){stars.find("a").css("width","100%");stars.slice(0,stars.index(elem)+1).each(function(){$(this).children("a").addClass("on").css("background-position","-"+(width*stars.index(this))+"px -"+height+"px");});$('.yousay').html(stars.index(elem)+1);}function drain(){stars.each(function(){$(this).children("a").removeClass("on");});$('.yousay').html('-');}function reset(){stars.slice(0,averageIndex).each(function(){$(this).children("a").addClass("on").css("background-position","-"+(width*stars.index(this))+"px -"+height+"px");});var percent=averagePercent?averagePercent*10:0;if(percent>0){stars.slice(averageIndex,1).children("a").css("width",percent+"%").addClass("on").css("background-position","-"+((parseInt(averageIndex+averagePercent,10)/100)*width*items-width/2)+"px -"+height+"px");$('.yousay').html(averageIndex+"."+averagePercent);}else
{$('.yousay').html(averageIndex);}}}).remove();};if($.browser.msie){document.execCommand('BackgroundImageCache',false,true);}