function getFlashPluginVersion() 
{ 
  var version = { 
        major: -1, 
        minor: -1, 
        installed: false,
        scriptable: false,
        machoArchitectureProblem: false
      };
var osxFlashVersion = 12;

  var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 
  if (!plugin) 
  {
    return version;
  }

  version.installed = true;

  var description = plugin.description; 
  
  // use RegExp to obtain the relevant version strings 
  // obtain an array of size 2 with version information
  
  var versionArray = description.match(/[\d.]+/g); 
  
  if (!versionArray)
  {
    return version;
  }

  if (versionArray.length >= 1 && !isNaN(versionArray[0]))
  {
    version.major = parseFloat(versionArray[0]);
  }

  if (versionArray.length >= 2 && !isNaN(versionArray[1]))
  {
    version.minor = parseFloat(versionArray[1]);
  }
    
  if (version.major < 6 || navigator.product != 'Gecko')
  {
    return version;
  }

  if (version.major > 6 || version.minor >= 47)
  {
    version.scriptable = true;
  }
  
  if((version.major < osxFlashVersion) && (navigator.userAgent.indexOf("Mach-O") != -1))
  {
  	version.scriptable = false;
  	version.machoArchitectureProblem = true;
  
  }

  return version;
}

function identifyFlash() 
{ 
  if ((window.ActiveXObject) && 
      (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
  {
    document.write("<p>This browser is an <b>IE browser<\/b> which" +
        " supports ActiveX -- this article is about scripting the plugin in Netscape Gecko browsers.<\/p>");
    return;
  }
  var flashversion = getFlashPluginVersion();

  if (!flashversion.installed)
  {
    document.write("<p>Flash is not installed as a plugin. " +
                   "You need to install the latest version available from " +
                   "<a href='http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English'>here.<\/a>" +
                   "<\/p>");
    return;
  }

  if (flashversion.major == -1 || flashversion.minor == -1)
  {
    document.write("<p>Flash is installed as a plugin but the version could not be determined.<\/p>");
    return;
  }

  if (flashversion.scriptable)
  {
    document.write("<p>Flash is installed as a plugin and is scriptable in Gecko. " +
				   "The version of Flash installed is " + flashversion.major + "r" + flashversion.minor + "<\/p>");
    return;
  }
  if ((!flashversion.scriptable) && (!flashversion.machoArchitectureProblem))
  {
	document.write("<p>Flash is not scriptable and so the examples in this article will not work ." +
                   "You need to install the latest scriptable version available from " +
                   "<a href='http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English'>here.<\/a>" +
                   "<\/p>");
    return;
  }
if(flashversion.machoArchitectureProblem)
{
	document.write("<p>Flash is not yet scriptable for your OS X browser.  Check back soon for updates -- currently, the examples in this article will not work.  " +
					"The version of Flash installed is " + flashversion.major + "r" + flashversion.minor + "<\/p>");
	return;
					 
}
  document.write("<p>Flash is installed as a plugin and " +
                 "is version " + flashversion.major + "r" +
                 flashversion.minor + "<\/p>");
} 

// guardo el valor del IE
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Maneja todos los mensajes de FSCommands en una película
function imagenes_DoFSCommand(comando, argumentos) {
	var imagenesObj = InternetExplorer ? imagenes : document.imagenes;
	alert("se ha activado el comando: " + comando + " con los siguientes argumentos: " + argumentos);
}

// compatibilidad del código con IE - MICROSOFT
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
{
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub imagenes_FSCommand(ByVal command, ByVal args)\n');
	document.write(' call imagenes_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

// Condicionalmente crea el objeto dependiendo del navegador
// IE soporta ActiveX, entonces crea un objeto que lo soporta
// Mozilla soporta MIME type, entonces, si es Mozilla, crea un objeto que soporta MIME type
function createFlash(id, src, width, height, flashVars, wmode, actualizar_div){

	//alert("b: " + actualizar_div);
	
	if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
	{
	
		var objeto = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
		objeto += " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\"";
		objeto += " width=\"" + width + "\" height=\"" + height + "\" id=\"" + id + "\">";
		objeto += " <param name=\"movie\" value=\"" + src + "\">";
		objeto += " <param name=\"quality\" value=\"high\">";
		if(flashVars!="") {
			objeto += " <param name=\"FlashVars\" value=\"" + flashVars + "\">";
		}
		if(wmode) {
			objeto += " <param name=\"wmode\" value=\"transparent\">";
		}
		objeto += " <param name=\"swliveconnect\" value=\"true\">";
		objeto += "<\/object>";
		
		if(!actualizar_div) {
			document.write(objeto);
		} else {
			//alert(objeto);
			document.getElementById(actualizar_div).innerHTML = objeto;
		}
	
	} else {
		var version_check = getFlashPluginVersion();
		if (version_check.scriptable)
		{
	
			var objeto = "<object id=\"" + id + "\" data=\"" + src + "\" type=\"application/x-shockwave-flash\"";
			objeto += " width=\"" + width + "\" height=\"" + height + "\">";
			objeto += "<param name=\"movie\" value=\"" + src + "\">";
			objeto += "<param name=\"quality\" value=\"high\">";
			if(flashVars!="") {
				objeto += " <param name=\"FlashVars\" value=\"" + flashVars + "\">";
			}
			if(wmode) {
				objeto += " <param name=\"wmode\" value=\"transparent\">";
			}
			objeto += "<param name=\"swliveconnect\" value=\"true\">";
			objeto += "<embed src=\"" + src + "\" width=\"" + width + "\" height=\"" + height + "\" swLiveConnect=\"true\"";
			if(flashVars!="") {
				objeto += " FlashVars value=\"" + flashVars + "\"";
			}
			if(wmode) {
				objeto += " wmode value=\"transparent\"";
			}
			objeto += " quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"";
			objeto += " type=\"application/x-shockwave-flash\" name=\"" + id + "\"></embed>";
			objeto += "<\/object>";

			if(!actualizar_div) {
				document.write(objeto);
			} else {
				//alert(objeto);
				document.getElementById(actualizar_div).innerHTML = objeto;
			}

		} else
			identifyFlash()
		
	}
}
