// Page ID: 225
// Language ID: 1
// Version: 1.0
function AddToCart(product_id,quantity,stock) {
if (stock >= quantity) {
$.ajax({
url: '/includes/asp/shop_command.asp?cmd=cart_add&product_id=' + product_id + '&quantity=' + quantity,
cache: false,
dataType: 'html',
type: 'get',
complete: function(data){
UpdateMiniCart(true,product_id);
}
})
} else {
alert('Denne vare er desværre ikke på lager, og kan derfor ikke lægges i kurven');
}
}
function RemoveFromCart(item_id) {
$.ajax({
url: '/includes/asp/shop_command.asp?cmd=cart_remove&item_id=' + item_id,
cache: false,
dataType: 'html',
type: 'get',
complete: function(data){
UpdateMiniCart(false);
}
})
}
function UpdateMiniCart(show_cart,product_id) {
$.ajax({
url: '/includes/modules/shop/cart/update_minicart.asp',
cache: false,
dataType: 'html',
type: 'get',
complete: function(data){
$('#cart_item_list').empty();
var json = $.parseJSON(data.responseText)
$.each(json.cart_items, function(x) {
$('#cart_item_list').append('
' +
'' +
'
' +
'
' +
'' +
'');
});
if (json.cart_items.length > 0) {
$('#site_cart').attr("class","selected_cart");
} else {
$('#site_cart').attr("class","normal_cart");
}
$('.cart_items').html('' + json.cart_total.total_cart_items + ' ' + (json.cart_total.total_cart_items == 1 ? 'vare' : 'varer') + ' i kurven');
$('.cart_ammount').html('DKK ' + json.cart_total.total_cart_price);
$('#inner_cart_total').html('DKK ' + json.cart_total.total_cart_price);
if (show_cart == true) {
ShowMiniCart(true,product_id);
$('#cart_box').delay(3000).hide();
}
}
})
}
function HighlightProductMinicart(product_id) {
$('#product_' + product_id)
.animate( { 'background-color':'#FFF9D7' }, 200 )
.delay(1500)
.animate( { 'background-color':'transparent' }, 300,
function() { $(this).removeAttr("style"); }
);
}
function ShowMiniCart(scrollTop,highlight_product) {
if (scrollTop == true && $(document).scrollTop() != 0) {
$(document.body).animate(
{ scrollTop: 0 },
function() {
$('#cart_box').show();
if (highlight_product != undefined) {
HighlightProductMinicart(highlight_product);
}
}
);
} else {
setTimeout(function() {
$('#cart_box').show();
if (highlight_product != undefined) {
HighlightProductMinicart(highlight_product);
}
},100);
}
}
function IsNumeric(sText)
{
var ValidChars = "0123456789.,";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}