///////////////////// swfPlayerGobalFunctions /////////////////////

var swfFormFixStatus = false;
var swfFormFixDelay = 0;

swfPlayerSetFormFixStatus = function () {
	clearInterval(swfFormFixDelay);
	swfFormFixStatus = true;
}

swfPlayerCheckFormFixStatus = function () {
	return swfFormFixStatus;
}

/////////////////////////// end ////////////////////////


///////////////////// swfPlayerControl /////////////////////

function swfPlayerControl(){}

var _this = swfPlayerControl.prototype = new Object();

_this.constructor			= swfPlayerControl;

_this.className = "swfPlayerControl";

_this.browser = "";

_this.aSwfControls = [];
_this.aSwfPlayerName = [];
_this.aSwfControlStatus = [];

_this.init = function () {

	if (navigator.appName.indexOf("Microsoft") != -1) {
		// IE
		this.browser = "IE";
	} else {
		// FireFox
		this.browser = "FF";
	}
	
}

_this.addSwfControl = function (cControl, cPlayer) {
	this.aSwfControls.push(cControl);
	this.aSwfPlayerName.push(cPlayer);
	this.aSwfControlStatus.push(false);
}

_this.swfFormFixInit = function (cControl) {
	var lOk = true;	
	for (nIndex = 0; nIndex <= this.aSwfControls.length - 1; nIndex = nIndex + 1) {
		if (this.aSwfControls[nIndex] == cControl) {
			this.aSwfControlStatus[nIndex] = true;	
		}
	}
	for (nIndex = 0; nIndex <= this.aSwfControls.length - 1; nIndex = nIndex + 1) {
		if (!this.aSwfControlStatus[nIndex]) {
			lOk = false;
		}			
	}
	if (lOk) {
		//  All form fix requests received
		this.swfFormFixProcessing();
	}
}

_this.swfFormFixProcessing = function(aSwfPlayers) {
	swfFormFixDelay = setInterval( function () {swfPlayerSetFormFixStatus()}, 200);
	if (this.browser == "IE") {
		SWFFormFix(this.aSwfPlayerName[this.aSwfPlayerName.length - 1]);
	}
}			

_this.swfBrowser = function () {
	return this.browser;
}

/////////////////////////// end ////////////////////////


///////////////////// InstallSwf ///////////////

function InstallSwf(){}

var _this = InstallSwf.prototype = new Object();

_this.constructor	= InstallSwf;

_this.className = "InstallSwf";

_this.name;
_this.parent;
_this.version;

_this.playerVersion;
_this.majorVersion;
_this.minorVersion;
_this.releaseVersion;
_this.message;
_this.playerDiv;
_this.minimumMajor;
_this.requiredMajor;
_this.requiredMinor;
_this.requiredRelease;

