/* Featured section of the home page */

$(document).ready(function() {

	/****************************************************************************************
	Setup the basic cycle 
	****************************************************************************************/
	$('div#bnr-surround').cycle({ 			   
		speed: '600', 
		timeout: '8000',
		pause: 1,
		after: onAfter 
	});
	
	/****************************************************************************************
	Pause the cycle if there is any interaction
	****************************************************************************************/	
	$('ul#bnr-nav li a').hover(function() {
		$('div#bnr-surround').cycle('stop');
	});

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

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

	$('a#ft2').mouseout(function(){
		
  	});

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

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


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');	
	}
	
} 



