function fotonueva(checked) {
	if (checked) document.getElementById("subida").style.display='block'; else 	document.getElementById("subida").style.display='none'; 
}

function controlo_ingreso_animal() {
	if (document.getElementById('nombre').value=="") {
		alert("Debe ingresar el nombre de su animal");
		return false;
	}

	if (document.getElementById('especie').value=="") {
		alert("Debe seleccionar la especie de su animal");
		return false;
	}

	var combo_raza=document.getElementById('raza');

	if (combo_raza==undefined) {
		alert("Seleccione especie y raza");
		return false;
	} else {
		if (combo_raza.value=="") {
			alert("Seleccione especie y raza");
			return false;
		}
	}

	return true;
}


//Nueva funcion que evalua la tecla presionada
function keyNumber(e)
{
		var keynum
		var keychar
		var numcheck
		
		if(window.event) // IE
		{
			keynum = e.keyCode
		}
		else if(e.which) // Netscape/Firefox/Opera
		{
			keynum = e.which
		}
		return keynum;
} 


function index_login(event) {
	
		var tecla=keyNumber(event);
		
		if (tecla==13) {
			document.getElementById('index_submit').submit();
		}
	
}





function search_animal(event) {
	
		var tecla=keyNumber(event);
		
		if (tecla==13) {
			document.getElementById('formularioBusqueda').submit();
		}
	
}

function set_focus_login() {
	document.getElementById('name_user_index').focus();	
	
}






//Fin de la nueva funcion

function show_properties(objeto) {
	for (var i in objeto) {
		alert(i+"="+objeto[i]);	
	}
	
}

function cargo_razas(especie) {
	  if (especie!='') {
      	ajax.requestFile = "inc/ajax/ajax_carga_razas.php?especie="+especie+"&";
      	ajax.method = "GET";
      	ajax.onCompletion = cargo_razas_completada;
      	ajax.runAJAX();
      } else {
		document.getElementById('razas').innerHTML="No hay especie seleccionada";
      }
}

function cargo_razas_completada() {
	var resultado=ajax.response;
	if (resultado.indexOf("<")>=0) {
		document.getElementById('razas').innerHTML=resultado;
	} else {
		document.getElementById('razas').innerHTML="<option value='-1'>Seleccione especie</option>";
	}
}

function valido_alta_duenio() {
	if (document.getElementById('localidad').value=="") {
		alert("La localidad es un campo obligatorio");
		return false;
	}

	if (document.getElementById('email').value=="") {
		alert("La direccion de mail es un campo obligatorio");
		return false;
	}



	if (document.getElementById('usuario').value=="") {
		alert("El nombre del usuario es un campo obligatorio");
		return false;
	}

	if (document.getElementById('password').value=="" || document.getElementById('password2').value=="") {
		alert("Ambas contraseņas son datos obligatorios");
		return false;
	}

	if (document.getElementById('password').value!="" && document.getElementById('password2').value!="" && document.getElementById('password').value!=document.getElementById('password2').value) {
			alert("Ambas contraseņas no coinciden");
			return false;
	}

	return true;
}

function valido_alta_veterinario() {

		if (document.getElementById('nombre').value=="") {
		alert("El nombre es un campo obligatorio");
		return false;
	}


	if (document.getElementById('localidad').value=="") {
		alert("La localidad es un campo obligatorio");
		return false;
	}


	if (document.getElementById('matricula').value=="") {
		alert("La matricula es un campo obligatorio");
		return false;
	}


	if (document.getElementById('email').value=="") {
		alert("La direccion de mail es un campo obligatorio");
		return false;
	}

	if (document.getElementById('direccion').value=="") {
		alert("La direccion del profesional es  un campo obligatorio");
		return false;
	}



	if (document.getElementById('usuario').value=="") {
		alert("El nombre del usuario es un campo obligatorio");
		return false;
	}

	if (document.getElementById('password').value=="" || document.getElementById('password2').value=="") {
		alert("Ambas contraseņas son datos obligatorios");
		return false;
	}

	if (document.getElementById('password').value!="" && document.getElementById('password2').value!="" && document.getElementById('password').value!=document.getElementById('password2').value) {
			alert("Ambas contraseņas no coinciden");
			return false;
	}

	return true;
}
