﻿ jQuery.query = function() { 
            var r = {}; 
            var q = location.search;         
            q = q.replace(/^\?/,''); // remove the leading ?         
            q = q.replace(/\&$/,''); // remove the trailing & 
            jQuery.each(q.split('&'), function(){ 
                    var key = this.split('=')[0]; 
                    var val = this.split('=')[1]; 
                    // convert floats 
                    if(/^[0-9.]+$/.test(val)) 
                            val = parseFloat(val); 
                    // ingnore empty values 
                    if(val) 
                            r[key] = val; 
            }); 
            return r; 
}; 

$(function(){
    $('.auto-submit-star').rating({
        callback: function(value, link){
        $('#rating').fadeOut('fast',function() {
         var did= $.query()['did'];                           
            $.ajax({
                type: "POST",
                url: "rateArticle.aspx",
                data: "did="+ did +"&votes=" + value,
                success: function(html){ 
                    $("#rating").html(html)
                    $("#rating").fadeIn('slow');
                }
            });  
        });
        }
    });
});
