﻿// CMS Shop
var CMSShop = new Object();

CMSShop.GetCart = function(onComplete, onError)
    {
            $.ajax({
               async: true,
               type: "POST",
               url: "services/CMSShop.asmx/GetShoppingCart",
               data:"{}",
               contentType:'application/json; charset=utf-8',
               dataType: "json",
               success: onComplete,
               error: onError
             });

    }
    
CMSShop.GetSum = function(onComplete, onError)
    {
            $.ajax({
               async: true,
               type: "POST",
               url: "services/CMSShop.asmx/GetSum",
               data:"{}",
               contentType:'application/json; charset=utf-8',
               dataType: "json",
               success: onComplete,
               error: onError
             });

    }
    
CMSShop.AddToCart = function(id, variant, amount, onSuccess, onError)
    {
        amount = amount.replace(/,/,".");
            $.ajax({
               async:true,
               type: "POST",
               url: "services/CMSShop.asmx/AddToShoppingCart",
               data:"{productID:'" + id + "', variantID:' " + variant + "', amount:'"+ amount +"'}",
               contentType:'application/json; charset=utf-8',
               dataType: "json",
               success: onSuccess,
               error: onError
             });

    }
    
CMSShop.RemoveFromCart = function(id, variant, onSuccess, onError)
    {
            $.ajax({
               async:true,
               type: "POST",
               url: "services/CMSShop.asmx/RemoveFromShoppingCart",
               data:"{productID:'" + id + "', variantID:' " + variant + "'}",
               contentType:'application/json; charset=utf-8',
               dataType: "json",
               success: onSuccess,
               error: onError
             });
    }
    
    
