cookiename = 'shop';

function getBasket()
{
  basket = new Object();
  basket.sum = 0;
  basket.price = 0;
  basket.books = new Array();
  basket.amount = new Array();
  x = document.cookie.indexOf(cookiename + '=');
  if (document.cookie && x > -1)
  {
    c = document.cookie.substring(x + cookiename.length + 1).split('%2F');
    prices = {
			'9783000145148': 43.5,
			'9783981079821': 14,
			'9783981079814': 12,
			'9783981079807': 11,
			'9783981079838': 19.9,
			'9783981079852': 36.9,
			'9783981079869': 16.9,
			'9783981079883': 19.9,
			'9783981079890': 19.9,
			'9783981079845': 19.9
		}
    for (book in c) {
			book = c[book].split('%3A');
			if (book.length == 2) {
				amount = parseInt(book[1]);
				if (!isNaN(amount) && amount > 0 && prices[book[0]]) {
					basket.sum += amount;
					basket.price += prices[book[0]] * amount;
					basket.amount[book[0]] = amount;
				}
			}
		}
	}
  return basket;
}

basket = getBasket();
if (_GET['from'] ? (_GET['from'] == '2' || _GET['from'] == '3') : lang == 'de') {
  if (basket.sum) {
    document.write('<p>' + basket.sum.toString() + (basket.sum == 1 ? ' Buch' : ' B&uuml;cher') +' zu ' + basket.price.toFixed(2).replace(/\./, ',') + '&nbsp;&euro; im <a href="http://shop.kalliope-paperbacks.de/order.php?lang=de">Warenkorb</a>');
  }
  else {
    document.write('<p>Ihr Warenkorb ist leer.');
  }
  if (document.all) {
    if (!document.cookie) {
      document.write('<br><br></b>Um die Online-Bestellfunktion nutzen zu k&ouml;nnen, muss Ihr Browser Cookies akzeptieren.<b>');
    }
  }
  else if (!navigator.cookieEnabled) {
    document.write('<br><br></b>Um die Online-Bestellfunktion nutzen zu k&ouml;nnen, muss Ihr Browser Cookies akzeptieren.<b>');
  }
}
else
{
  if (basket.sum) {
    document.write('<p>' + basket.sum.toString() + ' book' + (basket.sum == 1 ? '' : 's') + ' for ' + basket.price.toFixed(2) + '&nbsp;&euro; in your <a href="http://shop.kalliope-paperbacks.de/order.php">basket</a>');
  }
  else {
    document.write('<p>Your basket is empty.');
  }
  if (document.all) {
    if (!document.cookie) {
      document.write('<br><br></b>For online ordering, cookies have to be enabled.<b>');
    }
  }
  else if (!navigator.cookieEnabled) {
    document.write('<br><br></b>For online ordering, cookies have to be enabled.<b>');
  }
}
document.write('</p>');

