var teaser = {
	defaults: {lbl_show: 'Show', lbl_hide: 'Hide'},
	bind: function () {
		$("a.collapse").click(function (event) {
			teaser.toggle();
			event.preventDefault();
			if (!event.isDefaultPrevented()) {
				return false;
			}
		});		
		$(".rotator_box_thumb ul li").not(".last").click(function (event) { 
			teaser.move($(this));
			event.preventDefault();
			if (!event.isDefaultPrevented()) {
				return false;
			}			
		}).hover(function () {
			$(this).addClass('hover');
		}, function () {
			$(this).removeClass('hover');
		});
	},
	init: function (options) {		
		this.opts = $.extend(this.defaults, options);		
		$(".rotator_box_main .desc").show(); //Show Banner
		$(".rotator_box_main .block").animate({opacity: 0.85}, 1); //Set Opacity
		$(".rotator_box_thumb ul li:first").addClass('active');
		this.bind();
		$(".rotator_box_thumb ul li").not(".last").each(function (i) {
			var jQ = $(this);
			if (i > 0) {
				setTimeout(function () {
					teaser.move(jQ);
				}, 6000 * i);
			}
		});
	},
	move: function (jQ) {
		//Set Variables
		var imgAlt = jQ.find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = jQ.find('a').attr("href"); //Get Main Image URL
		var imgDesc = jQ.find('.block').html(); 	//Get HTML of block
		var imgDescHeight = $(".rotator_box_main").find('.block').height();	//Calculate height of block	
		
		if (jQ.is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			$(".rotator_box_main .block").animate({opacity: 0, marginBottom: -imgDescHeight}, 250, function () {
				$(".rotator_box_main .block").html(imgDesc).animate({opacity: 0.85,	marginBottom: "0" }, 250);
				$(".rotator_box_main img").attr({src: imgTitle, alt: imgAlt});
			});
		}
		
		$(".rotator_box_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		jQ.addClass('active');  //add class of 'active' on this list only
	},
	toggle: function () {		
		$(".rotator_box_main .block").slideToggle();
		$("a.collapse").toggleClass("show");
		if ($("a.collapse").hasClass("show")) {
			$("a.collapse span.icon").text("+");
			$("a.collapse span.text").text(this.opts.lbl_show);
		} else {
			$("a.collapse span.icon").text("-");
			$("a.collapse span.text").text(this.opts.lbl_hide);
		}
	}	
};
