
Event.observe(window, 'load', function() {

	// if on home page  null the refs
	if(isHomePage()) {
	
		$('nav_home').href='#';
		$('nav_news').href='#';
		$('nav_biog').href='#';
		$('nav_gallery').href='#';
		$('nav_shop').href='#';
		$('nav_links').href='#';
		$('nav_contact').href='#';
		
	// setup fx
		Event.observe('nav_home', 'click', function() { Effect.Shake('nav_home');getPage('home') });		   
		Event.observe('nav_news', 'click', function() { Effect.Shake('nav_news');getPage('news') });
		Event.observe('nav_biog', 'click', function() { Effect.Shake('nav_biog');getPage('biog') });		
		Event.observe('nav_gallery', 'click', function() { Effect.Shake('nav_gallery');getPage('gallery') } );		
		Event.observe('nav_shop', 'click', function() { Effect.Shake('nav_shop');getPage('shop') });		
		Event.observe('nav_links', 'click', function() { Effect.Shake('nav_links');getPage('links') });		
		Event.observe('nav_contact', 'click', function() { Effect.Shake('nav_contact');getPage('contact') });	
	
	} else {
	// null the mplayer
		//$('musicplayer').innerHTML='';
	// alter the lower page refs
		$('nav_news').href='easy-orchestra.html?news';
		$('nav_biog').href='easy-orchestra.html?biog';
		$('nav_gallery').href='easy-orchestra.html?gallery';
		$('nav_shop').href='easy-orchestra.html?shop';
		$('nav_links').href='easy-orchestra.html?links';
		$('nav_contact').href='easy-orchestra.html?contact';

	}

checkLayout();
Event.observe(window, 'resize', function() {
$('maincontent').style.visibility='hidden';
setTimeout(checkLayout,50);
});

});
// end onload 


///////////// utilities ///////////////
var currentMovieHeight='525'; // 

function checkLayout() {
// resize movie to fit in container
var minH=200; // minimum movie height
var baseH=525; // actual movie height
var setH=baseH;
var movH=$('easymovie').getHeight();
var conH=$('maincontent').getHeight();
if(movH>conH || conH<baseH) { setH=conH; } 
$('easymovie').style.height=setH+'px';
$('maincontent').style.visibility='visible';
currentMovieHeight=setH;
}

function getSubID() {
var p='home'; // default
// if page str is in location then load flash movie 
var loc=location.href;
	if(loc.include("news")) { p='news';
	} else if (loc.include("biog")) { p='biog';
	} else if (loc.include("gallery")) { p='gallery';
	} else if (loc.include("shop")) { p='shop';
	} else if (loc.include("links")) { p='links';
	} else if (loc.include("contact")) { p='contact';
	}		
return p;
}



function getPage(page) {
	// loads the flash page content (without browser reload)
	loadFlashContent(page);
}

// record if jukebox already loaded
var jukeboxLoaded=false;


function loadFlashContent(id) {
var movH=currentMovieHeight;
var so = new SWFObject("_swf/easymovie.swf", "easymovie", "900", movH, "8", "#FFFFFF");
so.addVariable("sub", id);
so.useExpressInstall('_swf/swfobject/expressinstall.swf');
so.addParam("wmode", "transparent");
so.addParam("scale", "exactfit");
so.write("flashcontent");
	// jukebox
	if(jukeboxLoaded==false) {
	var so = new SWFObject("_swf/easyjuke.swf", "easyjuke", "210", "100", "8", "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.addParam("scale", "exactfit");
	so.write("musicplayer");
	jukeboxLoaded=true;
	}
}


function isHomePage()  {
var lo=location.href;
	if(lo.include('easy-orchestra.html') || lo.endsWith('/') || lo.endsWith('com') || lo.endsWith('#')) {
		return true;
	}
return false;
}


