$(function(){
	
	/*DROPDOWN MENU*/

	$('#navbar a.top').mouseover(function (){
		$('#navbar .sub').hide();
		$(this).next('.sub').show();
	});
	
	$('#navbar a.top').mouseout(function (){
		$(this).next('.sub').hide();
	});

	$('#navbar .sub').mouseover(function (){
		$(this).show();
	});
	
	$('#navbar .sub').mouseout(function (){
		$(this).hide();
	});
	
	
	
	$('#openhiddentext').click(function (){$('#hiddentext').toggle()});
	
	initquote ();
	
	function initquote () {
		var $this_li = $('#rotator_qu li:first')
		$this_li .fadeIn (1000);
		var height = $this_li .height();
		$('#banner_qu, #rotator_qu').animate({'height':height});
	}
	
	$('#quotelink').click(function swapquote () {
		var $this_li = $('#rotator_qu li:visible');
		var $next_li = $this_li.next('li').length ? $this_li.next('li') : $('#rotator_qu li:first');
		
		$this_li.fadeOut (1000);
		$next_li.fadeIn (1000);
		var height = $next_li.height();
		$('#banner_qu, #rotator_qu').animate({'height':height});
		return false;
	})

	init_rotator();
	
	function init_rotator() {
		if (!$('#rotator').length) {return;}
		var speed = 3000;
	
		function rotate(element) {
			var $next_li = $(element).next('li').length ? $(element).next('li') : $('#rotator li:first');
			function doIt() {rotate($next_li);}
			$(element).fadeOut(speed);
			$($next_li).fadeIn(speed, function() {setTimeout(doIt, speed);});
		}
	
		$('#rotator li:first').show();
		$(window).load(function() {	rotate($('#rotator li:visible:first'));	});
	}
})

