﻿var Cart = 
{
    _addToCartUrl: '',
    _addRMToCartUrl: '',

    set_addToCartUrl : function(value)
    {
        if (Cart._addToCartUrl != value)
            Cart._addToCartUrl = value;
    },

    set_addRMToCartUrl: function(value) {
        if (Cart._addRMToCartUrl != value)
            Cart._addRMToCartUrl = value;
    },

    addtocart: function(imageID, sizeID)
    {
        $.ajax({
            url: Cart._addToCartUrl,
            data: {imageID: imageID, sizeID: sizeID},
            dataType: 'json',
            type: 'POST',
            cache: false,
            success: function(result)
            {
                if (result.isSuccessful == true)
                {
                    $.prompt('The image has been added to your shopping cart.');
                }
                else
                {
                    $.prompt(result.errorMessage);
                }
            },
            error: function(error)
            {
                alert('There has been an error. If this problem persists, please contact the site administrator.');
            }
        });
    },

    addrmtocart: function(imageID, typeID, dimensionID, durationID) {
        $.ajax({
            url: Cart._addRMToCartUrl,
            data: { imageID: imageID, typeID: typeID, dimensionID: dimensionID, durationID: durationID  },
            dataType: 'json',
            type: 'POST',
            cache: false,
            success: function(result) {
                if (result.isSuccessful == true) {
                    $.prompt('The image has been added to your shopping cart.');
                }
                else {
                    $.prompt(result.errorMessage);
                }
            },
            error: function(error) {
                $.prompt('There has been an error. If this problem persists, please contact the site administrator.');
            }
        });
    }
    
}


