stlib.namespace("stlib.rating");stlib.rating=(function(){var a={1:"Aweful",2:"Bad",3:"So So",4:"Good",5:"Great",6:"Excellent"};function b(h,j){var c=jQuery(h),e,k=jQuery("span",c);function d(r){var n,m,l,p,o,q;n=r<0.25?"":(r<0.75?"half":"full");m=r<1.25?"":(r<1.75?"half":"full");l=r<2.25?"":(r<2.75?"half":"full");p=r<3.25?"":(r<3.75?"half":"full");o=r<4.25?"":(r<4.75?"half":"full");q=r<5.25?"":(r<5.75?"half":"full");jQuery("a[rel='1']",c).addClass(n);jQuery("a[rel='2']",c).addClass(m);jQuery("a[rel='3']",c).addClass(l);jQuery("a[rel='4']",c).addClass(p);jQuery("a[rel='5']",c).addClass(o);jQuery("a[rel='6']",c).addClass(q)}function i(){var m=this,l=parseInt(jQuery(m).attr("rel"),10);jQuery("a",c).removeClass("full half");switch(l){case 1:break;case 2:jQuery("a[rel='1']",c).addClass("full");break;case 3:jQuery("a[rel='1']",c).addClass("full");jQuery("a[rel='2']",c).addClass("full");break;case 4:jQuery("a[rel='1']",c).addClass("full");jQuery("a[rel='2']",c).addClass("full");jQuery("a[rel='3']",c).addClass("full");break;case 5:jQuery("a[rel='1']",c).addClass("full");jQuery("a[rel='2']",c).addClass("full");jQuery("a[rel='3']",c).addClass("full");jQuery("a[rel='4']",c).addClass("full");break;case 6:jQuery("a",c).addClass("full");break}jQuery(m).addClass("full");k.html(a[l])}function g(){var l;jQuery("a",c).removeClass("half").removeClass("full");k.html("&nbsp;");l=jQuery(c).closest("div.rater").attr("rel");l=parseFloat(l);if(isNaN(l)===true){return}d(l)}function f(m){var n=this,l=jQuery(n).attr("rel");m.preventDefault();c.addClass("locked");jQuery("a",c).unbind("click mouseenter mouseleave");jQuery.post("/rating/"+j+"/"+l+"/",function(p){var o=p[0].result;if(o==="success"){jQuery("#rater-message").html("<p>Thanks for rating!!")}else{if(o==="ipaddress"){jQuery("#rater-message").html("<p>Your rating was not recorded. We only take one rating per hour from the same IP address. Please come back in an hour to rate this posting. Thank you.</p>")}}})}jQuery("a",c).hover(i,g).click(f)}return{init:b}}());
