/*----------------------------------------------------------------------------------------------------------------------------------------*/
/*    Author       : Matt lowe (mattlowe81@hotmail.com)                                                                                   */
/*    Description  : Interface templates                                                                                                  */
/*    Version      : 1                                                                                                                    */
/*    Dependencies : jquery-1.5.1.min.js                                                                                                  */
/*                   jquery.easing-1.3.min.js                                                                                             */
/*                   jquery.mousewheel-3.0.4.min.js                                                                                       */
/*                   jquery.fancybox-1.3.2.min.js                                                                                         */
/*----------------------------------------------------------------------------------------------------------------------------------------*/

/*contents
	1.)  accordions()
	2.)  ajaxSignupForm
	3.)  backgroundCarousels()
	4.)  carouselNewsItems
	5.)  collectionCarouselMetaItems
	6.)  externalLinks()
	7.)  fancyboxes()
	8.)  footers()
	9.)  formValidations()
	10.) frameImgAspectRatio()
	11.) getNaturalLanguage()
	12.) ie6FocusReplication()
	13.) internalLinks()
	14.) carouselTabNavigationCarousels
	15.) scaleCollectionCarouselListItems
	16.) scaleFullScreenCarousels
	17.) setWaiAria
	18.) stores
	19.) tabComponents
	20.) tooltips
	21.) touceDeviceHoverReplication
*       22.) setCollectionsMenu()

*/

/*
global 
	alert            : true,
	console          : true,
	document         : true,
	google           : true,
	GSmallMapControl : true,
	GMapTypeControl  : true,
	GLatLng          : true,
	GMarker          : true,
	jQuery           : true,
	navigator        : true,
	window           : true
*/

var $j = jQuery.noConflict();
window.width = $j(window).width();
window.querystring = location.search.replace( '?', '' ).split( '&' );
window.queryObj = {};
for(var i=0; i<window.querystring.length; i++ )
{
	var name  = window.querystring[i].split('=')[0];
	var value = window.querystring[i].split('=')[1];
	window.queryObj[name] = value;
}

