// Page ID: 222
// 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;
}
function validate_form_11(frm) {
mai = /^[0-9a-zA-Z\.\_\-]+\@[0-9a-zA-Z\.\_\-]{1,}\.[a-zA-Z]{2,4}$/;
nav = /^[\wæøåäö\s.]+$/i
err = 0;
str = 'Der opstod følgende fejl:\n\n'
if(!nav.test(frm.f_47.value)) { str += '- Navn er ikke udfyldt korrekt!\n'; err++; }
if(frm.f_48.value.length == 0) { str += '- Telefon er ikke udfyldt korrekt!\n'; err++; }
if(!mai.test(frm.f_49.value)) { str += '- E-mail er ikke udfyldt korrekt!\n'; err++; }
if(!IsNumeric(frm.f_63.value)) { str += '- Postnummer er ikke udfyldt korrekt!\n'; err++; }
if(err>0) { alert(str) } else { frm.action = frm.form_redirect.value; frm.form_validate.value = 'true'; frm.submit(); }}