// 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 errores siguientes:\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);
}

// Este script carga un object de Windows Media Player evitando la protección de Microsoft
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,5,715"');
	document.write('	TYPE="application/x-oleobject" width="'+ancho+'" height="'+alto+'" align="top"');
	document.write('	standby="Cargando componentes Microsoft Windows Media Player..." ID="MediaPlayer" VIEWASTEXT>');
	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="true">');
	document.write('        <PARAM NAME="ShowControls" VALUE="true">');
	document.write('        <PARAM NAME="Autosize" VALUE="false">');
	document.write('        <PARAM NAME="ShowStatusBar" VALUE="true">');
	document.write('        <embed	SRC="'+pelicula+'" width="'+ancho+'" height="'+alto+'" AutoStart=1 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>');
}