var Wednesday = 
{
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	accordions:function()
	{
		//OBJECT DECLARATION
		function Accordion(el)
		{
			//PROPERTIES
			this.__ACCORDION        = el;
			this.__TOGGLER_ELEMENTS = el.find('.toggler');
			this.createTogglerLinks();
			this.__TOGGLER_LINKS    = el.find('a.toggler-link');
			this.__COLLAPSERS       = el.find('.element');

			return this.init();
		}

		//OBJECT METHODS
		Accordion.prototype =
		{
			init:function()
			{
				this.hideElements();
				this.bindClickEvents();
			},

			bindClickEvents:function()
			{
				var that = this;
				this.__TOGGLER_LINKS.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						$j(this).parent().siblings('li').find('.element').hide();
						$j(this).next().toggle();
						that.maintainState();
					}
				);
			},

			createTogglerLinks:function()
			{
				this.__TOGGLER_ELEMENTS.each
				(
					function(el)
					{
						$j(this).wrap('<a class="toggler-link" href="#"></a>');
					}
				)
			},

			hideElements:function()
			{
				this.__COLLAPSERS.hide();
			},

			maintainState:function()
			{
				var testQuery = this.__ACCORDION.find('ul:visible');
				if(testQuery.length===0)
				{
					this.__ACCORDION.addClass('all-closed');
				}
				else
				{
					this.__ACCORDION.removeClass('all-closed');
				}
			}
		}

		//OBJECT INSTANTIATION
		$j('.accordion').each
		(
			function()
			{
				var obj = new Accordion($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	ajaxSignupForm:function()
	{
		$j('#signup-form').submit
		(
			function(event)
			{
				event.preventDefault(); 
				var form = $j(this),
				url = form.attr('action'),
				fields = form.serializeArray(),
				values = {};

				for(i in fields)
				{
					values[fields[i].name] = fields[i].value
				}

				$j.post
				(
					url,
					values,
					function(data)
					{
						var content = $j(data).find('#newsletterThanksMsg');
						if(!content.length)
						{
							content = $j(data).find('.regCnt');
						}

						if(!content.length)
						{
							content = 'An error occurred, please try again later.';
						}
                                                
						var message = content.html(); 
						form.find('.errors').empty().append('<li>' + message + '</li>');
					}
				);
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	backgroundCarousels:function()
	{
		//OBJECT DECLARATION
		function BackgroundCarousel(el)
		{
			//PROPERTIES
			this.__CAROUSEL             = el;
			this.__TRANSITION_DURATION  = parseInt(this.__CAROUSEL.attr('data-transition-duration'))*1000;
			this.__TRANSITION_DELAY     = parseInt(this.__CAROUSEL.attr('data-transition-delay'))*1000;
			this.__BACKGROUND_COUNT     = parseInt(this.__CAROUSEL.attr('data-background-count'));
			this.__BACKGROUND__IMG_PATH = this.__CAROUSEL.attr('data-background-path');
			this.__count                = 1;
			this.createDivs();
			this.__BACKGROUND_DIVS      = this.__CAROUSEL.find('div.background');

			return this.init();
		}

		//OBJECT METHODS
		BackgroundCarousel.prototype =
		{
			init:function()
			{
				this.hideDivs();
				this.resetDivs();
				this.play();
			},

			createDivs:function()
			{
				var i;
				for(i=0; i<this.__BACKGROUND_COUNT; i++)
				{
					this.__CAROUSEL.append($j('<div class="background background-' + i + '" style="background-image:url(' +  this.__BACKGROUND__IMG_PATH + i + '.jpg)"></div>'));
				}
			},

			hideDivs:function()
			{
				this.__BACKGROUND_DIVS.hide();
			},

			resetDivs:function()
			{
				this.__BACKGROUND_DIVS.eq(0).addClass('current').show();
			},

			maintainCount:function()
			{
				if(this.__count === this.__BACKGROUND_COUNT)
				{
					this.__count=0;
				}
			},

			play:function()
			{
				var that = this;
				animation = $j('body').animate
				(
					{
						opacity: '1'
					},
					that.__TRANSITION_DELAY,
					function()
					{
						that.__BACKGROUND_DIVS.eq(that.__count).addClass('top');
						that.__BACKGROUND_DIVS.eq(that.__count).fadeIn
						(
							that.__TRANSITION_DURATION,
							function()
							{
								$j('div.current').removeClass('current').hide();
								that.__BACKGROUND_DIVS.eq(that.__count).removeClass('top').addClass('current');
								that.__count++;
								that.maintainCount();
								that.play();
							}
						);
					}
				);
			}
		}

		//OBJECT INSTANTIATION
		$j('.background-carousel').each
		(
			function()
			{
				var obj = new BackgroundCarousel($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	carouselNewsItems:function()
	{
		//OBJECT DEFINITION
		function NewsItem(el)
		{
			//PROPERTIES
			this.__NEWS_ITEM         = el;
			this.__NEWS_ITEM_SUMMARY = this.__NEWS_ITEM.find('div.entry-summary');
			this.__NEWS_ITEM_CONTENT = this.__NEWS_ITEM.find('div.entry-content div.box');
			this.__OPEN_LINK         = $j('<a class="open"  href="#" title="'+ window.languageJSON.__LINK_TEXT.__OPEN.title +'">'+ window.languageJSON.__LINK_TEXT.__OPEN.text +'</a>');
			this.__CLOSE_LINK        = $j('<a class="close" href="#" title="'+ window.languageJSON.__LINK_TEXT.__CLOSE.title +'">'+ window.languageJSON.__LINK_TEXT.__CLOSE.text +'</a>');
			this.__OPEN_DURATION	 = 500;
			this.__CLOSE_DURATION	 = 250;

			return this.init();
		}

		//OBJECT METHODS
		NewsItem.prototype =
		{
			init:function()
			{
			    if(this.__NEWS_ITEM_CONTENT.length)
			    {
				this.prepare();
				this.attachClickEvents();
			    }
			},

			prepare:function()
			{
				this.__NEWS_ITEM_CONTENT.parent().addClass('invisible');
				this.__NEWS_ITEM_SUMMARY.append(this.__OPEN_LINK);
				this.__NEWS_ITEM_CONTENT.append(this.__CLOSE_LINK);
			},

			attachClickEvents:function()
			{
				var that = this;
				this.__OPEN_LINK.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						that.__NEWS_ITEM_CONTENT.parent().removeClass('invisible').addClass('visible');
					}
				)

				this.__CLOSE_LINK.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						that.__NEWS_ITEM_CONTENT.parent().removeClass('visible').addClass('invisible');
					}
				)
			}
		}

		//OBJECT INSTANTIATION
		$j('div.news li.hentry').each
		(
			function()
			{
				var obj = new NewsItem($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	collectionCarouselMetaItems:function()
	{
		//OBJECT DECLARATION
		function MetaItem(el)
		{
			//PROPERTIES
			this.__META_SCALE           = el;
			this.__META_SCALE_CONTAINER = this.__META_SCALE.parent().parent();
			this.attachResizeEvent();

			return this.init();
		}

		//OBJECT METHODS
		MetaItem.prototype =
		{
			init:function()
			{
				this.setMetaScaleWidth();
			},

			setMetaScaleWidth:function()
			{
				var currentWidth = this.__META_SCALE_CONTAINER.width();
				if(currentWidth > window.width)
				{
					this.__META_SCALE.css('width', window.width);
				}
				else
				{
					this.__META_SCALE.css('width', '100%');
				}
			},

			attachResizeEvent:function()
			{
				var that = this;
				$j(window).bind
				(
					'resize',
					function()
					{
						that.init();
					}
				);
			}
		}

		//OBJECT INSTANTIATION
		$j('div.meta-wrapper div.meta-scale').each
		(
			function()
			{
				var obj = new MetaItem($j(this));
				obj = null;
			}
		);

		function productsList(el)
		{
			//PROPERTIES
			this.__PRODUCTS_CONTAINER              = el;
			this.__PRODUCTS_CONTAINER_WIDTH        = this.__PRODUCTS_CONTAINER.width();
			this.__PRODUCTS_CONTAINER_HEIGHT       = this.__PRODUCTS_CONTAINER.height();
			this.__PRODUCTS_CONTAINER_TITLE        = this.__PRODUCTS_CONTAINER.children('h3');
			this.__PRODUCTS_CONTAINER_TITLE_HEIGHT = this.__PRODUCTS_CONTAINER_TITLE.height();
			this.__PRODUCTS_CONTAINER_TABLE        = this.__PRODUCTS_CONTAINER.children('table');
			this.__PRODUCTS_CONTAINER_TABLE_WIDTH  = this.__PRODUCTS_CONTAINER_TABLE.width();

			if(this.__PRODUCTS_CONTAINER_TABLE_WIDTH < 100)
			{
				this.__PRODUCTS_CONTAINER_TABLE_WIDTH = 100;
			}

			this.__PRODUCTS_CONTAINER.children('h3:not(:has(a))').append('<a class="icon replaced down-arrow" href="#">View more</a>');

			return this.init();
		}

		//OBJECT METHODS
		productsList.prototype =
		{
			init:function()
			{
				this.prepare();
				this.attachClickEvents();
			},

			prepare:function()
			{
				this.setInfoPanelDisplayStatus('close', 50);
			},

			attachClickEvents:function()
			{
				var that = this;

				this.__PRODUCTS_CONTAINER_TITLE.toggle
				(
					function()
					{
						if(!(that.__PRODUCTS_CONTAINER.is(":animated")) && !(that.__PRODUCTS_CONTAINER_TABLE.is(":animated")))
						{
							that.setInfoPanelDisplayStatus('open', 500);
						}
					},
					function()
					{
						if(!(that.__PRODUCTS_CONTAINER.is(":animated")) && !(that.__PRODUCTS_CONTAINER_TABLE.is(":animated")))
						{
							that.setInfoPanelDisplayStatus('close', 500);
						}
					}
				);
			},

			setInfoPanelDisplayStatus:function(status, speed)
			{
				var that = this;
				switch(status)
				{
					case 'open':
						that.__PRODUCTS_CONTAINER.stop(true, true).animate
						(
							{
								width: that.__PRODUCTS_CONTAINER_WIDTH,
								height: that.__PRODUCTS_CONTAINER_HEIGHT
							},
							500,
							function()
							{
								that.__PRODUCTS_CONTAINER_TABLE.css('display', 'table');
								that.__PRODUCTS_CONTAINER_TABLE.stop(true, true)
								.animate
								(
									{
										opacity: 1
									},
									speed,
									function()
									{
										that.__PRODUCTS_CONTAINER_TABLE.show(0);
									}
								)
							}
						);
					break;
					case 'close':
						that.__PRODUCTS_CONTAINER_TABLE.stop(true, true).animate
						(
							{
								opacity: 0
							},
							500,
							function()
							{
								that.__PRODUCTS_CONTAINER_TABLE.hide(0);
								that.__PRODUCTS_CONTAINER.stop(true, true)
								.animate
								(
									{
										width: that.__PRODUCTS_CONTAINER_TABLE_WIDTH,
										height: that.__PRODUCTS_CONTAINER_TITLE_HEIGHT
									},
									speed
								);
							}
						);
					break;
				}
			}
		}

		function showShopTheLookItems()
		{
			$j('div.shop-the-look').each
			(
				function()
				{
					var obj = new productsList($j(this));
					obj = null;
				}
			);
		}
		showShopTheLookItems();
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	externalLinks:function()
	{
		//OBJECT DECLARATION
		function ExternalLinksObject(el)
		{
			//PROPERTIES
			this.__LINKS    = el;

			this.__LINKS.bind
			(
				'click',
				function(e)
				{
					e.preventDefault();
					window.open(this);
				}
			);
		}

		//OBJECT INSTANTIATION
		var obj = new ExternalLinksObject($j('a[rel="ext"]'));
		obj = null;
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	fancyboxes:function()
	{
		$j("a.fancybox").fancybox
		(
			{
				"centerOnScroll"	: false,
				'padding'		: '0',
				'opacity'		: true,
				'overlayShow'		: true,
				'overlayColor'		: '#000',
				'overlayOpacity'	: '0.7',
				'titleShow'		: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'onComplete':function(e)
				{
					Wednesday.formValidations();
				}
			}
		);

		$j("a.signup").fancybox
		(
			{
				"centerOnScroll"	: false,
				'padding'		: '0',
				'overlayColor'		: '#000',
				'overlayOpacity'	: '0.3',
				'onStart':function(e)
				{
					$j('html').addClass('pinned-lightbox');
				},
				'onClosed':function(e)
				{
					$j('html').removeClass('pinned-lightbox');
				},
				'onComplete':function(e)
				{
					Wednesday.formValidations();
					Wednesday.ajaxSignupForm();
				}
			}
		);
		
		$j("a.search").fancybox
		(
			{
				"centerOnScroll"	: false,
				'padding'		: '0',
				'overlayColor'		: '#000',
				'overlayOpacity'	: '0.3',
				'onStart':function(e)
				{
					$j('html').addClass('search-lightbox pinned-lightbox');
				},
				'onClosed':function(e)
				{
					$j('html').removeClass('search-lightbox pinned-lightbox');
				},
				'onComplete':function(e)
				{
					Wednesday.formValidations();
					Wednesday.ajaxSignupForm();
				}
			}
		);

		$j("a.fancybox.fancybox-title-inside").fancybox
		(
			{
				'titlePosition'		: 'inside',
				'transitionIn' 		: 'elastic',
				'transitionOut'		: 'elastic'
			}
		);

		$j("a.fancybox.fancybox-title-outside").fancybox
		(
			{
				'titlePosition'		: 'outside',
				'transitionIn' 		: 'elastic',
				'transitionOut'		: 'elastic'
			}
		);

		$j("a.fancybox.fancybox-title-over").fancybox
		(
			{
				'titlePosition'		: 'over',
				'transitionIn' 		: 'elastic',
				'transitionOut'		: 'elastic'
			}
		);

		$j("a.fancybox.fancybox-iframe-content").fancybox
		(
			{
				'autoScale'    		: false,
				'height'       		: '75%',
				'titlePosition'		: 'over',
				'transitionIn' 		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'         		: 'iframe',
				'width'	       		: '75%'
			}
		);

		$j("a.fancybox[rel=fancybox-group]").fancybox
		(
			{
				'titlePosition'		: 'over',
				'transitionIn' 		: 'elastic',
				'transitionOut'		: 'elastic',
				'titleFormat'  		: function(title, currentArray, currentIndex, currentOpts){return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';}
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	footers:function()
	{
		//OBJECT DECLARATION
		function Footer(el)
		{
			//PROPERTIES
			this.__FOOTER             = el;
			this.__FOOTER_INNER       = this.__FOOTER.find('div#footer-inner');
			this.__FOOTER_SWITCH      = $j('<p id="footer-switch" class="clearfix"></p>');
			this.__FOOTER_SWITCH_LINK = $j('<a href="#"><span>' + window.languageJSON.__FOOTER_TEXT.__FOOTER_SWITCH_TEXT.text + '</span></a>');
			this.__SLIDE_DURATION     = 150;

			return this.init();
		}

		//OBJECT METHODS
		Footer.prototype =
		{
			init:function()
			{
				this.prepare();
				this.attachClickEvents();
			},

			prepare:function()
			{
				this.__FOOTER_SWITCH_LINK.appendTo(this.__FOOTER_SWITCH);
				this.__FOOTER.prepend(this.__FOOTER_SWITCH);
				this.__FOOTER_INNER.css('height', this.__FOOTER_INNER.height());
				this.__FOOTER_INNER.hide();
			},

			attachClickEvents:function()
			{
				var that = this;
				this.__FOOTER_SWITCH_LINK.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						that.__FOOTER_INNER.slideToggle(that.__SLIDE_DURATION);
					}
				);
			}
		}

		//OBJECT INSTANTIATION
		$j('div#footer').each
		(
			function()
			{
				var obj = new Footer($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	formValidations:function()
	{
		//OBJECT DECLARATION
		function FormValidation(el)
		{
			//PROPERTIES
			this.form        = el;
			this.errorsList  = $j('<ul class="list-unsigned errors"></ul>');
			this.inputs      = this.form.find('div.input:not(.submit)');
			this.submit      = this.form.find('div.submit input:not(.inactive)');
			this.formError   = false;

			this.form.prepend(this.errorsList);

			//VARS
			var onBlurHandler, that = this;

			this.errorsList.attr
			(
				{
					'aaa:atomic' :"true",
					'aaa:live'   :"polite"
				}
			);

			this.inputs.attr
			(
				{
					'aaa:atomic' :"true",
					'aaa:live'   :"polite"
				}
			);

			onBlurHandler = function(e)
			{
				//VARS
				var targetInput, tag, elementContainer, elementAnchor, shortMessage, longMessage, emailAddress, numeric, hasError, inputError=false, shortErrorString="", longErrorString="", validationTests, $jthis;

				targetInput = e.target;
				tag = targetInput.tagName.toUpperCase();
				if(!(tag === "SELECT" || tag === "INPUT" || tag === "TEXTAREA"))
				{
					e.stopPropagation();
					return;
				}

				$jthis = $j(targetInput);
				elementContainer = targetInput.parentNode;
				elementAnchor    = $j(elementContainer).find('.named-anchor').attr('id');
				($j(elementContainer).attr('data-validation')) ? validationTests = $j(elementContainer).attr('data-validation') : validationTests = "";

				if (validationTests==="")
				{
					return;
				}

				if(validationTests.match(/mandatory/))
				{
					shortMessage = window.languageJSON.__ERROR_MESSAGES.__MANDATORY.short_description;
					longMessage  = window.languageJSON.__ERROR_MESSAGES.__MANDATORY.long_description;
					hasError     = !$jthis.val();
					that.setFormError(hasError);
					if(hasError===true)
					{
						inputError=true;
						shortErrorString += " " + shortMessage;
						longErrorString  += " " + longMessage;
					}
				}

				if (validationTests.match(/maximumFourtyCharacters/))
				{
					shortMessage = window.languageJSON.__ERROR_MESSAGES.__MAXIMUM_FOURTY_CHARACTERS.short_description;
					longMessage  = window.languageJSON.__ERROR_MESSAGES.__MAXIMUM_FOURTY_CHARACTERS.long_description;
					hasError     = that.hasValue(targetInput) && (targetInput.value.length > 40);
					that.setFormError(hasError);
					if(hasError===true)
					{
						inputError=true;
						shortErrorString += " " + shortMessage;
						longErrorString  += " " + longMessage;
					}
				}

				if (validationTests.match(/email/))
				{
					shortMessage = window.languageJSON.__ERROR_MESSAGES.__EMAIL.short_description;
					longMessage  = window.languageJSON.__ERROR_MESSAGES.__EMAIL.long_description;
					emailAddress =/^([a-zA-Z0-9_.\-])+@([a-zA-Z0-9_.\-])+\.([a-zA-Z])+([a-zA-Z])+/;
					hasError     = that.hasValue(targetInput) && !emailAddress.test(targetInput.value);
					that.setFormError(hasError);
					if(hasError===true)
					{
						inputError=true;
						shortErrorString += " " + shortMessage;
						longErrorString  += " " + longMessage;
					}
				}

				if (validationTests.match(/numeric/))
				{
					shortMessage = window.languageJSON.__ERROR_MESSAGES.__NUMERIC.short_description;
					longMessage  = window.languageJSON.__ERROR_MESSAGES.__NUMERIC.long_description;
					numeric      =/^[0-9]+[0-9]*$j/;
					hasError     = that.hasValue(targetInput) && !numeric.test(targetInput.value);
					that.setFormError(hasError);
					if(hasError===true)
					{
						inputError=true;
						shortErrorString += " " + shortMessage;
						longErrorString  += " " + longMessage;
					}
				}

				//ERROR MESSAGING
				if(inputError===true)
				{
					that.errorsList.find('#warning-' + elementAnchor).remove();
					$j(elementContainer).removeClass('valid').addClass('invalid');
					$j('<li id="warning-' + elementAnchor +'">' + '<strong><a href="#' + elementAnchor + '" rel="internal">' + $j(elementContainer).find("label").attr("for", targetInput.id).html() + '</a></strong> ' + longErrorString + '</li>').appendTo('ul.errors');
					$j(elementContainer).find('p.notification').remove();
					$j('<p class="notification invalid"><span>' +  shortErrorString + '</span></p>').appendTo( $j(elementContainer));
					Wednesday.internalLinks();
				}
				else
				{
					$j(elementContainer).removeClass('invalid').addClass('valid');
					that.errorsList.find('#warning-' + elementAnchor).remove();
					$j(elementContainer).find('p.notification').remove();
					$j('<p class="notification valid"><span>Valid</span></p>').appendTo( $j(elementContainer));
				}
			};

			this.form.bind
			(
				'focusout',
				onBlurHandler
			);
			this.submit.bind
			(
				'click',
				function(e)
				{
					that.formError=false;
					that.form.find("select, input, textarea").trigger('focusout');

					if(that.formError===true)
					{
						e.preventDefault();
					}
				}
			);
		}

		//OBJECT METHODS
		FormValidation.prototype =
		{
			hasValue:function(input)
			{
				if($j(input).val().length>0)
				{
					return true;
				}
				else
				{
					return false;
				}
			},
			setFormError:function(error)
			{
				if(error===true)
				{
					this.formError = true;
				}
			}
		};

		//OBJECT INSTANTIATION
		$j('.validate').each
		(
			function()
			{
				var obj = new FormValidation($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	frameImgAspectRatio:function()
	{
		//OBJECT DECLARATION
		function Frame(el)
		{
			this.__FRAME     = el;
			this.__FRAME_IMG = this.__FRAME.find('img.scale, div.scale');
			this.attachResizeEvent();

			return this.init();
		}

		//OBJECT METHODS
		Frame.prototype =
		{
			init:function()
			{
				this.scaleImg();
				this.measureImg();
			},

			measureImg:function()
			{
				if(this.__FRAME_IMG.height() >= this.__FRAME.height())
				{
					this.__FRAME_IMG.removeClass('scale-width').addClass('scale-height');
					this.scaleImg();
				}
				if(this.__FRAME_IMG.width() >= this.__FRAME.width())
				{
					this.__FRAME_IMG.removeClass('scale-height').addClass('scale-width');
					this.scaleImg();
				}
			},

			scaleImg:function()
			{
				if(this.__FRAME_IMG.hasClass('scale-height'))
				{
					this.__FRAME_IMG.css('width', 'auto');
					this.__FRAME_IMG.css('height', this.__FRAME.height());
				}

				if(this.__FRAME_IMG.hasClass('scale-width'))
				{
					this.__FRAME_IMG.css('height', 'auto');
					this.__FRAME_IMG.css('width', this.__FRAME.width());
				}
			},

			attachResizeEvent:function()
			{
				var that = this;
				$j(window).bind
				(
					'resize',
					function()
					{
						that.init();
					}
				);
			}
		}

		//OBJECT INSTANTIATION
		$j('div.frame').each
		(
			function()
			{
				var obj = new Frame($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	getNaturalLanguage:function()
	{
		$j.getJSON
		(
			window.jsonPath,
			function(data)
			{
				window.languageJSON = data;
				Wednesday.init();
			}
		);



	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	ie6FocusReplication:function()
	{
		$j('body.ie6 a').focus
		(
			function()
			{
				$j(this).addClass('focus');
			}
		)
		.blur
		(
			function()
			{
				$j(this).removeClass('focus');
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	internalLinks:function()
	{
		//OBJECT DECLARATION
		function InternalLinksObject(el)
		{
			//PROPERTIES
			this.__LINKS    = el;
			this.__DURATION = 500;
			this.__EASING   = 'swing';

			//VARS
			var newHash, target, newLocation, that = this;

			this.__LINKS.bind
			(
				'click',
				function(e)
				{
					e.preventDefault();
					newHash=this.hash;
					target=$j(newHash).offset().top;
					newLocation=this;
					$j('html:not(:animated),body:not(:animated)').animate
					(
						{scrollTop: target},
						that.__DURATION,
						that.__EASING,
						function()
						{
							window.location.href=newLocation;
						}
					);
				}
			);
		}

		//OBJECT INSTANTIATION
		var obj = new InternalLinksObject($j('a[rel="internal"]').not('.tabs a'));
		obj = null;
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	carouselTabNavigationCarousels:function()
	{
		function TabNavigationCarousel(el)
		{
			//PROPERTIES
			this.__TAB                    = el;
			this.__TAB_NAVIGATION         = this.__TAB.find('.tab-navigation');
			this.__TAB_NAVIGATION_ITEMS   = this.__TAB_NAVIGATION.find('li');
			this.__TAB_NAVIGATION_WRAPPER = $j('<div class="tab-navigation-wrapper"><div class="tab-navigation-wrapper-inner"></div></div>')
			this.__NEXT_LINK              = $j('<a class="replaced next" href="#" rel="next">Next</a>');
			this.__PREV_LINK              = $j('<a class="replaced prev" href="#" rel="prev">Prev</a>');
			this.__SLIDE_DURATION         = 1000;
			this.__wrapperWidth           = null;
			this.__carouselWidth          = null;
			this.__endThreshold           = null;
			this.__endReset               = null;
			this.__startThreshold         = 0;
			this.__startReset             = 0;
			this.__scrollTarget           = null;
			this.__currentTarget          = null;

			return this.init();
		}

		TabNavigationCarousel.prototype =
		{
			init:function()
			{
				this.prepare();
				if(!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)))
				{
					this.attachHoverEvents();
				}
				this.attachClickEvents();
				this.attachResizeEvent();
			},

			prepare:function()
			{
				this.setScalableProperties();
				this.__TAB_NAVIGATION.wrap(this.__TAB_NAVIGATION_WRAPPER);
				this.__NEXT_LINK.insertBefore(this.__TAB_NAVIGATION);
				this.__PREV_LINK.insertBefore(this.__TAB_NAVIGATION);
				this.__TAB_NAVIGATION_WRAPPER= this.__TAB.find('.tab-navigation-wrapper');
				this.setCarouselWidth();
				this.maintainLinks();
			},

			attachHoverEvents:function()
			{
				var that = this;
				this.__TAB.bind
				(
					'mouseenter',
					function()
					{
						that.__TAB_NAVIGATION_WRAPPER.removeClass('screen-offset');
					}
				)
				.bind
				(
					'mouseleave',
					function()
					{
						that.__TAB_NAVIGATION_WRAPPER.addClass('screen-offset');
					}
				)
			},

			attachClickEvents:function()
			{
				var that = this;
				this.__NEXT_LINK.bind
				(
					"click",
					function(e)
					{
						e.preventDefault();
						if(!(that.__TAB_NAVIGATION.is(":animated")))
						{
							that.__TAB_NAVIGATION .animate
							(
								{
									left: that.getScroll("next")
								},
								that.__SLIDE_DURATION,
								'easeOutExpo',
								function()
								{
									that.maintainLinks();
								}
							);
						}
					}
				);

				this.__PREV_LINK.bind
				(
					"click",
					function(e)
					{
						e.preventDefault();
						if(!(that.__TAB_NAVIGATION.is(":animated")))
						{
							that.__TAB_NAVIGATION .animate
							(
								{
									left: that.getScroll("prev")
								},
								that.__SLIDE_DURATION,
								'easeOutExpo',
								function()
								{
									that.maintainLinks();
								}
							);
						}
					}
				);
			},

			attachResizeEvent:function()
			{
				var that = this;
				$j(window).bind
				(
					'resize',
					function()
					{
						that.setScalableProperties();
						that.maintainLinks();
					}
				);
			},

			setScalableProperties:function()
			{

				this.__wrapperWidth          = this.__TAB.outerWidth();
				this.__carouselWidth         = this.getCarouselWidth();
				this.__endThreshold          = -(this.__carouselWidth);
				this.__endReset              = -(this.__carouselWidth - this.__wrapperWidth);
				this.setCarouselWidth();
			},

			getScroll:function(direction)
			{
				this.__currentScroll = parseInt(this.__TAB_NAVIGATION.css('left'));
				if(direction==="next")
				{
					this.__scrollTarget = this.__currentScroll - this.__wrapperWidth;

					if((this.__scrollTarget-this.__wrapperWidth) < this.__endThreshold)
					{
						this.__scrollTarget = this.__endReset;
					}
				}
				if(direction==="prev")
				{
					this.__scrollTarget = this.__currentScroll + this.__wrapperWidth;
					if((this.__scrollTarget+this.__wrapperWidth) > this.__startThreshold)
					{
						this.__scrollTarget = this.__startReset;
					}
				}
				return this.__scrollTarget;
			},

			maintainLinks:function()
			{
				this.__currentScroll = parseInt(this.__TAB_NAVIGATION.css('left'));

				if(this.__currentScroll===this.__startReset)
				{
					this.__PREV_LINK.hide();
				}
				else
				{
					this.__PREV_LINK.show();
				}

				if(this.__currentScroll<=this.__endReset)
				{
					this.__NEXT_LINK.hide();
				}
				else
				{
					this.__NEXT_LINK.show();
				}
			},

			getCarouselWidth:function()
			{
				var width=0;
				this.__TAB_NAVIGATION_ITEMS.each
				(
					function()
					{
						width += $j(this).outerWidth();
					}
				)
				return width;
			},

			setCarouselWidth:function()
			{
				this.__TAB_NAVIGATION.css('width', this.getCarouselWidth()+"px");
			}
		}

		//OBJECT INSTANTIATION
		$j('div.gallery-item div.frame div.tabs').each
		(
			function()
			{
				if($j('body').hasClass('ie6')===false)
				{
					var obj = new TabNavigationCarousel($j(this));
					obj = null;
				}
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	newsCaptionDisplay:function()
	{
		$j('div.news div.panel').bind
		(
			'mouseenter',
			function(e)
			{
				$j(this).find('h3.meta').removeClass('screen-offset');
			}
		)
		.bind
		(
			'mouseleave',
			function(e)
			{
				if(!($j(e.relatedTarget).hasClass('gallery-item')))
				{
				    return;
				}
				$j(this).find('h3.meta').addClass('screen-offset');
			}
		)
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	preloadImages:function()
	{
	    if($j('html.template-homepage').length)
        {
            $j.preloadCssImages();
        }
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	scaleCollectionCarouselListItems:function()
	{
		function scaleListItems()
		{
			$j('div.collection-carousel li.carousel-item').each
			(
				function()
				{
					$j(this).css('width', $j(this).children('img.look').width());
				}
			);
		}
		scaleListItems();

		$j(window).bind
		(
			'resize',
			function()
			{
				scaleListItems();
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	scaleFullScreenCarousels:function()
	{
		if($j('div.full-screen-carousel').length>0)
		{
			function scaleCarousels()
			{
				$j('div.full-screen-carousel div.carousel-clip, div.full-screen-carousel div.carousel-clip li.carousel-item').css('width', window.width);
				$j('div.full-screen-carousel .clone-suffix').css('margin-left', -(window.width));
				$j('div.full-screen-carousel .clone-prefix').css('margin-right', -(window.width));
			}
			scaleCarousels();
			$j(window).bind
			(
				'resize',
				function()
				{
					scaleCarousels();
				}
			)
		}
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	setWaiAria:function()
	{
		//LANDMARK ROLES (application, banner, complimnetary, contentinfo, form, main, navigation, search)
		$j('body').attr("role","application");
		$j('.logo').attr("role","banner");
		$j('#content').attr("role","main");
		$j('.navigation').attr("role","navigation");
		$j('.legal').attr("role","contentinfo");
		$j('form').attr("role","form");

		//DESCRIBEDBY
		var figureElements = $j('div.figure img');
		figureElements.each
		(
			function()
			{
				$j(this).attr("aria-describedby", $j(this).next().attr('id'));
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	stores:function()
	{
		//OBJECT DEFINITION
		function StoresList(el)
		{
			//PROPERTIES
			this.__STORES_CONTAINER          = el;
			this.__STORES_NAVIGATION         = this.__STORES_CONTAINER.find('div.grid-8');
			this.__STORES_ACCORDION          = this.__STORES_CONTAINER.find('.accordion');
			this.__STORES_ACCORDION_TOGGLERS = this.__STORES_CONTAINER.find('.accordion a.toggler-link');
			this.__STORE_CONTAINER           = this.__STORES_CONTAINER.find('div.grid-16');
			this.__STORES                    = this.__STORES_CONTAINER.find('div.store');
			this.__STORE_LINKS               = this.__STORES_CONTAINER.find('a[rel="store"]');
			this.__FADE_OUT_DURATION         = parseInt(this.__STORES_CONTAINER.attr('data-fade-out-duration'));
			this.__FADE_IN_DURATION          = parseInt(this.__STORES_CONTAINER.attr('data-fade-in-duration'));
			this.__SLIDE_DURATION            = parseInt(this.__STORES_CONTAINER.attr('data-slide-duration'));

			return this.init();
		}

		//OBJECT METHODS
		StoresList.prototype =
		{
			init:function()
			{
				this.prepare();
				this.attachClickEvents();
			},

			prepare:function()
			{
				this.__STORES_CONTAINER.addClass('stores-closed');
				this.__STORES_NAVIGATION.addClass('grid-p-prefix-8');
				this.hideStores();
			},

			attachClickEvents:function()
			{
				var that = this;
				this.__STORES_ACCORDION_TOGGLERS.bind
				(
					'click',
					function(e)
					{
						if(that.__STORES_ACCORDION.hasClass('all-closed') && (!that.getNavigationClosed()))
						{
							that.closeNavigation();
						}
					}
				);

				this.__STORE_LINKS .bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						if(!$j(this).hasClass('current-store-link'))
						{
							that.clearStoreLinks();
							$j(this).addClass('current-store-link current');
							storeIdentifier = $j(this).attr('href');
							storeAnchor     = 'a' + $j(this).attr('href');
							storeElement    = $j((storeAnchor)).parent();
							storeLatitude   = storeElement.find('.geo span.latitude').html();
							storeLongitude  = storeElement.find('.geo span.longitude').html();
							storeIdentifier   = storeIdentifier.replace("anchor", "map").replace("#", "");

							if(that.getNavigationClosed())
							{
								that.openNavigation();
							}
							else
							{
								that.fadeOutCurrentStore();
							}
						}
					}
				);
			},

			fadeOutCurrentStore:function()
			{
				var that = this;
				var displayedDiv = $j("div.current-store");
				this.__STORES.removeClass('current-store');
				if(displayedDiv.length>0)
				{
					displayedDiv.fadeOut
					(
						that.__FADE_OUT_DURATION,
						function()
						{
							that.displayGlobalStoreElement();
						}
					);
				}
				else
				{
					that.displayGlobalStoreElement();
				}
			},

			displayGlobalStoreElement:function()
			{
				var that = this;
				storeElement.addClass('current-store').fadeIn
				(
					that.__FADE_OUT_DURATION,
					function()
					{
						that.displayStoreGoogleMap();
					}
				);
			},

			displayStoreGoogleMap:function()
			{
				var map;
				var MY_MAPTYPE_ID = 'Stores';
				var MAP_STYLES    = [{featureType: "all", stylers: [{hue: "#fff"},{saturation: -100},{lightness: 20}]}];
				function initialize(latitude, longitude,mapContainer)
				{
					var LOCATION_PARAM = new google.maps.LatLng(latitude, longitude);
					var mapOptions = {zoom: 12,center: LOCATION_PARAM, mapTypeControlOptions: {mapTypeIds: [google.maps.MapTypeId.ROADMAP, MY_MAPTYPE_ID]},mapTypeId: MY_MAPTYPE_ID};
					map = new google.maps.Map(document.getElementById(mapContainer), mapOptions);
					var styledMapOptions = {name: "Moncler"};
					var monclerMapType   = new google.maps.StyledMapType(MAP_STYLES, styledMapOptions);
					map.mapTypes.set(MY_MAPTYPE_ID, monclerMapType);
					var marker = new google.maps.Marker({position: LOCATION_PARAM});
					marker.setMap(map);
				}
				initialize(storeLatitude, storeLongitude, storeIdentifier);
			},

			clearStoreLinks:function()
			{
				this.__STORE_LINKS.removeClass('current-store-link').removeClass('current');;
			},

			getNavigationClosed:function()
			{
				return this.__STORES_CONTAINER.hasClass('stores-closed');
			},

			hideStores:function()
			{
				this.__STORES.hide();
			},

			openNavigation:function()
			{
				var that = this;
				this.__STORES_NAVIGATION.animate
				(
					{
						'padding-left': 0
					},
					that.__SLIDE_DURATION,
					'easeInOutQuint',
					function()
					{
						that.__STORES_CONTAINER.removeClass('stores-closed');
						that.__STORE_CONTAINER.css('display', 'block');
						that.fadeOutCurrentStore();
					}
				);
			},

			closeNavigation:function()
			{
				var that = this;
				this.__STORES_CONTAINER.addClass('stores-closed');
				var displayedDiv = $j("div.current-store");
				displayedDiv.fadeOut
				(
					that.__FADE_OUT_DURATION,
					function()
					{
						that.__STORES_NAVIGATION.animate
						(
							{
								'padding-left': 320
							},
							that.__SLIDE_DURATION,
							'easeInOutQuint',
							function()
							{
									that.clearStoreLinks();
									that.__STORE_CONTAINER.css('display', 'none');
							}
						);
					}
				);
			}
		}

		//OBJECT INSTANTIATION
		$j('div.stores').each
		(
			function()
			{
				var obj = new StoresList($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	tabComponents:function()
	{
		//OBJECT DECLARATION
		function TabComponent(el)
		{
			//PROPERTIES
			this.__COMPONENT       = el;
			this.__TAB_HEADERS     = this.__COMPONENT.find('.tab-header');
			this.__TAB_NAVIGATION  = this.__COMPONENT.find('.tab-navigation');
			this.__TAB_LINKS       = this.__TAB_NAVIGATION.find('a');
			this.__FIRST_TAB_LINK  = this.__TAB_LINKS.first();
			this.__TAB_PANELS      = this.__COMPONENT.find('div.panel');
			this.__FIRST_TAB_PANEL = this.__TAB_PANELS.first();

			return this.init();
		}

		//OBJECT METHODS
		TabComponent.prototype =
		{
			init:function()
			{
				this.prepare();
				this.attachTabEvent();
			},

			attachTabEvent:function()
			{
				var that = this;
				this.__TAB_LINKS.each
				(
					function()
					{
						$j(this).bind
						(
							'click',
							function(e)
							{
								e.preventDefault();
								that.clearLinks();
								that.hidePanels();
								$j(this).attr('class', 'current');
								var hash = 'a' + $j(this).attr('href');
								that.__COMPONENT.find(hash).parent().removeClass('screen-offset').attr('aria-hidden', 'false');
							}
						);
					}
				);
			},

			prepare:function()
			{
				this.__TAB_PANELS.attr("role","tabpanel");
				this.__TAB_NAVIGATION.attr("role","tablist");
				this.__TAB_LINKS.attr("role","tab");
				this.__TAB_LINKS.each
				(
					function()
					{
						$j(this).attr('id', this.hash.substr(1).replace("anchor", "link"));
					}
				);

				this.__TAB_PANELS.each
				(
					function()
					{
						var anchorLink = $j(this).find('a.named-anchor').attr('id').replace("anchor", "link");
						$j(this).attr("aria-labelledby",anchorLink);
					}
				);

				this.__TAB_HEADERS.addClass('screen-offset');
				this.hidePanels();
				this.__FIRST_TAB_LINK.addClass('current');
				this.__FIRST_TAB_PANEL.removeClass('screen-offset').attr('aria-hidden', 'false');
			},

			clearLinks:function()
			{
				this.__TAB_LINKS.removeClass('current');
			},

			hidePanels:function()
			{
				this.__TAB_PANELS.addClass('screen-offset').attr('aria-hidden', 'true');
			}
		};

		//OBJECT INSTANTIATION
		$j('div.tabs').each
		(
			function()
			{
				var obj = new TabComponent($j(this));
				obj = null;
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	tapestry:function()
	{
		function Tapestry(el)
		{
			this.__TAPESTRY                      = el;
			this.__TAPESTRY_STATE_COUNT          = this.__TAPESTRY.find('div.spotlight').length;
			this.__INSTRUCTIONS_FADE_IN_DURATION = 100;
			this.__INSTRUCTIONS_DISPLAY_DURATION = parseInt(this.__TAPESTRY.attr('data-instruction-display-duration'))*1000;
			this.__TAPESTRY_FADE_IN_DURATION     = 400;
			this.__instructions_closed           = false;
			this.count=1;

			if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i))
			{
				instructionText = window.languageJSON.__TAPESTRY_INSTRUCTION_TEXT.touch;
				instructionGraphic = "touch";
			}
			else
			{
				instructionText = window.languageJSON.__TAPESTRY_INSTRUCTION_TEXT.desktop;
				instructionGraphic = "desktop";
			}
			this.__INSTRUCTIONS = $j('<div class="box instructions" id="instructions-' + instructionGraphic + '"><div class="box-inner"><p>' + instructionText + '</p></div></div>');
			//this.__INSTRUCTIONS.insertBefore(this.__TAPESTRY);
			this.__CLOSE_INSTRUCTIONS = $j('<a id="close-instructions" href="#close"></a>');
			//this.__CLOSE_INSTRUCTIONS.prependTo(this.__TAPESTRY);
			var that = this;

			//this.displayInstructions();
            //JAH Start autoscroll
            that.__TAPESTRY.animate({
                        'opacity': 1
                    },
                    6000,
                    function() {
                        that.animateScrollTo();
                    }
                );

			if((navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)) && (!$j('html').hasClass('livestream')))
			{
				this.__TAPESTRY_PREV_LINK              = $j('<a class="tapestry-carousel-link tapestry-carousel-prev" href="#"></a>');
				this.__TAPESTRY_NEXT_LINK              = $j('<a class="tapestry-carousel-link tapestry-carousel-next" href="#"></a>');
				this.__TAPESTRY_PREV_LINK.appendTo(this.__TAPESTRY);
				this.__TAPESTRY_NEXT_LINK.appendTo(this.__TAPESTRY);
				this.__TAPESTRY_STATES_INDICATOR       = $j('<div class="tapestry-states-indicator"></div>');
				this.__TAPESTRY_STATES_CURRENT_COUNTER = $j('<span class="current-count"></span>');
				this.__DIVIDE                          = $j('<span>/</span>');
				this.__TAPESTRY_STATES_COUNTER         = $j('<span class="state-count"></span>');
				this.__TAPESTRY_STATES_INDICATOR.appendTo(this.__TAPESTRY);
				this.__TAPESTRY_STATES_CURRENT_COUNTER.appendTo(this.__TAPESTRY_STATES_INDICATOR);
				this.__DIVIDE.appendTo(this.__TAPESTRY_STATES_INDICATOR);
				this.__TAPESTRY_STATES_COUNTER.appendTo(this.__TAPESTRY_STATES_INDICATOR);
				this.__TAPESTRY_STATES_CURRENT_COUNTER.html("1");
				this.__TAPESTRY_STATES_COUNTER.html(this.__TAPESTRY_STATE_COUNT);

				this.mainTainTapestryLinks();

				this.__TAPESTRY_PREV_LINK.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						if(that.count>1)
						{
							that.count--;
							that.__TAPESTRY.attr('id', 'state-' + (that.count));
							that.mainTainTapestryLinks();
							that.__TAPESTRY_STATES_CURRENT_COUNTER.html(that.count);
						}
					}
				)

				this.__TAPESTRY_NEXT_LINK.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						if(that.count<that.__TAPESTRY_STATE_COUNT)
						{
							that.count++;
							that.__TAPESTRY.attr('id', 'state-' + (that.count));
							that.mainTainTapestryLinks();
							that.__TAPESTRY_STATES_CURRENT_COUNTER.html(that.count);
						}
					}
				)
			}
			else
			{
				this.__TAPESTRY_SCROLLER    = $j('<div class="tapestry-scroller"></div>');
				this.__STATE_CHANGE_TRIGGERS = new Array(this.__TAPESTRY_STATE_COUNT);
				this.setStateChangeTriggers();
				this.__TAPESTRY_SCROLLER.insertBefore(this.__TAPESTRY);
				this.setTapestryScrollerHeight();
                
//                //JAH Stop autoscroll

                    that.__TAPESTRY.bind(
                    "mousemove",
                    function(e) {
                        if($j(this).is(':animated')) {
                            that.__TAPESTRY.stop();  
                        }
                    }
                );

				$j(window).bind
				(
					"scroll",
					function()
					{
						var currentScroll = $j(window).scrollTop();
//                        console.log('TAPESTRY Count:'+that.count);                        
						var i;
						for(i = 1; i<that.__TAPESTRY_STATE_COUNT; i++)
						{
//                            console.log('currentScroll:' + currentScroll + ' : ' + that.__STATE_CHANGE_TRIGGERS[i] +':'+i);
							if(currentScroll >= that.__STATE_CHANGE_TRIGGERS[i])
							{
								that.count=i+1;
								that.setTapestryState();
//                                console.log('-- currentScroll:' + currentScroll + ' : ' + that.__STATE_CHANGE_TRIGGERS[i] +' ,Trigger:'+that.count);
							}
						}
                        //JAH Force state 1 if scrollTop is less than State 1 height.
                        if(currentScroll < that.__STATE_CHANGE_TRIGGERS[1]) {
                            that.count=1;
                            that.setTapestryState();
//                            console.log('-- currentScroll:' + currentScroll + ' : ' + that.__STATE_CHANGE_TRIGGERS[1] +' ,Trigger:'+that.count);
                        }
					}
				);

				$j(document).keydown
				(
					function(e)
					{
                        //JAH Stop autoscroll
                        that.__TAPESTRY.stop();
						switch(e.keyCode)
						{
							//up
							case 38:
							e.preventDefault();
							$j(window).scrollTop(that.__STATE_CHANGE_TRIGGERS[that.count-1]-1);
         						break;

         						//down
							case 40:
							e.preventDefault();
							$j(window).scrollTop(that.__STATE_CHANGE_TRIGGERS[that.count]);
         						break;
						}
					}
				);
			}
		}

		Tapestry.prototype =
		{
            animateScrollTo:function()
			{
                //JAH Start autoscroll
                var that = this;
                var __TAPESTRY_ANIMATE_DURATION = 2500;
                
                that.__CLOSE_INSTRUCTIONS.remove();
                that.__TAPESTRY.animate({
                        'opacity': 1
                    },
                    __TAPESTRY_ANIMATE_DURATION,
                    function() {
                        $j(window).scrollTop(that.__STATE_CHANGE_TRIGGERS[that.count]);
                        if(that.count <= that.__TAPESTRY_STATE_COUNT) {
                            that.count++;
                            that.animateScrollTo();
                        }
                    }
                );
            },

			displayInstructions:function()
			{
				var that = this;
				this.__TAPESTRY.css('opacity', '0.3');
				this.__CLOSE_INSTRUCTIONS.bind
				(
					"click",
					function(e)
					{
						e.preventDefault();
						that.__instructions_closed=true;
						that.__INSTRUCTIONS.fadeOut
						(
							function()
							{
								that.__TAPESTRY.animate
								(
									{
										'opacity': 1
									},
									that.__TAPESTRY_FADE_IN_DURATION,
									function()
									{
										that.__CLOSE_INSTRUCTIONS.remove();
									}
								);
							}
						);
					}
				);

				this.__INSTRUCTIONS.css
				(
					{
						'opacity':0,
						'display':'block'
					}
				).animate
				(
					{
						'opacity':1,
						'margin-top':'+=100'
					},
					this.__INSTRUCTIONS_FADE_IN_DURATION,
					function()
					{
						$j('a#top-anchor').animate
						(
							{
								'opacity': 1
							},
							that.__INSTRUCTIONS_DISPLAY_DURATION,
							function()
							{
								if(that.__instructions_closed===false)
								{
									that.__INSTRUCTIONS.fadeOut
									(
										function()
										{
											that.__TAPESTRY.animate
											(
												{
													'opacity': 1
												},
												that.__TAPESTRY_FADE_IN_DURATION,
												function()
												{
                                                    that.__CLOSE_INSTRUCTIONS.remove();
												}
											);
										}
									);
								}
							}
						);
					}
				);
			},

			setTapestryState:function()
			{
				this.__TAPESTRY.attr('id', 'state-' + this.count);
//                console.log('TAPESTRY id:' + this.__TAPESTRY.attr('id')+' ,TAPESTRY Count'+this.count);
			},

			getTapestryScrollerHeight:function()
			{ 
                var totalHeight = (Math.round(this.__TAPESTRY.height()) * (this.__TAPESTRY_STATE_COUNT)) + 10;
                //console.log('$j(document).height() = ' + $j(window).height() + ', totalHeight = ' + totalHeight + ', this.__TAPESTRY.height() = ' + this.__TAPESTRY.height() + ', this.__TAPESTRY_STATE_COUNT = ' + this.__TAPESTRY_STATE_COUNT);
				return totalHeight;
			},
			setTapestryScrollerHeight:function()
			{
                //console.log('this.getTapestryScrollerHeight()' + this.getTapestryScrollerHeight());
				this.__TAPESTRY_SCROLLER.css('height', this.getTapestryScrollerHeight());
			},
			setStateChangeTriggers:function()
			{
				var i;
				var height = this.__TAPESTRY.height();
				for (i=0; i<this.__TAPESTRY_STATE_COUNT; i++)
				{
					this.__STATE_CHANGE_TRIGGERS[i] = i * height;
                    //console.log('this.__STATE_CHANGE_TRIGGERS[i]' + this.__STATE_CHANGE_TRIGGERS[i]);
				}
			},
			mainTainTapestryLinks:function()
			{
				if(this.count===1)
				{
					this.__TAPESTRY_PREV_LINK.css('display', 'none');
				}
				else
				{
					this.__TAPESTRY_PREV_LINK.css('display', 'block');
				}

				if(this.count===this.__TAPESTRY_STATE_COUNT)
				{
					this.__TAPESTRY_NEXT_LINK.css('display', 'none');
				}
				else
				{
					this.__TAPESTRY_NEXT_LINK.css('display', 'block');
				}
			}
		}

		//OBJECT INSTANTIATION
		$j('div.tapestry').each
		(
			function()
			{
				if($j('body').hasClass('ie6')===false)
				{
					var obj = new Tapestry($j(this));
					obj = null;
				}
				else
				{
					$j('#state-1').attr('id', 'state-16');
				}
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	tooltips:function()
	{
        if(!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)))
        {
            //PROPERTIES
            this.__toolTipDiv           = $j('<div id="tooltip" aaa:atomic="true" aaa:live="rude"><div id="tooltip-top"></div><div id="tooltip-body"></div></div>');
            this.__toolTipDiv.appendTo($j('#wrapper'));
            this.__toolTipBody          = this.__toolTipDiv.find('#tooltip-body');
            this.__titledElements       = $j('.carousel .relational-navigation a');
            this.__TOOLTIP_WIDTH_OFFSET = this.__toolTipDiv.outerWidth() / 2;

            var that = this;
            this.__toolTipDiv.hide();

            this.__titledElements.each
            (
                function()
                {
                    var __TITLE, __LINK_WIDTH_OFFSET, __LINK_HEIGHT_OFFSET;

                    __TITLE              = $j(this).attr('title');
                    __LINK_WIDTH_OFFSET  = $j(this).outerWidth() /2;
                    __LINK_HEIGHT_OFFSET = 10;

                    $j(this).bind
                    (
                        'mouseenter',
                        function()
                        {
                            $j(this).attr('title', "");
                            that.__toolTipBody.html(__TITLE);
                            that.__toolTipDiv.show();
                        }
                    )
                    .bind
                    (
                        'mousemove',
                        function(e)
                        {
                            that.__toolTipDiv.css
                            (
                                {
                                    'left': (e.pageX - that.__TOOLTIP_WIDTH_OFFSET),
                                    'top' : e.pageY + __LINK_HEIGHT_OFFSET
                                }
                            );
                        }
                    )
                    .bind
                    (
                        'mouseout',
                        function()
                        {
                            that.__toolTipDiv.hide();
                            $j(this).attr('title', __TITLE);
                        }
                    );
                }
            );
        }         
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	touceDeviceHoverReplication:function()
	{
		if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i))
		{
			$j("a.overlay-link").each
			(
				function()
				{
	                    		var onClick;
	                    		var firstClick = function(e)
	                    		{
	                    			e.preventDefault();
	                        		onClick = secondClick;
	                        		return false;
	                    		};

	                    		var secondClick = function(e)
	                    		{
	                        		onClick = firstClick;
			                        return true;
	                    		};

	                    		onClick = firstClick;

	                    		$j(this).click
	                    		(
	                    			function(e)
	                    			{
	                        			return onClick(e);
						}
					);
	                	}
	                );
	        }
	},

        /*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	setCollectionsMenu:function()
	{
                var active_item = $j(".navigation.primary-navigation > li.active > a").attr('title');
                                
                if (active_item != undefined && active_item.toLowerCase() == 'collections') {
                                                                                    
                    $j('ul.navigation.secondary-navigation > li').each(function(index) {
                              
                        var _class = $j(this).children('a').attr('class');                        
                        var id = $j(this).children('a').attr('id');

                        if (_class != 'visible' && id != 'menu-past-seasons')
                        {
                            $j(this).appendTo('ul.navigation.secondary-navigation > li > a#menu-past-seasons');    
                            $j(this).children('a').removeClass('screen-offset');
                        }
   
                    });
                   
                    $j("ul.navigation.secondary-navigation > li > a#menu-past-seasons").children('li').hide();
                    $j("ul.navigation.secondary-navigation > li > a#menu-past-seasons").hover(function() { //When past-seasons is hovered...  
                    $j(this).children('li').show();
                        }, function() {
                    $j(this).children('li').hide(); 
                    });
                }
	},

	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	carousels:function()
	{
		//OBJECT DECLARATION
		function Carousel(el, options)
		{
			//OBJECT PROPERTIES
			this.__SCROLL_OPTION            = options.scroll;
			this.__DIRECT_NAVIGATION_OPTION = options.directNavigation;
			this.__FLEXIBLE_WIDTH_OPTION    = options.flexibleWidth

			this.scrollTarget               = null;
			this.carousel                   = el;
			this.carouselClip               = this.carousel.find('div.carousel-clip');
			this.carouselList               = this.carouselClip.find('.carousel-items');

			var that                        = this;

			if(this.__FLEXIBLE_WIDTH_OPTION === "true")
			{
				var length = that.carouselList.find('li.carousel-item').length;

				for(iterator=0; iterator<5; iterator++)
				{
					this.carousel.find('li.carousel-item:nth-child(' + iterator +')').clone().addClass(''+iterator +' exclude postfix').attr('id', "").appendTo(this.carouselList);
				}

				var postfixCount=0;
				for(iterator=length; iterator>(length-4); iterator--)
				{
					this.carousel.find('li.carousel-item:nth-child(' + (iterator+postfixCount) +')').clone().addClass(''+ iterator +' exclude prefix').attr('id', "").prependTo(this.carouselList);
					postfixCount++;
				}
			}
			this.carouselListItems          = this.carouselList.find('li.carousel-item');
			this.carouselListItemsFiltered  = this.carouselList.find('li.carousel-item:not(.exclude)');

			this.__COUNT 		        = 0;
			this.__PAGE_COUNT               = 0;


			//ADD DIRECT NAVIGATION
			if(this.__DIRECT_NAVIGATION_OPTION != "false")
			{
				this.directNavigation();
			}

			this.manipulateCarouselList();


			//PROPERTIES
			this.__CAROUSEL_LENGTH         = this.carouselListItemsFiltered.length;
			this.__CAROUSEL_ITEM_WIDTH     = this.getCarouselListItemWidth();
			this.__CAROUSEL_CLIP_WIDTH     = this.carouselClip.width();
			this.__CAROUSEL_VIEWABLE_ITEMS = Math.round(this.__CAROUSEL_CLIP_WIDTH / this.__CAROUSEL_ITEM_WIDTH);

			if(this.__FLEXIBLE_WIDTH_OPTION === "true")
			{
				this.__CAROUSEL_VIEWABLE_ITEMS = 2;
			}
			this.__CAROUSEL_CLONE_NUMBER   =  this.__CAROUSEL_VIEWABLE_ITEMS

			//FINITE SCROLL PROPERTIES
			this.__CAROUSEL_START          = 0;
			this.__CAROUSEL_END            = -(this.getCarouselListWidth() - this.__CAROUSEL_CLIP_WIDTH);


			this.__SLIDE_DURATION = 750;

			this.setCarouselListWidth();
			this.navigation();

			if(this.__DIRECT_NAVIGATION_OPTION != "false")
			{
				this.maintainDirectLinks(this.__COUNT);
			}

			this.highlightCurrent();

			if(this.hasSufficientItems())
			{
				//FINITE PREP
				if(this.__SCROLL_OPTION === "finite")
				{
					this.finiteScrollReset();
				}

				//INFINITE PREP
				if(this.__SCROLL_OPTION === "infinite")
				{
					this.infinitePrefixClones();
					this.infiniteSuffixClones();
				}
				this.attachClickEvents();
			}

			//IF FLEXIBLE WIDTH SET CENTER
			if(this.__FLEXIBLE_WIDTH_OPTION === "true")
			{
				this.setCenterPosition();
			}

			var targetArticleId, targetArticleEl, targetArticleIndex = null;

			//QUERY STRING METHOD
			if(window.queryObj["articleId"])
			{
				targetArticleId    = window.queryObj["articleId"];
				targetArticleEl    = $j('#' + targetArticleId);
				targetArticleIndex = (that.carouselListItemsFiltered.index(targetArticleEl));
				if(this.hasSufficientItems())
				{
					this.scroll("direct", targetArticleIndex);
				}
			}

			$j(window).bind
			(
				'resize',
				function()
				{
					if(that.__FLEXIBLE_WIDTH_OPTION === "true")
					{
						that.setCenterPosition();
					}
					else
					{
						that.setCarouselListWidth();
						that.__CAROUSEL_END            = -(that.getCarouselListWidth() - that.carouselClip.width());
						that.__CAROUSEL_ITEM_WIDTH = that.getCarouselListItemWidth();
						that.carouselList.css('left', -parseInt(that.__CAROUSEL_ITEM_WIDTH * that.__COUNT));
					}
				}
			);


		}


		//OBJECT METHODS
		Carousel.prototype =
		{
			directNavigation:function()
			{
				that = this;
				this.directNavigation = $j('<ul class="list-unsigned list-hor list-hor-divide-1 direct-navigation clearfix"></ul>');
				this.carouselListItemsFiltered.each
				(
					function(index, el)
					{
						var itemCount = parseInt(index + 1);
						if(itemCount<10)
						{
							itemCount = '0' + itemCount;
						}
						that.directNavigation.append
						(
							$j('<li><a href="#" id="' + index + '"">' + '<span class="item-count">' + itemCount + '</span>' +  " " + '<span class="item-label">' + $j(el).find('.item-label').html() + '</span>' + '</a></li>')
						);
					}
				);
				this.directNavigation.appendTo(this.carousel);
				this.directNavigationlinks = this.directNavigation.find('a');
				this.directNavigationlinks.bind
				(
					'click',
					function(e)
					{
						e.preventDefault();
						var index = $j(this).attr('id');
						if(index > that.__COUNT)
						{
							that.scroll("direct", index);
						}
						else if(index < that.__COUNT)
						{
							that.scroll("direct",index);
						}
					}
				);
			},

			getCenterPosition:function()
			{
				var center = $j(window).width() / 2;
				var listItemPosition    = this.carouselListItemsFiltered.eq(this.__COUNT).position();
				var leftPoint           = listItemPosition.left;
				var listItemSize     	= this.carouselListItemsFiltered.eq(this.__COUNT).width();
				var halfWayDimension    = listItemSize/2;
				return (center - (leftPoint + halfWayDimension));
			},

			setCenterPosition:function()
			{
				this.carouselList.css('left', this.getCenterPosition());
			},

			attachClickEvents:function()
			{
				var that = this;
				this.nextLink.bind
				(
					'click',
					function(e)
					{
						/*NEXT*/
						that.__CAROUSEL_ITEM_WIDTH  = that.getCarouselListItemWidth();
						that.scroll("relational", "next");
						e.preventDefault();
					}
				);

				this.prevLink.bind
				(
					'click',
					function(e)
					{
						that.__CAROUSEL_ITEM_WIDTH = that.getCarouselListItemWidth();
						that.scroll("relational", "prev");
						e.preventDefault();
					}
				);

				if(this.__DIRECT_NAVIGATION_OPTION != "false")
				{
					this.directNavigationlinks.bind
					(
						'click',
						function(e)
						{
							var index = $j(this).attr('id');
							that.scroll("direct", index);
						}
					);
				}
			},

			scrollResetTrigger:function()
			{
				if(this.__SCROLL_OPTION === "infinite")
				{
					this.infiniteScrollReset();
				}
				if(this.__SCROLL_OPTION === "finite")
				{
					this.finiteScrollReset();
				}
			},

			infiniteScrollReset:function()
			{
				if(this.__COUNT === this.__CAROUSEL_LENGTH)
				{
					this.carouselList.css('left', 0);
					this.__COUNT=0;
					this.maintainDirectLinks(this.__COUNT);
					this.highlightCurrent();
				}
				if(this.__COUNT === -1)
				{
					this.carouselList.css('left', -(this.__CAROUSEL_LENGTH -1) * this.__CAROUSEL_ITEM_WIDTH);
					this.__COUNT=this.__CAROUSEL_LENGTH -1;
					this.maintainDirectLinks(this.__COUNT);
					this.highlightCurrent();
				}
			},

			finiteScrollReset:function()
			{
				this.nextLink.css('display', 'block');
				this.prevLink.css('display', 'block');

				if(this.__COUNT === this.__CAROUSEL_LENGTH-1)
				{
					this.nextLink.css('display', 'none');
					this.prevLink.css('display', 'block');
				}
				if(this.__COUNT === 0)
				{
					this.nextLink.css('display', 'block');
					this.prevLink.css('display', 'none');
				}
			},

			navigation:function()
			{

				this.carouselNavigation = $j('<ul class="list-unsigned navigation relational-navigation"></ul>');
				this.nextListItem = $j('<li class="next"></li>');
				this.prevListItem = $j('<li class="prev"></li>');

				if(this.hasSufficientItems())
				{
					this.nextLink = $j('<a class="replaced" href="#" rel="next" title="' + window.languageJSON.__LINK_TEXT.__CAROUSEL_NEXT.title +'">' + window.languageJSON.__LINK_TEXT.__CAROUSEL_NEXT.text + '</a>');
					this.prevLink = $j('<a class="replaced" href="#" rel="prev" title="' + window.languageJSON.__LINK_TEXT.__CAROUSEL_PREV.title +'">' + window.languageJSON.__LINK_TEXT.__CAROUSEL_PREV.text + '</a>');
					this.nextLink.prependTo(this.nextListItem);
					this.prevLink.prependTo(this.prevListItem);
				}

				this.prevListItem.prependTo(this.carouselNavigation);
				this.nextListItem.prependTo(this.carouselNavigation);
				this.carouselNavigation.appendTo(this.carousel);
			},

			manipulateCarouselList:function()
			{
				this.carouselList.addClass('list-unsigned list-hor clearfix');
			},

			infinitePrefixClones:function()
			{
				var that = this;
				var iterator;
				var cloneIndex = 1;
				for(iterator=0; iterator<that.__CAROUSEL_CLONE_NUMBER; iterator++)
				{
					that.carousel.find('li.carousel-item:nth-child(' + cloneIndex +')').clone().appendTo(that.carouselList).attr('aria-hidden', 'true').addClass('clone clone-prefix clone-prefix-'+ cloneIndex).css({'margin-right': -((iterator+1) * that.__CAROUSEL_ITEM_WIDTH)+"px"});
					cloneIndex ++;
				}
			},

			infiniteSuffixClones:function()
			{
				var that = this;
				var iterator;
				var cloneIndex = that.__CAROUSEL_LENGTH;
				for(iterator=0; iterator<that.__CAROUSEL_CLONE_NUMBER; iterator++)
				{
					that.carousel.find('li.carousel-item:nth-child(' + cloneIndex +')').clone().appendTo(that.carouselList).attr('aria-hidden', 'true').addClass('clone clone-suffix clone-suffix-'+ cloneIndex).css({'margin-left': -((iterator+1) * that.__CAROUSEL_ITEM_WIDTH)+"px"});
					cloneIndex --;
				}
			},

			setCarouselListWidth:function()
			{
				if(this.__FLEXIBLE_WIDTH_OPTION === "false")
				{
					this.carouselList.css('width', this.getCarouselListWidth() + "px");
				}

				if(this.__FLEXIBLE_WIDTH_OPTION === "true")
				{
					var totalWidth = null;
					this.carouselListItems.each
					(
						function()
						{
							totalWidth += $j(this).width();
						}
					)
					this.carouselList.css('width', totalWidth * 4);
				}
			},

			getCarouselListItemWidth:function()
			{
				return this.carouselListItems.first().outerWidth();
			},

			getCarouselListItemCount:function()
			{
				return this.carouselListItems.length;
			},

			getCarouselListWidth:function(carousel)
			{
				return this.getCarouselListItemWidth() * this.getCarouselListItemCount();
			},

			hasSufficientItems:function()
			{
				return (this.__CAROUSEL_VIEWABLE_ITEMS < this.__CAROUSEL_LENGTH);
			},

			maintainDirectLinks:function(index)
			{
				this.directNavigationlinks.removeClass('directLinkCurrent');
				this.directNavigationlinks.eq(index).addClass('directLinkCurrent');
			},

			highlightCurrent:function()
			{
				this.carouselListItemsFiltered.removeClass('current-item');
				this.carouselListItemsFiltered.eq(this.__COUNT).addClass('current-item');
			},

			scroll:function(scrollAmount, scrollDirection)
			{
				if(!(this.carouselList.is(":animated")))
				{
					that = this;
					if(scrollAmount==="relational")
					{
						(scrollDirection==="next") ? this.__COUNT++ : this.__COUNT--;
						if(this.__FLEXIBLE_WIDTH_OPTION === "true")
						{
								//FLEXIBLE WIDTH
								this.__scrollTarget = this.getCenterPosition();
						}
						else
						{
								//FIXED WIDTH
								this.__scrollTarget = -parseInt(this.__CAROUSEL_ITEM_WIDTH * this.__COUNT);
						}
					}
					else
					{
						this.__COUNT = scrollDirection;
						if(this.__FLEXIBLE_WIDTH_OPTION === "true")
						{
							this.__scrollTarget = this.getCenterPosition();
						}
						else
						{
							this.__scrollTarget = -parseInt(this.__CAROUSEL_ITEM_WIDTH * scrollDirection);
						}
					}

					this.carouselList.animate
					(
						{
							left: that.__scrollTarget
						},
						that.__SLIDE_DURATION,
						'easeOutExpo',
						function()
						{
							that.scrollResetTrigger();
						}
					);

					if(this.__DIRECT_NAVIGATION_OPTION != "false")
					{
						this.maintainDirectLinks(this.__COUNT);
					}

					this.highlightCurrent();
				}
			}
		}

		$j('.carousel').each
		(
			function()
			{
				var scroll, directNavigation, flexibleWidth;
				$j(this).attr('data-config-scroll')     ? scroll           = $j(this).attr('data-config-scroll')     : scroll           = "finite";
				$j(this).attr('data-direct-navigation') ? directNavigation = $j(this).attr('data-direct-navigation') : directNavigation = "true";
				$j(this).attr('data-flexible-width')    ? flexibleWidth    = $j(this).attr('data-flexible-width')    : flexibleWidth    = "false";
				var obj = new Carousel
				(
					$j(this),
					{
						'scroll'           : scroll,
						'directNavigation' : directNavigation,
						'flexibleWidth'    : flexibleWidth
					}
				);
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	scrollPanes:function()
	{
		$j('.scroll-pane, .module').each
		(
			function()
			{
				$j(this).jScrollPane
				(
					{
						showArrows: false
					}
				);
				var api = $j(this).data('jsp');
				var throttleTimeout;
				$j(window).bind
				(
					'resize',
					function()
					{
						if ($j.browser.msie)
						{
							if (!throttleTimeout)
							{
								throttleTimeout = setTimeout
								(
									function()
									{
										api.reinitialise();
										throttleTimeout = null;
									},
									50
								);
							}
						}
						else
						{
							api.reinitialise();
						}
					}
				);
			}
		);
	},


	/*--------------------------------------------------------------------------------------------------------------------------------*/
	/*--------------------------------------------------------------------------------------------------------------------------------*/
	init:function()
	{
		this.preloadImages();
		this.tabComponents();
		this.setWaiAria();
		this.ie6FocusReplication();
		this.formValidations();
		this.internalLinks();
		this.externalLinks();
		this.carouselNewsItems();
		this.tapestry();
		this.accordions();
		this.backgroundCarousels();
		this.stores();
		this.footers();
		this.scaleCollectionCarouselListItems();
		this.scaleFullScreenCarousels();
		this.touceDeviceHoverReplication();
		this.carousels();
		this.frameImgAspectRatio();
		this.carouselTabNavigationCarousels();
		this.newsCaptionDisplay();
		this.tooltips();
		this.collectionCarouselMetaItems();
		this.scrollPanes();
		this.fancyboxes();
	}
};

$j(window).bind
(
	'resize',
	function()
	{
		window.width = $j(window).width();
	}
);

$j(document).ready
(
	function()
	{
		Wednesday.getNaturalLanguage();
        Wednesday.setCollectionsMenu();
	}
);

$j(window).load
(
	function()
	{
		$j(window).trigger('resize');
		$j('html.template-full-screen div#preloader-mask').delay(1000).fadeOut(500);
        $j('html.template-homepage div#preloader-mask').css('display','none');
		$j('.delay-display').css('visibility','visible');
		//This is used for functions that rely on images loading to measure:
        //frameImgAspectRatio
        //tabNavigationCarousels
        //collectionCarouselMetaItems
        //scaleCollectionCarouselListItems
        //scaleFullScreenCarousels
	}
);
