function cambiaFoto(foto,posicion){
	if(posicion=="H"){
		document.getElementById("marcoFoto").src="img/borde2.png";
	}else{
		document.getElementById("marcoFoto").src="img/borde2V.png";
	}	
	
	document.getElementById("ampliacion").style.backgroundImage="url('ftp/" + foto + "')";
	
}

function cambiaFoto2(id){
	
	document.getElementById("ifrfotos").src="cargar-foto.asp?id=" + id;
	
}

function paginacion(pagina){
	document.getElementById("formPaginacion").p.value=pagina;
	document.getElementById("formPaginacion").submit();
}

function buscar(){
	document.getElementById("formBuscador").submit();
}

function enviar(){
	var texto="";
	
	if(document.getElementById("formulario").NombreApellidos.value==""){
		texto+="* Persona de contacto.\n"
	}
	
	if(document.getElementById("formulario").EMAIL.value==""){
		texto+="* Email.\n"
	}
	
	if(document.getElementById("formulario").Comentarios.value==""){
		texto+="* Comentario.\n"
	}
	
	if(document.getElementById("formulario").captcha.value==""){
		texto+="* Escriba los caracteres de la imagen.\n"
	}
	
	if(texto!=""){
		//jConfirm(texto, 'Debe rellenar los siguientes campos',function(r){
		//	this.close;
		//});
		jAlert(texto,'Debe rellenar los siguientes campos');
		
		//alert(texto)
	}else{
		//document.getElementById("formulario").submit();
		
		
		url = "comprobar-captcha.asp?captcha=" + document.getElementById("formulario").captcha.value;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseComprobarCaptcha;
		http.send(null);
		
		
	}
}


function handleHttpResponseComprobarCaptcha() {
	if (http.readyState == 4) {    
		var respuesta=http.responseText;
		if(respuesta=="si"){
			document.getElementById("formulario").action="enviar-contacto.asp"
			document.getElementById("formulario").error.value="no"
			document.getElementById("formulario").submit();
		}else{
			document.getElementById("formulario").action="contacto.asp"
			document.getElementById("formulario").error.value="error"
			document.getElementById("formulario").submit();
		}	
	}    
}
