	var smallBagEffect;
	var blnSmallBag = false;
	function showSmallBag()
	{
		if (typeof(smallBagEffect) == 'object')
			smallBagEffect.cancel();

		if (blnSmallBag == false)
		{
			var bagHeight = $('smallBag').getHeight();
			$('smallBag').style.top = 170-bagHeight+"px";
			if($('scrollWrapper').style.zIndex==2)
				$('scrollWrapper').style.zIndex = -1;
			smallBagEffect = new Effect.Move($('smallBag'),{
				x:0,
				y:bagHeight,
				duration: 0.5,
				mode: 'relative',
				afterFinish: function() {
					blnSmallBag = true;
				}
			});
		}
	}

	function hideSmallBag()
	{
		if (typeof(smallBagEffect) == 'object')
			smallBagEffect.cancel();

		var bagHeight = $('smallBag').getHeight();
		
		smallBagEffect = new Effect.Move($('smallBag'),{
			x:0,
			y:-bagHeight,
			duration: 0.5,
			delay:0.5,
			mode: 'relative',
			afterFinish: function() {
				if($('scrollWrapper').style.zIndex == -1)
					$('scrollWrapper').style.zIndex = 2;
				blnSmallBag = false;
			}
		});
	}
	
	function stopSmallBag()
	{
		if (typeof(smallBagEffect) == 'object')
			smallBagEffect.cancel();
	}

	var bigBagEffect;
	var blnShowBigBag = false;
	function showBigBag()
	{
		blnShowBigBag = true;
		blnSmallBag = false;
		if (typeof(bigBagEffect) == 'object')
			bigBagEffect.cancel();

		$('bigbag').style.top = -556+"px";
		if($('scrollWrapper').style.zIndex==2)
			$('scrollWrapper').style.zIndex = -1;
		bigBagEffect = new Effect.Parallel([
			new Effect.Move($('bigbag'),{sync: true, x:0,y:623, mode: 'relative'}),
			new Effect.Fade($('scrollWrapper'),{sync: true, from:1, to:0})
		], { 
		  duration: 1.2,
			afterFinish: function() {$('overviewWrapper').style.overflowY = 'auto';}
		});
	}

	function hideBigBag()
	{
		if (itemRemoved)
		{
			window.location.reload();
		}
		else
		{
			blnShowBigBag = false;
			if (typeof(bigBagEffect) == 'object')
				bigBagEffect.cancel();
			
			$('overviewWrapper').style.overflowY = 'hidden';
			var bagHeight = $('smallBag').getHeight();
			$('smallBag').style.top = 170-bagHeight+"px";
			
			bigBagEffect = new Effect.Parallel([
				new Effect.Move($('bigbag'),{sync: true, x:0,y:-623, mode: 'relative'}),
				new Effect.Appear($('scrollWrapper'),{sync: true, from:0, to:1})
			], { 
			  duration: 0.8,
			  afterFinish: function() {
				if($('scrollWrapper').style.zIndex == -1)
					$('scrollWrapper').style.zIndex = 2;
				}
			});
		}
	}

	function bagMouseOver(obj)
	{
		if (!blnShowBigBag)
		{
			obj.id = 'over';
			showSmallBag();
		}
	}

	function bagMouseOut(obj)
	{
		if (blnShowBigBag)
		{
			obj.id = '';
		}
		else
		{
			obj.id = '';
			hideSmallBag();
		}
	}
				
	var countriesVisible = false;
	var effect;

	function showCountries(obj)
	{
		if (!countriesVisible)
		{
			obj.up().addClassName('open');
			effect = new Effect.Appear(obj, {duration:0.5, from:0, to:1});
			countriesVisible = true;
		}
	}
			
	function selectCountry(country, countrycode)
	{
		new Ajax.Request('/ajax/setcountry.asp',
		{
			method:'post',
			parameters: {countrycode: countrycode},
			onSuccess: function(transport)
			{
				var response = transport.responseText;
				var data = response.evalJSON();
				$('delivery').innerHTML = data.verzendkosten;
				$('total').innerHTML = data.totaal;
				$('messagevrij').innerHTML = data.message;
				$('countrybox').innerHTML = country;
				$('countries').style.display = "none";
				$('countries').parentNode.removeClassName('open');
				if ($('checkout'))
					$('checkout').removeClassName('disabled');
				countriesVisible = false;
				//alleen bij betaalwijze
				if($('deliverto'))
				{
					$('aflcountry').value = country;
					if(data.samecountry)
					{
						$('same').disabled=false;
						$('showmessage').addClassName('hide');
					}
					else
					{
						$('same').disabled=true;
						$('other').checked=true;
						deliverto('other');
						$('showmessage').removeClassName('hide');
					}
				}
			}
		});
	}
	
	function selectCustomerCountry(country, countrycode)
	{
		$('countrybox2').innerHTML = country;
		$('country').value = country;
		$('countrycode').value = countrycode;
		$('countries2').style.display = "none";
		$('countries2').parentNode.removeClassName('open');
		countriesVisible = false;
	}

	var itemRemoved = false;
	function removeItem(product, size, nummer)
	{
		itemRemoved = true;
		new Ajax.Request('/ajax/removeitem.asp',
		{
			method:'post',
			parameters: {
				product: product,
				size: size
			},
			onSuccess: function(transport)
			{
				var response = transport.responseText;
				var data = response.evalJSON();

				if (data.subtotaal==0)
					$('overview').innerHTML = "<span>There're no items in the bag</span>"
				else
				{
					$('subtotal').innerHTML = data.subtotaal;
					$('total').innerHTML = data.totaal;
					if ($('discount'))
						$('discount').innerHTML = data.discount;
					$('delivery').innerHTML = data.verzendkosten;
					$('item'+nummer).remove();
				}
			}
		});
	}

	function checkout(obj)
	{
		if (!obj.hasClassName('disabled'))
			document.location.href = '/bestellen/gegevens.asp'
	}
	
	function deliverto(address)
	{
		if	(address == 'same')
		{
			$('deliveryAddress').addClassName('hide');
			$('afleveren').value = 0;
		}
		else
		{
			$('deliveryAddress').removeClassName('hide');
			$('afleveren').value = 1;
		}
	}
