
///////////////////// mainControl ///////////////

function mainControl(){}

var _this = mainControl.prototype = new Object();

_this.constructor	= mainControl;

// class objects
_this.swfAudioControl;
_this.swfVideoControl;
_this.galleryControl;
_this.montageControl;
_this.aVideoControlVars;
_this.aAudioControlVars;
_this.aGalleryVars;

// holders for HTML variables
_this.cMediaFolder;
_this.cImageFolder;
_this.cImageHolderID;
_this.aSoundTracks;
_this.nInitialTrack;
_this.cVideoName;
_this.aImages;
_this.aMontages;
_this.cMontageHolderID;
_this.cSectionName;

// other variables
_this.lVideoOn;
_this.lAudioOn;


_this.init = function (	aVars ) {

	// passed from HTML
	this.cMediaFolder			= aVars[0];
	this.cImageFolder			= aVars[1];
	this.cImageHolderID		= aVars[2];
	this.aSoundTracks			= aVars[3];
	this.nInitialTrack		= aVars[4];
	this.cVideoName			= aVars[5];
	this.aImages				= aVars[6];
	this.aMontages				= aVars[7];
	this.cMontageHolderID	= aVars[8];
	this.cSectionName   	= aVars[9];
				
	this.lVideo = false;
	this.lAudioOn = false;

	switch ( this.cSectionName )
	{
		case "Portfolio":
			this.galleryControl = new galleryControl();
			this.galleryControl.parent = this;
			this.aGalleryControlVars = [this.aImages, this.cMediaFolder, this.cImageHolderID];
			this.galleryControl.init(this.aGalleryControlVars, false); 
			
			break;
		case "Product":
			/*if ( this.aImages.length > 1 )
			{
				this.galleryControl = new galleryControl();
				this.galleryControl.parent = this;
				this.aGalleryControlVars = [this.aImages, this.cMediaFolder, this.cImageHolderID];
				this.galleryControl.init(this.aGalleryControlVars, true); 
			}
			else
			{
				document.getElementById("SingleImage").style.marginLeft = (document.getElementById("SingleImage").width/2)*(-1) + "px";
			}
			*/

			this.swfVideoControl = new videoControl();
			this.aVideoControlVars = ["videoPlayer"];
			this.swfVideoControl.init(this.aVideoControlVars); 

/*			this.swfAudioControl = new audioControl();
			this.swfAudioControl.parent = this;
			this.aAudioControlVars = ["audioPlayer", this.cMediaFolder, this.aSoundTracks, this.nInitialTrack];
			this.swfAudioControl.init(this.aAudioControlVars); 
*/			break;
	}

/*	this.montageControl = new montageControl();
	this.montageControl.parent = this;
	this.aMontageControlVars = [this.aMontages, this.cImageFolder, this.cMontageHolderID];
	this.montageControl.init(this.aMontageControlVars);
*/

} ;

_this.htmlStartVideo = function () {
	
	if (this.lAudioOn ) { clearTimeout(this.swfAudioControl.hDelay); }

	this.lVideoOn = true;

	//this.swfAudioControl.stop();
	//this.swfAudioControl.disable();				

	//document.getElementById("Gallery").style.display   = "none";
	//document.getElementById("VideoArea").style.display = "block";
	
	if ( this.aImages.length > 1 ) { this.galleryControl.pause(); }

	this.swfVideoControl.play(this.cMediaFolder + this.cVideoName, 2); // delay is in seconds	

	document.getElementById("WatchText").innerHTML  = "Stop";
	var oListenDiv = document.getElementById("ListenText");
	if ( oListenDiv ) { oListenDiv.innerHTML = "Listen"; }
}

_this.htmlStopVideo = function () {

	clearTimeout(this.swfVideoControl.hDelay);
	
	this.lVideoOn     = false;
	
	this.swfVideoControl.stop();
	
	this.swfAudioControl.enable();				
		
	//document.getElementById("Gallery").style.display   = "block";
	//document.getElementById("VideoArea").style.display = "none";
	
	if ( this.aImages.length > 1 ) { this.galleryControl.resume(); }

	document.getElementById("WatchText").innerHTML  = "Play Video";
	var oListenDiv = document.getElementById("ListenText");
	if ( oListenDiv ) { oListenDiv.innerHTML = "Listen"; }
}

_this.htmlPlayVideo = function() {
	if ( document.getElementById("WatchText").innerHTML == "Play Video" ) {
		this.htmlStartVideo();
	} else {
		this.htmlStopVideo();
	} ;
} ;

