
	load_musicplayer();	
	var scrollbox = $('#scrollbox').get(0); 
	var scrolltext = $('#tracktext').get(0);
	var scrollinterval = (typeof scrollinterval!="undefined") ? scrollinterval : null;
	
	if (typeof soundscape.writeflashtag.written !="undefined")
	if (soundscape.playlist.currenttrack)
	if (soundscape.playlist.isTrackPlaying()) {
		$('.showcontrols').fadeIn(); 
		$('.play_btn').hide();
		$('.pause_btn').show();
		var track = soundscape.playlist.currenttrack;
		$(scrolltext).html("Track "+track.track+" - "+track.title+" - Album: "+track.album+" (2008)");
		$('div.showhidetext').show('slow',function() { 
			scrollinterval = scroll({ delay:20, obj:scrollbox, interval:scrollinterval })
		});
	} else {
		$('.showcontrols').fadeIn(); 		
	}
	
	function load_musicplayer() {
		

		if (typeof load_musicplayer.loaded != "undefined") return;
		
		soundscape.playlist.setTrackList
		([
			{ album:'My Name Is Amos', track:'01', title:'Far Away', path:'music/01 Far Away.mp3' },
			{ album:'My Name Is Amos', track:'02', title:'My Name Is Amos', path:'music/02 My Name Is Amos.mp3' },
			{ album:'My Name Is Amos', track:'03', title:'Quebec', path:'music/03 Quebec.mp3' },
			{ album:'My Name Is Amos', track:'04', title:'Give it up', path:'music/04 Give it up.mp3' },
			{ album:'My Name Is Amos', track:'05', title:'Montreal', path:'music/05 Montreal.mp3' },
			{ album:'My Name Is Amos', track:'06', title:'Slacking', path:'music/06 Slacking.mp3' },
			{ album:'My Name Is Amos', track:'07', title:'Where do I go', path:'music/07 Where do I go.mp3' },
			{ album:'My Name Is Amos', track:'08', title:'Better than that', path:'music/08 Better than that.mp3' },
			{ album:'My Name Is Amos', track:'09', title:'Tell me', path:'music/09 Tell me.mp3' },
			{ album:'My Name Is Amos', track:'10', title:'Message on your answering machine', path:'music/10 Message on your answering machine.mp3' },
		]);	
		
		soundscape.protected.engineLoadedEventListeners.push(function(src) {
			timeout(function() { 
				timeout(function() { play_btn_onclick(); }, 1000); 
				if (!document.getElementById('nav')) return;
				$('.showcontrols').fadeIn(); 
			}, 7000);
		});
		soundscape.protected.soundStartEventListeners.push(function(src) {
			if (!document.getElementById('nav')) return;
			var track = soundscape.playlist.currenttrack;
			$(scrolltext).html("Track "+track.track+" - "+track.title+" - Album: "+track.album+" (2008)");
			$('.play_btn').hide();
			$('.pause_btn').show();
		});
		soundscape.protected.soundUnpauseEventListeners.push(function() {
			if (!document.getElementById('nav')) return;
			$('.play_btn').hide();
			$('.pause_btn').show();
		});
		soundscape.protected.soundPauseEventListeners.push(function() {
			if (!document.getElementById('nav')) return;
			$('.play_btn').show();	
			$('.pause_btn').hide();
		});
		soundscape.protected.soundStopEventListeners.push(function(src) {
			if (!document.getElementById('nav')) return;
			$('.play_btn').show();
			$('.pause_btn').hide();
		});
		soundscape.protected.soundFinishedEventListeners.push(function() {
			var track = soundscape.playlist.currenttrack;
			var lasttrack = soundscape.playlist.tracklist[soundscape.playlist.tracklist.length-1]
			if (track==lasttrack) {
				clearInterval(scrollinterval);				
				$('div.showhidetext').hide('slow');
				timeout(function() {
					scrolltext.style.left = "0px";		
					var firsttrack = soundscape.playlist.tracklist[0];
					soundscape.playlist.setCurrentTrack(firsttrack);
					soundscape.playlist.stopTrack();
				},1000);
			}
			if (!document.getElementById('nav')) return;			
			$('.play_btn').show();
			$('.pause_btn').hide();
		});
		soundscape.writeflashtag();	
	}


	function play_btn_onclick() {
		soundscape.playlist.playPauseTrack();
		if (!document.getElementById('nav')) return;
		$('.play_btn').blur();
		var track = soundscape.playlist.currenttrack;
		$(scrolltext).html("Track "+track.track+" - "+track.title+" - Album: "+track.album+" (2008)");
		$('div.showhidetext').show('slow', function() {
			idle(function() { 
				scrollinterval = scroll({ delay:20, obj:scrollbox, interval:scrollinterval })
			},500);
		});
	}
	function pause_btn_onclick() {
		$('.pause_btn').blur();
		soundscape.playlist.playPauseTrack();
		clearInterval(scrollinterval);
		$('div.showhidetext').hide('slow');
	}
	function next_btn_onclick() {
		$('.next_btn').blur();
		soundscape.playlist.playNextTrack();
		var track = soundscape.playlist.currenttrack;
		$(scrolltext).html("Track "+track.track+" - "+track.title+" - Album: "+track.album+" (2008)");
		scrolltext.style.left = "0px";		
		$('div.showhidetext').show('slow', function() {	
			clearInterval(scrollinterval);
			idle(function() { 
				scrollinterval = scroll({ delay:20, obj:scrollbox, interval:scrollinterval })
			},500);
		});
	}
	function prev_btn_onclick() {
		$('.prev_btn').blur();
		soundscape.playlist.playPrevTrack();
		var track = soundscape.playlist.currenttrack;
		$(scrolltext).html("Track "+track.track+" - "+track.title+" - Album: "+track.album+" (2008)");
		scrolltext.style.left = "0px";		
		$('div.showhidetext').show('slow', function() {	
			clearInterval(scrollinterval);
			idle(function() { 
				scrollinterval = scroll({ delay:20, obj:scrollbox, interval:scrollinterval })
			},500);
		});
	}	
	function scroll(vars) {
		if (vars.interval) clearInterval(vars.interval);
		if (window.location.hash=="#page-gallery.php" || window.location.hash=="#fr-page-gallery.php") { return; } // lindsay added
		var parent = vars.obj; 
		parent.style.position = "relative";
		parent.style.overflow = "hidden";		
		var obj = vars.obj.firstChild;
		if (obj.nodeType==3) obj = obj.nextSibling;
		obj.style.position = "relative";
		if (!obj.style.left ) obj.style.left = parent.offsetWidth+"px";

		return interval(function(){
			objwidth = obj.offsetWidth; 
			objleft = parseInt(obj.style.left);
			if (objwidth + objleft < 0) {
				obj.style.left = parent.offsetWidth+"px"
			} else {
				obj.style.left = (objleft-1)+"px"	
			}
		}, vars.delay);	
	}
