/***************** FUNCIONES PROPIAS **********************/
/* Funcion para centrar el contendor del logo*/
function centrar_contenedor_logo(){
   /*
    * En realidad el alto y ancho de la pagina es decir del contendor deberia ser
	* 825 * 600 pero como la foto tiene margenes los rectifico 
   */
   centrarcapa('contenedorlogo', 825, 600, 600, 425);
}

/* Funcion para centrar el contendor principal*/
function centrar_contenedor_principal(){
   anchopagina = (window.screen.width);
   altopagina = (window.screen.height - 200); /* le descuento la barra*/
   centrarcapa('contenedor_principal', anchopagina, altopagina, 825, 600);
}
/* Funcion para centrar las paginas. Centra la capa que tenga como identificador el contenedor principal*/
function centrarcapa(micapa, anchopagina, altopagina, anchocapa, altocapa){

 micapa =  document.getElementById(micapa);
 /* Calculamos el tanto por ciento*/
 
 ttop = (100 - ((altocapa * 100) / altopagina))/ 2;
 tleft =  (100 - ((anchocapa * 100) / anchopagina))/ 2;

 nuevotop = Math.abs(Math.round(ttop));
 nuevoleft = Math.abs(Math.round(tleft));

 micapa.style.top = String(nuevotop) + "%"; 
 micapa.style.left = String(nuevoleft) + "%"; 
}

/********* Esta funcion muestra una foto en una ventana nueva *********/
function Muestra_Foto(theFoto) {
  var windowprops ='top=100,left=100,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no, width=430, height=550';  
  var winName = 'ImagenAmpliada';
  var theURL = './img/fotosCatalogoReal/' + theFoto;
  var myWindow;
  myWindow = window.open(theURL,winName,windowprops);
  myWindow.document.bgColor = "black"; 
} 

function Muestra_Pagina_Mapa_Espinardo() {
  var windowprops ='top=50,left=50,toolbar=no,location=no,status=no, menubar=no,scrollbars=no, resizable=no,width=790,height=620';  
  var winName = 'MapaEspinardo';
  var theURL = './espinardo.htm';
  window.open(theURL,winName,windowprops);
  
} 

/* Esta funcion muestra el flash que contiene el logo de la pagina index*/
function PonLogoIndex(){
  var vid = 'FlashLogoIndex';
  var vUrl = './portalCN/img/foto_index_portal_dos_mariposas.swf';
  var vAncho = '550';
  var vAlto = '400';
  var vSalign = '';
  var vWmode = 'opaque';
  var vBgcolor = '#000000';
  var vLoop = 'true';
  pon_flash_ext(vUrl,vAncho,vAlto,vSalign,vWmode,vBgcolor,vLoop, vid); 
}
/* Esta función muestra el flash que contiene el mapa de espinardo*/
function PonMapaEspinardo(){
  var vid = 'FlashMapaEspinardo';
  var vUrl = './img/espinardo.swf';
  var vAncho = '770';
  var vAlto = '600';
  var vSalign = '';
  var vWmode = 'opaque';
  var vBgcolor = '#000000';
  var vLoop = 'false';
  pon_flash_ext(vUrl,vAncho,vAlto,vSalign,vWmode,vBgcolor,vLoop,vid); 
}


/************************ FUNCIONES DE AYUDA **************************/
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; 
    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 " +"<\/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 macromedia.com" + "<\/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>");
  }

  function pon_flash_ext(vurl,vancho,valto,vsalign,vwmode,vbgcolor, vLoop, vid) 
  {    
    if ((window.ActiveXObject) && (navigator.userAgent.indexOf("MSIE")!= -1) && (navigator.userAgent.indexOf("Windows") != -1))
    {
      document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
      document.write(' width="' + vancho + '" height="' + valto + '" id="'+ vid +'" align="top">');
      document.write(' <param name="movie" value="' + vurl + '">');
      document.write(' <param name=quality value=high>');
	  document.write(' <param name=menu value=false>');
 	  document.write(' <param name=loop value=' + vLoop + '>');
      document.write(' <param name="wmode" value="'+ vwmode +'" >');
      document.write(' <param name="scale" value="noscale">');
      document.write(' <param name="swliveconnect" value="true">');
      document.write(' <param name="bgcolor" value="'+ vbgcolor +'" >');
      document.write(' <param name="salign" value="'+ vsalign +'">');
      document.write('<' + '/object>');
    }
    else
    {
      var version_check = getFlashPluginVersion();

      if (version_check.scriptable)
      {
        document.write('<object id="'+ vid +'" data="' + vurl + '" type="application/x-shockwave-flash"');
        document.write(' width="' + vancho + '" height="' + valto + '" align="top">');
        document.write('<param name="movie" value="' + vurl + '" type="application/x-shockwave-flash">');
        document.write('<param name="quality" value="high">');
        document.write(' <param name=menu value=false>');
        document.write(' <param name=loop value=' + vLoop + '>');
        document.write(' <param name="wmode" value="'+ vwmode +'" >');
        document.write(' <param name="scale" value="noscale">');
        document.write(' <param name="salign" value="'+ vsalign +'">');
        document.write(' <param name="bgcolor" value="'+ vbgcolor +'" >');
        document.write('<param name="swliveconnect" value="true">');               
        document.write('<embed src="' + vurl + '" quality="high" menu="false" loop=' + vLoop + ' scale="noscale" salign="'+ vsalign +'" bgcolor="'+ vbgcolor +'" width="' + vancho + '" height="' + valto + '" name="'+ vid +'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'); 
        document.write('<\/object>'); 
      }
      else
        identifyFlash()
    }
  }


