function buscar() {
	if (document.buscador.pclave.value == "") {
		alert("Por favor, escriba una palabra clave");
		return false;
	} else {
		return true;
	}
}

function actualizacion() {
	document.compra.action="comprar.php";
	document.compra.submit();
}

function registrar() {
	if (document.registro.fusuario.value == "" || document.registro.fclave.value == "" || document.registro.dni.value == "" || document.registro.fapellidos.value == "" || document.registro.fdomicilio.value == "" || document.registro.fciudad.value == "" || document.registro.fprovincia.value == "0" || document.registro.ftmovil.value == "" || document.registro.fcp.value == "") {
		alert("Por favor, rellene los campos obligatorios"); 
		return false;
	}
	strEmail = document.registro.fusuario.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El email no tiene un formato válido");
		return false;
	}
	return true;
}

function identificar() {
	if (document.identifica.fusuario.value == "" || document.identifica.fclave.value == "") {
		alert("Por favor, indique su email y su clave");
		return false;
	}
	strEmail = document.fusuario.fcorreo.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El email no tiene un formato válido");
		return false;
	}
	return true;
}

function recuperar() {
	if (document.recupera.fusuario.value == "") {
		alert("Por favor, indique su email");
		return false;
	}
	strEmail = document.recupera.fusuario.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El email no tiene un formato válido");
		return false;
	}
	return true;
}

function contactar() {
	if (document.contacto.fcorreo.value == "" || document.contacto.fcorreo.value == "" || document.contacto.fmensaje.value == "") {
		alert("Por favor, rellene todos los campos");
		return false;
	}
	strEmail = document.contacto.fcorreo.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El email no tiene un formato válido");
		return false;
	}
	return true;
}

function chequeo_fechas() {
	if (document.reserva.fdesde.value == "") {
		alert("Tiene que indicar la fecha inicial del alquiler");
		return false;
	}
	if (document.reserva.fhasta.value == "") {
		alert("Tiene que indicar la fecha final del alquiler");
		return false;
	}
	return true;
}

function chequeo_alquiler() {
	var dir1 = 0;
	var dir2 = 0;
	if (document.alquiler.envio.length != undefined) {
		for (i=0; i < document.alquiler.envio.length; i++){
			if (document.alquiler.envio[i].checked == true){
				dir1 = 1;
				break //exist for loop, as target acquired.
			}
		}
	} else {
		dir1 = 1;
	}
	if (document.alquiler.recogida.length != undefined) {
		for (i=0; i < document.alquiler.recogida.length; i++){
			if (document.alquiler.recogida[i].checked == true){
				dir2 = 1;
				break //exist for loop, as target acquired.
			}
		}
	} else {
		dir2 = 1;
	}
	if (dir1 > 0 && dir2 > 0) {
		// alert('OK');
		return true;
	} else  {
		alert('Tiene que indicar dirección de envío y recogida');
		return false;
	}
	return false;
}

function chequeo_direccion() {
	if (document.direccion.etiqueta.value == "" || document.direccion.direccion.value == "" || document.direccion.localidad.value == "" || document.direccion.codigopostal.value == "" || document.direccion.provincia.selectedIndex < 1) {
		alert("Todos los campos son obligatorios");
		return false;
	}
	return true;
}

function chequeo_outlet() {
	if (document.outlet.nombre.value == "" || document.outlet.apellidos.value == "" || document.outlet.email.value == "" || document.outlet.telefono.value == "") {
		alert("Por favor, rellene los campos obligatorios");
		return false;
	}
	strEmail = document.outlet.email.value;
	if ((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)){
		// return true;
	} else {
		alert("El email no tiene un formato válido");
		return false;
	}
	return true;
}

function chequeo_busqueda_avanzada() {
	if (document.busqueda.hasta.value == "" || document.busqueda.hasta.value == "") {
		if (document.busqueda.pclave.value == "") {
			alert("Tiene que indicar al menos una palabra clave o seleccionar un rango de fechas");
			return false;
		}
	}
	return true;
}

function amplia(foto) {
	window.open(foto,'Vip-closet','width=300,height=300,toolbar=no,scrollbar=no');
}

function cambia(foto,ruta) {
	document['bolso'].src = foto;
	document['bolso'].name = ruta;
}
