var FLASH_VIDEO_SUPPORT = 10;


/**
 * Creates W3C compliant code for Flash inclusion with optional fallback image.
 * See MSDN "Activating ActiveX Controls":
 * http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp
 *
 * @param  flashFile      Filename of the Flash movie
 * @param  flashWidth     Width of the Flash movie/fallback image
 * @param  flashHeight    Height of the Flash movie/fallback image
 * @param  fallbackImage  Filename of the fallback image
 */
function displayFlashMovie(flashFile, flashWidth, flashHeight, fallbackImage) {
  if(flashFile && flashFile.trim() != ''){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + flashWidth + '" height="' + flashHeight + '">');
	document.write('  <param name="movie" value="' + flashFile + '" />');
	document.write('  <param name="allowScriptAccess" value="sameDomain" />');
	document.write('  <param name="wmode" value="transparent" />');

	/*document.write('  <!--[if !IE]>-->');
	document.write('  <object type="application/x-shockwave-flash" data="' + flashFile + '" width="' + flashWidth + '" height="' + flashHeight + '">');
	document.write('  <!--<![endif]-->');

	if (fallbackImage && fallbackImage.trim() != '') {
	  document.write('    <img src="' + fallbackImage + '" width="' + flashWidth + '" height="' + flashHeight + '" alt="" />');
	}

	document.write('  <!--[if !IE]>-->');
	document.write('  <embed src="'+flashFile+'" width="'+flashWidth+'" height="'+flashHeight+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="fma" allowScriptAccess="sameDomain" wmode="opaque"></embed>');
	document.write('  </object>');
	document.write('  <!--<![endif]-->');*/
	document.write('  <embed src="'+flashFile+'" width="'+flashWidth+'" height="'+flashHeight+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="fma" allowScriptAccess="sameDomain" wmode="opaque"></embed>');

	document.write('</object>');
  }
}


/**
 * Prototype for Javascript string object: Trim leading and succeeding spaces
 * See SELFHTML Forumsarchiv - "String.trim" als Beispiel fuer prototypische Vererbung:
 * http://forum.de.selfhtml.org/archiv/2004/2/t71920/#m414814
 */
String.prototype.trim = function() { return(this.replace(/\s+$/,"").replace(/^\s+/,"")); };





/**
 * Detects if Flash is present, optionally for a required major version.
 * Example: detectFlash(10) - Checks for Flash 10 (required for video playback)
 *
 * @param  requiredMajorVersion  Optionally checks for a major Flash version
 * @return boolean
 */
function detectFlash(requiredMajorVersion) {
  // -- Flash version required --
  var requiredMajorVersion = (arguments.length == 1 && !isNaN(arguments[0])) ? arguments[0] : 0;
  // -- Flash version detected --
  var detectedMajorVersion = -1;               
  var axo;                                                    

  var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
  if (plugin) {
	// -- for Mozilla based browsers --
	detectedMajorVersion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)); 
	if (detectedMajorVersion == 0) {
		detectedMajorVersion = 10;
	}
  } else {
	// -- for IE --
	try {
	  axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
	} catch(e) {}
	if (axo != null) detectedMajorVersion = axo.GetVariable("$version").split(" ")[1].split(",")[0];
  }
  return (detectedMajorVersion >= requiredMajorVersion);
}
 


