var booknotice = {
	setNotice: function(element, bookISBN){
		$(element).parent().html('Gemerkt');
		$('#shoppingcart').addClass('full');
		var merkcounter = $('#merkcounter').html();
		
		if(merkcounter==null){
			$('#merklinkid').html($('#merklinkid').html()+' [<span id="merkcounter">1</span>]');
		} else {
			merkcounter = parseInt(merkcounter);
			$('#merkcounter').html(merkcounter+1);
		}
		$.ajax({
			type: 'POST',
			url: '/stuff/booknotice.inc.php',
			cache: false,
			data: 'isbn='+bookISBN+'&action=addCookie&name=booknotice',
			success: function(data) {
			}
		});
	},
	removeNotice: function(element, bookISBN){
		$(element).parent().parent().parent().remove();
		var merkcounter = $('#merkcounter').html();
		merkcounter = parseInt(merkcounter);
		if (merkcounter>1) {
			$('#merkcounter').html(merkcounter-1);
		} else {
			$('#shoppingcart').removeClass('full').addClass('empty');
			$('#merklinkid').html('Merkliste');
		}
		
		$.ajax({
			type: 'POST',
			url: '/stuff/booknotice.inc.php',
			cache: false,
			data: 'isbn='+bookISBN+'&action=removeCookie&name=booknotice',
			success: function(data) {
			}
		});
	},
	orderAll: function(element, bookISBNs){
		var isbnArray = bookISBNs.split(",");
		for(var i = 0; i < isbnArray.length; i++) {
			var url = 'https://service.buchversand-stein.de/stShop/hanser/shop/goto.html?tx_zsctemparticles_pi1%5bart_no%5d='+isbnArray[i]+'&amp;tx_zsctemparticles_pi1%5buseDB%5d=1';
			$.ajax({
				type: 'POST',
				url: url,
				cache: false,
				async: false,
				success: function(data) {
					alert("ding");
				},
				complete: function(XMLHttpRequest, textStatus) {
					alert(XMLHttpRequest.status);
					alert(textStatus);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					alert(textStatus);
					alert(errorThrown);
				}
			});
		}
	}
}


