<!-- Foto Ajustada a ventana-------------------------------------------------------------------------

var titulopordefecto = "Foto Ampliada"; //Si no se especifica un título al llamar a la función colocará el que se especifique aquí
var ventana;
var cont=0;

function afoto(cual,titulo)
{
if(cont==1){ventana.close();ventana=null}
if(titulo==null){titulo=titulopordefecto}
ventana=window.open('','ventana','resizable=yes,scrollbars=no')
ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)">');
ventana.document.close();
cont++;
}
function redimensionar(ancho, alto)
{
ventana.resizeTo(ancho+12,alto+28);
ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}
//................................................................................................>


<!-- Chequea Formulario II ----------------------------------------------------------------------------
function  chequea(formulario)
{
if(!formulario.nombre.value.length)
{
	alert("El campo nombre y apellidos es obligatorio");
	return false;
}
if(!formulario.mail.value.length)
{
	alert("El campo mail es obligatorio");
	return false;
}
if(!formulario.acepto.checked){
	alert("Debe leer y aceptar las condiciones generales del servicio");
	return false;
}
return true;
}
//................................................................................................>

<!-- Precarga Botones ----------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//....................................................................................................>


<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//....................................................................................................>


<!-- Ajustar Iframe ----------------------------------------------------------------------------
function ajustar_iframe(nombreFrame)
{
    if(document.getElementById && !(document.all))
    {
        height = document.getElementById(nombreFrame).contentDocument.body.scrollHeight;
        document.getElementById(nombreFrame).style.height = height;
        width = document.getElementById(nombreFrame).contentDocument.body.scrollWidth;
        document.getElementById(nombreFrame).style.width = width;
    }
   else if(document.all)
    {
        height = document.frames(nombreFrame).document.body.scrollHeight;
        document.all[nombreFrame].style.height = height;
        width = document.frames(nombreFrame).document.body.scrollWidth;
        document.all[nombreFrame].style.width = width;
    }
}
//....................................................................................................>

<!--Fecha Válida ----------------------------------------------------------------------------

function fechaValida(f)
{
	f = f.replace(/\/([0-9])\//, "/0$1/");
	f = f.replace(/^([0-9])\//, "0$1/");
	re=/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]$/
	if(f.length==0 || !re.exec(f))
	{
		return false;
	}
	 
	/* comprobamos que la fecha es válida */
	var d = new Date()
	/* la función tiene como entrada: año, mes, día */
	d.setFullYear(f.substr(6 , 4), 
			  f.substr(3, 2) - 1,
			  f.substr(0, 2))
	 
	/* ¿el mes del objeto Date es el mes introducido por el usuario?
	   OJO: getMonth() devuelve el número de mes del 0 al 11
	 
	   ¿el día del objeto Date es el día introducido por el usuario?
	   OJO: getDate() devuelve el día del mes */
	if(d.getMonth() != f.substr(3, 2) - 1 
		|| d.getDate() != f.substr(0,2))
	{
		return false;
	}
	return true;
}
//....................................................................................................>

<!-- Chequea Formulario ----------------------------------------------------------------------------
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments, valcheck;
  for (i=0; i<(args.length-2); i+=3)
  {
    test=args[i+2];
	val=MM_findObj(args[i]);
	valcheck=val;
    if (val)
	{
	  nm=val.name;
	  if ((val=val.value)!="")
	  {
        if (test.indexOf('Rcheck')!=-1)
	    {
		  if (!valcheck.checked)
		    errors += '- '+nm+' debe de ser aceptado.\n';
		}
        else if (test.indexOf('Rdate')!=-1)
	    {
		  if (!fechaValida(valcheck.value))
		    errors += '- '+nm+' fecha incorrecta.\n';
		}
        else if (test.indexOf('isEmail')!=-1)
	    {
	      p=val.indexOf('@');
          if (p<1 || p==(val.length-1))
  		    errors+='- '+nm+' debe conter unha dirección válida de correo.\n';
        }
	    else if (test!='R')
	    {
	      num = parseFloat(val);
          if (isNaN(val))
		    errors+='- '+nm+' debe conter 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 conter un número entre '+min+' e '+max+'.\n';
    	  } //if test inRange
	    } // if test != R
	  } //if test indexof
	  else if (test.charAt(0) == 'R')
	    errors += '- '+nm+' debe conter algún valor.\n';
	} // if val
  } //for
  if (errors)
    alert('Errores no formulario:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//....................................................................................................>

<!-- Abrir ventana nueva ------------------------------------------------------------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//....................................................................................................>

