try {
if (!cllc.exists) { throw "cllcObjUndefined"; }

cllc.homepage = {
	model: {
		slider_count: null,
		slider_cur_image: 0,
		slider_image_width: null,
		slider_delay: 8000,
		brand_promos_image_height: null
	},

	init: function() {
		cllc.homepage.model.slider_count = $('#header_images li').length;
		cllc.homepage.model.slider_image_width = parseInt($('#header_images li').width(), 10);
		cllc.homepage.model.brand_promos_image_height = parseInt($('#brand_promos li').height(), 10);
		
		$('#header_images_nav li:first').addClass('active');

		var feature_rotator = setInterval(function() {
			cllc.homepage.model.slider_cur_image = (cllc.homepage.model.slider_cur_image < cllc.homepage.model.slider_count - 1)
				? cllc.homepage.model.slider_cur_image + 1
				: 0;
			$('#header_images_nav li:eq('+cllc.homepage.model.slider_cur_image+')').trigger('click.machine');
		}, cllc.homepage.model.slider_delay);

		// Setup both the human click and machine click event handlers.
		// These both do the same thing except that the human click also performs a clearInterval
		// on the image rotator.
		$('#header_images_nav li').bind('click click.machine', function(event) {
			event.preventDefault();

			var $this = $(this);
			var index = $('#header_images_nav li').index(this);

			$this.siblings().removeClass('active');
			$this.addClass('active');
			
			$('#header_images').animate({
				left: -1 * index * cllc.homepage.model.slider_image_width
			}, {
				duration: 250
			});
		})
		.click(function(event) { clearInterval(feature_rotator); });
		
		$('#brand_names li').bind('click', function(event) {
			event.preventDefault();

			var $this = $(this);
			var index = $('#brand_names li').index(this);

			$this.siblings().removeClass('active');
			$this.addClass('active');
			
			$('#brand_promos').animate({
				top: -1 * index * cllc.homepage.model.brand_promos_image_height
			}, {
				duration: 250
			});
		})
	}
};

} catch(e) { cllc.standard_error_handler(e); }

$(cllc.homepage.init);