var nombre = navigator.appName;
if (nombre == "Microsoft Internet Explorer")
{
document.write("<font color=\"#FF3300\"><h5>Estas utilizando un navegador que no cumple los estandares de la web, actualice a uno mejor, Firefox, <a href=\"http://www.mozilla-europe.org/es/firefox/\" target=\"_blank\">Descargar</a></h5></font>");
}

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 verimg(id){//Muetra datos de la foto
var foto=document.getElementById(id);
var ver=document.getElementById("i"+id);
foto.style.display = "";
ver.innerHTML = "<img src=\"../images/no_ver.png\" onclick=\"noverimg("+id+")\">";
}

function noverimg(id){//Cculta:Muetra datos de la foto
var foto=document.getElementById(id);
var ver=document.getElementById("i"+id);
foto.style.display = "none";
ver.innerHTML = "<img src=\"../images/ver.png\" onclick=\"verimg("+id+")\">";
}

function verfoto(ruta, idtema, idpost){//:Muetra la foto
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 > 640) {this.width=640} if(this.height > 480) {this.height=480}\" src=\"../fotos/"+ruta+"\">";

ruta = "galeria.php?mode=clic&id="+ruta;
// 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
}
}
if (idtema){
location.href="http://birdphotoforum.com/foro/showthread.php?tid="+idtema+"&pid="+idpost+"#pid"+idpost;
}else{
alert("Esta foto no fue enviada en un tema, recuerde dar enviar en el tema donde la subio para guardar correctamente la foto...");
}
}

function salva(id){//Salva la edicion de una fotografia desde la galeria
var Categoria = document.forms['form']['categoria'].value;
var Album = document.forms['form']['album'].value;
var Nombre=document.getElementById("nombre").value;
var Lugar=document.getElementById("lugar").value;
var Lat=document.getElementById("lat").value;
var Long=document.getElementById("long").value;
var Etiquetas=document.getElementById("etiquetas").value;
var Tema=document.getElementById("tema").value;

ruta = "galeria_editar.php?mode=ee&id="+id+"&categoria="+Categoria+"&nombre="+Nombre+"&lugar="+Lugar+"&lat="+Lat+"&long="+Long+"&etiquetas="+Etiquetas+"&tema="+Tema+"&id_album="+Album;
// 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);
}
}
}

function editar_gal(campo, id, texto){
document.getElementById(campo+"_"+id).style.display= "none";
document.getElementById("ed_"+campo+"_"+id).style.display= "";
document.getElementById("txt_"+campo+id).value = texto;
}

function salvar_gal(campo, id){
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 borrar(id){ //Borra foto de la galeria
	if (confirm("Seguro que deseas borrar esta foto? "+id)) {
		var TablaFoto=document.getElementById("t"+id);
		var Cargando=document.getElementById("cargando");
		Cargando.style.position= "absolute";
		Cargando.style.width= 54;
		Cargando.style.height= 55;
		Cargando.style.border = "3px solid #C8C8C8";
		Cargando.style.background = "#FFFFFF";
		Cargando.style.color = "#000000";
		Cargando.style.zIndex = 1000;
		Cargando.style.textAlign = "center";
		Cargando.style.verticalAlign = "middle";
		Cargando.style.fontSize = "16px";
		var ypos = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
		Cargando.style.left = (screen.availWidth-54)/2 + 'px';
		Cargando.style.top = (screen.availHeight-55)/2 + ypos - 70 + 'px';
		Cargando.innerHTML= "Cargando<br/><img src=\"../images/cargando.gif\"";
		Cargando.style.display = "";
		ruta = "galeria_editar.php?mode=b&id="+id;
		alert(ruta);
		// 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);
		Cargando.style.display = "none";
		TablaFoto.style.display = "none";
		}
		}
	}
}

function elimina_album(id, nombre){
	if (confirm("Seguro que deseas borrar el album "+nombre+" ?")) {
			var Cargando=document.getElementById("cargando");
			Cargando.style.position= "absolute";
			Cargando.style.width= 54;
			Cargando.style.height= 55;
			Cargando.style.border = "3px solid #C8C8C8";
			Cargando.style.background = "#FFFFFF";
			Cargando.style.color = "#000000";
			Cargando.style.zIndex = 1000;
			Cargando.style.textAlign = "center";
			Cargando.style.verticalAlign = "middle";
			Cargando.style.fontSize = "16px";
			var ypos = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
			Cargando.style.left = (screen.availWidth-54)/2 + 'px';
			Cargando.style.top = (screen.availHeight-55)/2 + ypos - 70 + 'px';
			Cargando.innerHTML= "Cargando<br/><img src=\"../images/cargando.gif\"";
			Cargando.style.display = "";
			ruta = "galeria_albunes.php?mode=b&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
			alert(ajax.responseText);
			Cargando.style.display = "none";
			location.href="http://quedadanatural.com/foro/galeria_albunes.php";
			}
			}
	}
}

function agrega_idportada(nombre){
	document.formulario.id_portada.value = "";
	document.formulario.id_portada.value = nombre;
}