window.addEvent("domready", function() {

	/* initialize the filmstrip */
	if ($("galleryFilmStrip"))
	{
		new Asset.javascript("/fileadmin/templates/main/scripts/filmstrip.js", {"onload": function() {
			new FilmStrip($("galleryFilmStrip"), $("galleryNext"), $("galleryPrevious"), $("navigationText"));
		}});
	}
	if ($$(".add-to-basket-button").length > 0)
	{
		$$(".add-to-basket-button").each(function(button) {
			button.addEvent("click", function(btn) {
				var form = button.getParent("form");
				var quantityInput = form.getFirst(".add-to-basket-quantity");
				if (parseInt(quantityInput.get("value"), 10) == 0)
				{
					quantityInput.set("value", 1);
				}
				form.submit();
			});
		});
	}
	
	if ($$(".product-quantity").length > 0)
	{
		$$(".product-quantity").each(function(input) {
			var button = new Element("div", {"class": "remove-product-button"});
			button.addEvent("click", function(event) {
				var button = $(event.target);
				var input = button.getParent().getFirst("input.product-quantity");
				input.set("value", 0);
				$("basketForm").submit();
			});
			button.inject(input, "after");
		});
	}

	/* check if we need to initialize the form */
	if ($$(".product-attribute").length > 0)
	{
		new Asset.javascript("/fileadmin/templates/main/scripts/productform.js", {onload: function() {
			new ProductForm($$(".product-attribute"));
		}});
	}


	// add show/hide functionality to the "I require/do not require delivery" radio buttons
	if ($("deliveryRequired"))
	{
		$("deliveryRequired").addEvent("change", function() {
			refreshDeliveryContainerDisplay();
		});
		$("deliveryNotRequired").addEvent("change", function() {
			refreshDeliveryContainerDisplay();
		});
		refreshDeliveryContainerDisplay();
	}

});

function refreshDeliveryContainerDisplay()
{
	if ($("deliveryRequired").checked)
	{
		// show the delivery area
		$("deliveryDetailsContainer").setStyle("display", "block");
	}
	else
	{
		// hide the delivery area
		$("deliveryDetailsContainer").setStyle("display", "none");
	}
}

var RecaptchaOptions = {
   theme : 'white'
};






