function rsMakeFavorite( obj ){
    var regexp = /\/cs\/([^\/]+)\//;
    var com = regexp.exec(window.location);
    
    if ( com.length == 0 ){
        alert('Could not add to favorites.');
        return;
    }
    
    var url = '/cs/' + com[1] + '/join/rs/' + obj.id + '?x-r=favorite';
    // https://intranet.wested.org/cs/main/join/rs/{id}?x-r=favorite
    
    $.get( url, {}, function() {
        obj.parentNode.innerHTML = "Your favorite has been saved.";
    });
}

$(document).ready(function() {
    // do this stuff when the HTML is all ready
    $("a.add").click(function() {
        rsMakeFavorite( this );
    });
});

