// Skin Specific JS goes here

$j(document).ready(function(){    
      
	$j('a.listenWindow').bind('click', function () {
		window.open(this.href, '_blank', 'width=250,height=50,resizable');
		return false;
	});
	
	$j('a.watchWindow').bind('click', function () {
		window.open(this.href, '_blank', 'width=340,height=280,resizable');
		return false;
	});
	
	$j('a.vimeoWatchWindow').bind('click', function () {
		window.open(this.href, '_blank', 'width=420,height=320,resizable');
		return false;
	});

// Home Page Tabs
	$j('.navTab').bind('click', function () {
		$j('.navTab').removeClass('navTabActive');
		$j(this).addClass('navTabActive');
		$j('.tabContentWrap').removeClass('active');
		if ($j(this).is('#navTab-1')) {
			$j("#tabContentWrap-1").addClass('active');
		}
		if ($j(this).is('#navTab-2')) {
			$j("#tabContentWrap-2").addClass('active');
		}
		if ($j(this).is('#navTab-3')) {
			$j("#tabContentWrap-3").addClass('active');
		}
		if ($j(this).is('#navTab-4')) {
			$j("#tabContentWrap-4").addClass('active');
		}
		if ($j(this).is('#navTab-5')) {
			$j("#tabContentWrap-5").addClass('active');
		}
		else {
			$j('#tabContentWrap-1').addClass('active');
		}
	});


// Rotator
	function fadeRotator() {
		if (currentRotator == totalRotatorItems) {
			var nextRotator = 0;
			var prevRotator = currentRotator - 1;
		} else if (currentRotator == 0) {
			var nextRotator = currentRotator + 1;
			var prevRotator = totalRotatorItems;
		} else {
			var nextRotator = currentRotator + 1;
			var prevRotator = currentRotator - 1;
		}
		$j(this).oneTime (4000, function() {
			if (rotatorRunning == 1) {
				$j('.rotatorItemWrap:eq(' + currentRotator + ')').fadeOut(2000);
				$j('.rotatorItemWrap:eq(' + nextRotator + ')').fadeIn(2000);
				currentRotator = nextRotator;
				fadeRotator ();
				$j('#rotatorMenu li').removeClass('active');
				$j('#rotatorMenu li:eq(' + currentRotator + ')').addClass('active');
			}
		});
	}
	rotatorRunning = 1;
	var totalRotatorItems = $j('.rotatorItemWrap').size();
	totalRotatorItems = totalRotatorItems - 1
	currentRotator = 0;
	$j('.rotatorItemWrap:gt(0)').hide();
	if ($j('#rotatorMenu').length) {
		var i = 0
		while (i <= totalRotatorItems) {
			i++;
			$j('#rotatorMenu').append('<li>' + i + '</li>');
		}
	}
	$j('#rotatorMenu li:first').addClass('active');
	fadeRotator();

	$j('#rotatorMenu li').bind('click', function () {
		var clickedElementIndex = $j('#rotatorMenu li').index(this);
		rotatorRunning = 0;
		if (clickedElementIndex != currentRotator) {
			$j('.rotatorItemWrap').fadeOut(1000);
			$j('.rotatorItemWrap:eq(' + clickedElementIndex + ')').fadeIn(1000);
			$j('#rotatorMenu li').removeClass('active');
			$j(this).addClass('active');
			currentRotator = clickedElementIndex
		}	
	});
// Final closing brackets
});