
// --------------------------------------------------------------------------------------------
// Star ratings
// --------------------------------------------------------------------------------------------

function rtpStar(type_id, rating, max_stars) {
    var id = 'rtp_rating[' + type_id + ']'; 
    var current_value = document.getElementById(id).value * 1;

    if (rating == 0)
        rating = current_value;    
                
    for (i = 1; i <= max_stars; i++) {
        id = 'rtp_star_' + type_id + '_' + i;
        if (i <= rating)
            document.getElementById(id).className = 'rtp-star-on';
        else
            document.getElementById(id).className = 'rtp-star-off';
    }
}

function rtpSetStar(type_id, rating) {
    var id = 'rtp_rating[' + type_id + ']';
    document.getElementById(id).value = rating;
}

function rtpShowStars(type_id, max_stars) {
    var i, stars, id;

    for (i = 1; i <= max_stars; i++) {
        id = 'rtp_star_' + type_id + '_' + i;        
        document.getElementById(id).className = 'rtp-star-off';
    }
    

}

// --------------------------------------------------------------------------------------------
// Admin screens.  Allows a 'master' checkbox on tables that either checks or unchecks all columns
// --------------------------------------------------------------------------------------------
function rtpCheckAll(master_checkbox, checkboxes) {    
    // Note: there's a gotcha here: we get an ARRAY of checkboxes only if > 1 checkbox exists.  
    // Otherwise we get just the single checkbox.
    if (typeof(checkboxes.length) == 'undefined')
        checkboxes.checked = master_checkbox.checked;
    else {
        for (i = 0; i < checkboxes.length; i++)
            checkboxes[i].checked = master_checkbox.checked;
    }
}

