/*
 ### jQuery Star Rating Plugin v3.12 - 2009-04-16 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
	* Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/

if(window.jQuery)(function($){if($.browser.msie)try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}$.fn.rating=function(j){if(this.length==0)return this;if(typeof arguments[0]=='string'){if(this.length>1){var k=arguments;return this.each(function(){$.fn.rating.apply($(this),k)})};$.fn.rating[arguments[0]].apply(this,$.makeArray(arguments).slice(1)||[]);return this};var j=$.extend({},$.fn.rating.options,j||{});this.not('.star-rating-applied').addClass('star-rating-applied').each(function(){var a=(this.name||'unnamed-rating').replace(/\[|\]+/g,"_");var b=$(this.form||document.body);var c=$(this);var d=b.data('rating')||{count:0};var e=d[a];var f;if(e)f=e.data('rating');if(e&&f){f.count++}else{f=$.extend({},j||{},($.metadata?c.metadata():($.meta?c.data():null))||{},{count:0,stars:[],inputs:[]});f.serial=d.count++;e=$('<span class="star-rating-control"/>');c.before(e);e.addClass('rating-to-be-drawn');if(c.attr('disabled'))f.readOnly=true};var g=$('<div class="star-rating rater-'+f.serial+'"><a title="'+(this.title||this.value)+'">'+this.value+'</a></div>');e.append(g);if(this.id)g.attr('id',this.id);if(this.className)g.addClass(this.className);if(f.half)f.split=2;if(typeof f.split=='number'&&f.split>0){var h=($.fn.width?g.width():0)||f.starWidth;var i=(f.count%f.split),spw=Math.floor(h/f.split);g.width(spw).find('a').css({'margin-left':'-'+(i*spw)+'px'})};if(f.readOnly)g.addClass('star-rating-readonly');else g.addClass('star-rating-live').mouseover(function(){$(this).rating('fill');$(this).rating('focus')}).mouseout(function(){$(this).rating('draw');$(this).rating('blur')}).click(function(){$(this).rating('select')});if(this.checked)f.current=g;c.hide();c.change(function(){$(this).rating('select')});g.data('rating.input',c.data('rating.star',g));f.stars[f.stars.length]=g[0];f.inputs[f.inputs.length]=c[0];f.rater=d[a]=e;f.context=b;c.data('rating',f);e.data('rating',f);g.data('rating',f);b.data('rating',d)});$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');return this};$.extend($.fn.rating,{focus:function(){var a=this.data('rating');if(!a)return this;if(!a.focus)return this;var b=$(this).data('rating.input')||$(this.tagName=='INPUT'?this:null);if(a.focus)a.focus.apply(b[0],[b.val(),$('a',b.data('rating.star'))[0]])},blur:function(){var a=this.data('rating');if(!a)return this;if(!a.blur)return this;var b=$(this).data('rating.input')||$(this.tagName=='INPUT'?this:null);if(a.blur)a.blur.apply(b[0],[b.val(),$('a',b.data('rating.star'))[0]])},fill:function(){var a=this.data('rating');if(!a)return this;if(a.readOnly)return;this.rating('drain');this.prevAll().andSelf().filter('.rater-'+a.serial).addClass('star-rating-hover')},drain:function(){var a=this.data('rating');if(!a)return this;if(a.readOnly)return;a.rater.children().filter('.rater-'+a.serial).removeClass('star-rating-on').removeClass('star-rating-hover')},draw:function(){var a=this.data('rating');if(!a)return this;this.rating('drain');if(a.current){a.current.data('rating.input').attr('checked','checked');a.current.prevAll().andSelf().filter('.rater-'+a.serial).addClass('star-rating-on')}else $(a.inputs).removeAttr('checked');this.siblings()[a.readOnly?'addClass':'removeClass']('star-rating-readonly')},select:function(a){var b=this.data('rating');if(!b)return this;if(b.readOnly)return;b.current=null;if(typeof a!='undefined'){if(typeof a=='number')return $(b.stars[a]).rating('select');if(typeof a=='string')$.each(b.stars,function(){if($(this).data('rating.input').val()==a)$(this).rating('select')})}else b.current=this[0].tagName=='INPUT'?this.data('rating.star'):(this.is('.rater-'+b.serial)?this:null);this.data('rating',b);this.rating('draw');var c=$(b.current?b.current.data('rating.input'):null);if(b.callback)b.callback.apply(c[0],[c.val(),$('a',b.current)[0]])},readOnly:function(a,b){var c=this.data('rating');if(!c)return this;c.readOnly=a||a==undefined?true:false;if(b)$(c.inputs).attr("disabled","disabled");else $(c.inputs).removeAttr("disabled");this.data('rating',c);this.rating('draw')},disable:function(){this.rating('readOnly',true,true)},enable:function(){this.rating('readOnly',false,false)}});$.fn.rating.options={split:0,starWidth:32};$(function(){$('input[type=radio].star').rating()})})(jQuery);
