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 ComprobarFecha33(Cadena){
	var Fecha= new String(Cadena)	// Crea un string
	var RealFecha= new Date()	// Para sacar la fecha de hoy
	// Cadena Año
	var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length))
	// Cadena Mes
	var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))
	// Cadena Día
	var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
        	//alert('Año inválido')
		return false;
	}

	// Valido el mes
	if (isNaN(Mes) || parseInt(Mes, 10)<1 || parseInt(Mes, 10)>12){
		//alert('Mes inválido')
		return false;
	}

	// Valido el Dia
	if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){
		//alert('Día inválido')
		return false;
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			//alert('Día inválido')
			return false;
		}
	}
}

function RecordarUsuario() {
	var Datuak="";
	
	Datuak=window.prompt("Introduzca su correo electrónico y le enviaremos los datos de acceso:","");

	if ((Datuak!=null) && (Datuak.length>0)){
		document.Login.Accion.value = "gogoratu";
		document.Login.MailLogin.value = Datuak;
		document.Login.submit();
	}
}

function OcultarZona (Tipo) {
	document.getElementById(Tipo).style.display='none';
}

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 IsNumeric(sText) {
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   return IsNumber; 
  }


function ValidarRegistroEU() {
	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Erabiltzaile izena idatzi.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("Erabiltzaile izenak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Erabiltzaile izena tarterik gabe izan behar da.");
			document.Formularioa.Usuario.focus();
			return (false);
		}*/
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Posta elektronikoa idatzi.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Baliozko posta elektronikoa idatzi.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}

	limpio = limpia(document.Formularioa.Clave.value);
	if (limpio == "") {
		alert("Pasahitza idatzi.");
		document.Formularioa.Clave.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("Pasahitzak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Clave.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Pasahitza tarterik gabe izan behar da.");
			document.Formularioa.Clave.focus();
			return (false);
		}*/
	}

	limpio2 = limpia(document.Formularioa.Clave2.value);
	if (limpio2 == "") {
		alert("Pasahitza berretsi.");
		document.Formularioa.Clave2.focus();
		return (false);
	}
	else {
		if (document.Formularioa.Clave.value != document.Formularioa.Clave2.value) {
			alert("Pasahitza eta egiaztapena ez datoz bat, saia zaitez berriz, mesedez.");
			document.Formularioa.Clave.focus();
			return (false);
		}
	}

	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Idatzi zure izena.");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Apellido1.value);
	if (limpio == "") {
		alert("Idatzi zure lehenengo abizena.");
		document.Formularioa.Apellido1.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Direccion1.value);
	if (limpio == "") {
		alert("Idatzi zure helbidea.");
		document.Formularioa.Direccion1.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Ciudad.value);
	if (limpio == "") {
		alert("Idatzi zure hiria.");
		document.Formularioa.Ciudad.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.CodPostal.value);
	if (limpio == "") {
		alert("Idatzi posta kodea.");
		document.Formularioa.CodPostal.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.IdPais.value);
	if (limpio == "0") {
		alert("Aukeratu zure herrialdea.");
		document.Formularioa.IdPais.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Telefono.value);
	if (limpio == "") {
		alert("Idazti zure telefonoa.");
		document.Formularioa.Telefono.focus();
		return (false);
	}

	if (!document.getElementById("Acepto").checked) {
		alert("Pribatutasun politikaren baldintzak onartu behar dituzu.");
		return (false);
	}
		
	return (true);
}

function ValidaNireDatuakEU() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Idatzi zure izena.");
		document.Formularioa.Nombre.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Apellido1.value);
	if (limpio == "") {
		alert("Idatzi zure lehenengo abizena.");
		document.Formularioa.Apellido1.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Erabiltzaile izena idatzi.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("Erabiltzaile izenak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Posta elektronikoa idatzi.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Baliozko posta elektronikoa idatzi.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}

	limpio = limpia(document.Formularioa.Foto.value);
	if (limpio != "") {
		var i=limpio.lastIndexOf(".");
		if (i>0) {
			var ext= limpio.substr(i+1).toLowerCase();
			if (!((ext=="jpg")||(ext=="jpeg")||(ext=="gif")||(ext=="png"))) {
				alert("Irudiaren formatoa ez da zuzena, JPG, JPEG, GIF edo PNG izan beharko da.");
				return false;
			}
		}
	}

	limpio = limpia(document.Formularioa.Clave.value);
	if (limpio != "") {
		if (limpio.length < 3) {
			alert("Pasahitzak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Clave.focus();
			return (false);
		}

		limpio2 = limpia(document.Formularioa.Clave2.value);
		if (limpio2 == "") {
			alert("Pasahitza berretsi.");
			document.Formularioa.Clave2.focus();
			return (false);
		}
		else {
			if (document.Formularioa.Clave.value != document.Formularioa.Clave2.value) {
				alert("Pasahitza eta egiaztapena ez datoz bat, saia zaitez berriz, mesedez.");
				document.Formularioa.Clave.focus();
				return (false);
			}
		}
	}

	return (true);
}

function ValidaClaveEU() {
	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Erabiltzaile izena idatzi.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("Erabiltzaile izenak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Erabiltzaile izena tarterik gabe izan behar da.");
			document.Formularioa.Usuario.focus();
			return (false);
		}*/
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Posta elektronikoa idatzi.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Baliozko posta elektronikoa idatzi.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}
	return (true);
}

