//Redimensiona la imagen en función del tamaño del navegador del cliente
function resize()
{
	var alto_imagen_original=document.getElementById("photo").height;
	var ancho_imagen_original=document.getElementById("photo").width;
//alert(alto_imagen_original);
//alert(ancho_imagen_original);
	var alto_fijo;
	var resolucion_alto=screen.height;
	if (resolucion_alto<=768)
		alto_fijo=320;
	else if (resolucion_alto==800)
		alto_fijo=350;
	else
		alto_fijo=310;

	if (resolucion_alto < (alto_imagen_original+alto_fijo))
	{
		//Establecemos la altura de la fotografia
		var nuevo_alto_imagen=resolucion_alto-alto_fijo-70;
		var nuevo_ancho_imagen=Math.floor((nuevo_alto_imagen*ancho_imagen_original)/alto_imagen_original);
//alert(nuevo_alto_imagen);
//alert(nuevo_ancho_imagen);
		document.getElementById("photo").style.width=nuevo_ancho_imagen+"px";
		document.getElementById("photo").style.height=nuevo_alto_imagen+"px";
		document.getElementById("cajafoto").style.marginTop="-"+(nuevo_alto_imagen/2)+"px";
		var ancho_imagen=document.getElementById("photo").width;
		var navegador=navigator.appName;

		if (ancho_imagen_original%10==0)
		//ancho de la imagen multiplo de 10 => la imagen tienen 10px de borde
			var totalMargen=20;

		//Reajustamos el ancho del titulo y el comentario de la foto
		document.getElementById("tituloFoto").style.width=(nuevo_ancho_imagen+totalMargen)+"px";
		document.getElementById("comentarioFoto").style.width=(nuevo_ancho_imagen+totalMargen)+"px";

		//Recolocamos el titulo y el comentario para lo que no sea Explorer
		if (navegador.indexOf("Microsoft")==-1)
		{
			document.getElementById("tituloFoto").style.marginLeft=(ancho_imagen_original-nuevo_ancho_imagen-totalMargen)/2+"px";
			document.getElementById("comentarioFoto").style.marginLeft=(ancho_imagen_original-nuevo_ancho_imagen-totalMargen)/2+"px";
		}
	}
}
                function markField(id)
                {
                        document.getElementById(id).style.backgroundColor="yellow";
                }
                function unmarkField(id)
                {
                        document.getElementById(id).style.backgroundColor="white";
                }
                function setLabelColor(id,color)
                {
                        document.getElementById(id).style.color=color;
                }
		function comprobarCaptcha()
		{
			idCaptcha=parseInt(document.getElementById("selectedCaptcha").value);
			seleccionadoLista=parseInt(document.getElementById("captcha").value);
			if ((idCaptcha==1 && seleccionadoLista==3) || (idCaptcha==2 && seleccionadoLista==2) || (idCaptcha==3 && seleccionadoLista==1) || (idCaptcha==4 && seleccionadoLista==1) || (idCaptcha==5 && seleccionadoLista==1) || (idCaptcha==6 && seleccionadoLista==0) || (idCaptcha==7 && seleccionadoLista==2))
				return true;
			else
				return false;
		}
		function insertarComentario()
		{
			if (document.getElementById("url").value!="" && document.getElementById("url").value.indexOf("http://")!=0)
				document.getElementById("url").value="http://"+document.getElementById("url").value;
			if (document.getElementById("email").value=="   ")
				document.getElementById("comentarioID").value=window.prompt("ID de comentario a responder");
			if (document.getElementById("name").value=="" || document.getElementById("message").value=="")
				window.alert("[es] Introduzca, al menos, nombre y mensaje\n[en] Insert, at least, name and message");
			else if (comprobarCaptcha()==false)
				window.alert("[es] Número de rojos incorrecto\n[en] Number of reds is incorrect");
			else if ((document.getElementById("email").value!="" && document.getElementById("email").value!="   ") && (document.getElementById("email").value.indexOf("@")==-1 || document.getElementById("email").value.indexOf(".")==-1))
				window.alert("[es] eMail incorrecto\n[en] Incorrect email");
			else
				document.getElementById("formularioComentario").submit();
		}
		function operacionEMS()
		{
			if (document.getElementById("emsMail").value=="")
				window.alert("[es] Introduzca un eMail válido\n[en] Insert a valid eMail");
			else if (document.getElementById("emsMail").value!="" && (document.getElementById("emsMail").value.indexOf("@")==-1 || document.getElementById("emsMail").value.indexOf(".")==-1))
                                window.alert("[es] eMail incorrecto\n[en] Invalid email");
			else
				document.getElementById("formEMS").submit();
		}
		function mostrarPieDeFoto()
		{
			document.getElementById("comentarioPieDeFoto").style.visibility="visible";
		}
                function ocultarPieDeFoto()
                {
                        document.getElementById("comentarioPieDeFoto").style.visibility="hidden";
                }
