// JavaScript Document

function removeSelected(url){
	var msgCON = document.getElementById('cart_response');
	var cartAJAX = document.getElementById('cart_ajax');
	var cartNotificationAJAX = document.getElementById('h_04');

	objElements = document.getElementById('add2cart_form').elements;
	var toRemoveOBJ = "";
	for(i=0;i<objElements.length;i++){
		if(objElements[i].checked == true) toRemoveOBJ += (objElements[i].value+"|");
	}
	
	if(toRemoveOBJ == ''){
		alert("Please check the beats that you want to remove.");
	}else{
		var actReq = confirm("Warning: This operation cannot be undone.\nAre you sure you want to remove this item(s) in your cart?");
		if (actReq == true){

			msgCON.style.display = 'block';
			msgCON.innerHTML = processing;
			$.get(sdom+"modules/ajax-remove-selected-ci.mod.php", { toRemove: toRemoveOBJ },
			function(data){
				msgCON.innerHTML = data;
				if(data != ""){
					$.get(sdom+"modules/ajax-refresh-cart.mod.php", {  },
					function(data){
						cartAJAX.innerHTML = data;
					});
					/*
					$.get(sdom+"modules/ajax-cart-notification.mod.php", {  },
					function(data){
						cartNotificationAJAX.innerHTML = data;
					});*/
				}
			});

		} else return false;
	}
	return false;
}

function removeSingleItem(bid){
	var actReq = confirm("Warning: This operation cannot be undone.\nAre you sure you want to remove this item in your cart?");
	var msgCON = document.getElementById('cart_response');
	var cartAJAX = document.getElementById('cart_ajax');
	var cartNotificationAJAX = document.getElementById('h_04');
	if (actReq == true){

		msgCON.style.display = 'block';
		msgCON.innerHTML = processing;
		$.get(sdom+"modules/ajax-remove-selected-ci.mod.php", { toRemove: bid },
		function(data){
			msgCON.innerHTML = data;
			if(data != ""){
				$.get(sdom+"modules/ajax-refresh-cart.mod.php", {  },
				function(data){
					cartAJAX.innerHTML = data;
				});
				/*
				$.get(sdom+"modules/ajax-cart-notification.mod.php", {  },
				function(data){
					cartNotificationAJAX.innerHTML = data;
				});*/
			}
		});

	} else return false;
}

function emptyCart(url){
	var actReq = confirm("Warning: This operation cannot be undone.\nAre you sure you want to remove all item(s) in your cart?");
	var msgCON = document.getElementById('cart_response');
	var cartAJAX = document.getElementById('cart_ajax');
	var cartNotificationAJAX = document.getElementById('h_04');

	if (actReq == true){
		msgCON.style.display = 'block';
		msgCON.innerHTML = processing;
		$.get(sdom+"modules/ajax-empty-cart.mod.php", {  },
		function(data){
			msgCON.innerHTML = data;
			if(data != ""){
				$.get(sdom+"modules/ajax-refresh-cart.mod.php", {  },
				function(data){
					cartAJAX.innerHTML = data;
				});
				/*
				$.get(sdom+"modules/ajax-cart-notification.mod.php", {  },
				function(data){
					cartNotificationAJAX.innerHTML = data;
				});*/
			}
		});
	}
	else return false;
}

