/**
 * Functions for rendering video
 */

var volume = 100;
var currentSound = "";


function setSound( sound ){	
	var soundWrapper = document.getElementById( 'soundWrapper' );
	if( soundWrapper != null ){
		soundWrapper.innerHTML = "<EMBED id='embedSound' SRC='/images/stories/audio/"+sound+".mp3' AUTOSTART=true WIDTH=250 HEIGHT=60 LOOP=1><br/>";
		soundWrapper.innerHTML += "<a href='/images/stories/audio/download.php?src="+sound+".mp3'>Download MP3 file</a>";
	}
}

function setVideo( streamName ){
	// find object
	
	obj = document.getElementById('playerHolder');
	if( obj != null ){
		drawPlayer( obj, streamName );
	}
}

function drawPlayer( obj, s ){
	var output = "";
	output +='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320" height="240" id="FLVPlayer">';
     output +='<param name="movie" value="/content/File/video/FLVPlayer_Progressive.swf" />';
     output +='<param name="salign" value="lt" />';
     output +='<param name="quality" value="high" />';
     output +='<param name="scale" value="noscale" />';
     output +='<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=/content/File/video/Clear_Skin_3&streamName=/content/File/video/'+s+'&autoPlay=true&autoRewind=false" />';
     output +='<embed src="/content/File/video/FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=/content/File/video/Clear_Skin_3&streamName=/content/File/video/'+s+'&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="320" height="240" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> ';   
	output +='</object>';
	obj.innerHTML = output;
}
/**
 * Checks for presence of Flash plugin.  If not founds writes warning div
 * to screen.  <div class="alert">
 */
function checkForFlash(){
	

	var flashinstalled = 0;
	var flashversion = 0;
	MSDetect = "false";
	if (navigator.plugins && navigator.plugins.length)
	{
		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		debugger;
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	else
		MSDetect = "true";
	
//	
//	if( (flashinstalled == 0) || (flashversion < 7) ){
//		document.write( '<div class="alert">' );
//		document.write( '<strong>Flash Plugin Required</strong> <br />' );
//		document.write( 'This page requires that you have the Macromedia Flash plug-in installed on your computer.' );
//		document.write( 'If you\'re unable to view the video on the right hand side of this page, please download the Macromedia Flash 7.0 or higher plug-in for your web browser from the following location:<br /> ' );
//		document.write( ' <a href="http://www.adobe.com/shockwave/download/alternates/" target="_blank">Open download in new window' );
//		document.write( ' </a></div>' );
//	}
	
}