_this.init = function (cName, aPlayer, cXmlData, cXmlContent) {
	this.playerDiv = aPlayer[0];
	this.version = true;
	this.playerVersion 		= swfobject.getFlashPlayerVersion(); 
	this.majorVersion 		= this.playerVersion.major;
	this.minorVersion 		= this.playerVersion.minor;
	this.releaseVersion 	= this.playerVersion.release;	
	this.minimumMajor     = "9";
	this.requiredMajor 		= "9";
	this.requiredMinor    = "0";
	this.requiredRelease  = "115";

	if (this.majorVersion < this.minimumMajor) {
		this.message = '<p>You have Adobe Flash Player Version ' + this.majorVersion + '.' + this.minorVersion + '.' + this.releaseVersion + '.0 installed.</p>'
		this.message = this.message + '<p>The slideshows, sound tracks and Videos on this website require the use of Adobe Flash Player Version 9 or higher.</p>';
		this.message = this.message + '<br><br><br><br><br><br>'
		this.message = this.message + 'Please click on the button below to update your Flash Player from the Adobe website: -</p><br>'
		this.message = this.message + '<p><a style="position:absolute; float:left; top:240px; left:220px;" href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>'		
		document.getElementById(this.playerDiv).style.display='block';
		document.getElementById(this.playerDiv).innerHTML  = this.message	
		this.version = false;
	} else {
		if (this.majorVersion == this.requiredMajor) {
			if (this.releaseVersion < this.requiredRelease) {
				this.message = '<p>You have Adobe Flash Player Version ' + this.majorVersion + '.' + this.minorVersion + '.' + this.releaseVersion + '.0 installed.'
				this.message = this.message + '  Versions of Adobe Flash Player Version ' + this.requiredMajor + ' less than '  + this.requiredMajor + '.' + this.requiredMinor + '.' + this.requiredRelease + '.0'
				this.message = this.message + ' are known to contain bugs that may cause some aspects of this website to not function correctly.</p>';
				this.message = this.message + 'Please click on the "Enter Website" below to enter the website, or click on the "Get Adobe Flash Player" button to update your Flash Player: -</p><br>'	
				this.message = this.message + '<a onclick="BypassFlashUpdate()" style="position:absolute; float:left; top:170px; left:10px;" href="#"><img src="images/enterbutton.png" style="border:0px;" alt="Enter Website" /></a>'
				this.message = this.message + '<a style="position:absolute; float:left; top:170px; right:10px;" href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" style="border:0px;" alt="Get Adobe Flash player" /></a>'	
				this.message = this.message + '<br><br><br><p>If you choose to enter the website directly, please be aware that it may not run correctly, in which case please re-enter and download the Flash update.</p>'				
				document.getElementById(this.playerDiv).style.display='block';
				document.getElementById(this.playerDiv).innerHTML  = this.message
				this.version = false;
			}
		}
	}
}

_this.hide = function () {
	document.getElementById(this.playerDiv).style.display='none';		
}

_this.loaded = function () {
	return this.version;	
}

///////////////////// end ////////////////////////


///////////////////// videoControl ///////////////

function videoControl(){}

var _this = videoControl.prototype = new swfPlayerControl();

_this.constructor	= videoControl;

_this.className = "videoControl";

_this.name;
_this.parent;
_this.oPlayer;
_this.playerName;
_this.playerElement;
_this.playerDiv; 
_this.playerRootUrl;
_this.playerUrl; 
_this.playerWidth; 
_this.playerHeight; 
_this.playerVersion; 
_this.playerBackground; 

_this.loaded;
_this.formFix;

_this.delay;

_this.xmlData;
_this.xmlContent;

_this.init = function (cName, aPlayer, cXmlData, cXmlContent) {
	
	swfPlayerControl.prototype.init.call(this, cName) 

	this.name = cName;
				
	this.loaded = false;

	if (aPlayer[1].substr(aPlayer[1].length - 1, 1) == "/") {
		this.playerRootUrl = aPlayer[1];	
	} else {
		this.playerRootUrl = aPlayer[1] + "/";		
	}

	this.setPlayer(aPlayer);

	this.xmlData 		= cXmlData;
	this.xmlContent = cXmlContent;
	
	this.instantiate();
	
}

_this.swfInit = function () {
	this.playerElement.swfInit(this.xmlData, this.xmlContent);			
}

_this.swfStart = function () {
	var self = this;
	if (this.loaded) {
		this.playerElement.swfStart();	
	} else {
		this.delay = setInterval( function () {self.delayedStart()}, 50); 
	}	
}

_this.delayedStart = function () {
	if (this.loaded) {
		this.playerElement.swfStart();	
		clearInterval(this.delay);
	}
}

_this.swfDeletePlayer = function () {	
	if (this.playerElement) {
		this.playerElement.swfReset();
	}
	swfobject.removeSWF(this.playerDiv);
	delete this.oPlayer;
}

_this.swfStop = function () {
	if (this.loaded) {
		this.playerElement.swfStop();
	}
}

_this.swfPauseResume	= function () {
	if (this.loaded) {
		this.playerElement.swfPauseResumeVideo();
	}
}

_this.swfMute = function () {
	if (this.loaded) {
		this.playerElement.swfMutePlaySound();
	}
}

_this.swfVolume = function (nVolume) {
	if (this.loaded) {
		this.playerElement.swfVolume(nVolume);
	}
}

