var bopenCloseIdentifier = false;

	function DeleteItem(id)
	{
		$("#cartdata").load(document.getElementById('web_server_tak').value + "/cart/delete/1/" + id, {}, function(){
			if(document.getElementById("incart_total") != null)
			{
				document.getElementById("cart_total_price").innerHTML = document.getElementById("incart_total").innerHTML;
				document.getElementById("cart_total_count").innerHTML = document.getElementById("incart_ctotal").innerHTML;
			}
			else
			{
				document.getElementById("cart_total_price").innerHTML = 0;
				document.getElementById("cart_total_count").innerHTML = 0;
			}
		});
	}
	
	function UpdateCart()
	{
		var count = document.getElementById("product_list").value;
		var tmpTest = '{"recal":1,"product_list":' + count;
		for(var i = 0; i < count; i++)
		{
			tmpTest += ',"product_' + i + '":' + document.getElementById("product_" + i).value;
			tmpTest += ',"product_qty_' + i + '":' + document.getElementById("product_qty_" + i).value;			
		}
		tmpTest += "}";
		//alert(tmpTest);
		var tmpJson = JSON.parse(tmpTest);
		$("#cartdata").load(document.getElementById('web_server_tak').value + "/cart/cart", tmpJson, function(){
			document.getElementById("cart_total_price").innerHTML = document.getElementById("incart_total").innerHTML;
			document.getElementById("cart_total_count").innerHTML = document.getElementById("incart_ctotal").innerHTML;
		}); 
	}
	
	function BindClose()
	{
		$("#topMenuOpen").click( function() {
			if(bopenCloseIdentifier == false)
			{
				OpenCart();
			}
		});  	
	}
	
	function BindOpen()
	{
		$("#topMenuClose").click( function() {
			if(bopenCloseIdentifier == true)
			{
				CloseCart();
			}
		}); 	
	}
	
	function OpenCart()
	{
		document.getElementById('sliderContent').innerHTML = document.getElementById('carthide').innerHTML;
		
		$("#slider").animate({ 
			marginTop: "-400px"
			}, 500, null, function() {
				// Init jCarousel
				$("#cartdata").load(document.getElementById('web_server_tak').value + "/cart/cart", {}); 
			});
		bopenCloseIdentifier = true;
		BindOpen();
	}
	
	function CloseCart()
	{
		$("#slider").animate({ 
			marginTop: "0px"}, 500, null, function() {
				document.getElementById('sliderContent').innerHTML = document.getElementById('cartshow').innerHTML;
				bopenCloseIdentifier = false;
				BindClose();
		});	
	}
	
	function SwapCart()
	{
		if(bopenCloseIdentifier == true)
		{
			CloseCart();
		}
		else
		{	
			OpenCart();
		}
	}
	
	$(document).ready(function() 
	{
		document.getElementById('sliderContent').innerHTML = document.getElementById('cartshow').innerHTML;	
		BindClose();
	});
	
	window.onresize = function cartResize()
	{
		//var winheight = parseInt(document.documentElement.scrollWidth)
		var winheight   = parseInt(document.body.scrollWidth);
		var boheight = 992;//parseInt(document.body.scrollWidth)
	
		if (winheight >= boheight)
		{
			document.getElementById('presence').style.marginBottom="0px";
			//document.getElementById('footercontent').style.width = '800px';
		}
		else if (winheight < boheight)
		{
			document.getElementById('presence').style.marginBottom="20";
			//document.getElementById('footercontent').style.width= ( winheight )+'px';
		}
	}