$(function() {

	// TODO: this should actually target the li so that it can be styled properly
	var $cartToggler = $('#micro-cart-tool a.cart');

	// initialize micro cart toggle
	$cartToggler.toggler({
		openCallback	: function() {
			localStorage.setItem('micro-cart-toggle', true);
		},
		closeCallback	: function() {
			localStorage.removeItem('micro-cart-toggle');
		}
	});
	
	// open the stickytools if they were open last request
	if (localStorage.getItem('micro-cart-toggle')) {
		$cartToggler.toggler('toggle', { duration: 0 });
	}
	
	// make the microcart toggle closed before redirecting
	$('li.checkout-link a').click(function() {
		var checkoutLink = this;
		$cartToggler.toggler('toggle', {
			closeCallback: function() {
				localStorage.removeItem('micro-cart-toggle');
				window.location = checkoutLink.href;
			}
		});
		
		return false;
	});


});

/*
select_locale=function()
{
	$('#localeSelect').show();
	var locationObj = document.location;
	var hlink= locationObj.href;

	if(hlink.indexOf("?locale")>0)
	{

		// remove the ?locale=xx-xx from the string
	    hlink=locationObj.href.substring(0,locationObj.href.indexOf("?locale"));

	}


	hlink += '?locale='+$('#localeSelect option:selected').val();

	console.debug(hlink);
	window.location.href = hlink;

}
*/

