jQuery(document).ready(function($) {

	count = $('.sliderPostWrapper').size();
	current = 1;
	timeron = 1;
	moving = 0;
	
	
		$('.sliderContent').animate({
			'opacity' : '0'
		}, 1);
		
		$('.sliderContent:eq(0)').animate({
			'opacity' : '0.8', 
			'top' : '-=100px'
		}, 400);
	
	
	$.timer(4000, function (timer) {
	
		if(timeron == 0) { timer.stop(); }
		
		if(current < count && timeron == 1) {
			moving = 1;
			$('.sliderContent:eq(' + (current-1) + ')').animate({
				'top' : '+=100px', 
				'opacity': '0'
			}, 300, function() {
				current++;
				$('#sliderWrapper').animate({
					"left": "-=525px"
				}, 400, function() {
					$('.sliderContent:eq('+ (current-1) +')').animate({
						'top' : '-=100px', 
						'opacity': '0.8'
					}, 300, function() {
						moving = 0;
					});
				});
			});
		}
		
  	});
	
	
	
	$('.sliderControlLeft').click(function(event) {
		event.preventDefault();

		if(current > 1 && moving == 0) {
				moving = 1;
				$('.sliderContent:eq(' + (current-1) + ')').animate({
					'top' : '+=100px', 
					'opacity': '0'
				}, 300, function() {
					current--;
					$('#sliderWrapper').animate({
						"left": "+=525px"
					}, 400, function() {
						$('.sliderContent:eq('+ (current-1) +')').animate({
							'top' : '-=100px', 
							'opacity': '0.8'
						}, 300, function() {
							moving = 0;
						});
					});
				});
		}
		timeron = 0;
	
	});
	
	$('.sliderControlRight').click(function(event) {
		event.preventDefault();

		if(current < count && moving == 0) {
			moving = 1;
		
				$('.sliderContent:eq(' + (current-1) + ')').animate({
					'top' : '+=100px', 
					'opacity': '0'
				}, 300, function() {
					current++;
					$('#sliderWrapper').animate({
						"left": "-=525px"
					}, 400, function() {
						$('.sliderContent:eq('+ (current-1) +')').animate({
							'top' : '-=100px', 
							'opacity': '0.8'
						}, 300, function() {
							moving = 0;
						});
					});
				});

		}
		timeron = 0;
	
	});

});