// detecta el plugin de flash y escribe el objeto en html o la imagen segun el resultado dela comprobacion
function detectarEscribirFlash(rutaSWF, rutaImagen, flashVersion, ancho, altura, enlace, target, parametros) {
	var splitRuta= rutaSWF.split("/");
	var archivo = splitRuta[splitRuta.length-1].split(".");
	var nombre = archivo[0];
	var requiredVersion = eval(flashVersion);

	var flash2Installed = false;
	var flash3Installed = false;
	var flash4Installed = false;
	var flash5Installed = false;
	var flash6Installed = false;
	var flash7Installed = false;
	var maxVersion = 8;
	var actualVersion = 0;
	var hasRightVersion = false;
	var jsVersion = 1.0;
	
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows
	
	jsVersion = 1.1;

	
	if(isIE && isWin){
	  try{
		flash2Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.2");
		if (flash2Installed != null) flash2Installed =true;
	  } 
	  catch(e){
		flash2Installed=false;
	  }
	  try{
		flash3Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
		if (flash3Installed != null) flash3Installed =true;
	  } 
	  catch(e){
		flash3Installed=false;
	  }

	  try{
		flash4Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.4");
		if (flash4Installed != null) flash4Installed =true;
	  } 
	  catch(e){
		flash4Installed=false;
	  }

	  try{
		flash5Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5");
		if (flash5Installed != null) flash5Installed =true;
	  } 
	  catch(e){
		flash5Installed=false;
	  }

	  try{
		flash6Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
		if (flash6Installed != null) flash6Installed =true;
	  } 
	  catch(e){
		flash6Installed=false;
	  }

	  try{
		flash7Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		if (flash7Installed != null) flash7Installed =true;
	  } 
	  catch(e){
		flash7Installed=false;
	  }
	  
	  try{
		flash8Installed = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8");
		if (flash8Installed != null) flash8Installed =true;
	  } 
	  catch(e){
		flash8Installed=false;
	  }
	}else{
		  
		  if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"]
			|| navigator.plugins["Shockwave Flash"]) {
	
		  var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		  var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
	
		  var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		  flash2Installed = flashVersion == 2;
		  flash3Installed = flashVersion == 3;
		  flash4Installed = flashVersion == 4;
		  flash5Installed = flashVersion == 5;
		  flash6Installed = flashVersion == 6;
		  flash7Installed = flashVersion == 7;
		  flash8Installed = flashVersion >= 8;
		}
	  }
	}
  for (var i = 2; i <= maxVersion; i++) {
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;
	if (actualVersion >= requiredVersion && rutaSWF != ''){
			document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
			document.write('  codebase="" ');
			document.write(' ID="'+ nombre +'" WIDTH="'+ ancho +'" HEIGHT="'+ altura +'">');
			document.write(' <PARAM NAME=movie VALUE="'+ rutaSWF +'?'+ parametros +'"><PARAM NAME=wmode VALUE=transparent><PARAM NAME=quality VALUE=high><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=bgcolor VALUE=#FFFFFF><PARAM NAME="autostart" VALUE="true"><PARAM NAME=menu VALUE=false><PARAM NAME="FlashVars" VALUE="'+parametros+'">'); 
			document.write(' <EMBED src="'+ rutaSWF +'?'+ parametros +'" quality=high bgcolor=#FFFFFF  menu=false FLASHVARS='+ parametros+'');
			document.write(' swLiveConnect=TRUE autostart=true loop=true wmode=transparent WIDTH="'+ ancho +'" HEIGHT="'+ altura +'" NAME="'+ nombre +'" ALIGN=""');
			document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="">');
			document.write(' </EMBED>');
			document.write(' </OBJECT>');
	  }else{
		  if (target != '' && target != 'null'){
			document.write('<a href="'+ enlace +'" target="' + target + '"><IMG SRC="'+ rutaImagen +'" BORDER=0 ID="'+ nombre +'"></a>');
		  }else{
			document.write('<a href="'+ enlace +'"><IMG SRC="'+ rutaImagen +'" BORDER=0 ID="'+ nombre +'"></a>');
		}
  }
}