_this.setPlayer = function (aPlayer) {
		
	this.playerDiv 					= aPlayer[0];
	this.playerUrl 					= this.playerRootUrl + aPlayer[2];
	this.playerWidth 				= aPlayer[3];
	this.playerHeight 			= aPlayer[4];
	this.playerVersion 			= aPlayer[5];
	this.playerBackground 	= aPlayer[6];

	this.playerName = "";
	var cTemp = this.playerUrl.toLowerCase();

	var aParts = cTemp.split("/");
	var cName = aParts[aParts.length - 1].replace(".swf", "");
	if ( typeof top[cName] == "undefined") {
		top[cName] = 0;
	}
	top[cName] = top[cName] + 1;
	this.playerName = cName + top[cName];
}

_this.instantiate = function ( ) {
		
	var swfVariables 		= {swfCallBack:this.name + ".swfStatus"};
	var swfParameters 	= {wmode:"transparent"};
	var swfAttributes 	= {id:this.playerName, name:this.playerName};
	var swfInstall			= "";
	swfobject.embedSWF(this.playerUrl + "?rnd=" + (new Date()).getTime().toString(), this.playerDiv, this.playerWidth, this.playerHeight, this.playerVersion, swfInstall, swfVariables, swfParameters, swfAttributes);
	
}

_this.swfStatus = function(cStatus) {
	switch(cStatus) {	
		case "Movie:Loaded":	
 			this.playerElement = document.getElementById(this.playerName);		
 			this.swfFormFixInit();	
			break;
		default:
			break;
	}
	this.parent.swfStatus(this.name, cStatus);
}

_this.swfFormFixInit = function () {
	var self = this; 	
	this.formFix = setInterval( function () {self.waitingFormFix()}, 50); 
	this.addSwfControl(this.name, this.playerName);
	swfPlayerControl.prototype.swfFormFixInit.call(this, this.name);
}

_this.waitingFormFix = function () {
	var self = this; 	
	if (swfPlayerCheckFormFixStatus()) {
		clearInterval(this.formFix);
		this.loaded = true;
		this.swfInit();
		// this.parent.swfStatus(this.name,"SwfFormFixed");
	}	
}

///////////////////// end ////////////////////////


///////////////////// slideshowControl /////////////////////

function slideshowControl(){}

var _this = slideshowControl.prototype = new swfPlayerControl();

_this.constructor = slideshowControl;

_this.className = "slideshowControl";

_this.name;
_this.parent;
_this.oPlayer;
_this.playerName;
_this.playerElement;
_this.playerDiv; 
_this.playerRootUrl;
_this.playerUrl; 
_this.playerWidth; 
_this.playerHeight; 
_this.playerVersion; 
_this.playerBackground; 

_this.slideshowStatus;

_this.loaded;
_this.formFix;

_this.delay;

_this.xmlData;
_this.xmlContent;

_this.init = function (cName, aPlayer, cXmlData, cXmlContent) {
		
	swfPlayerControl.prototype.init.call(this, cName) 
	
	this.name = cName;
			
	this.loaded = false;		
	
	this.slideshowStatus = "Initial";
		
	if (aPlayer[1].substr(aPlayer[1].length - 1, 1) == "/") {
		this.playerRootUrl = aPlayer[1];	
	} else {
		this.playerRootUrl = aPlayer[1] + "/";		
	}

	this.setPlayer(aPlayer);

	this.xmlData 		= cXmlData;
	this.xmlContent = cXmlContent;
	
	this.instantiate();
		
}	

_this.swfInit = function () {
	this.playerElement.swfInit(this.xmlData, this.xmlContent);			
}

_this.swfStart = function () {
	var self = this;
	if (this.loaded) {
		this.playerElement.swfStart();	
	} else {
		this.delay = setInterval( function () {self.delayedStart()}, 50); 
	}	
}

_this.delayedStart = function () {
	if (this.loaded) {
		clearInterval(this.delay);
		this.playerElement.swfStart();
	}
}

_this.swfDeletePlayer = function () {	
	if (this.playerElement) {
		this.playerElement.swfReset();
	}
	swfobject.removeSWF(this.playerDiv);
	delete this.oPlayer;
}

