/////////////////////////// functions called by HTML ///////////////////

// These functions represent the external interface to the HTML page.

function slideshowGoto(nImg) 						{main ? main.htmlSlideshowGoto(nImg) 				: false;}
function slideshowStart() 							{main ? main.htmlSlideshowStart() 					: false;}
function slideshowStop() 								{main ? main.htmlSlideshowStop() 						: false;}
function slideshowPauseResume() 				{main ? main.htmlSlideshowPauseResume() 		: false;}
function slideshowPrevious() 						{main ? main.htmlSlideshowPrevious() 				: false;}
function slideshowNext() 								{main ? main.htmlSlideshowNext() 						: false;}

function bypassFlashUpdate()						{main ? main.swfBypassUpdate() 							: false;}

function stopMedia() 										{main ? main.htmlStopMedia() 								: false;}

/////////////////////////// end //////////////////////////////////


///////////////////////// main /////////////////////////////////

var main;



/* AMS Require /js/CoreLibs/CoreLib.js */
AddEvent( window, "load", function(){

	main = new mainControl(); 
	main.init( "main" ); 

} );

AddEvent( window, "unload", function(){

	stopMedia();

});

/////////////////////////// end //////////////////////////////////


//////////////////////// main control ////////////////////////////


function mainControl(){}

var _this = mainControl.prototype = new Object();

_this.constructor	= mainControl;

_this.className = "mainControl";

_this.name;

_this.swfSlideshowControl;


_this.init = function (cName) {

	// passed from HTML
	this.name = cName;
    if ( Boolean(typeof aSlideshowPlayer != 'undefined' && aSlideshowPlayer ))
    {
	    this.swfInstall = new InstallSwf();
	    this.swfInstall.parent = this;
	    this.swfInstall.init(this.name + ".swfInstall", aInstallSwf[0], aSlideshowPlayer[1]);	 	
	    if (this.swfInstall.loaded()) {   	
		    this.swfInit();	
	    }
    }
}

_this.swfBypassUpdate = function () {
	this.swfInstall.hide();	
	this.swfInit();
}

_this.swfInit = function () {
	 
	if ( Boolean(typeof aSlideshowPlayer != 'undefined' && aSlideshowPlayer) ) {
	    this.swfSlideshowControl = new slideshowControl();
	    this.swfSlideshowControl.parent = this;
	    this.swfSlideshowControl.init(this.name + ".swfSlideshowControl", aSlideshowPlayer, cXmlGenericContent, cXmlSlideshowContent);	
	    this.swfSlideshowControl.swfStart();
	}
		    	    		
}

// Basic Player Controls

_this.htmlBasicStopMedia	= function () {
	if(this.swfBasicControl) {
		this.swfBasicControl.swfDeletePlayer();
		delete this.swfBasicControl;
	}
}


// Slide Show Player Controls

_this.htmlSlideshowStopMedia	= function () {
	if(this.swfSlideshowControl) {
		this.swfSlideshowControl.swfDeletePlayer();
		delete this.swfSlideshowControl;
	}
}

_this.htmlSlideshowGoto = function (nImg) {
	this.swfSlideshowControl.swfGotoImage(nImg);
}

_this.htmlSlideshowPauseResume	= function () {
	this.swfSlideshowControl.swfPauseResume();
}

_this.htmlSlideshowStart	= function () {
	this.swfSlideshowControl.swfStart();
}

_this.htmlSlideshowStop	= function () {
	this.swfSlideshowControl.swfStop();
}

_this.htmlSlideshowPrevious	= function () {
	this.swfSlideshowControl.swfPreviousImage();
}

_this.htmlSlideshowNext	= function () {
	this.swfSlideshowControl.swfNextImage();
}

// Common functions


_this.htmlStopMedia	= function () {
	if ( Boolean(typeof aSlideshowPlayer != 'undefined' && aSlideshowPlayer) ) { this.htmlSlideshowStopMedia();}
}

_this.showMovieStatus = function(cStatus) {
	document.getElementById("movieStatus").value = document.getElementById("movieStatus").value + cStatus + "\r\n"; 	
}

_this.swfStatus = function(cName, cStatus) {
	switch (cName) {
		case "main.swfSlideshowControl":	
			this.showMovieStatus(cName + " " + cStatus);
			break;		
	}
}			


/////////////////////////// end //////////////////////////////////

