Cufon.replace('.box h2, #content h2, .side-box h2', { fontFamily: 'GothamMedium' });
Cufon.replace('#navigation ul li a', { fontFamily: 'GothamMedium', hover: true });
Cufon.replace('.slide-nav ul li a', { hover: true, textShadow:'1px 1px 1px #4487ac' });


$(document).ready(function(){

	$('.side-box ul:first').addClass('links-list');
	$('#navigation li:last-child').addClass('last');

	$('#slider li a').hover(function() {
		var elem = $(this);
		if (elem.hasClass('active')) {
			// Do nothing
		} else {
    		$(this).find('a').stop().animate({'left':10}, 350, 'easeOutQuart');
    	}
    }, function() {
    	var elem = $(this);
    	if (elem.hasClass('active')) {
			// Do nothing
		} else {
    		$(this).find('a').stop().animate({'left':0}, 350, 'easeOutQuart');
    	}
    });
    
    var sliderButtons = $('#slider li a');
    var sliderArea = $('.slide-cnt');
    var currentSlide = 1;
    
    sliderButtons.click(function(){
    	var buttonIndex = sliderButtons.index(this);
    	sliderButtons.removeClass('active');
    	$(this).addClass('active');
    	slideTo = buttonIndex * 250;
    	currentSlide = buttonIndex + 1;
    	sliderArea.find('.slider-panel').stop().animate({'top':'-'+slideTo+'px'},800,'easeInOutExpo');
    });
    
    $('h1#logo a').hover(function() {  
		$('a.back-home').stop().animate({'width': 110}, 300,'easeInOutExpo', function(){ $(this).show(); });
	}, function() {  
		$('a.back-home').stop().animate({'width': 1}, 300, 'easeInOutExpo', function(){ $(this).hide(); });
	});
	
	
	function move_to_next(){
	
		if (currentSlide == 3){
			sliderButtons.removeClass('active');
    		$('#slider li a:first').addClass('active');
			sliderArea.find('.slider-panel').stop().animate({'top':0},800,'easeInOutExpo');
			currentSlide = 0;
		} else {
			currentSlide = currentSlide + 1;
			slideToSlide = currentSlide - 1;
			slideTo = slideToSlide * 250;
			sliderArea.find('.slider-panel').stop().animate({'top':'-'+slideTo+'px'},800,'easeInOutExpo');
			sliderButtons.removeClass('active');
    		$('#slider li a').eq(slideToSlide).addClass('active');
		}
		
	}
	
	// START AUTO-ROTATE CODE
	var timer;
  	var donext = function (x){ move_to_next(); }
  
  	var dotimer = function (){
    	if(timer != null) {
      		clearInterval(timer);
    	}
  
    	timer = setInterval(function() {
      		donext();
    	}, 8000); // Change the time in between rotations here (in milliseconds)   
  	}
  
  	dotimer();
  	
  	sliderButtons.hover(function(){
  		clearInterval(timer);
  	},function(){
  		dotimer();
  	});
  	// END AUTO-ROTATE CODE

});
