var playerVersionInfo;

if(!playerVersionInfo)
{
    playerVersionInfo = new Array();
}
playerVersionInfo["player_flash"] = "10/24/07 rev 0 - Flash - Special for .NET";	

////////////////////////////////////////////////////////////////////////////////////////
//  Control functions for Flash FLV Player
//  CUSTOM CREATED FOR .NET PAGES, not DeskTV!!
//  10/24/07
//
//  - All functions will have a target id passed to it.  No hard-coded ids!
//
//  Functions available for flash FLV media:
//  - create player
//  - remove player?
//  - assign stream/file
//  - player state (playing, paused, stopped, etc.)
//  - play
//  - stop
//  - pause
//  - volume up/down
//  - mute
//  - get current time
//  - goto time
//  - get buffering percentage

//  - get current bandwidth?
//  - set bandwidth (and restart stream)?
//  - get next event?

// Register player type as available for use
var playerTypeAvailable;
if(!playerTypeAvailable)
{
    playerTypeAvailable = new Array();
}
playerTypeAvailable["Flash"] = true;	

// Register media extensions for windows media
var mediaExtensions
if(!mediaExtensions)
{
	mediaExtensions = new Array();
}
mediaExtensions["flv"] = "Flash";


////////////////////////////////////////////////////////////////////////////////
// Register player functions
//

var playerFunctions;
if(!playerFunctions)
{
    playerFunctions = new Array();
}
playerFunctions["Flash"] = new Object();	

//
// Due to a quirk / bug in flash, if the flash is inside a form, some extra steps are needed to make it work
// This is only necessary for Internet Explorer (I think)
//
// Run playerFunctions["Flash"].preparePlayer(playerID) before creating the flash object with .createPlayerHTML()
// Once the Flash Object as been created, run playerFunctions["Flash"].fixFlashFunctions(playerID) before accessing any other Flash functions
//

playerFunctions["Flash"].preparePlayer = function(playerID)
{
	window[playerID] = new Object();  
	
}

playerFunctions["Flash"].fixFlashFunctions = function(playerID)
{
	var realMovie = document.getElementById(playerID);
	if(realMovie)
	{
		for(var method in window[playerID])
		{
			if(typeof(window[playerID][method]) == "function")
			{
				eval("realMovie[method] = function() {return eval(this.CallFunction(\"<invoke name=\\\""+method+"\\\" returntype=\\\"javascript\\\">\" + __flash__argumentsToXML(arguments,0) + \"</invoke>\"));  }");
			}
		}
		window[playerID] = realMovie;
	}
}
//
// CREATE PLAYER
//

playerFunctions["Flash"].createPlayerHTML = function(playerID, thevideoURL, videoWidth, videoHeight, scaleVideoToFit)
{
/*
    alert ('creat now');
    var s1 = new SWFObject('http://hwcdn.net/c2a4g6j9/cds/hwplayer.swf','mpl','470','320','9');
    s1.addParam('allowfullscreen','true');
    s1.addParam('allowscriptaccess','always');
    s1.addParam('flashvars','file=http://hwcdn.net/f9v3z6n2/fms/harris_01-06-08.flv.smil');
    s1.write('preview');
*/
/*
	// both OBJECT and EMBED use the same id  -  works in Win32
	var mHTML = "";
	mHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"" +
		"width=\"" + videoWidth + "\" height=\"" + videoHeight + "\" id=\"" + playerID + "\">\n" +
  		"<param name=\"movie\" value=\"http://hwcdn.net/c2a4g6j9/cds/hwplayer.swf\" />\n" +
  		"<param name=\"FlashVars\" value=\"file="+ thevideoURL +"&autostart=true&scaleToFit="+scaleVideoToFit+"\" />\n" +
  		"<param name=\"quality\" value=\"high\" />\n" +
  		"<param name=\"allowfullscreen\" value=\"true\" />\n" +
  		"<param name=\"allowscriptaccess\" value=\"always\" />\n" +
  		"<param name=\"autostart\" value=\"true\" />\n" +
  		"<param name=\"bgcolor\" value=\"#efefef\" />\n" +
		"<param name=\"scaleMode\" value=\"noScale\" />\n" +
  		"<embed src=\"http://hwcdn.net/c2a4g6j9/cds/hwplayer.swf\" id=\"" + playerID + "\" quality=\"high\" " +
		//"FlashVars=\"videoURL="+ thevideoURL +"&scaleToFit="+scaleVideoToFit+"\"" +
		"FlashVars=\"file=http://hwcdn.net/f9v3z6n2/fms/solomon_02-03-08.flv.smil&type=highwinds" +"&scaleToFit="+scaleVideoToFit+"\"" +
		"pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" " +
  		"width=\"" + videoWidth + "\" height=\"" + videoHeight + "\" scaleMode=\"noScale\" bgcolor=\"#efefef\"></embed>\n" +
		"</object>\n";
*/
	return mHTML;

}

//
//  PLAY
//

playerFunctions["Flash"].play = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVPlay();
	}
}; // semicolon needed for obfuscation

//
//  STOP
//

playerFunctions["Flash"].stop = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVStop();
	}
};

//
//  PAUSE
//

playerFunctions["Flash"].pause = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVPause();
	}
};

//
//  MUTE
//

playerFunctions["Flash"].getMute = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetMute();
	}
	else
	{
		return false;
	}
};

// muteStatus = true / false

playerFunctions["Flash"].setMute = function(targetID, muteStatus)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVSetMute(muteStatus);
	}
};


//
//  VOLUME
//
// Global volume range is 0-100.  This matches current Flash player, so no change is needed

playerFunctions["Flash"].getVolume = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetVolume();
	}
	else
	{
		return false;
	}
};

// newVolume = 0-100

playerFunctions["Flash"].setVolume = function(targetID, newVolume)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVSetVolume(newVolume);
	}
};

//
//  GET & SET CURRENT TIME
//
// Time used is in seconds (with tenths, ie: 100.2)

playerFunctions["Flash"].getCurrentTime = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetTime();
	}
	else
	{
		return false;
	}
};

// use gotoTime instead?

playerFunctions["Flash"].setCurrentTime = function(targetID, newTime)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVSetTime(newTime);
	}
};

//
// CONTROLLER / PLAY STATE & BUFFERING
//
// PlayState values:
// "Playing"
// "Stopped"
// "Paused"
// "Buffering"
// "Loading"
// "Ready" or "Not Loaded" ?  <-- Flash returns "Not Loaded"
//
// Buffering will return 0-100

playerFunctions["Flash"].getPlayState = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetStatus();
	}
	else
	{
		return false;
	}
};



playerFunctions["Flash"].getBuffering = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetBuffering();
	}
	else
	{
		return false;
	}
};

//
// VERSION INFO
//
// Returns a string of whatever is valid for player type
//

playerFunctions["Flash"].getVersion = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return FlashVersionInfo; // Need to set?
	}
	else
	{
		return false;
	}
};

//
// SET MEDIA FILE
//

playerFunctions["Flash"].setFile = function(targetID, theURL)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		targetEl.FLVSetURL(theURL);
	}
};


//
// BITRATE
//
// Returns the bitrate of the media - for flash, it may not change
//

playerFunctions["Flash"].getBitrate = function(targetID)
{
	var targetEl = getElement(targetID);
	if(targetEl)
	{
		return targetEl.FLVGetBitrate();
	}
	else
	{
		return 0;
	}
};

