// JavaScript Document
var $j = jQuery.noConflict();
var isRotating = 0; /* Controls "button mashing" (ie. repeated clicks of the buttons). */
var isStopped = 0;
var rotate;

$j("document").ready(function() {
	$j("a").css("outline",0);
	
	equalHeight($j(".exclusives-text"));
	equalHeight($j(".shows-caption"));
	equalHeight($j("#slider-container, .exclusives-container"));
	rotate = setInterval("rotateNext()", 5000); /* Controls the time between transitions (5000 = 5 seconds) */
	$j("#slide-right").click(rotateNext);
	$j("#slide-left").click(rotatePrev);
	
	var tabContainers = $j('div.tabcontent');
	tabContainers.hide().filter(':first').show();
	$j('div#tabs a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).show();
		$j('div#tabs a').removeClass('selected');
		$j(this).addClass('selected');
		return false;
	}).filter(':first').click(); 	
});

function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $j(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

function rotateNext() {
	if(isRotating == 1){ return; }
	isRotating = 1;
	var oCurPhoto = $j('#slider-container .current');
	var oNxtPhoto = oCurPhoto.next('.slides');
	if (oNxtPhoto.length == 0){
		oNxtPhoto = $j('#slider-container .slides:first');
	}
	oCurPhoto.animate({ left: "670px" },500,
		function() {
			oCurPhoto.removeAttr('style');
			oCurPhoto.removeClass('current');
		});
	
	oNxtPhoto.animate({ left: "0px" }, 500,
		function() {
			oNxtPhoto.addClass('current');
			isRotating = 0;
		});
}
function rotatePrev() {
	if( isRotating == 1 ){
		return;
	}
	isRotating = 1;	
	var oCurPhoto = $j('#slider-container .current');
	var oNxtPhoto = oCurPhoto.prev();
	if (oNxtPhoto.length == 0){
		oNxtPhoto = $j('#slider-container .slides:last');
	}
	oCurPhoto.animate({ left: "-670px" },500,
		function() {
			oCurPhoto.removeAttr('style');
			oCurPhoto.removeClass('current');
		});
	oNxtPhoto.css("left","670px");
	oNxtPhoto.animate({ left: "0px" },500,
		function() {
			oNxtPhoto.addClass('current');
			isRotating = 0;
		});

}

