// Este script hace un redirect a la dirección pedida
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnvalue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una direción de e-mail.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es obligatorio.\n'; }
    } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function Popup_centrado(theURL,winname,features,ancho,alto) { 
   var left = Math.floor( ((screen.width)-ancho) / 2);
   var top = Math.floor( ((screen.height)-alto) / 2);
   var parametros = features + ',top=' + top + ',left=' + left + ',width=' + ancho + ',height=' + alto;
   window.open(theURL,winname,parametros);
}

function embedAudioVideo(pelicula,ancho,alto) {
	document.write('<object ');
	document.write('	classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"');
	document.write('    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1"');
	document.write('	type="application/x-oleobject" width="'+ancho+'" height="'+alto+'" align="top"');
	document.write('	standby="Cargando componentes Microsoft Windows Media Player..." id="MediaPlayer">');
	document.write('        <param name="Filename" value="'+pelicula+'">');
	document.write('        <param name="AnimationatStart" value="false">');
	document.write('        <param name="TransparentatStart" value="false">');
	document.write('        <param name="AutoStart" value="false">');
	document.write('        <param name="ShowControls" value="true">');
	document.write('        <param name="Autosize" value="false">');
	document.write('        <param name="ShowStatusBar" value="true">'); alto = alto + 10;
	document.write('        <embed src="'+pelicula+'" width="'+ancho+'" height="'+alto+'" AutoStart=0 align="top" type="application/x-mplayer2" ');
	document.write('		pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&"');
	document.write('        ShowControls=1 Autosize=0 ShowStatusBar=1></embed>');
	document.write('</object>');
}

function embedFlash(pelicula,ancho,alto){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+ancho+'" height="'+alto+'" id="FLVPlayer">');
	document.write('  <param name="movie" value="/img/FLVPlayer_Progressive.swf" />');
	document.write('  <param name="salign" value="lt" />');
	document.write('  <param name="quality" value="high" />');
	document.write('  <param name="scale" value="noscale" />');
	document.write('  <param name="FlashVars" value="&MM_ComponentVersion=1&skinname=/img/Clear_Skin_3&streamname='+pelicula+'&autoPlay=true&autoRewind=false" />');
	document.write('  <embed src="/img/FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinname=/img/Clear_Skin_3&streamname='+pelicula+'&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="'+ancho+'" height="'+alto+'" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />');
	document.write('</object>');
}


function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

