$(document).ready(function() {

	var arc_params = {
		center: [-47,-32],
		radius: 55,
		start: 135,
		end: 495,
		dir: 1
	};
	function enCircle() {
		$('#cCircle').animate({path : new $.path.arc(arc_params)}, 3000, enCircle);
	}

	enCircle();
	
	var reasonIndex = 0;
	
	function fadeOutReason() {
		$('.reasonBox:eq(' + reasonIndex + ')').fadeOut('slow', fadeInReason);
	}
	
	function fadeInReason() {
		if (reasonIndex == 9) {
			reasonIndex = 0;
		} else {
			reasonIndex = reasonIndex + 1;
		}
		$('.reasonBox:eq(' + reasonIndex + ')').fadeIn('slow');
	}

	window.setInterval(fadeOutReason, 5000);

	$(".reasonBox").click(function() {
		$.prettyPhoto.open('http://ensoatl.com/wp-content/uploads/2010/07/topten.png','Top Ten');
	});

	window.setInterval(function() {
		$('.change1:hidden:first').show('slow');
		$('.change1:first').hide('slow', function() {
			$('.change1:first').insertAfter($('.change1:visible:last'));
		});
		
		$('.change2:hidden:first').show('slow');
		$('.change2:first').hide('slow', function() {
			$('.change2:first').insertAfter($('.change2:visible:last'));
		});
		
		$('.change3:hidden:first').show('slow');
		$('.change3:first').hide('slow', function() {
			$('.change3:first').insertAfter($('.change3:visible:last'));
		});
	}, 10000);
	
	$('.upbutton').click(function() {
		$('#picColumn1 .picBox:eq(3)').show('normal');
		$('#picColumn1 .picBox:eq(0)').hide('normal', function() {
			$('#picColumn1 .picBox:eq(0)').insertAfter($('#picColumn1 .picBox:last'));
		});
		
		$('#picColumn2 .picBox:eq(3)').show('normal');
		$('#picColumn2 .picBox:eq(0)').hide('normal', function() {
			$('#picColumn2 .picBox:eq(0)').insertAfter($('#picColumn2 .picBox:last'));
		});
		
		$('#picColumn3 .picBox:eq(3)').show('normal');
		$('#picColumn3 .picBox:eq(0)').hide('normal', function() {
			$('#picColumn3 .picBox:eq(0)').insertAfter($('#picColumn3 .picBox:last'));
		});
	});
	
	$('.downbutton').click(function() {
		$('#picColumn1 .picBox:last').insertBefore($('#picColumn1 .picBox:first'));
		$('#picColumn1 .picBox:first').show('normal');
		$('#picColumn1 .picBox:eq(3)').hide('normal');
		
		$('#picColumn2 .picBox:last').insertBefore($('#picColumn2 .picBox:first'));
		$('#picColumn2 .picBox:first').show('normal');
		$('#picColumn2 .picBox:eq(3)').hide('normal');
		
		$('#picColumn3 .picBox:last').insertBefore($('#picColumn3 .picBox:first'));
		$('#picColumn3 .picBox:first').show('normal');
		$('#picColumn3 .picBox:eq(3)').hide('normal');
	});
	
	$(".hoverBox").hover(function() {
		$(this).toggleClass("active");
	});
	
	$(".greenBox").click(function() {
		$(this).next(".greenHidden").slideToggle("normal");
		
		return false;
	});
	
	$(".greenSubMenu").click(function() {
		$(this).next(".subGreenHidden").slideToggle("normal");
		return false;
	});

});
