////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Functions that call similar ones in the top frame - this just passes up our "commands"
//	To the Flash navigation / SWFAddress element..
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 *	selectPage allows you to pass an <a> obj to the parent element in order to select a new page.
 *	this object needs a rel attribute to work properly..
 *	Use to navigate pages and get Flash to keep up...
 *	e.g.	<a href="./music.html" onClick="return selectPage(obj)" rel="/music">Music</a>
 *	The rel attribute needs to be formatted /toplevel/sublevel/subsublevel/ etc. with a trailing  
 * slash.
 */
function selectPage(obj) {
	//alert("selectPage " + obj.rel);
	return top.selectPage(obj);
}
/**
 *	selectTrack allows you to pass an <a> obj to the parent element in order to select a music track
 *	this object needs a href attribute with a path to the music file to work properly.
 *	Use to tell Flash to play a music track
 *	e.g.	<a href="./mp3s/track1.mp3" onClick="return selectTrack(obj)">Play</a>
 *	The href attribute needs to point towards an mp3 file.
 */
function selectTrack(obj) {
	top.flashSelectTrack(obj.href, obj.title);
	return false;
}
/**
 *	Use to tell Flash to stop any music playing.
 */
function stopMusic() {
	top.flashStopMusic();
	return false;
}
/**
 *	Use to tell Flash to resume playing the selected music track (if no track is selected), you will
 *	get any ambient sounds that are used..
 */
function playMusic() {
	top.flashPlayMusic();
	return false;
}
/**
 *	Use to tell Flash to mute audio.
 */
function mute() {
	top.flashMute();
	return false;
}
/**
 *	Use to tell Flash to unmute audio.
 */
function unmute() {
	top.flashUnmute();
	return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Functions to keep track of the JWPlayer state - if you play a video, this will tell Flash
//	to stop playing any audio / music...
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 *	Use to respond to state changes in the JWPlayer instance.
 */
function stateTracker(obj)
{
	//alert("state tracker " + obj + " state " + obj['newstate']);
	if('BUFFERING' == obj['newstate']) {
			stopMusic();
	} else if('COMPLETED' == obj['newstate']) {
			playMusic();
	}
}
/**
 *	a global "player" object that we keep track of JWPlayer in.
 */
var player;
/**
 *	If you configure JWPlayer correctly, this will get called when the player is instanciated
 *  Here, you can add any listeners to it..
 */
function playerReady(obj) {
	var id = obj['id'];
	var version = obj['version'];
	var client = obj['client'];
	//alert('the videoplayer '+id+' has been instantiated');
	player = document.getElementById(id);
	
	player.addModelListener('STATE', 'stateTracker');
}
/**
 *	Helper function - if you need to talk to the JWPlayer or any other Flash movie.
 */
function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
}

function resetScroll() {
	//alert("resetScroll iframe " + top + " parent " + parent);
	parent.resetScroll();
}
/*
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(resetScroll);
*/