var num;
var timer;
var cur = 1;


function startRotate(){
	
	var i = 0;
	$('#testimonials').find('div').each(function(){
		i++;
		$(this).attr('ID','testimonial_'+i).css('position','absolute');
	});
	
	num = i;
	
	$('#testimonial_'+cur).hide();
	
	var next_cur = cur;
	
	while(next_cur == cur){
		next_cur = Math.floor(Math.random()*num)+1;
	}
	cur = next_cur;
	
	$('#testimonial_'+cur).show();
	
	
	setInterval("rotateImage()", 5000 );
}

function rotateImage(){
	var cur_im = $('#testimonial_'+cur);
	
	var next_cur = cur;
	
	while(next_cur == cur){
		next_cur = Math.floor(Math.random()*num)+1;
	}
	
	cur = next_cur;
	
	var next_im = $('#testimonial_'+cur);
	
	cur_im.fadeOut(1200);
	next_im.fadeIn(1200);
}


$(document).ready(function() {
	
	$('h3 > a').parent().css('margin-bottom','2px');
	$('.home_box h3').css('margin-bottom','6px');
	
	$('.frontnews:last-child').css('margin-bottom','0');
	
	var m_t = $(".main").height()-$('.menu > ul').height()-100;
	
	if(m_t < 100) m_t = 100;
	
	$("#acl_logo").css('margin-top',m_t);
	
	$('.column_right').height($(".main").height());
	
	$('textarea').autoResize({
		// On resize:
		onResize : function() {
			$(this).css({opacity:0.8});
		},
		// After resize:
		animateCallback : function() {
			$(this).css({opacity:1});
		},
		// Quite slow animation:
		animateDuration : 300,
		// More extra space:
		extraSpace : 20
	});
	
	
	startRotate();
	
});
