
			//Quick fix - remove the leading spaces from breadcrumbs
			/*$('#breadcrumb li a').each(function(){
				$(this).html(this.innerHTML.replace(/^\s/, ''));
			});*/
				
		 	//Polish on the word 'AND' - convert to & and colourise:
			/*$('#navigation li a, body.browse #outerwrap.category #breadcrumb li, #filters li a')
				.each(function(){
					var textCheck = $(this).text();
					console.log(textCheck);
					$(this).html(textCheck.replace(/\s(and)\s/gi, '<em class="highlight"> &amp; </em>'));
				});*/
		
		//Cufon'd headings in Helvetica light:
		//if (!$.browser.msie && $.browser.version != '6.0') {
			Cufon
				.set('fontFamily', 'HelveticaLight')
				.replace
					// ('body.browse #outerwrap.category #breadcrumb li')
					('#pagebody h1:not(.orderconf #pagebody h1)')
					('#pagebody h2:not(#pagebody h2.name, #pagebody h2.orderNum, #checkout_container h2, #signInForm h2, .guestReg h2)')
					('#pagebody h3.tabPanelTitle')
					('#pagebody div.imagedisplay h4')
					('div.detailsdisplay div.alternativeview h4')
					('body.rangeDetail #bodycontent h3')
					('body.emailfriend h1');
	//	}

	//Dorma actions for onDOMReady: 
	$(function(){		
	
		//Adjust the alternativeproducts panel to be full-screen width:
		//$('div.alternativeproduct', '#productdetailscontainer').appendTo('#wrapper');
		
		//Adjust the footer to be full-screen width
		$('#footer').appendTo('#wrapper');
		
		//Move the error messages into a nice spot
		var message = $('#content div.message');
		
		if (message.length) {
			
			message.hide();
			
			var messageTarget, insertPoint, insertMode;
			
			//Set up a cascade of elements to check for:
			
			if ($('#productdetailscontainer').length) { //PDP's
				messageTarget = $('#productdetailscontainer');
				insertPoint = '#productdetailscontainer';
				insertMode = 'prepend';
				if ($('#maincontent #Common_header_espot .espot').length) {
					$('#productdetailscontainer').parent().addClass("messSel");
				}
					
			}
			else if ($('#checkout_container').length) { //Basket tables
				messageTarget = $('#checkout_container');
				insertPoint = '#offer_code';
				insertMode = 'before';
			}
			else if ($('#basket_container').length) { //Basket tables
				messageTarget = $('#basket_container');
				insertPoint = '#offer_code';
				insertMode = 'before';
			}
			else if ($('#newUserRegistration').length) { //Registration forms
				messageTarget = $('#newUserRegistration');
				insertPoint = 'h1';
				insertMode = 'after';
			}
			else if ($('body.rangeDetail').length) { //Range details
				messageTarget = $('#maincontent');
				insertMode = 'prepend';
			}
		
			//Move the message and show it:
			if (messageTarget && messageTarget.length) {
					messageTarget.addClass('withMessage');
					
					switch (insertMode) {
						case 'insert':
						case 'after':
							message.insertAfter($(insertPoint), messageTarget);
						break;
						case 'before':
							message.insertBefore($(insertPoint), messageTarget);
						break;
						case 'prepend':
							message.prependTo(messageTarget);
						break;
					}
			} 
			
			message.filter(':has(*)').fadeIn(500);
		}
		
		//Show the basket with a 'full' icon if required:
		var basketQty = $('#NumItemsInCart').text();
		if (basketQty > 0) { 
				$('#basketStatus').addClass('full');
			}

		//Enhance the main product image with zoom 
		 if (typeof($().jqzoom) != 'undefined') {
			 $('a.pdlargerimage', 'body.productdetails')
			 .add('a.pdlargerimage', 'body.rangeDetail')
				 .jqzoom({
						zoomWidth:428,
						zoomHeight:362,
						xOffset:3,
						yOffset:0, //To account for the padding+border on the image frame
						title:false
				 })
				 .lightBox({
						overlayBgColor: '#F4F4F4',
						overlayOpacity: 0.5,
						imageLoading: '/wcsstore/ConsumerDirectStorefrontAssetStore/images/Master1_2/icon_lightBox_ticker.gif'
				 });
			}
			
			//Poopoo - I'm fixing things here that should be fixed in Java. 
			$('#resultsNavigation').each(function(){
				$(this).find('ol.pageControls')
					.find('li.previousPage a')
						.text('Previous Page')
					.end()
					.find('li.nextPage a')
						.text('Next Page')
					.end()
					.find('a')
						.css('display', 'block');
			});

			
			//hide the 'details' heading:
			$('#pagebody ol.tabbedPanels')
				 .find('li:first h3').hide();

			//Do some nice tabbing on the details panel:
			//Set the default tab
			$('#pagebody ol.tabs, #pagebody ol.tabbedPanels')
			.find('li:first').addClass('active');
			 
			$('#pagebody ol.tabs a').click(function(){
				$(this)
				.closest('li')
						.addClass('active')
						.siblings('li').removeClass('active')
				.closest('ol')
				.siblings('ol.tabbedPanels')
					.children('li.tab').removeClass('active')
					.filter('li.tab:eq(' + $('ol.tabs a').index(this) + ')').addClass('active');
				return false;
			});

			/* Kill some extra space on the breadcrumbs - appears after Cufon has run:
			Cufon.CSS.ready(function(){$('body.browse ul#breadcrumb > span').remove();}); */
			
			//Show the 'update quantity' button in the basket, only after a change has been made:
			 //This should be input[type=text] but the markup is poo
			$('#basket_display td.quantity input.input')
				.bind('change keydown',	function(){
					$(this).siblings('span.action')
						.find('a')
							.text('')
							.attr('title', 'Update your basket with this quantity')
						.show(200);
				});
			
		//Mostly for testing, but can be left in - replace any 'no image' placeholders in the masthead with a random pic:
		var mastheadSamples = ['sample_categoryImage_books.jpg', 'sample_categoryImage_fabricDetail.jpg', 'sample_categoryImage_madison.jpg', 'sample_categoryImage_floor.jpg', 'sample_categoryImage_hermione.jpg', 'sample_categoryImage_ribbon.jpg'];
		$('#maincontent .masthead img[src*=NoImage]').attr('src', '/ConsumerDirectStorefrontAssetStore/images/Master1_2/samples/' + mastheadSamples[Math.round(Math.random() * mastheadSamples.length)]);
		
		//product details page enhancement
		$('.priceHasWasPrice #priceelement').addClass('priceElementHasWasPrice'); /* Dorma only */


	   //product images lightbox functions
	   if($("a.tbProd").length) {
   			$("a.tbProd").lightBox({
					overlayBgColor: '#FFFFFF',
					overlayOpacity: 0.5,
					imageLoading: '/wcsstore/ConsumerDirectStorefrontAssetStore/images/Master1_2/icon_lightBox_ticker.gif',
					useNavigation: false
			 });
		}
	});
