/*
	Copyright Code Computerlove Ltd 2010
	Build: 0.0.80.368
	Date: 10/06/2010 16:12:01
*/

(function($j){

	Code.registerNamespace('Website.Pages');

	/*
	 * Class: Website.Core
	 */
	Website.Pages.Homepage = {
		
		// Constants
		selectors : {
			featuredPromos : "FeaturedPromos",
			featurePromoSelector : "FeaturePromoSelector"
		},

		/*
		 * Function: Init Resources Index - this function is based on the fact that the tabs script in core.js has been executed
		 */
		_initHomepage : function() {
			
			var _self = this;
			
			// attach jQueryCarousel plugin to the elements
			$j("#" + _self.selectors.featuredPromos).carousel({ dispItems: 1, loop: true, pagination: true, animSpeed: "normal" });
			$j("#" + _self.selectors.featurePromoSelector).carousel({ direction: "vertical", dispItems: 3, loop: true });
			
			// on click of each li within the PromoSelector carousel trigger the corresponding pagination link within the featurePromo carousel
			$j("#" + _self.selectors.featurePromoSelector + " li").each(function(i){
				$j(this).click(function(e){
					e.preventDefault();
					var ii = i + 1
					$j("#FeaturedPromos .carousel-pagination a:nth-child(" + ii + ")").trigger('click');
				});
			})
			
		},
		
		/*
		 * Function: onReady
		 */
		onReady: function(){
			var _self = this;
			_self._initHomepage();
		}
		

	};

	$j().ready(function(){
		Website.Pages.Homepage.onReady();
	});

})(jQuery);