function ValidaArbolesEU() {
	limpio = limpia(document.Formularioa.Titulo.value);
	if (limpio == "") {
		alert("Zuhaitzaren izena idatzi.");
		document.Formularioa.Titulo.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Foto.value);
	if (limpio != "") {
		var i=limpio.lastIndexOf(".");
		if (i>0) {
			var ext= limpio.substr(i+1).toLowerCase();
			if (!((ext=="jpg")||(ext=="jpeg")||(ext=="gif")||(ext=="png"))) {
				alert("Irudiaren formatoa ez da zuzena, JPG, JPEG, GIF edo PNG izan beharko da.");
				return false;
			}
		}
	}
	return (true);
}

function ValidarRegistroES() {
	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Escribe un nombre de usuario.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("El nombre de usuario debe tener al menos 3 caracteres.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Erabiltzaile izena tarterik gabe izan behar da.");
			document.Formularioa.Usuario.focus();
			return (false);
		}*/
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Escribe tu dirección de correo electrónico.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Escribe una dirección de correo electrónico válida.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}

	limpio = limpia(document.Formularioa.Clave.value);
	if (limpio == "") {
		alert("Escribe una clave.");
		document.Formularioa.Clave.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("La clave debe tener al menos 3 caracteres.");
			document.Formularioa.Clave.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Pasahitza tarterik gabe izan behar da.");
			document.Formularioa.Clave.focus();
			return (false);
		}*/
	}

	limpio2 = limpia(document.Formularioa.Clave2.value);
	if (limpio2 == "") {
		alert("Confirma la clave.");
		document.Formularioa.Clave2.focus();
		return (false);
	}
	else {
		if (document.Formularioa.Clave.value != document.Formularioa.Clave2.value) {
			alert("Las claves no coinciden, inténtalo de nuevo, por favor.");
			document.Formularioa.Clave.focus();
			return (false);
		}
	}

	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Escribe tu nombre.");
		document.Formularioa.Nombre.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Apellido1.value);
	if (limpio == "") {
		alert("Escribe tu primer apellido.");
		document.Formularioa.Apellido1.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Direccion1.value);
	if (limpio == "") {
		alert("Escribe tu dirección.");
		document.Formularioa.Direccion1.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Ciudad.value);
	if (limpio == "") {
		alert("Escribe tu ciudad.");
		document.Formularioa.Ciudad.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.CodPostal.value);
	if (limpio == "") {
		alert("Escribe tu código postal.");
		document.Formularioa.CodPostal.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.IdPais.value);
	if (limpio == "0") {
		alert("Elige tu país.");
		document.Formularioa.IdPais.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Telefono.value);
	if (limpio == "") {
		alert("Escribe tu teléfono.");
		document.Formularioa.Telefono.focus();
		return (false);
	}

	if (!document.getElementById("Acepto").checked) {
		alert("Debes aceptar las condiciones de la política de privacidad.");
		return (false);
	}
		
	return (true);
}

function ValidaNireDatuakES() {
	limpio = limpia(document.Formularioa.Nombre.value);
	if (limpio == "") {
		alert("Escribe tu nombre.");
		document.Formularioa.Nombre.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Apellido1.value);
	if (limpio == "") {
		alert("Escribe tu primer apellido.");
		document.Formularioa.Apellido1.focus();
		return (false);
	}

	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Escribe tu nombre de usuario.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("El nombre de usuario debe tener al menos 3 caracteres.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Erabiltzaile izena tarterik gabe izan behar da.");
			document.Formularioa.Usuario.focus();
			return (false);
		}*/
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Escribe tu dirección de correo electrónico.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Escribe una dirección de correo electrónico válida.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}
	
	limpio = limpia(document.Formularioa.Foto.value);
	if (limpio != "") {
		var i=limpio.lastIndexOf(".");
		if (i>0) {
			var ext= limpio.substr(i+1).toLowerCase();
			if (!((ext=="jpg")||(ext=="jpeg")||(ext=="gif")||(ext=="png"))) {
				alert("El formato de la imagen no es correcto. El formato debe ser JPG, JPEG, GIF o PNG.");
				return false;
			}
		}
	}	

	limpio = limpia(document.Formularioa.Clave.value);
	if (limpio != "") {
		if (limpio.length < 3) {
			alert("Pasahitzak 3 karaktere gutxienez izan behar ditu.");
			document.Formularioa.Clave.focus();
			return (false);
		}

		limpio2 = limpia(document.Formularioa.Clave2.value);
		if (limpio2 == "") {
			alert("Pasahitza berretsi.");
			document.Formularioa.Clave2.focus();
			return (false);
		}
		else {
			if (document.Formularioa.Clave.value != document.Formularioa.Clave2.value) {
				alert("Pasahitza eta egiaztapena ez datoz bat, saia zaitez berriz, mesedez.");
				document.Formularioa.Clave.focus();
				return (false);
			}
		}
	}
		
	return (true);
}

