// JavaScript Document

var posicion;

	function validar()
	{
		var msg="";

		if (document.formu.txtIdProvincia.value == 0)
		{
			msg=msg+"Debes seleccionar una provincia\n";
		}
		
		if (document.formu.txtNombre.value == '')
		{
			msg=msg+"Debes rellenar el nombre del gato\n";
		}
		
		if (document.formu.txtFoto.value == '')
		{
			msg=msg+"Debes incluir una foto\n";
		}
		
		if (document.formu.txtDia.value == '')
		{
			msg=msg+"Debes rellenar el día\n";
		}
		else 
		{
			if (IsNumeric(document.formu.txtDia.value)==false)
			{
				msg=msg+"El día debe ser un número\n";
			}//fin if
			else
			{
				if (document.formu.txtDia.value<1 || document.formu.txtDia.value>31)
				{
					msg=msg+"El día debe estar comprendido entre 1 y 31\n";
				}//fin si
			}//fin else
		}//fin else
		
		if (document.formu.txtMes.value == '')
		{
			msg=msg+"Debes rellenar el mes\n";
		}
		else 
		{
			if (IsNumeric(document.formu.txtMes.value)==false)
			{
				msg=msg+"El mes debe ser un número\n";
			}//fin if
			else
			{
				if (document.formu.txtMes.value<1 || document.formu.txtMes.value>12)
				{
					msg=msg+"El mes debe estar comprendido entre 1 y 12\n";
				}//fin si
			}//fin else
		}//fin else
		
		if (document.formu.txtAgno.value == '')
		{
			msg=msg+"Debes rellenar el año\n";
		}
		else 
		{
			if (IsNumeric(document.formu.txtAgno.value)==false)
			{
				msg=msg+"El año debe ser un número\n";
			}//fin if
		}//fin else	
			
		/*if(document.formu.txtMes.value==2)
		{				
			if ((document.formu.txtAgno.value%4)==0) && ((document.formu.txtAgno.value%100)!=0 || (document.formu.txtAgno.value%400)==0)
			{
				if(document.formu.txtDia.value>29)
				{
					msg=msg+"El día debe estar comprendido entre 1 y 29\n";
				}//fin si
			} //fin si
		}//fin funcion	*/	
		
		if (document.formu.txtDescripcion.value == '')
		{
			msg=msg+"Debes rellenar la descripcion\n";	
		}

		if(msg)
		{
			alert(msg);
		}
		else
		{
			document.formu.hdnFecha.value=document.formu.txtAgno.value+"-"+document.formu.txtMes.value+"-"+document.formu.txtDia.value
			document.formu.submit();
		}
	}//fin funcion
	
	function IsNumeric(valor) 
	{ 
		var log=valor.length; var sw="S"; 
		
		for (x=0; x<log; x++) 
		{ 
			v1=valor.substr(x,1); 
			v2 = parseInt(v1); 
		//Compruebo si es un valor numérico 
			if (isNaN(v2))
			{ 
				sw= "N";
			}//fin if 
		} //fin for
		if (sw=="S") 
		{
			return true;
		} //fin if
		else 
		{
			return false; 
		} //fin else
	}//fin funcion 
	
	function cambiarGato(id, id2, id3)
	{
		document.cambGato.hdnIdGato.value = id;
		document.cambGato.hdnIdProvincia.value = id2;
		document.cambGato.hdnIdPosicion.value = id3;
		document.cambGato.submit();
	}//fin funcion	

