var removerowid;


	function onloadFloatingCart()
	{
		var c = $('#cartcount').val();
		
		if(c != "" && c > 0)
		{
		
			$('#checkoutbutton').show();
		}
	}
	
	function removeitem(itemid, webid, rowid, url)
	{
		
		
		removerowid = rowid;
		$.ajax({
			   type: "POST",
			   url: url,
			   data: "webid="+webid+"&itemid="+itemid+"&action=ajax-action",
			   success: changecart,
			   dataType:"xml"
			   
			 });

		 
	}

	function changecart(msg)
	{
		var amended = false;
		var price = 0.00; 
		$(msg).find('total_price').each(function() {
				
				
				amended = true;
				
				var price_new = parseFloat($(this).text());
				price = parseFloat(price) + price_new;
				

				$("#"+removerowid).children().remove();
				$("#"+removerowid).remove();

				removerowid = null;
				
				
				
				});
		
		
		
		if(!amended)
		{
			$("#"+removerowid).children().remove();
			$("#"+removerowid).remove();
			//$('#checkoutbutton').remove();
			
			removerowid = null;
			$('#runningtotal').html("0.00");
			
			//hide checkout button
			$('#checkoutbutton').hide();
			
		}
		else
		{
			$('#runningtotal').html(parseFloat(price).toFixed(2));
			$('#checkoutbutton').show();
		}
	}
	
	function calculate(msg)
	{
		var amended = false;
		var price = 0.00; 
		$(msg).find('total_price').each(function() {
				
				
				amended = true;
				
				var price_new = parseFloat($(this).text());
				price = parseFloat(price) + price_new;

				removerowid = null;
				
				
				
				});

		
		
			$('#runningtotal').html(parseFloat(price).toFixed(2));
			
			$('#checkoutbutton').show();
		
	}
	
	
	function addToCart(webid)
	{
		$.ajax({
			   type: "POST",
			   url: "ajaxcart.do",
			   data: "webid="+webid,
			   success: changecart,
			   dataType:"xml"
			   
			 });
	}
	
	
	