function ValidaClaveES() {
	limpio = limpia(document.Formularioa.Usuario.value);
	if (limpio == "") {
		alert("Escribe tu nombre de usuario.");
		document.Formularioa.Usuario.focus();
		return (false);
	}
	else {
		if (limpio.length < 3) {
			alert("El nombre de usuario debe tener al menos 3 caracteres.");
			document.Formularioa.Usuario.focus();
			return (false);
		}
		/*if (limpio.indexOf(" ") != -1) {
			alert("Erabiltzaile izena tarterik gabe izan behar da.");
			document.Formularioa.Usuario.focus();
			return (false);
		}*/
	}

	limpio = limpia(document.Formularioa.Mail.value);
	if (limpio == "") {
		alert("Escribe tu dirección de correo electrónico.");
		document.Formularioa.Mail.focus();
		return (false);
	}
	else {
		if (!validate_email("Mail","Escribe una dirección de correo electrónico válida.")) {
			document.Formularioa.Mail.focus();
			return (false);
		} 
	}
	return (true);
}

function ValidaArbolesES() {
	limpio = limpia(document.Formularioa.Titulo.value);
	if (limpio == "") {
		alert("Escribe el nombre del árbol.");
		document.Formularioa.Titulo.focus();
		return (false);
	}
	limpio = limpia(document.Formularioa.Foto.value);
	if (limpio != "") {
		var i=limpio.lastIndexOf(".");
		if (i>0) {
			var ext= limpio.substr(i+1).toLowerCase();
			if (!((ext=="jpg")||(ext=="jpeg")||(ext=="gif")||(ext=="png"))) {
				alert("El formato de la imagen no es correcto. El formato debe ser JPG, JPEG, GIF o PNG.");
				return false;
			}
		}
	}

	return (true);
}
function validate_email(field,alerttxt) {
	tm=document.getElementById(field);
	apos=tm.value.indexOf("@");
	dotpos=tm.value.lastIndexOf(".");
	if (apos<1||dotpos-apos<2) {
		alert(alerttxt);
		return false;
	}
	else {
		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 resizeImage(im,dim,posim) {
	// 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';
			}
		}
	}
}


/*===Scroll de imagenes===*/
var numElem=0;
var timerID=0;

function it(nE) {
	numElem=nE;
	x=document.getElementById("scroll_dentro");
	x.style.width=((175*numElem)+2) + "px";
}
function st() {
	/*Parar el movimiento*/
	clearTimeout(timerID);
}
function dr() {
	/*Mover a la derecha*/
	clearTimeout(timerID);
	timerID=setTimeout("dcha()", 50);
}
function di() {
	/*Mover a la izquierda*/
	clearTimeout(timerID);
	timerID=setTimeout("izda()", 50);
}
function dcha() {
	x=document.getElementById("scroll_dentro");
	if ( (175*numElem+parseInt(x.style.left)) >= 590 ) {
		x.style.left=(parseInt(x.style.left)-10) + "px";
		timerID=setTimeout("dcha()", 50);
	}
}
function izda() {
	x=document.getElementById("scroll_dentro");
	if ( parseInt(x.style.left) <= 0 ) {
		x.style.left=(parseInt(x.style.left)+10) + "px";
		timerID=setTimeout("izda()", 50);
	}
}
/*===/Scroll de imagenes===*/

/*===Scroll de imagenes 2===*/
var numElem2=0;
var timerID2=0;

