$(document).ready(function() {

	// Menu rollovers
	$('.menu li:not(".active") img').hover(
		function() {
			this.src = this.src.replace("-off","-on");
		},
		function() {
			this.src = this.src.replace("-on","-off");
		}
	);
	
	function slideChange(next) {
	    var $active = $('#slider .active');
		var nextIndex = '#slider li:nth-child(' + next + ')';
		var $next =  $(nextIndex);
		
		
	   $active.addClass('last-active');

	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
	        });
	}
	
	$('#buttons li a').click(function() {
		var $active = $('#slider .active');
		var next = $('#buttons li a').index(this);
		if($('#slider li').index($active) == next) {return;}
		next++;
		slideChange(next);
		return false;
	});
	
	$('#scrolldown').mousedown(function() {
		var theHeight = $('.scroll-content').height();
		theHeight = theHeight - $('.scroll').height();
		theHeight = '-' + theHeight + 'px';
		$('.scroll-content').animate({
			top : theHeight
			}, 1000 );
	});
	
	$('#scrollup').mousedown(function() {
		$('.scroll-content').animate({
			top : '0'
			}, 1000 );
	});
	
	$('#scrolldown').mouseup(function() {
		$('.scroll-content').stop();
	});
	
	$('#scrollup').mouseup(function() {
		$('.scroll-content').stop();
	});
	
	$('.clearme').one('focus', function() {
	  $(this).val('');
	});
	
});




