﻿function updateThumbnails() {
    $("a[rel^='prettyPhoto']").prettyPhoto({
        animationSpeed: 'normal', /* fast/slow/normal */
        padding: 40, /* padding for each side of the picture */
        opacity: 0.6, /* Value betwee 0 and 1 */
        showTitle: true, /* true/false */
        allowresize: true, /* true/false */
        counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
        theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
        callback: function() { }
    });
}

function toggleArtworkView() {
    $.post("/Artwork/ToggleSearchArtworkView", function(data) {
        location.reload();
    });
}

function toggleArtistView() {
    $.post("/Artists/ToggleSearchArtistView", function(data) {
        location.reload();
    });
}

function CancelFromPage() {
    var returnUrl = $("#returnUrl").val();
    if (returnUrl.length > 0) {
        location.href = returnUrl;
    }
    else {
        location.href = $("#defaultReturnUrl").val();
        
    }
}

function addToFaveArtwork() {
    $("#faveArtworkTrigger").show();
    var id = $(this).attr("id").replace("fave", "");
    $.post("/Artwork/AddToFavourites", { id: id }, function(data) {
        if (data != "False") {
            $("#faveArtworkTrigger").css("background-color", "#FFFF00").animate({ backgroundColor: "#003366" }, 1500);
        }
        else {
            alert("You have reached the limit of 10 favourite artwork items. Please remove some first before adding any further artwork");
        }

    });
    
    return false;

}

function addToFaveArtists() {

    $("#faveArtistsTrigger").show();
    var id = $(this).attr("id").replace("fave", "");
    $.post("/Artists/AddToFavourites", { id: id }, function(data) {
    if (data != "False") {
        $("#faveArtistsTrigger").css("background-color", "#FFFF00").animate({ backgroundColor: "#339999" }, 1500);
        }
        else {
            alert("You have reached the limit of 10 favourite artists. Please remove some first before adding any further artists");
        }
    });

    return false;
}

function removeFromFaveArtists() {
    var id = $(this).attr("id").replace("fave", "");
    $.post("/Artists/RemoveFromFavourites", { id: id }, function(data) {
        if (data == 0) {
            $("#faveArtistsTrigger").hide();
        }
        else {
            $("#faveArtistsTrigger").css("background-color", "#FFFF00").animate({ backgroundColor: "#339999" }, 1500);
        }
    });

    return false;
}

function removeFromFaveArtwork() {
    var id = $(this).attr("id").replace("fave", "");
    $.post("/Artwork/RemoveFromFavourites", { id: id }, function(data) {
        if (data == 0) {
            $("#faveArtworkTrigger").hide();
        }
        else {
            $("#faveArtworkTrigger").css("background-color", "#FFFF00").animate({ backgroundColor: "#003366" }, 1500);
        }
    });

    return false;
}
function clearFaveArtists() {
    
        $.post("/Artists/ClearFavourites", function(data) {
            if (data == 0) {
                $("#faveArtistsTrigger").hide();
            }
        });
    

    return false;
}
function clearFaveArtwork() {
    
        $.post("/Artwork/ClearFavourites", function(data) {
            if (data == 0) {
                $("#faveArtworkTrigger").hide();
            }
        });
    

    return false;
}
function clearHistory() {
    
        $.post("/Artwork/ClearHistory", function(data) {
            if (data == 0) {
                $("#historyTrigger").hide();
            }
        });
    

    return false;
}
