Event.observe( document, 'dom:loaded', setupPage );

function setupPage() {

//	alert( 'setupPage' );

	$$('#Content #Navigation li').each(function(el){
		var thisID = el.identify().substring( 2 );
		var liel = $( "li"+thisID );
		liel.update( "<span>"+thisID+"</span>");
		liel.observe('click', function(event) {
			setNav( thisID );
		});
	});

	setNav( "Overview" );
}

function setNav( towhat ) {
//	alert( towhat );

//	$$('#Content #Navigation li').removeClassName( "liselected" );
//	$$('#Content #Navigation li').addClassName( "liselected" );

	$$('#Content #Navigation li').each(function(el){
		var thisID = el.identify().substring( 2 );
		if ( thisID == towhat ) {
			el.addClassName( "liselected" );
			$( thisID ).show();
		} else {
			el.removeClassName( "liselected" );
			$( thisID ).hide();
		}
	});
	
	if ( towhat != "Videos" ) {
		$('BusyVideo').update( '<img src="http://files.stairways.com/aragom-img/busy-movie.png" alt="Busy Movie" width="480" height="335" />' );
		$('BusyVideo').observe('click', function(event) {
			playVideo( 'BusyVideo' );
		});
	}
	
	return true;
}

function playVideo( what ) {

	$('BusyVideo').stopObserving('click');
	$('BusyVideo').update( 
				'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="480" ' +
				'height="335" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> ' +
				'<param name="src" value="http://files.stairways.com/movies/aragom/busy.mov" /> ' +
				'<param name="autoplay" value="true" /> ' +
				'<param name="controller" value="true" /> ' +
				'<param name="loop" value="false" /> ' +
				'<embed src="http://files.stairways.com/movies/aragom/busy.mov" width="480" height="335" autoplay="true" ' +
				'controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/" /> ' +
				'</object>'
	);
	
	return true;
}

