function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}

//Evento
function salvar_id(){
id = document.getElementById("cientifico").value;
id_f = document.getElementById("id_foto").value;

var divMensaje=document.getElementById("mensaje");
divMensaje.innerHTML= "<img src=\"images/progreso.gif\">";

ruta = "operaciones.php?modo=si&id_f="+id_f+"&id="+id
// Creo la conexion con el servidor y le envio la variable evento (que le indica si debe ingresar o verificar) y el dato a utilizar
var ajax=nuevoAjax();
ajax.open("GET", ruta, true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(null);

ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
// Muestro el mensaje enviado desde el servidor
divMensaje.innerHTML=ajax.responseText;
}
}
}

function salvar_d(id_foto){//SALVA DATOS de fotos
id = document.getElementById("id"+id_foto).value;
id_f = document.getElementById("id_foto"+id_foto).value;
fotografo = document.getElementById("fotografo"+id_foto).value;
lugar = document.getElementById("lugar"+id_foto).value;
comentarios = document.getElementById("comentarios"+id_foto).value;

ruta = "operaciones.php?modo=sd&id_f="+id_f+"&id="+id+"&fotografo="+fotografo+"&lugar="+lugar+"&comentarios="+comentarios;

var progreso=document.getElementById("progreso");
progreso.innerHTML="<img src=\"images/progreso.gif\">";

// Creo la conexion con el servidor y le envio la variable evento (que le indica si debe ingresar o verificar) y el dato a utilizar
var ajax=nuevoAjax();
ajax.open("GET", ruta, true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(null);

ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
// Muestro el mensaje enviado desde el servidor
var a=document.getElementById("a"+id_foto);//fotografo
var b=document.getElementById("b"+id_foto);//lugar
var c=document.getElementById("c"+id_foto);//comentarios
var Editar=document.getElementById("editar"+id_f);
var Datos_foto=document.getElementById("datos_foto"+id_foto);
a.innerHTML = fotografo;
b.innerHTML = lugar;
c.innerHTML = comentarios;
Editar.style.display = "none";
Datos_foto.style.display = "";
progreso.innerHTML= "";
}
}
}

function ver(id_foto){//Muestra para editar
var Editar=document.getElementById("editar"+id_foto);
var Datos_foto=document.getElementById("datos_foto"+id_foto);
Editar.style.display = "";
Datos_foto.style.display = "none";
}

function verver(){//Muestra la tabla para nuevo mensaje de libro de visitas
var Nuevo=document.getElementById("nuevo");
Nuevo.style.display = "";
}

function verifican(){
	if (document.mauricio.nombre.value == ""){
	var Id=document.getElementById("idnombre");
	Id.style.color = "red";
	Id.innerHTML= "Digite su nombre antes de continuar";
	setTimeout('document.mauricio.nombre.focus()',75);
	}
}

function verificac(){	
	if (document.mauricio.correo.value == ""){
	var Id=document.getElementById("idcorreo");
	Id.style.color = "red";
	Id.innerHTML= "Digite su correo antes de continuar";
	setTimeout('document.mauricio.correo.focus()',75);
	}
}

function verificam(){
	if (document.mauricio.mensaje.value == ""){
	var Id=document.getElementById("idmensaje");
	Id.style.color = "red";
	Id.innerHTML= "Digite su mensaje antes de continuar";
	setTimeout('document.mauricio.mensaje.focus()',75);
	}
}

function editardatos(campo, id){
document.getElementById(campo).style.display = "none";
document.getElementById(campo + "_editar").style.display = "";
}

function salvadatos(campo, id){
var valor = document.getElementById(campo + "_dato").value;

if (campo = 'cien'){
campo = 'nombre_cientifico'
alert(campo);
}

ruta = "operaciones.php?modo=salvadatos&id="+id+"&campo="+campo+"&valor="+valor;;

// Creo la conexion con el servidor y le envio la variable evento (que le indica si debe ingresar o verificar) y el dato a utilizar
var ajax=nuevoAjax();
ajax.open("GET", ruta, true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(null);

ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
// Muestro el mensaje enviado desde el servidor
alert(ajax.responseText);
}
}
}
