	
	function nextNewsItem() {
	
		jQuery.get('rpc/', {}, function(html) {
			
			$('#news').fadeOut('slow', function() {
				$('#news').html(html).fadeIn('slow', function() {
					setTimeout(nextNewsItem, 10000);
				});
			});
			
		});
		
	}

	// DO AS SOON AS POSSIBLE
	jQuery(function($) {

		// start the rotation	
		nextNewsItem();
	
		// make buttons pretty		
		$('button').button({
			icons: {
				primary: "ui-icon-triangle-1-e"
			}
		});
		
	});


	// DO WHEN EVERYTHING LOADED
	jQuery(window).load(function() {

		$ = jQuery;

		// roll out first content		
		$('div#default').fadeIn('slow');
		
		// first fix stuff that requires button's to be visible (because of rollOut()), 
		// functionality stuff last
		$('button')
			.bind('selectstart', function() {
				return false;
			}).bind('mousedown', function() {
				return false;
			}).click(function() {
	
				var $button = $(this).closest('button').toggleClass('selected');
				
				$('button').not($button).removeClass('selected');
				
				$('button')
					.button('option', 'icons', {primary: "ui-icon-triangle-1-e"})
					.filter('.selected')
						.button('option', 'icons', {primary: "ui-icon-triangle-1-s"});
				
				if ($button.attr('rel')) {
	
					$('#content .section').hide();
					
					if ($(this).is('.selected'))
						$($(this).attr('rel')).fadeIn('slow');
					else
						$('#content #default').fadeIn('slow');
	
				} else if ($button.next().is('ul')) {
				
					// toggle this lists sliding
					$('#content ul:visible').add($button.next(':hidden')).animate(
						{ 
							height: 'toggle', 
							opacity: 'toggle' 
						}, 
						"normal"
					);
				}
			
			});

	});

