/*******************************************************************************************
 * viewBasketLink
 * Written by Craig Francis
 * Allow the 'basket' item in the navigation bar to have a big hit area, with no visible link
 *******************************************************************************************/

	var viewBasketLink = new function() {

		//--------------------------------------------------
		// Old browsers

			if (!document.getElementById || !document.getElementsByTagName) {
				return;
			}

		//--------------------------------------------------
		// Initialisation

			this.init = function() {

				//--------------------------------------------------
				// Debug

					console.log('viewBasketLink.js: Initialisation');

				//--------------------------------------------------
				// Get a reference to the basketWrapper

					var basketWrapper = document.getElementById('pageBasket');
					if (!basketWrapper) {
						console.log('viewBasketLink.js: Could not return basketWrapper');
						return;
					}

					var basketLink = document.getElementById('basketLink');
					if (!basketLink) {
						console.log('viewBasketLink.js: Could not return basketLink');
						return;
					}

				//--------------------------------------------------
				// Link

					var links = basketLink.getElementsByTagName('a');
					if (links.length == 1) {
						var linkHref = links[0].href;
					} else {
						console.log('viewBasketLink.js: One link not found in basketLink');
						return;
					}

				//--------------------------------------------------
				// Add action

					addLinkEvent(basketWrapper, function() {
							window.location = linkHref;
						});

				//--------------------------------------------------
				// Debug

					console.log('viewBasketLink.js: Done');

			}

		//--------------------------------------------------
		// Set JS styles

			addCssRule('#basketLink { position: absolute; left: -5000px; }');

		//--------------------------------------------------
		// On page load

			addLoadEvent(function() {
				viewBasketLink.init();
			});

	}
