jQuery.fn.rating=function(B){B=jQuery.extend({url:"/",method:"post",pk:1,selectedPrefix:"r",hoverHandler:function(E,F){switch(E){default:console.log("Looking for %s handler",E);break}},clickHandler:function(E,F){console.log("You clicked %s",E);return E},onError:function(E,G,F){console.log("Ajax Failed %s",G)},onSuccess:function(E,F){console.log("Ajax Completed")},defaultRating:0},B);var D=function(F,G,E){jQuery("<li />").html("<span>"+G+"</span>").attr("class",G).appendTo("ul.Ajax-Rating");if(E){$("ul.Ajax-Rating").addClass(B.selectedPrefix+(F+1));console.log("current rating: %d",(F+1));B.defaultRating=(F+1)}};var C=function(){return jQuery("<div />").html(jQuery("<ul />").attr("class","Ajax-Rating"))};var A=function(E){jQuery(E).after(C());jQuery(E).hide();return jQuery(E).each(function(F,G){jQuery(G).children("option").each(function(I,H){jQuery("div.tagContainer").append(D(I,H.innerHTML,H.selected))});jQuery("ul.Ajax-Rating li").mouseover(function(){state=jQuery(this).attr("class");jQuery(this).parent("ul.Ajax-Rating").attr("class","Ajax-Rating "+B.selectedPrefix+state);B.hoverHandler(state,this)}).click(function(){queryData=B.clickHandler(jQuery(this).attr("class"),this);jQuery.ajax({data:{key:B.pk,q:queryData},dataType:"json",url:B.url,type:B.method,success:B.onSuccess,error:B.onError})}).mouseout(function(){jQuery(this).parent("ul.Ajax-Rating").attr("class","Ajax-Rating "+B.selectedPrefix+B.defaultRating)})})};return A(this)};