/* Featured section of the home page */

$(document).ready(function() {

	/****************************************************************************************
	Setup the basic cycle 
	****************************************************************************************/
	$('div#featured').cycle({ 			   
		fx:     'scrollLeft', 
		easing: 'easeInCubic',
		speed:  '600', 
		timeout: '4000',
		pause:  1, 
    	after:   onAfter 
	});
	
	/****************************************************************************************
	Pause the cycle if there is any interaction
	****************************************************************************************/	
	$('#featured-tabs a, div.featured-content').hover(function() {
		$('div#featured').cycle('stop');
	});

	/****************************************************************************************
	Show the correct slide when tabs are hovered over
	****************************************************************************************/	
	$('#featured-tabs a#ft1').mouseover(function(){
    	$('div#fc1').css('display', 'block');		
		$('div#fc1').css('left', '0');	
		$('div#fc1').css('top', '0');		
		$('div#fc2').css('display', 'none');	
		$('div#fc3').css('display', 'none');	
		$('div#fc4').css('display', 'none');
		$(this).addClass("activetab");
  	});

	$('#featured-tabs a#ft1').mouseout(function(){
		$(this).addClass("activetab");
		$('a#ft2').removeClass("activetab");
		$('a#ft3').removeClass("activetab");
		$('a#ft4').removeClass("activetab");
  	});
	
	$('#featured-tabs a#ft2').mouseover(function(){
    	$('div#fc2').css('display', 'block');	
		$('div#fc2').css('left', '0');	
		$('div#fc2').css('top', '0');		
		$('div#fc1').css('display', 'none');	
		$('div#fc3').css('display', 'none');	
		$('div#fc4').css('display', 'none');	
		$(this).addClass("activetab");
  	});

	$('#featured-tabs a#ft2').mouseout(function(){
		$(this).addClass("activetab");
		$('a#ft1').removeClass("activetab");
		$('a#ft3').removeClass("activetab");
		$('a#ft4').removeClass("activetab");
  	});

	$('#featured-tabs a#ft3').mouseover(function(){
    	$('div#fc3').css('display', 'block');		
		$('div#fc3').css('left', '0');	
		$('div#fc3').css('top', '0');		
		$('div#fc1').css('display', 'none');	
		$('div#fc2').css('display', 'none');	
		$('div#fc4').css('display', 'none');
		$(this).addClass("activetab");
  	});

	$('#featured-tabs a#ft3').mouseout(function(){
		$(this).addClass("activetab");
		$('a#ft1').removeClass("activetab");
		$('a#ft2').removeClass("activetab");
		$('a#ft4').removeClass("activetab");
  	});
	
	$('#featured-tabs a#ft4').mouseover(function(){
    	$('div#fc4').css('display', 'block');		
		$('div#fc4').css('left', '0');	
		$('div#fc4').css('top', '0');		
		$('div#fc1').css('display', 'none');	
		$('div#fc2').css('display', 'none');	
		$('div#fc3').css('display', 'none');
		$(this).addClass("activetab");
  	});
	
	$('#featured-tabs a#ft4').mouseout(function(){
		$(this).addClass("activetab");
		$('a#ft1').removeClass("activetab");
		$('a#ft2').removeClass("activetab");
		$('a#ft3').removeClass("activetab");
  	});
	
});



function onAfter() { 

	if (this.id == "fc1") {
		$('#ft1').addClass('activetab');
		$('#ft2, #ft3, #ft4').removeClass('activetab');
	}
	else if (this.id == "fc2") {
		$('#ft2').addClass('activetab');
		$('#ft1, #ft3, #ft4').removeClass('activetab');
	}	
	else if (this.id == "fc3") {
		$('#ft3').addClass('activetab');
		$('#ft1, #ft2, #ft4').removeClass('activetab');	
	}
	else if (this.id == "fc4") {
		$('#ft4').addClass('activetab');
		$('#ft1, #ft2, #ft3').removeClass('activetab');	
	}
	
} 


