
jQuery.fn.rating=function(settings){settings=jQuery.extend({cancel:'Cancel Rating',currentValue:''},settings);var prevElem=null;var valueElem=null;var container=jQuery(this);var CancelElem=null;var event={fill:function(el){var stars=jQuery(valueElem).siblings('.star');var index=stars.index(el)+1;jQuery(valueElem).siblings('.star').children('a').css('width','100%').end()
jQuery(valueElem).siblings('.star').slice(0,index).addClass('star_on').end();$('#userscore').html(index+'/10');},drain:function(){var stars=jQuery(valueElem).siblings('.star');stars.filter('.star_on').removeClass('star_on').end().filter('.star_hover').removeClass('star_hover').end();},reset:function(){var stars=jQuery(valueElem).siblings('.star');jQuery(valueElem).siblings('.star').slice(0,settings.currentValue).addClass('star_on').end();}};return this.each(function(i){if(i==0){valueElem=jQuery('<input type="hidden" name="'+this.name+'" value="" >');jQuery(this).before(valueElem);var CancelElem=jQuery('<span></span>');prevElem=CancelElem;jQuery(this).before(prevElem);jQuery(CancelElem).mouseover(function(){event.drain();jQuery(this).addClass('star_on');}).mouseout(function(){event.reset();jQuery(this).removeClass('star_on');});jQuery(CancelElem).click(function(){settings.currentValue=jQuery(this).children('a').attr('title');$(valueElem).val(settings.currentValue);event.drain();return false;});}
if(settings.currentValue!=''){if(i>=settings.currentValue){preElemTemp=jQuery('<div class="star"><a href="javascript:void(0);" title="'+this.value+'">'+this.value+'</a></div>');}else{preElemTemp=jQuery('<div class="star star_on"><a href="javascript:void(0);" title="'+this.value+'">'+this.value+'</a></div>');}}else{preElemTemp=jQuery('<div class="star"><a href="javascript:void(0);" title="'+this.value+'">'+this.value+'</a></div>');}
jQuery(prevElem).after(preElemTemp);if($('#video_voted').val()==0){jQuery(preElemTemp).mouseover(function(){event.drain();event.fill(this);}).mouseout(function(){event.drain();event.reset();});jQuery(preElemTemp).click(function(){settings.currentValue=jQuery(this).children('a').attr('title');jQuery(valueElem).val(settings.currentValue);event.drain();event.fill(this);var myurl,myparams;try{if($('#video_id')){myurl='/dotvrating.php';myparams='score='+settings.currentValue+'&video_id='+$('#video_id').val();}}catch(e){}
jQuery.getJSON(myurl,myparams,function(json){$('#medscore').attr("src","/images/midGscore_"+json.score+".gif");alert(json.alert);return false;});});}
prevElem=preElemTemp;preElemTemp=null;if(i+1==this.length){event.reset();}
$(this).remove();});}