var url = window.location.host; 

function insertTmp()
{
    $(function(){
    $('.star').rating({
        callback: function(value, link){    
        // 'this' is the hidden form element holding the current value
        // 'value' is the value selected
        // 'element' points to the link element that received the click.
        alert("The value selected was '" + value + "'\n\nWith this callback function I can automatically submit the form with this code:\nthis.form.submit();");
       
        // To submit the form automatically:
        //this.form.submit();
       
        // To submit the form via ajax:
        //$(this.form).ajaxSubmit();
    }
    });
    });
}

function applyRate(val, count, module, object_id)
{
    $.post(
        "http://"+url+"/index.php",
        {
            s:          "ajax", 
            ajax:       "rating", 
            func:       "applyRate",
            val:        val,
            count:      count,
            object_id:  object_id,
            module:     module
        },
        function( data0 )
        {
            if( data0 )
            {     
                $.post(
                    "http://"+url+"/index.php",
                    {
                        s:          "ajax", 
                        ajax:       "rating", 
                        func:       "showStarRating",
                        object_id:  object_id,
                        module:     module
                    },
                    function( data )
                    {
                        if( data )
                        {      
                            $("#" + module + "_" + object_id).html(data);
                        }
                    }
                );
            }
        }
    ); 
    return false;
}