﻿function CreateProductReviewSuccess(data, textStatus, jqXHR, source) {
    $('#createReview').block({
        message: '<h2>Thanks, your review has been submitted.</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $.colorbox.close(); }, 2000);
};

function CreateProductReviewError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $('#createReview').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $('#createReview').unblock(); }, 2000);
};

function CreateProductReviewInProgress(source) {
    $('#createReview').block({
        message: '<h2>Processing...</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });
};

function CreateStockAvailabilityRequestSuccess(data, textStatus, jqXHR, source) {
    $('.mainDetail').block({
        message: '<h2>Thanks for your request, we will email you once this item is back in stock.</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); $('p.stockEnquiry').slideUp('slow'); }, 2000);
};

function CreateStockAvailabilityRequestError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $('.mainDetail').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); }, 2000);
};

function CreateStockAvailabilityRequestInProgress(source) {
    $('.mainDetail').block({
        message: '<h2>Processing...</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });
};

//product buy

function AddtoBasketSuccess(data, textStatus, jqXHR, source) {
    $('.mainDetail').block({
        message: '<h2>This item has been added to your basket.</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); $('div#basketContainer').html(data); $('div#basketContainer').slideDown('slow'); }, 2000);
};

function AddtoBasketError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $('.mainDetail').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); $('div#basketContainer').slideDown('slow'); }, 2000);
};

function AddtoBasketInProgress(source) {

    $('div#basketContainer').slideUp('slow');

    $('.mainDetail').block({
        message: '<h2>Adding to basket...</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });
};

//product buy list

function ListAddtoBasketSuccess(data, textStatus, jqXHR, source) {
    $(source).closest('div.prodCont').block({
        message: '<h2>This item has been added to your bag.</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $(source).closest('div.prodCont').unblock(); $('div#basketContainer').html(data); $('div#basketContainer').slideDown('slow'); }, 2000);
};

function ListAddtoBasketError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $(source).closest('div.prodCont').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });

    setTimeout(function () { $(source).closest('div.prodCont').unblock(); $('div#basketContainer').slideDown('slow'); }, 2000);
};

function ListAddtoBasketInProgress(source) {

    $('div#basketContainer').slideUp('slow');

    $(source).closest('div.prodCont').block({
        message: '<h2>Adding to bag...</h2>',
        css: { border: '1px solid #666', color: '#000', padding: 20 },
        overlayCSS: { backgroundColor: '#ccc', opacity: 0.6 }
    });
};

//product like

function LikeProductSuccess(data, textStatus, jqXHR, source) {

    setTimeout(function () {
        
        $('.prodsup a.adore').html("adored &#x2714;");
        $('.prodsup a.adore').unbind();
        $('.prodsup a.adore').removeAttr('href');
        $('.prodsup p.adore').highlightFade({ color: 'rgb(211,199,164)', speed: 2000, iterator: 'linear' });
        $('.prodsup p.adore').html(data + " people adore this item");
     }, 2000);
};

function LikeProductError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $('.mainDetail').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); $('.prodsup a.adore').html("adore"); }, 2000);
};

function LikeProductInProgress(source) {

    $('.prodsup a.adore').html("adoring..");

};

//product like list page

function ListLikeProductSuccess(data, textStatus, jqXHR, source) {

    $(source).highlightFade({ color: 'rgb(211,199,164)', speed: 2000, iterator: 'linear' });
    $(source).html("adored &#x2714;");
    $(source).unbind();
    $(source).removeAttr('href');

};

function ListLikeProductError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $(source).closest('div.prodCont').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $(source).closest('div.prodCont').unblock(); $(source).html("adore"); }, 2000);
};

function ListLikeProductInProgress(source) {

    $('.prodsup p.adore').slideUp('slow');

};

//add to wishlist
function AddtoWishListSuccess(data, textStatus, jqXHR, source) {
    $(source).html("added to wishlist &#x2714;");
    $(source).unbind();
    $(source).removeAttr('href');
};

function AddtoWishListError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $('.mainDetail').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $('.mainDetail').unblock(); $(source).html("add to wishlist"); }, 2000);
};

function AddtoWishListInProgress(source) {

    $(source).html("adding..");

};

//add to wishlist list page
function ListAddtoWishListSuccess(data, textStatus, jqXHR, source) {
    $(source).highlightFade({ color: 'rgb(211,199,164)', speed: 3000, iterator: 'linear' });
    $(source).html("added to wishlist &#x2714;");
    $(source).unbind();
    $(source).removeAttr('href');
};

function ListAddtoWishListError(jqXHR, textStatus, errorThrown, source) {
    var err = eval("(" + jqXHR.responseText + ")");

    $(source).closest('div.prodCont').block({
        message: '<h2>' + err.Message + '</h2>',
        css: { border: '3px solid #967e64', color: '#827055', padding: 20 },
        overlayCSS: { backgroundColor: '#967e64', opacity: 0.6 }
    });

    setTimeout(function () { $(source).closest('div.prodCont').unblock(); $(source).html("add to wishlist"); }, 2000);
};

function ListAddtoWishListInProgress(source) {

    $(source).html("adding..");

};
