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_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;
}

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 VerArticulo (cual) {
		OcultarZona ("general");
		OcultarZona ("cochecitos");
		OcultarZona ("sillas");
		OcultarZona ("mochilas");
		var obj=cual
		if (obj) document.getElementById(cual).style.display='';
	}

function OcultarZona (Tipo) {
	document.getElementById(Tipo).style.display='none';
}

function Muestra (cual) {
		var obj=cual
		if (obj) document.getElementById(cual).style.display='';
		document.getElementById('Emisora').value='';
		document.getElementById('Referencia').value='';
		document.getElementById('Identificacion').value='';
		document.getElementById('Importe').value='';
	}

function Esconde (cual) {
	document.getElementById(cual).style.display='none';
	document.getElementById('Emisora').value='xx';
		document.getElementById('Referencia').value='xx';
		document.getElementById('Identificacion').value='xx';
		document.getElementById('Importe').value='xx';
}

function ValidarGaldera() {
	limpio = limpia(document.consulta.pregunta.value);
	if (limpio == "") {
		alert("Introduzca la pregunta que desea realizar.");
		document.consulta.pregunta.focus();
		return (false);
	}
	return (true);
}

function Validar() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Introduce tu nombre y apellidos");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Mensaje.value);
	if (limpio == "") {
		alert("Introduce tu mensaje.");
		document.Formularioa.Mensaje.focus();
		return (false);
	}
	return (true);
}

function ValidarE() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Sartu zure izen-abizenak");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Mensaje.value);
	if (limpio == "") {
		alert("Sartu zure iruzkinak.");
		document.Formularioa.Mensaje.focus();
		return (false);
	}
	return (true);
}

function ValidarCur() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Introduce tu nombre y apellidos");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Curriculum.value);
	if (limpio == "") {
		alert("Introduce tu currículum.");
		document.Formularioa.Curriculum.focus();
		return (false);
	}
	return (true);
}

function ValidarCurE() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Sartu zure izen-abizenak");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Curriculum.value);
	if (limpio == "") {
		alert("Sartu zure Curriculum");
		document.Formularioa.Curriculum.focus();
		return (false);
	}
	return (true);
}

function ValidarInscripcion() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Introduzca su nombre.");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Apellidos.value);
	if (limpio == "") {
		alert("Introduzca sus apellidos.");
		document.Formularioa.Apellidos.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.DNI.value);
	if (limpio == "") {
		alert("Introduzca su DNI.");
		document.Formularioa.DNI.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Telefono.value);
	if (limpio == "") {
		alert("Introduzca su teléfono.");
		document.Formularioa.Telefono.focus();
		return (false);
	}

	if (!document.getElementById("CondiLeg").checked) {
		alert("Debe aceptar las condiciones de uso legal de la web.");
		return false
	}
	return (true);
}

function ValidarDomiciliacion() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Introduzca su nombre.");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Apellidos.value);
	if (limpio == "") {
		alert("Introduzca sus apellidos.");
		document.Formularioa.Apellidos.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.DNI.value);
	if (limpio == "") {
		alert("Introduzca su NIF/DNI.");
		document.Formularioa.DNI.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Telefono.value);
	if (limpio == "") {
		alert("Introduzca su teléfono.");
		document.Formularioa.Telefono.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Direccion.value);
	if (limpio == "") {
		alert("Introduzca su dirección.");
		document.Formularioa.Direccion.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Entidad.value);
	if (limpio == "") {
		alert("Introduzca el nombre de la entidad bancaria.");
		document.Formularioa.Entidad.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Titular.value);
	if (limpio == "") {
		alert("Introduzca el nombre y apellidos del titular de la cuenta.");
		document.Formularioa.Titular.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.CCC.value);
	if (limpio == "") {
		alert("Introduzca el número de cuenta corriente o libreta.");
		document.Formularioa.CCC.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Emisora.value);
	if (limpio == "") {
		alert("Introduzca el nombre de la entidad emisora.");
		document.Formularioa.Emisora.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Referencia.value);
	if (limpio == "") {
		alert("Introduzca la referencia.");
		document.Formularioa.Referencia.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Identificacion.value);
	if (limpio == "") {
		alert("Introduzca la identificación.");
		document.Formularioa.Identificacion.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Importe.value);
	if (limpio == "") {
		alert("Introduzca el importe.");
		document.Formularioa.Importe.focus();
		return (false);
	}

	if (!document.getElementById("CondiLeg").checked) {
		alert("Debe aceptar las condiciones de uso legal de la web.");
		return false
	}
	return (true);
}