function it2(nE) {
	numElem2=nE;
	x=document.getElementById("scroll_dentro");
	document.getElementById("scroll_dentro").style.width=((117*numElem2)+2) + "px";

}
function st2() {
	/*Parar el movimiento*/
	clearTimeout(timerID2);
}
function dr2() {
	/*Mover a la derecha*/
	clearTimeout(timerID2);
	timerID2=setTimeout("dcha2()", 50);
}
function di2() {
	/*Mover a la izquierda*/
	clearTimeout(timerID2);
	timerID2=setTimeout("izda2()", 50);
}
function dcha2() {
	x=document.getElementById("scroll_dentro");
	if ( (117*numElem2+parseInt(x.style.left)) >= 570 ) {
		x.style.left=(parseInt(x.style.left)-10) + "px";
		timerID2=setTimeout("dcha2()", 50);
	}
}
function izda2() {
	x=document.getElementById("scroll_dentro");
	if ( parseInt(x.style.left) <= 0 ) {
		x.style.left=(parseInt(x.style.left)+10) + "px";
		timerID2=setTimeout("izda2()", 50);
	}
}
/*===/Scroll de imagenes 2===*/

/*===Resize imagen para el scroll===*/
/* Preparado para el scroll horizontal, esta reducida */
function resizeImage(im,dim,posim) {
	x=document.getElementById("img" + im);
	y=document.getElementById("dv" + im);
	
	if (!x.complete)
	{
		temporizadorResize=setTimeout("resizeImage("+im+","+dim+","+posim+")", 100);
		return -1;
	}

	//Tamaño de la imagen
	if (x.width >= x.height) {
		x.height = dim;
	}
	else {
		x.width = dim;
	}

	//Posicion
	y.style.overflow="hidden";
	
	if (posim == "no") return 1;
	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';
		}
	}
	return 1;
}
/*===/Resize imagen para el scroll===*/

function VERCAPA (cual) {
	var obj=cual
	var obj2="1" + cual
	var obj3="2" + cual
	if (obj2) document.getElementById(obj2).style.display='none';
	if (obj) document.getElementById(cual).style.display='';
	if (obj3) document.getElementById(obj3).style.display='';
}

function CERRARCAPA (cual) {
	var obj=cual
	var obj2="1" + cual
	var obj3="2" + cual
	if (obj2) document.getElementById(obj2).style.display='';
	if (obj) document.getElementById(cual).style.display='none';
	if (obj3) document.getElementById(obj3).style.display='none';
}
function abrirVentana(url, nombre, opciones)
{
	var w=window.open(url, nombre, opciones);
	if (!w)
	{
		alert("La ventana ha sido bloqueada\r\nPara utilizar la p\xE1gina adecuadamente desactive el bloqueador de ventanas.");
		return false;
	}
	try
	{
		var sTest = w.name ;
		w.focus();
	}
	catch(e)
	{
		alert("No ha sido posible activar la nueva ventana. Revise la configuraci\xF3n de su bloqueador de ventanas.");
		return false;
	}
	return true;
}

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;
}

function AbrirVistaAerea() { //v2.0
  abrirCentro("MapaLocalizacion.asp", 550, 413);
}

function AbrirFichaAloja(id) { //v2.0
  abrirCentro("FichaAlojamiento.asp?Idalojamiento="+id, 850, 540);
}

function slide(id) {
	if ($(id).style.display=='none')
	{
		Effect.SlideDown(id);
		$('P_'+id).innerHTML='';
		while($('P_'+id).innerHTML!='');
		$('P_'+id).innerHTML='Ocultar búsqueda&nbsp;&nbsp;<img src="images/desplegar2.jpg" alt="nueva búsqueda"/>';
	}
	else {
		Effect.SlideUp(id);
		$('P_'+id).innerHTML='';
		while($('P_'+id).innerHTML!='');
		$('P_'+id).innerHTML='Nueva búsqueda&nbsp;&nbsp;<img src="images/desplegar.jpg" alt="nueva búsqueda"/>';
	}
	return false;
}

function ValidaCompraProducto() {
	limpio = limpia(document.Formularioa.Cantidad.value);
	if (limpio == "" || limpio == "0") {
		alert("Idatzi kopurua.");
		document.Formularioa.Cantidad.focus();
		return (false);
	}
	else {
		stock = parseInt(document.getElementById('Stock').value);
		usados = parseInt(document.getElementById('Usados').value);
		limpio = parseInt(limpio);
		if ((limpio + usados) > stock) {
			if (stock == 1){
				txt = "Ale bat besterik ez daukagu eskuragarri.";
			}
			else {
				txt = stock+" ale besterik ez dauzkagu eskuragarri.";
			}
			if (usados > 0 ) {
				if (usados > 1 ) {
					txt = txt + "\nDagoeneko badaude "+usados+" ale saskian.";
				}
				else {
					txt = txt + "\nDagoeneko badago ale bat saskian.";
				}
			}
			alert(txt);
			document.Formularioa.Cantidad.focus();
			return (false);
		}
	}
	return (true);
}

function EsNumero(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 Actualizar() {
	document.Productos.ZerEgin.value="actualizar";
	document.Productos.submit();
}

function IrCaja() {
	document.Productos.ZerEgin.value="Caja";
	document.Productos.submit();
}
