var cart_interval=2000;
function showCart(msg){
if (cart_interval>0){
clearTimeout(cart_interval);
$("#cartAlert").remove();
}
if(document.body.clientWidth >= 700){
cartHTML = '
';
}
else{
cartHTML = '
';
}
cartHTML += msg;
cartHTML += '
';
$("body").append(cartHTML);
$("#cartAlert").show('blind', { direction: 'vertical' }, 500, function () {
cart_interval = setTimeout('hideCart()',4000);;
});
}
function hideCart(){
$("#cartAlert").hide('blind', { direction: 'vertical' }, 500, function () {
clearTimeout(cart_interval);
cart_interval = 0;
$("#cartAlert").remove();
});
}
function getCart(){
if(document.body.clientWidth >= 700){
$.ajax({
type: "GET",
url: "ajax/getCart.php",
}).done(function( msg ) {
$('#ShoppingCart').html(msg);
});
}else{
$.ajax({
type: "GET",
url: "ajax/getCartMobile.php",
}).done(function( msg ) {
$('#ShoppingCartMobile').html(msg);
});
}
}
function add2cartFull(item){
if (submitform()){
$.ajax({
type: "POST",
url: "ajax/updateCart.php?action=add_product",
data: $("#cart_quantity").serialize()
}).done(function( msg ) {
to_cart_effect(item,msg);
});
}
}
function add2cart(product_id,quantity,item){
$.ajax({
type: "GET",
url: "ajax/updateCart.php",
data: { products_id: product_id, quantity: quantity,'action': 'buy_now_ajax' }
}).done(function( msg ) {
to_cart_effect(item,msg);
});
}
function add2cartRecommended(product_id,quantity,item){
$.ajax({
type: "GET",
url: "ajax/updateCart.php",
data: { products_id: product_id,'action': 'buy_now_ajax', 'recommended': 1 }
}).done(function( msg ) {
to_cart_effect(item,msg);
if(test_ab == 'a') mySlider.reloadSlider();
// get_shopping_cart();
// get_shipping_methods();
parent.jQuery.fancybox.close();
location.reload();
// $('#ProductRecommended'+product_id).hide(300);
});
}
function addPack2cart(pack_id,quantity,item){
$.ajax({
type: "GET",
url: "ajax/updateCart.php",
data: { pack_id: pack_id, quantity: quantity, 'action': 'buy_now_pack_ajax' }
}).done(function( msg ) {
to_cart_effect(item,msg);
});
}
function to_cart_effect(item,msg){
item.animate_from_to('#ShoppingCart', {
callback: function(){
getCart();
showCart(msg);
},
});
}