$(document).ready(function() {

	var slideLinks = $('#highlights h3 > a');
  
  var i = 1;
  var autoSlide = setInterval(
	  function() {
	  	var target = slideLinks[i].hash;
	  	$('#highlights .current').removeClass('current');
	    $('div' + target).addClass('current');
	    $(slideLinks[i]).addClass('current');
	    i++;
	    if( i >= slideLinks.length) i = 0;
	} , 7000);
	
	$('#highlights h3 > a').click(function(event) {
		event.preventDefault();
		var $this = $(this),
				target = $this.attr('href');
		$('#highlights .current').removeClass('current');
		$('div' + target).addClass('current');
		$this.addClass('current');
		clearInterval(autoSlide);
	});

  var $tabs = $('.tabs');
  
  // Hiding all panels, then showing the first one
  $('.panel').hide();
  $('.showing').show();
  
  // When a tab is clicked
  $tabs.find('li > a').click(function(e) {
  	e.preventDefault();
  	var target = $(this).attr('href'),
  			$target = $('div' + target);
  	
  	// Checking to see if it's showing already
  	if ( !$target.hasClass('showing') )
  	{
  		// Hiding the current panel, showing the new one
  		$('.showing').removeClass('showing').hide();
  		$target.addClass('showing').show();
  		
  		// Making the current tab inactive, and the new one active
  		$('.tabs .active').removeClass('active');
  		$(this).addClass('active');
  	}
  });
  
  // Hiding the thing to show/hide
  $('.to-hide').hide();
  
  // When clicking the toggle
  $('.show-hide').click(function(e) {
  	e.preventDefault();
  	var target = $(this).attr('href'),
  			$target = $('div' + target);
  			
  	// Checking to see if it's showing already
  	if ( !$target.hasClass('showing') )
  	{
  		// Showing
  		$target.addClass('showing').show();
  	} else {
  		// Hiding
  		$target.removeClass('showing').hide();
  	}
  });

});
