$(document).ready(function() {
	$.get('orders.php', {}, function (xml) {
		
		if($.cookie('ma_last') > $(xml).find('last').text() )
		{
			$('#orders').hide();
		}
		else
		{		
			$('#orders').show();
		}
		
		$('#orders').html($(xml).find('order').text());
		
		
	});
});

$('#toggle-orders').click(function() {

	if($('#orders').css('display') != 'none')
	{
		$.cookie('ma_last', Math.round(new Date().getTime()/1000), {expire: 7});
		$('#orders').hide();
		console.log('hide');
	}
	else
	{
		$.cookie('ma_last', '1', {expire: 7});
		$('#orders').show();
		console.log('show');
	}
});
