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; 
}

function editar(campo){//Muestra para editar, en BIRDATAS
var Editar=document.getElementById("a"+campo);
var Datos=document.getElementById(campo);
Editar.style.display = "";
Datos.style.display = "none";
}

function salvar(campo){//SALVA en BIRDATAS
var valor=document.getElementById("b"+campo).value;
var id=document.getElementById("id").value;
  switch (campo){
    case 1: { ruta = "operaciones.php?modo=e&campo=n_ingles&valor="+valor+"&id="+id; break }
    case 2: { ruta = "operaciones.php?modo=e&campo=n_cientifico&valor="+valor+"&id="+id; break }
	case 3: { ruta = "operaciones.php?modo=e&campo=orden&valor="+valor+"&id="+id; break }
	case 4: { ruta = "operaciones.php?modo=e&campo=familia&valor="+valor+"&id="+id; break }
	case 5: { ruta = "operaciones.php?modo=e&campo=n_espanol&valor="+valor+"&id="+id; break }
	case 6: { ruta = "operaciones.php?modo=e&campo=habitad&valor="+valor+"&id="+id; break }
	case 7: { ruta = "operaciones.php?modo=e&campo=descripcion&valor="+valor+"&id="+id; break }
  }

  // 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=ajax.responseText;
alert(a);
var Editar=document.getElementById("a"+campo);
var Datos=document.getElementById(campo);
Editar.style.display = "none";
Datos.style.display = "";
Datos.innerHTML = valor + " <img src=\"../images/editar.gif\" onclick=\"editar("+campo+")\">";
}
}
}

function editar_p(campo, id, texto){ //Editar foto en POST
document.getElementById(campo+"_"+id).style.display= "none";
document.getElementById("ed_"+campo+"_"+id).style.display= "";
document.getElementById("txt_"+campo+id).value = texto;
}

function salvar_p(campo, id){ //Salva edicion en POST
var Texto = document.getElementById("txt_"+campo+id).value
document.getElementById(campo+"_"+id).innerHTML= "<font color=\"#FFFF00\"><i>Guardando...</i></font>";
ruta = "galeria_editar.php?mode=salvar&campo="+campo+"&texto="+Texto+"&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
document.getElementById(campo+"_"+id).style.display= "";
document.getElementById("ed_"+campo+"_"+id).style.display= "none";
document.getElementById(campo+"_"+id).innerHTML= "<font color=\"#FFFF00\"><b>"+Texto+"</b></font>";
}
}
}

function ver(ruta){//Ver foto en galeria
var Foto=document.getElementById("foto");
Foto.style.position= "fixed";
Foto.style.display = "";
Foto.style.top = '0px';
Foto.innerHTML= "<img onclick=\"noverfoto()\" src=\"images/espanol/postbit_delete.gif\"><br/><img class=\"imagen\" onload=\"if(this.width > 800) {this.width=800} if(this.height > 600) {this.height=600}\" src=\"../fotos/"+ruta+"\">";
}

function noverfoto(){//Elimina foto
var Foto=document.getElementById("foto");
Foto.style.display = "none";
}

function eliminarfoto(id){
ruta = "operaciones.php?modo=bf&id="+id;
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=ajax.responseText;
alert(a);
}
}
}

function menu(e,menu){//Muetra submenu de galerias
var x = e.clientX;
var y = e.clientY;
a = document.getElementById("menu"+menu);
a.style.position= "absolute";
a.style.left = x + "px";
a.style.top = y + "px";
a.style.display = "";
}

function menuout(e,menu){//Oculta Muetra submenu de galerias
a = document.getElementById("menu"+menu);
a.style.display = "none";
}

function salvarxy(id){//Salva datos xy de mapas 
var valor=document.getElementById(id).value;
ruta = "operaciones.php?modo=xy&valor="+valor+"&campo="+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
var a=ajax.responseText;
alert(a);
}
}
}