var MM_FlashSnifferURL = "detectFlash.swf";

var MM_latestPluginRevision = new Object();
MM_latestPluginRevision["6.0"] = new Object();
MM_latestPluginRevision["5.0"] = new Object();
MM_latestPluginRevision["4.0"] = new Object();
MM_latestPluginRevision["3.0"] = new Object();
MM_latestPluginRevision["2.0"] = new Object();

MM_latestPluginRevision["6.0"]["Windows"] = 47;
MM_latestPluginRevision["6.0"]["Macintosh"] = 47;

MM_latestPluginRevision["5.0"]["Windows"] = 42;
MM_latestPluginRevision["5.0"]["Macintosh"] = 41;

MM_latestPluginRevision["4.0"]["Windows"] = 28;
MM_latestPluginRevision["4.0"]["Macintosh"] = 27;
MM_latestPluginRevision["4.0"]["Unix"] = 12;

MM_latestPluginRevision["3.0"]["Windows"] = 10;
MM_latestPluginRevision["3.0"]["Macintosh"] = 10;

MM_latestPluginRevision["2.0"]["Windows"] = 11;
MM_latestPluginRevision["2.0"]["Macintosh"] = 11;



var MM_FlashControlInstalled;	// is the Flash ActiveX control installed?
var MM_FlashControlVersion;	// ActiveX control version if installed

function MM_FlashInfo()
{
    if (navigator.plugins && navigator.plugins.length > 0)
    {
	this.implementation = "Plug-in";
	this.autoInstallable = false;	// until Netscape SmartUpdate supported

	if (navigator.plugins["Shockwave Flash"])
	{
	    this.installed = true;

	    var words =
		navigator.plugins["Shockwave Flash"].description.split(" ");

	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;

		this.version = words[i];
		

		this.revision = parseInt(words[i + 1].substring(1));
	    }
	}
	else
	{
	    this.installed = false;
	}
    }
    else if (MM_FlashControlInstalled != null)
    {
	this.implementation = "ActiveX control";
	this.installed = MM_FlashControlInstalled;
	this.version = MM_FlashControlVersion;
	this.autoInstallable = true;
    }
    else if (MM_FlashDetectedSelf())
    {
	this.installed = true;
	this.implementation = "Plug-in";
	this.autoInstallable = false;
    }

    this.canPlay = MM_FlashCanPlay;
}


var MM_FlashPluginsPage = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";

function MM_FlashDispatch(contentURL, contentVersion, requireLatestRevision,
			  upgradeURL, install, installURL, altURL,
			  overridePluginsPage,disableAutoInstall)
{
    if (disableAutoInstall == null)
    {
	alert("ERROR: MM_FlashDispatch() called with too few arguments.");
	return;
    }


    if (overridePluginsPage && installURL.substring(0, 7) != "http://")
    {
	alert("ERROR: MM_FlashDispatch() called with relative URL" +
	    " for PLUGINSPAGE (" + installURL + ")");

	return;
    }


    var player = new MM_FlashInfo();

    if (player.installed == null)
    {
	var sniffer =
	    "<EMBED HIDDEN=\"true\" TYPE=\"application/x-shockwave-flash\"" +
		  " WIDTH=\"18\" HEIGHT=\"18\"" +
		  " BGCOLOR=\"" + document.bgcolor + "\"" +
		  " SRC=\"" + MM_FlashSnifferURL +
			"?contentURL=" + contentURL + "?" +
			"&contentVersion=" + contentVersion +
			"&requireLatestRevision=" + requireLatestRevision +
			"&latestRevision=" +
			    MM_FlashLatestPluginRevision(contentVersion) +
			"&upgradeURL=" + upgradeURL +
			"\"" +
		  " LOOP=\"false\" MENU=\"false\"" +
		  " PLUGINSPAGE=\"" +
		    (overridePluginsPage ? installURL : MM_FlashPluginsPage) +
		    "\"" +
	    ">" +
	    "</EMBED>";

	document.open();
	document.write("<HTML><HEAD><TITLE>");
	document.write("Checking for the Flash Player");
	document.write("</TITLE></HEAD>");
	document.write("<BODY BGCOLOR=\"" + document.bgcolor + "\">");
	document.write(sniffer);
	document.write("</BODY>");
	document.write("</HTML>");
	document.close();
    }
    else if (player.installed)
    {
	if (player.canPlay(contentVersion, requireLatestRevision))
	{
	    location = contentURL;
	}
	else
	{
	if (disableAutoInstall)
	{
	location = upgradeURL;
	}else
	{
	    location = player.autoInstallable ? contentURL : upgradeURL;
	}
	}
    }
    else if (install)
    {
	if (disableAutoInstall){
	location = installURL;
	}
	else{
	location = player.autoInstallable ? contentURL : installURL;
	}
    }
    else
    {
	location = altURL;
    }
}



function MM_FlashRememberIfDetectedSelf(count, units)
{
    // the sniffer appends an empty search string to the URL
    // to indicate that it is the referrer

    if (document.location.search.indexOf("?") != -1)
    {
	if (!count) count = 60;
	if (!units) units = "days";

	var msecs = new Object();

	msecs.minute = msecs.minutes = 60000;
	msecs.hour = msecs.hours = 60 * msecs.minute;
	msecs.day = msecs.days = 24 * msecs.hour;

	var expires = new Date();

	expires.setTime(expires.getTime() + count * msecs[units]);

	document.cookie =
	    'MM_FlashDetectedSelf=true ; expires=' + expires.toGMTString();
    }
}