_this.swfStop = function () {	
	if (this.loaded) {
		this.playerElement.swfStop();
	}
}

_this.swfGotoImage = function (nImg) {
	this.playerElement.swfGoToImage(nImg);
}

_this.swfPauseResume	= function () {
	this.playerElement.swfPauseResume();
}

_this.swfPreviousImage	= function () {
	this.playerElement.swfPreviousImage();
}

_this.swfNextImage	= function () {
	this.playerElement.swfNextImage();
}

_this.setPlayer = function (aPlayer) {
		
	this.playerDiv 					= aPlayer[0];
	this.playerUrl 					= this.playerRootUrl + aPlayer[2];
	this.playerWidth 				= aPlayer[3];
	this.playerHeight 			= aPlayer[4];
	this.playerVersion 			= aPlayer[5];
	this.playerBackground 	= aPlayer[6];

	this.playerName = "";
	var cTemp = this.playerUrl.toLowerCase();

	var aParts = cTemp.split("/");
	var cName = aParts[aParts.length - 1].replace(".swf", "");
	if ( typeof top[cName] == "undefined") {
		top[cName] = 0;
	}
	top[cName] = top[cName] + 1;
	this.playerName = cName + top[cName];
		
}

_this.instantiate = function ( ) {
		
	var swfVariables 		= {swfCallBack:this.name + ".swfStatus"};
	var swfParameters 	= {wmode:"transparent"};
	var swfAttributes 	= {id:this.playerName, name:this.playerName};
	var swfInstall			= "";
	swfobject.embedSWF(this.playerUrl + "?rnd=" + (new Date()).getTime().toString(), this.playerDiv, this.playerWidth, this.playerHeight, this.playerVersion, swfInstall, swfVariables, swfParameters, swfAttributes);
	
}

_this.swfStatus = function(cStatus) {
	var self = this;
	switch(cStatus) {
		case "Movie:Loaded":
 			this.playerElement = document.getElementById(this.playerName);		
 			this.swfFormFixInit();	
			break;
		case "Paused:Off":
			this.slideshowStatus = "Playing";
			break;
		case "Paused:On":
			this.slideshowStatus = "Paused";
			break;
		case "Play:Started":
			this.slideshowStatus = "Started";
			break;
		default:
			break;
	}
	this.parent.swfStatus(this.name, cStatus);
}

_this.swfFormFixInit = function () {
	var self = this; 	
	this.formFix = setInterval( function () {self.waitingFormFix()}, 50); 
	this.addSwfControl(this.name, this.playerName);
	swfPlayerControl.prototype.swfFormFixInit.call(this, this.name);
}

_this.waitingFormFix = function () {
	if (swfPlayerCheckFormFixStatus()) {
		clearInterval(this.formFix);
		this.loaded = true;
		this.swfInit();
		// this.parent.swfStatus(this.name,"SwfFormFixed");
	}	
}

///////////////////// end ////////////////////////


///////////////////// audioControl /////////////////////

function audioControl(){}

var _this = audioControl.prototype = new swfPlayerControl();

_this.constructor			= audioControl;

_this.className = "audioControl";

_this.name;
_this.parent;
_this.oPlayer;
_this.playerName;
_this.playerElement;
_this.playerDiv; 
_this.playerRootUrl;
_this.playerUrl; 
_this.playerWidth; 
_this.playerHeight; 
_this.playerVersion; 
_this.playerBackground; 

_this.muted;
_this.paused;
_this.audioStatus;

_this.loaded;
_this.formFix;

_this.delay;

_this.xmlData;
_this.xmlContent;

_this.init = function (cName, aPlayer, cXmlData, cXmlContent) {
			
	swfPlayerControl.prototype.init.call(this, cName) 
		
	this.name = cName;

	this.loaded = false;		
	
	this.audioStatus = "Initial";
	
	if (aPlayer[1].substr(aPlayer[1].length - 1, 1) == "/") {
		this.playerRootUrl = aPlayer[1];	
	} else {
		this.playerRootUrl = aPlayer[1] + "/";		
	}
	
	this.setPlayer(aPlayer);

	this.xmlData = cXmlData;
	this.xmlContent = cXmlContent;
	
	this.instantiate();
		
}	
	
