/***************************************************************************
 [flashObject.js]
 
 Copyright (C) 2004 Next IT Corporation, Inc. Spokane, WA. All Rights Reserved. 
 This document is confidential work and intellectual property of Next IT 
 Corporation. Permission to copy, distribute or use any portion of this file 
 is prohibited without the express written consent of Next IT Corporation.

*****************************************************************************/

//*************************//
// JAVASCRIPT OBJECT CLASS //
//*************************// 

// flashobject is a wrapper that lets you play and stop flash pieces
// dynamically in both IE and Mozilla.  other browser types are untested.

// A lot of parts of this are hard coded at the moment, but could be easily
// changed.  an example would be the loop property, set to false for now...

// WRITTEN BY:		Chase Rogers		
// ARCHITECTED BY:	Roth Fouty	

// Constructor
FlashObject = function( span ) 
{
	this.flashObjectIdOfSpan = span;
	this.SoundOffset = '';
	this._flashObject = null;
};

// Start playing a flash file by re-writing the innerHtml of a tag.
// Usually a span tag, so it makes no visible alteration to the page.
FlashObject.prototype.StartFlash = function( src, id ) 
{
	this.flashObjectSrcOfFlash = src;
	this.flashObjectIdOfFlash = id;
	document.getElementById( this.flashObjectIdOfSpan ).innerHTML = "<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=https://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0 ID="+id+" WIDTH=2 HEIGHT=1 VIEWASTEXT><PARAM NAME=movie VALUE=\""+this.SoundOffset+src+"\"><PARAM NAME=quality VALUE=high><PARAM NAME=play VALUE=true><PARAM NAME=loop VALUE=false><PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED play=true loop=false swliveconnect=true name="+id+" src=\""+this.SoundOffset+src+"\" quality=low bgcolor=#333333 WIDTH=1 HEIGHT=2 TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>";
	this._flashObject = document.getElementById( id );
};

// Stops the flash cold in its tracks.
FlashObject.prototype.StopFlash = function() 
{
	document.getElementById( this.flashObjectIdOfSpan ).innerHTML = "";	
};

FlashObject.prototype.SelfHalt = function()
{
	try
	{
		if( this._flashObject != null )
		{
			if( this._flashObject.object != null )
			{
				if( this._flashObject.object.FrameNum != null && this._flashObject.object.TotalFrames != null )
				{
					if( this._flashObject.object.FrameNum >= (this._flashObject.object.TotalFrames-3) )
					{
						document.getElementById( this.flashObjectIdOfSpan ).innerHTML = "";		
						return true;
					}
					else
					{
						return false;
					}
				}
			}
		}
	}
	catch(e)
	{}
};