function MM_FlashDemur(count, units)
{
    if (!count) count = 60;
    if (!units) units = "days";

    var msecs = new Object();

    msecs.minute = msecs.minutes = 60000;
    msecs.hour = msecs.hours = 60 * msecs.minute;
    msecs.day = msecs.days = 24 * msecs.hour;

    var expires = new Date();

    expires.setTime(expires.getTime() + count * msecs[units]);

    document.cookie =
	'MM_FlashUserDemurred=true ; expires=' + expires.toGMTString();


    if (!MM_FlashUserDemurred())
    {
	alert("Your browser must accept cookies in order to " +
	      "save this information.  Try changing your preferences.");

	return false;
    }
    else
	return true;
}



function MM_FlashUserDemurred()
{
    return (document.cookie.indexOf("MM_FlashUserDemurred") != -1);
}



function MM_FlashLatestPluginRevision(playerVersion)
{
    var latestRevision;
    var platform;

    if (navigator.appVersion.indexOf("Win") != -1)
	platform = "Windows";
    else if (navigator.appVersion.indexOf("Macintosh") != -1)
	platform = "Macintosh";
    else if (navigator.appVersion.indexOf("X11") != -1)
	platform = "Unix";

    latestRevision = MM_latestPluginRevision[playerVersion][platform];

    return latestRevision;
}



function MM_FlashCanPlay(contentVersion, requireLatestRevision)
{
    var canPlay;

    if (this.version)
    {
	canPlay = (parseInt(contentVersion) <= this.version);

	if (requireLatestRevision)
	{
	    if (this.revision &&
		this.revision < MM_FlashLatestPluginRevision(this.version))
	    {
		canPlay = false;
	    }
	}
    }
    else
    {
	canPlay = MM_FlashDetectedSelf();
    }

    return canPlay;
}


function MM_FlashDetectedSelf()
{
    return (document.cookie.indexOf("MM_FlashDetectedSelf") != -1);
}


/* Funciones para evitar doble click en los controles flash */

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';
  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, "", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


function runSWF(archivo, ancho, alto, version, bgcolor, FlashVars,id, menu,  quality, allowScriptAccess) { 
if(version!=""){
	var version_data=version;
}else{
	var version_data="6,0,0,0";
}
if(menu!=""){
	menu_data=menu;
}else{
	menu_data=false;
}
if(bgcolor!=""){
	var bgcolor_data=bgcolor;
}else{
	var bgcolor_data="#FFFFFF";
}
if(id!=""){
	id_data=id;
}else{
	id_data="flashMovie";
}
if(quality!=""){
	quality_data=quality;
}else{
	quality_data="high";
}
if(allowScriptAccess!=""){
	allowScriptAccess_data=allowScriptAccess;
}else{
	allowScriptAccess_data="always";
}
var quality="high"; // calidad de visualización de la peli
 document.write('<object width='+ancho+' height='+alto+' id='+id_data+' type="application/x-shockwave-flash" data='+archivo+'>\n');
 document.write('<param name="bgcolor" value='+bgcolor_data+' />\n');
 document.write('<param name="movie" value='+archivo+' />\n');
 document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+' />\n');
 document.write('<param name="quality" value='+quality_data+' />\n');
 document.write('<param name="FlashVars" value='+FlashVars+' />\n');
 document.write('<param name="menu" value='+menu_data+' />\n');
 document.write('<param name="wmode" value="transparent" />\n');
 document.write('</object>\n');
}

function runSWF2(archivo, ancho, alto, version, bgcolor, FlashVars, id, menu, quality, allowScriptAccess, loop) { 
if(version!=""){
	var version_data=version;
}else{
	var version_data="6,0,0,0";
}
if(menu!=""){
	menu_data=menu;
}else{
	menu_data=false;
}
if(bgcolor!=""){
	var bgcolor_data=bgcolor;
}else{
	var bgcolor_data="#FFFFFF";
}
if(id!=""){
	id_data=id;
}else{
	id_data="flashMovie";
}
if(quality!=""){
	quality_data=quality;
}else{
	quality_data="high";
}
if(allowScriptAccess!=""){
	allowScriptAccess_data=allowScriptAccess;
}else{
	allowScriptAccess_data="always";
}
if(loop!=""){
	var loop_data=loop;
}else{
	var loop_data="true";
}
var quality="high"; // calidad de visualización de la peli
 document.write('<object width='+ancho+' height='+alto+' id='+id_data+' type="application/x-shockwave-flash" data='+archivo+'>\n');
 document.write('<param name="bgcolor" value='+bgcolor_data+' />\n');
 document.write('<param name="movie" value='+archivo+' />\n');
 document.write('<param name="allowScriptAccess" value='+allowScriptAccess_data+' />\n');
 document.write('<param name="quality" value='+quality_data+' />\n');
 document.write('<param name="FlashVars" value='+FlashVars+' />\n');
 document.write('<param name="menu" value='+menu_data+' />\n');
 document.write('<param name="wmode" value="transparent" />\n');
 document.write('<param name="loop" value='+loop_data+' />\n');
 document.write('</object>\n');
}