//important messages carousel js

function createStaticCarousel(){
	window.addEvent("domready", function() {
		
		staticCarousel();
	});
}

function createDynamicCarousel(){
	window.addEvent("domready", function() {
		generalInit();
		
		dynamicCarousel();
	});
}

function generalInit(){
	//trim whitespace
	$('important_messages_content').getElements('li').each(function(el){
		var trimmed_content = trim(el.innerHTML);
		el.innerHTML = trimmed_content;
	});
	
	
	function trim(str_trim){
		return str_trim.replace(/^\s*|\s*$/g,'');
	}

	
	//hide empty divs
	var empty_messages = $('important_messages_content').getElements(':empty');
	
	if(empty_messages != null){
		empty_messages.each(function(el){
			el.removeClass('imp_msg');
			el.dispose();
		});
	}
}

function staticCarousel(){
	//init carousel
	new iCarousel("important_messages_content", {
		idPrevious: "imp_message_left",
		idNext: "imp_message_right",
		idToggle: "undefined",
		item: {
			klass: "imp_msg",
			size: 586
		},
		animation: {
			duration: 500,
			amount: 1		
		}		
	});
}

function dynamicCarousel(){
	//init carousel
	new iCarousel("important_messages_content", {
		idPrevious: "imp_message_left",
		idNext: "imp_message_right",
		idToggle: "undefined",
		item: {
			klass: "imp_msg",
			size: 586
		},
		animation: {
			duration: 500,
			amount: 1,
			rotate:{  
				type: "auto",
				interval: "6000",
				onMouseOver: "stop"
			}
		}		
	});
}