function limpia(entry) {
  out = " "; // reemplazar lel espacio en blanco
  add = ""; // por vacio
  temp = "" + entry;

  while (temp.indexOf(out)>-1) {
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add + 
	temp.substring((pos + out.length), temp.length));
  }
  return(temp);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var w=window.open(theURL,winName,features);
  w.focus();
}

function EligeEvento () {
	OcultarEventos ("0");
	OcultarEventos ("1");
	var obj=document.getElementById(ValorCombo(document.Formularioa.Evento));
	if (obj) obj.style.display='';
}

function OcultarEventos (Evento) {
	document.getElementById(Evento).style.display='none';
}

function ValorCombo(elmto) {
	if (-1==elmto.selectedIndex) return 0

	if (elmto.item(elmto.selectedIndex))
		return elmto.item(elmto.selectedIndex).value;

	return 0
}

	function resizeImage(im,dim,posim) {
	// Ejemplo de HTML: <div id="dv1"><img src="exprimidito.jpg" id="img1"></div>
	// im: las imagenes tienen un id en el formato img1, img2, etc. im indica el numero ('img' + im)
	// dim: la dimension que debe tener la imagen en su dimension mas corta
	// posim [no | 0 | valor (px)] :
	//		no: no mueve la imagen
	//		0: centrado
	//		valor: mueve la imagen para centrarla en la dirección de su dimensión mas larga. En pixels

	x=document.getElementById("img" + im);
	y=document.getElementById("dv" + im);

	if (!x.complete)
	{
		temporizadorResize=setTimeout("resizeImage("+im+","+dim+","+posim+")", 100);
	}
	else {
		//Tamaño de la imagen
		if (x.width >= x.height) {
			x.height = dim;
		}
		else {
			//alert(x.width);
			x.width = dim;
		}
		//Tamaño del layer
		y.style.width=dim+"px";
		y.style.height=dim+"px";
		//Posicion
		//x.style.position="relative";
		y.style.overflow="hidden";
		
		if (posim == "no") return;
		if (posim == 0) {
		//Centrado por defecto
			if (x.width >= x.height) {
				x.style.left=-(((x.width*100/x.height) - 100)/2) + '%';
			}
			else {
				x.style.top=-(((x.height*100/x.width) - 100)/2) + '%';
			}
		}
		else {
			//Posición indicada
			if (x.width >= x.height) {
				x.style.left=-posim + 'px';
			}
			else {
				x.style.top=-posim + 'px';
			}
		}
	}
}

function IsDigit(e) {
    var code;
    if (e.preventDefault) {
        if (e.keyCode==0) {
            code=e.charCode;
        }
        else {
            return true
        }
    }
    else {
        code=e.keyCode;
    }
  return ((code >= 48) && (code <= 57));
}

function AbrirVistaAerea() { //v2.0
  abrirCentro("MapaAerea.htm", 550, 413);
}

function AbrirImprimir() { //v2.0
  abrirCentro("MapaImprimir.htm", 610, 413);
}

function abrirCentro(ref, w, h, opc, nombre) {
	var centro="";
	if (screen && screen.availWidth) {
		centro+=", left=" + ((screen.availWidth-w)/2);
		centro+=", top=" + ((screen.availHeight-h)/2);
	}
	w=MM_openBrWindow(ref, nombre, "width=" + w + ",height=" +h+centro + opc);
	return false;
}

