
function Rate(user, name, id, rating) {
    CreateCallback("ContentTailorRating.axd?name=" + name + "&user=" + user + "&id=" + id + "&rating=" + rating, RatingCallback);
}

function RatingCallback(response) {
    var rating = response.substring(0, 1);
    var status = response.substring(1);

    if (status == "OK") {
        if (typeof OnRating != "undefined")
            OnRating(rating);

        alert("You rating has been registered. Thank you!");
    }
    else if (status == "HASRATED") {
        alert(KEYhasRated);
    }
    else {
        alert("An error occured while registering your rating. Please try again");
    }
}
/// <summary>
/// Creates a client callback back to the requesting page
/// and calls the callback method with the response as parameter.
/// </summary>
function CreateCallback(url, callback) {
    var http = GetHttpObject();
    http.open("GET", url, true);

    http.onreadystatechange = function() {
        if (http.readyState == 4) {
            if (http.responseText.length > 0 && callback != null)
                callback(http.responseText);
        }
    };

    http.send(null);
}
/// <summary>
/// Creates a XmlHttpRequest object.
/// </summary>
function GetHttpObject() {
    if (typeof XMLHttpRequest != 'undefined')
        return new XMLHttpRequest();

    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) { }
    }

    return false;
}

