// Makes favorite requests to the server for the user
function setFavorite(bID) {
    var val = $("#f_" + bID).attr("src").split("_");
    if (val[1] == "off.png") { option = "ID"; } else { option = "DELETE"; }
    $("#f_" + bID).attr("src", "/images/favorite_waiting.png");
    $.get("/ajax/favorites.php?" + option + "=" + bID,
        function(data) {
            switch(data) {
                case "must login":
                    $("#f_" + bID).attr("src", "/images/star_off.png");
                    break;
                case "added":
                    $("#f_" + bID).attr("src", "/images/star_on.png");
                    break;
                case "deleted":
                    $("#f_" + bID).attr("src", "/images/star_off.png");
                    break;
            }
        });
}

// Makes favorite requests to the server for the user
function setCollect(pID) {
    var val = $("#c_" + pID).attr("src");
    if (val == "/images/icons/nolike.png") { option = "ID"; } else { option = "DELETE"; }
    $("#c_" + pID).attr("src", "/images/collection_waiting.png");
    $.get("/ajax/collection.php?" + option + "=" + pID,
        function(data) {
            switch(data) {
                case "must login":
                   alert("You must login in order to add this image to your collection.");
                    $("#c_" + pID).attr("src", "/images/icons/nolike.png");
                    break;
                case "added":
                    $("#c_" + pID).attr("src", "/images/icons/i_like.png");
                    break;
                case "already added":
                    alert("This post was already added.");
                    $("#c_" + pID).attr("src", "/images/icons/i_like.png");
                case "yours":
                    alert("It's your picture, com'mon we know you already like it!");
                    $("#c_" + pID).attr("src", "/images/icons/nolike.png");
                    break;
                case "deleted":
                    $("#c_" + pID).attr("src", "/images/icons/nolike.png");
                    break;
            }
        });
}