/*	function interval(func,delay) {
		// init
		if (typeof _interval == "undefined") _interval = {};		
		if (typeof _interval.count == "undefined") _interval.count = 0; 	
		if (typeof _interval.funcs == "undefined") _interval.funcs = new Array(); 
		// set interval
		if (typeof func =='string') return setInterval(func, delay); 
		if (typeof func =='function') {
			_interval.count++;
			_interval.funcs[_interval.count] = func;
			return setInterval("_interval.funcs['"+_interval.count+"']();", delay);
		}
	}
	function idle(func,delay) {
		// init
		if (typeof _idle == "undefined") _idle = {};		
		if (typeof _idle.lasttimeout == "undefined") _idle.lasttimeout = null;
		if (typeof _idle.lastfunc == "undefined") _idle.lastfunc = null;
		// set idle timeout
		if (_idle.timeout) { clearTimeout(_idle.timeout); _idle.timeout = null; _idle.lastfunc = null; }
		if (typeof(func)=='string') { 
			_idle.timeout = setTimeout(func, delay); 
			return _idle.timeout;
		}		
		if (typeof(func)=='function') { 
			_idle.lastfunc = func;
			_idle.timeout = setTimeout("_idle.lastfunc();", delay);
			return _idle.timeout;
		}
	}*/
