function addToCart(button, itemID){
$.get("/_ajax/shop.item.add.ajax.php", {"item_id":itemID}, function(data){
if(data.indexOf("<ok/>")>-1){
$("#cart-count").html(parseInt($("#cart-count").html())+1);
$(button).parent().html("התווסף לעגלת הקניות שלך.");
}});
}
function addToCartSpecial(button, itemID){
   var test = $("#sixtee").serialize();
$.get("/_ajax/shop.item.add.special.ajax.php", {"item_id":test}, function(data){
if(data.indexOf("<ok/>")>-1){
$("#cart-count").html(parseInt($("#cart-count").html())+1);
$(button).parent().html("Your Item has been added to your Shopping Cart.");
}});
}
function updtCartItemQntt(itemID, qntt){
$.get("/_ajax/shop.qntt.updt.ajax.php", {"item_id":itemID, "qntt":qntt}, function(data){
var itemTotal = parseFloat($("#item_"+itemID+"_total").html());
var totalPrice = parseFloat($("#cart_total").html());
var itemPrice = parseFloat($("#item_"+itemID+"_price").html());
if(data.indexOf("<ok/>")>-1){
var itemQntt = parseInt($("#item_"+itemID+"_qntt").html());
$("#item_"+itemID+"_total").html((itemTotal+itemPrice*qntt).toFixed(2));
$("#item_"+itemID+"_qntt").html(itemQntt+qntt);
}else if(data.indexOf("<rmv/>")>-1){
$("#item_"+itemID+"_row").remove();
}else if(data.indexOf("<empty/>")>-1){
$("#item_"+itemID+"_qntt").html(0);
document.location.reload();
}
$("#cart-count").html(parseInt($("#cart-count").html())+qntt);
$("#cart_total").html((totalPrice+itemPrice*qntt).toFixed(2));
$.get("/_ajax/shop.shipping.ajax.php", {"shipping_type":$("#ship_combo").find("option:selected").val()}, function(data){
var tmp = data.split("||");
if(tmp[0].indexOf("<ok/>")>-1){
$("#shipping_total").html(parseInt(tmp[1]).toFixed(2));
$("#cart_total").html(parseInt(tmp[2]).toFixed(2));
}});
});
}
function rmvCartItem(itemID){
$.get("/_ajax/shop.item.rmv.ajax.php", {"item_id":itemID}, function(data){
if(data.indexOf("<rmv/>")>-1){
$("#item_"+itemID+"_row").remove();
$("#cart-count").html(parseInt($("#cart-count").html())-1);
document.location.reload();
}else if(data.indexOf("<empty/>")>-1){
document.location.reload();
}});
}
$(document).ready(function(){
$("#ship_combo").change(function(){
$.get("/_ajax/shop.shipping.ajax.php", {"shipping_type":$(this).find("option:selected").val()}, function(data){
var tmp = data.split("||");
if(tmp[0].indexOf("<ok/>")>-1){
$("#shipping_total").html(parseInt(tmp[1]).toFixed(2));
$("#cart_total").html(parseInt(tmp[2]).toFixed(2));
}});
});
$("#charge-form").submit(function(){
var msg ="";
if($("input[name='phone1']").val() == ""){ msg+="אנא הזן מספר טלפון ליצירת קשר.\n"; }
if($("input[name='cc_num']").val() == ""){ msg+="אנא הזינו את מספר הכרטיס.\n"; }
if($("input[name='cc_owner']").val() == ""){ msg+="אנא הזינו את שם בעל הכרטיס.\n"; }
if($("input[name='tz']").val() == ""){ msg+="אנא הזינו את תעודת הזהות.\n"; }
if($("input[name='cc_cvv']").val() == ""){ msg+="אנא הזינו את ספרות ה CVV של כרטיס.\n"; }
if(msg){
alert(msg);
return false;
}
$("#charge-form").find("input[name='submit-btn']").attr("disabled","true");
return true;
});
});

