var plgmfv_box = []; var plgmfv_timer = null; window.addEvent('domready', function() { $$('div.plgmfv-inline-rating').each(function(el) { var pars = el.id.split('-'); el.getElements('a.plgmfv-toggler').each(function(tog) { tog.addEvent('click', function() { if (plgmfv_timer) clearTimeout(plgmfv_timer); if ("undefined" == typeof(plgmfv_box[el.id])) plgmfv_box[el.id] = new Fx.Morph(el.getElement('div.plgmfv-box'), {duration:1000, wait:false}); el.getElement('div.plgmfv-box').set("html", ''); new Request({ url: SITE_ROOT+"plugins/content/microformatsvotes/ajax.php", data: {"cid": pars[1], "context": pars[0], "rating": tog.get('text')}, timeout: 10000, noCache: true, onComplete: function(response){ var json = JSON.decode(response, false); if (!json) return; el.getElement('li#mfv-current-rating').setStyle('width', 20*json.average+'%'); plgmfv_box[el.id].start({'opacity': 0}).chain(function() { el.getElement('div.plgmfv-box').set('html', json.message); plgmfv_box[el.id].start({'opacity': 1}); plgmfv_timer = function() { plgmfv_box[el.id].start({'opacity': 0}).chain(function() { el.getElement('div.plgmfv-box').set('html', json.description); plgmfv_box[el.id].start({'opacity': 1}); }); plgmfv_timer = null; }.delay(2000); }); } }).send(); }); }); }) });