_this.swfInit = function () {
	this.playerElement.swfInit(this.xmlData, this.xmlContent);			
}

_this.swfStart = function (nIndex) {
	var self = this;
	if (this.loaded) {
		if (nIndex != undefined) {
			if (nIndex > 0) {
				this.playerElement.swfStart(nIndex - 1);
			}
		}	
	} else {
		this.delay = setInterval( function () {self.delayedStart(nIndex)}, 50); 
	}	
}

_this.delayedStart = function (nIndex) {
	if (this.loaded) {
		if (nIndex != undefined) {
			if (nIndex > 0) {
				this.playerElement.swfStart(nIndex - 1);
			}
		}
		clearInterval(this.delay);
	}
}

_this.swfDeletePlayer = function () {	
	if (this.playerElement) {
		this.playerElement.swfReset();
	}
	swfobject.removeSWF(this.playerDiv);
	delete this.oPlayer;
}

_this.swfStop = function () {
	if (this.loaded) {
		this.playerElement.swfStop();	
	}
}

_this.swfPauseResume	= function () {
	if (this.loaded) {
		this.playerElement.swfPauseResume();	
	}
}

_this.swfMute = function () {
	if (this.loaded) {
		this.playerElement.swfMute();	
	}
}

_this.swfVolume = function (nVol) {
	if (this.loaded) {
		this.playerElement.swfVolume(nVol);	
	}
}

_this.setPlayer = function (aPlayer) {
		
	this.playerDiv 					= aPlayer[0];
	this.playerUrl 					= this.playerRootUrl + aPlayer[2];
	this.playerWidth 				= aPlayer[3];
	this.playerHeight 			= aPlayer[4];
	this.playerVersion 			= aPlayer[5];
	this.playerBackground 	= aPlayer[6];

	this.playerName = "";
	var cTemp = this.playerUrl.toLowerCase();

	var aParts = cTemp.split("/");
	var cName = aParts[aParts.length - 1].replace(".swf", "");
	if ( typeof top[cName] == "undefined") {
		top[cName] = 0;
	}
	top[cName] = top[cName] + 1;
	this.playerName = cName + top[cName];
	
}

_this.instantiate = function ( ) {
		
	var swfVariables 		= {swfCallBack:this.name + ".swfStatus"};
	var swfParameters 	= {wmode:"transparent"};
	var swfAttributes 	= {id:this.playerName, name:this.playerName};
	var swfInstall			= "";
	swfobject.embedSWF(this.playerUrl + "?rnd=" + (new Date()).getTime().toString(), this.playerDiv, this.playerWidth, this.playerHeight, this.playerVersion, swfInstall, swfVariables, swfParameters, swfAttributes);
		
}

_this.swfStatus = function(cStatus) {
	var self = this; 
	switch(cStatus) {
		case "Movie:Loaded":
 			this.playerElement = document.getElementById(this.playerName);		
 			this.swfFormFixInit();
			break;
		case "Muted:Off":
			this.muted = false;
			break;
		case "Muted:On":
			this.muted = true;
			break;
		case "Paused:Off":
			this.paused = false;
			break;
		case "Paused:On":
			this.paused = true;
			break;
		case "Play:Started":
			this.audioStatus = "Started";
			break;
		case "Play:Stopped":
			this.audioStatus = "Stopped";
			break;
		case "Play:Finished":
			this.audioStatus = "Finished";
			break;
		default:
			break;
	}
	this.parent.swfStatus(this.name, cStatus);
}

_this.swfFormFixInit = function () {
	var self = this; 	
	this.formFix = setInterval( function () {self.waitingFormFix()}, 50); 
	this.addSwfControl(this.name, this.playerName);
	swfPlayerControl.prototype.swfFormFixInit.call(this, this.name);
}

_this.waitingFormFix = function () {
	if (swfPlayerCheckFormFixStatus()) {
		clearInterval(this.formFix);
		this.loaded = true;
		this.swfInit();
		// this.parent.swfStatus(this.name,"SwfFormFixed");
	}	
}

///////////////////// end ////////////////////////

