function slider(containerObj) {
	this.containerObj = null;
	this.currentPosition = 0;
	this.slideWidth = 873;
	this.slides = null;
	this.numberOfSlides = null;
	this.animateDuration = 2000;
	this.autoSlideInterval = 3000;
	this.autoSlideIntervalObj = null;

	this.init = function(containerObj) {
		this.containerObj = containerObj;
		this.slides = jQuery(this.containerObj+' .slide');
		this.numberOfSlides = this.slides.length;

		// Remove scrollbar in JS
		jQuery('.slidesContainer').css('overflow', 'hidden');

		// Wrap all .slides with #slideInner div
		this.slides
		.wrapAll('<div class="slideInner"></div>')
		// Float left to display horizontally, read just .slides width
		.css({
			'float' : 'left',
			'width' : this.slideWidth
		});

		// Set #slideInner width equal to total width of all slides
		jQuery(this.containerObj+' .slideInner').css('width', this.slideWidth * this.numberOfSlides);


		//bind model buttons
		jQuery(this.containerObj+' .slidesButtons li').bind('click', {containerObj: this.containerObj, slideWidth: this.slideWidth, animateDuration: this.animateDuration}, function(event) {
			//mark the current button as current
			jQuery(containerObj+' .slidesButtons li').removeClass('current');
			jQuery(this).addClass('current');

			//get the new left margin
			var newMarginLeft = event.data.slideWidth*(-jQuery(this).index());

			//only perform the animation if it is not on the current slide
			if(parseInt(jQuery(containerObj+' .slideInner').css('marginLeft')) != newMarginLeft) {
				//hide infobox
				jQuery('.infobox').fadeOut(300);
				jQuery('.learnmore').fadeOut(300);

				jQuery(containerObj+' .slideInner').animate({
					'marginLeft' : newMarginLeft
				}, 
				event.data.animateDuration,
				function() {
					//show infobox
					jQuery('.infobox').fadeIn(300, function() {
						//cause IE doesn't keep the transparency...
						jQuery('.infobox').css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(opacity=80)"');
						jQuery('.infobox').css('filter', 'progid:DXImageTransform.Microsoft.Alpha(opacity=80)');
					});

					jQuery('.learnmore').fadeIn(300);
				});
			}
		});
	};

	//Constructor
	this.init(containerObj);
};



brandButtons = {
	clickedContainer: null,
	formerClickedContainer: null,

	init: function() {
		//bind brand buttons
		jQuery('#navigation a').click(function() {
			brandButtons.clickedContainer = jQuery(this).index() +1;

			//mark button as current
			jQuery('#navigation a').removeClass('current');
			jQuery(this).addClass('current');

			if(jQuery('#initial-box').is(':visible')) {
				jQuery('#initial-box').fadeOut(500);
				jQuery('#slidesContainer'+(brandButtons.clickedContainer)).fadeIn();
			}
			else {
				if(brandButtons.formerClickedContainer != brandButtons.clickedContainer) {
					jQuery('.slidesContainer').hide();
					//jQuery('.slidesContainer').fadeOut(500, function() {
					jQuery('#slidesContainer'+(brandButtons.clickedContainer)).fadeIn(500);
					//});
				}
			}

			brandButtons.formerClickedContainer = brandButtons.clickedContainer;
		});
	}

};



jQuery(document).ready(function(){
	brandButtons.init();
});
