/**
* function doCart()
* 
* @desc Checks cookie-content, and add/ delete domain from cookie. Refreshes sidebarbox on change
* @access public
* @param string domain (e.g. 'platinpower.de')
* @return void
*
*/
function doCart(domain)
{
	if($.cookie('cart'))
	{
		//Cookie exist, but selected Domain is not in cart
		var cart = $.cookie('cart');
		if(cart.indexOf(domain) == -1)
		{
			cart_content = cart + "," + domain;
			$.cookie('cart', cart_content, { expires: 1 });
			$('#cart').load('boxes/cart.php');
		}
		
		//selected Domain is already in cart -> delete Domain from cookie
		else
		{
			//selected Domain is the only Domain in cart
			if(cart == domain)
			{
				$.cookie('cart', '', { expires: -1 });
				$('#cart').load('boxes/cart.php');
			}
			
			//There are more Domains in cart
			else
			{	
				//Selected Domain is the last one of the Cookie-String				
				if(cart.indexOf(domain) == (cart.length-domain.length))
				{
					cart_content = cart.replace(','+domain,'');
				}
				else
				{
					cart_content = cart.replace(domain+',','');
				}
				
				$.cookie('cart', '', { expires: -1 });
				$.cookie('cart', cart_content, { expires: 1 });
				$('#cart').load('boxes/cart.php');
			}
		}
	}
	else
	{
		//Cookie doesn't exist, add the first Domain
		var cart_content = domain;
		$.cookie('cart', cart_content, { expires: 1 });
		$('#cart').load('boxes/cart.php');
	}
}

/**
 * deleteCookie function.
 * 
 * @desc deletes hole cookie
 * @access public
 * @return void
 */
function deleteCookie()
{
	$.cookie('cart', '', { expires: -1 });
	$('#cart').load('boxes/cart.php');
}


/* jQuery Cookie functions
 * 
 * $.cookie('the_cookie'); // get cookie
 * $.cookie('the_cookie', 'the_value'); // set cookie
 * $.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
 * $.cookie('the_cookie', '', { expires: -1 }); // delete cookie
 */
