/* AJAX Star Rating : v1.0.3 : 2008/05/06  */
/* http://www.nofunc.com/AJAX_Star_Rating/ */
/* Heavily modified                       */

function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function XY(e) { var o=agent('msie')?{'x':event.clientX+document.documentElement.scrollLeft,'y':event.clientY+document.documentElement.scrollTop}:{'x':e.pageX,'y':e.pageY}; return o; }

star={};

star.mouse = function(event, id) {
    if(star.stop || isNaN(star.stop)) {
        star.stop = 0;

        document.onmousemove = function(event) {
            var object = obj(id), obj_x = 0, obj_y = 0;
            do {
                obj_x += object.offsetLeft;
                obj_y += object.offsetTop;
            } while (object = object.offsetParent);

            var rel_x =XY(event).x - obj_x, rel_y = XY(event).y - obj_y;

            if(rel_x < 1 || rel_x > 84 || rel_y < 0 || rel_y > 19) {
                star.revert(id);
            } else {
                obj(id).style.width = rel_x + 'px';
            }
        };
    }
};

star.update = function(event, id) {
    obj(id).title = parseInt(obj(id).style.width) / 84 * 100;
    star.stop = 1;
    document.onmousemove = '';
};

star.revert = function(id) {
    obj(id).style.width = Math.round(parseInt(obj(id).title) * 84 / 100) + 'px';
    star.stop = 1;
    document.onmousemove = '';
};

