
$(document).ready(function() {
						   
	// MOUSE OVERS					   
	$('.portletsList-caption').css({bottom:-130, opacity: 0.4});
	$('#portletsMiddle span').hover(
		function () {
			$('#portletsList-' + this.id).css({bottom:-0});	
		}, 	
		function () {
			$('#portletsList-' + this.id).css({bottom:-130});	
		}
	);
	
	//  TOP BUTTON
	$("#portletsTop").click(function(){
      movePortlets();
    });
	
	//  BOTTOM BUTTON
	$("#portletsBottom").click(function(){
      movePortlets();
    });
	


	// TIMED ROTATE
	rotatePortlets(3700);

});


function movePortlets() {
	
	
	var portletFirst = $('#portletsMiddle span:first');
	
	var portletHeight = portletFirst.height()
	
	portletFirst.animate({"height": "0px"}, 400, function() { $(this).appendTo('#portletsMiddle').css('height', portletHeight); });	
	
}


function rotatePortlets(speed) {
	
	var timer = setInterval('movePortlets()',speed);
	
	//pause the slideshow on mouse over
	$('#portlets').hover(
		function () {
			clearInterval(timer);
		}, 	
		function () {
			timer = setInterval('movePortlets()',speed);	
		}
	);
	
}

