if (window.jQuery) { (function(a) { if (a.browser.msie) { try { document.execCommand("BackgroundImageCache", false, true); } catch (b) { } } a.fn.rating = function(d) { if (this.length == 0) { return this; } if (typeof arguments[0] == "string") { if (this.length > 1) { var c = arguments; return this.each(function() { a.fn.rating.apply(a(this), c); }); } a.fn.rating[arguments[0]].apply(this, a.makeArray(arguments).slice(1) || []); return this; } var d = a.extend({}, a.fn.rating.options, d || {}); this.each(function() { var e = (this.name || "unnamed-rating").replace(/\[|\]+/g, "_"); var f = a(this.form || document.body); var k = f.data("rating") || { count: 0 }; var m = k[e]; var g; if (m) { g = m.data("rating"); g.count++; } else { g = a.extend({}, d || {}, (a.metadata ? a(this).metadata() : (a.meta ? a(this).data() : null)) || {}, { count: 0, stars: [] }); g.serial = k.count++; m = a('<input type="text" class="rating-star-control" name="' + e + '" value="" size="2"/>'); a(this).before(m.hide()); m.addClass("rating-to-be-drawn"); if (a(this).attr("disabled")) { g.readOnly = true; } a(this).before(g.cancel = a('<div class="rating-cancel"><a title="' + g.cancel + '">' + g.cancelValue + "</a></div>").mouseover(function() { a(this).rating("drain"); a(this).addClass("rating-star-hover"); }).mouseout(function() { a(this).rating("draw"); a(this).removeClass("rating-star-hover"); }).click(function() { a(this).rating("select"); }).data("rating", g)); } var j = a('<div class="rating-star rater-' + g.serial + '"><a title="' + (this.title || this.value) + '">' + this.value + "</a></div>"); a(this).after(j); if (this.id) { j.attr("id", this.id); } if (this.className) { j.addClass(this.className); } if (g.half) { g.split = 2; } if (typeof g.split == "number" && g.split > 0) { var i = (a.fn.width ? j.width() : 0) || g.starWidth; var h = (g.count % g.split), l = Math.floor(i / g.split); j.width(l).find("a").css({ "margin-left": "-" + (h * l) + "px" }); } if (g.readOnly) { j.addClass("rating-star-readonly"); } else { j.addClass("rating-star-live").mouseover(function() { a(this).rating("fill"); }).mouseout(function() { a(this).rating("draw"); }).click(function() { a(this).rating("select"); }); } if (this.checked) { g.current = j; } a(this).remove(); g.stars[g.stars.length] = j; g.element = k[e] = m; g.context = f; g.raters = k; m.data("rating", g); j.data("rating", g); f.data("rating", k); }); a(".rating-to-be-drawn").rating("draw").removeClass("rating-to-be-drawn"); return this; }; a.extend(a.fn.rating, { fill: function() { var c = this.data("rating"); if (!c) { return this; } if (c.readOnly) { return; } this.rating("drain"); this.prevAll().andSelf().filter(".rater-" + c.serial).addClass("rating-star-hover"); if (c.focus) { c.focus.apply(c.element, [this.text(), a("a", this)[0]]); } }, drain: function() { var c = this.data("rating"); if (!c) { return this; } if (c.readOnly) { return; } c.element.siblings().filter(".rater-" + c.serial).removeClass("rating-star-on").removeClass("rating-star-hover"); }, draw: function() { var c = this.data("rating"); if (!c) { return this; } this.rating("drain"); if (c.current) { c.element.val(c.current.text()); c.current.prevAll().andSelf().filter(".rater-" + c.serial).addClass("rating-star-on"); } else { c.element.val(""); } c.cancel[c.readOnly || c.required ? "hide" : "show"](); this.siblings()[c.readOnly ? "addClass" : "removeClass"]("rating-star-readonly"); }, select: function(c) { var d = this.data("rating"); if (!d) { return this; } if (d.readOnly) { return; } d.current = null; if (typeof c != "undefined") { if (typeof c == "number") { return d.stars[c].rating("select"); } if (typeof c == "string") { return a(d.stars).each(function() { if (this.text() == c) { this.rating("select"); } }); } } else { if (this.is(".rater-" + d.serial)) { d.current = this; } } this.data("rating", d); this.rating("draw"); if (d.callback) { d.callback.apply(d.element, d.current ? [d.current.text(), a("a", d.current)[0]] : [""]); } }, selectnocallback: function(c) { var d = this.data("rating"); if (!d) { return this; } if (d.readOnly) { return; } d.current = null; if (typeof c != "undefined") { if (typeof c == "number") { if (c > 0) { return d.stars[c].rating("selectnocallback"); } } if (typeof c == "string") { return a(d.stars).each(function() { if (this.text() == c) { this.rating("selectnocallback"); } }); } } else { if (this.is(".rater-" + d.serial)) { d.current = this; } } this.data("rating", d); this.rating("draw"); }, readOnly: function(c, d) { var e = this.data("rating"); if (!e) { return this; } e.readOnly = c ? true : false; if (d) { e.element.attr("disabled", "disabled"); } else { e.element.removeAttr("disabled"); } this.data("rating", e); this.rating("draw"); }, disable: function() { this.rating("readOnly", true, true); }, enable: function() { this.rating("readOnly", false, false); } }); a.fn.rating.options = { cancel: "Cancel Rating", cancelValue: "", split: 0, starWidth: 16 }; a(function() { a("input[type=radio].star").rating(); }); })(jQuery); }