_this.htmlPlayTrack = function (nIndex) {
	if ( document.getElementById("ListenText").innerHTML == "Listen" ) {
		if ( this.lVideoOn ) { 
			this.htmlStopVideo(); 
		} ;
		this.lAudioOn = true;
		this.swfAudioControl.play(nIndex, 1); // delay is in seconds
		document.getElementById("ListenText").innerHTML = "Stop";	
	} else {
		this.lAudioOn = false;
		this.swfAudioControl.stop(); // delay is in seconds
		document.getElementById("ListenText").innerHTML = "Listen";
	} ;
} ;

_this.htmlPauseResumeSlideShow = function() {
	if ( document.getElementById("SlideShowPauseResume").innerHTML == "pause" )
	{
		this.galleryControl.pause();
		document.getElementById("SlideShowPauseResume").innerHTML = "resume slideshow";
	}
	else
	{
		this.galleryControl.resume();
		document.getElementById("SlideShowPauseResume").innerHTML = "pause";
	}
}

_this.htmlPrevSlide = function() {
	if ( document.getElementById("SlideShowPauseResume").innerHTML == "pause" )
	{
		this.galleryControl.pause();
		document.getElementById("SlideShowPauseResume").innerHTML = "resume slideshow";
	}
	this.galleryControl.previous();
}

_this.htmlNextSlide = function() {
	if ( document.getElementById("SlideShowPauseResume").innerHTML == "pause" )
	{
		this.galleryControl.pause();
		document.getElementById("SlideShowPauseResume").innerHTML = "resume slideshow";
	}
	this.galleryControl.next();
}


/////////////////////// end /////////////////////////


///////////////////// galleryControl ///////////////

function galleryControl(){}

var _this = galleryControl.prototype = new Object();

_this.constructor	= galleryControl;

// class objects
_this.slideShowControl;

// containers for HTML variables
_this.aImages;
_this.cMediaFolder;
_this.cImageHolderID;

// other variables
_this.aSlideShowControlVars;
_this.aUrls;
_this.aDesc;

_this.init = function ( aVars, lOffset ) {
	
	
	this.aImages			= aVars[0];	
	this.cMediaFolder 	= aVars[1]; //  "/Media/"
	this.cImageHolderID 	= aVars[2]; // "Gallery"

	this.aUrls = [];
	this.aDesc = [];
	
	for( var nIndex = 0; nIndex < aImages.length; nIndex = nIndex + 1 ) { 
		this.aUrls[this.aUrls.length] = this.aImages[nIndex].src; 
		this.aDesc[this.aDesc.length] = this.aImages[nIndex].desc; 
	}

	this.slideShowControl = new slideShowControl();
	this.slideShowControl.parent = this;
	this.aSlideShowControlVars = [this.aUrls, this.cMediaFolder, document.getElementById(this.cImageHolderID), this.aDesc];
	this.slideShowControl.init(this.aSlideShowControlVars, lOffset); 
	
	this.slideShowControl.start();
	
}

_this.start = function () {
	this.slideShowControl.start();
} ;

_this.pause = function () {
	this.slideShowControl.pause();
} ;

_this.resume = function () {
	this.slideShowControl.resume();
} ;

_this.next = function () {
	this.slideShowControl.next();
}	

_this.previous = function () {
	this.slideShowControl.previous();
}	

/////////////////////// end /////////////////////////


///////////////////// montageControl ///////////////

function montageControl(){}

var _this = montageControl.prototype = new Object();

_this.constructor	= montageControl;

// class objects
_this.slideShowControl;

// containers for HTML variables
_this.aImages;
_this.cMediaFolder;
_this.cImageHolderID;

// other variables
_this.aSlideShowControlVars;
_this.aUrls;
_this.aDesc;

_this.init = function ( aVars ) {
	
	
	this.aImages			= aVars[0];	
	this.cMediaFolder 	= aVars[1]; //  "/Media/"
	this.cImageHolderID 	= aVars[2]; // "Montage"

	this.aUrls = [];
	this.aDesc = [];
	
	for( var nIndex = 0; nIndex < this.aImages.length; nIndex = nIndex + 1 ) { 
		this.aUrls[this.aUrls.length] = this.aImages[nIndex].src; 
		this.aDesc[this.aDesc.length] = this.aImages[nIndex].desc; 
	}

	this.slideShowControl = new slideShowControlII();
	this.slideShowControl.parent = this;
	this.aSlideShowControlVars = [this.aUrls, this.cMediaFolder, document.getElementById(this.cImageHolderID), this.aDesc];
	this.slideShowControl.init(this.aSlideShowControlVars); 

	this.slideShowControl.start();

}

_this.start = function () {
	this.slideShowControl.start();
} ;

_this.resume = function () {
	this.slideShowControl.resume();
} ;
	

/////////////////////// end /////////////////////////
