


$(document).ready(function() {
						   	
	//$('#portletsList span:first').addClass('currentportlet');
	
	$('.portletsList-caption').css({bottom:-130, opacity: 0.4});
	
	// MOUSE OVERS	
	$('#portletsCenter span').hover(
		function () {
			$('#portletsList-' + this.id).css({bottom:-0});
			//alert('he');
			//$(this).animate({opacity: 0.9}, 1000);
		}, 	
		function () {
			//$(this).animate({opacity: 1.0}, 1000);
			$('#portletsList-' + this.id).css({bottom:-130});	
		}
	);
	
	//  LEFT BUTTON
	$("#portletsLeft").click(function() {
      moveportlets();
    });

	//  RIGHT BUTTON
	$("#portletsRight").click(function(){
      moveportlets();
    });
	
	// TIMED ROTATE
	rotateportlets(4300);

});


function moveportlets() {
	
	var portletFirst = $('#portletsList span:first');
	
	var portletWidth = portletFirst.width()
	
	portletFirst.animate({"width": "0px"}, 400, function() { $(this).appendTo('#portletsList').css('width', portletWidth); });	

}



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


