//variables globales
var h;	//height ventana
var w;	//width ventana

//precarga de imagenes
var loader = new Image();
loader.src = "images/loader.gif";
var loader_ajax = new Image();
loader_ajax.src = "images/loader-ajax.gif";
var diana_on = new Image();
diana_on.src = "images/diana_on.png";
var diana_off = new Image();
diana_off.src = "images/diana_off.png";


//-------------------------- para ver los png en IE -------------------------------
function PNG_loader()
{
   for(var i=0; i<document.images.length; i++) {

      var img = document.images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
         var imgID = (img.id) ? "id='" + img.id + "' " : "";
         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
         var imgStyle = "display:inline-block;" + img.style.cssText;
         if (img.align == "left") imgStyle += "float:left;";
         if (img.align == "right") imgStyle += "float:right;";
         if (img.parentElement.href) imgStyle += "cursor:hand;";
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='noscale');\"></span>";
         img.outerHTML = strNewHTML;
         i--;
      }
   }
}
if (document.all) window.attachEvent("onload", PNG_loader);


//------------------------- para enviarme un correo sin spam -------------------------------
function envia_correo(persona)
{
   if (persona == "shalafi") var direccion = "raistlin_el_shalafi"+"@"+"hotmail"+".com";
   if (persona == "esv") var direccion = "postmaster"+"@"+"emiliosilveravazquez"+".com";
   document.location.href="mailto:"+direccion+"?subject=Correo de www.emiliosilveravazquez.com";
}


//------------------------- validacion de mail --------------------------------------
function isEmailAddress(theElement, nombre_del_elemento )
{
   var s = theElement.value;
   var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
   //if (s.length == 0 ) return true;
   if (filter.test(s)) return true;
   else
       alert("Ingrese una dirección de correo válida");
    theElement.focus();
   return false;
}


//------------------------------ muestra o esconde los articulos --------------------------------
var elemento;
var consulta;

function recibirConsulta()
{
	document.getElementById(elemento).innerHTML=consulta.req.responseText;
}

function muestra_elemento(elemento)
{
	if (document.getElementById(elemento).style.display=='block')
	{
		document.getElementById(elemento).style.display='none';
		document.getElementById("i_"+elemento).src="images/hidden.gif";
	}
	else
	{
		document.getElementById(elemento).style.display='block';
		document.getElementById("i_"+elemento).src="images/visible.gif";
	}
}

function muestra_art(elemento,fichero,numero)
{
	this.elemento = elemento;
	if (document.getElementById(elemento).style.display=='block')
	{
		document.getElementById(elemento).style.display='none';
		document.getElementById("i_"+elemento).src="images/hidden.gif";
	}
	else
	{
		document.getElementById(elemento).style.display='block';
		document.getElementById("i_"+elemento).src="images/visible.gif";
		document.getElementById(elemento).innerHTML="<p align='center'>Cargando...<br><img class='no_loader' border='0' src='images/loader-ajax.gif'>";
		consulta = new ajax.cargar("POST","articuloAjax.php","art="+fichero+"&num="+numero+"&nocache="+Math.random(),recibirConsulta);
	}
}


//-------------------------- ajustar velocidad del visor ----------------------------
function ajusta_velocidad(segundos)
{
	viewer.setSlideDuration(segundos*1000);
	document.getElementById('tiempo_foto').src="images/reloj"+segundos+".gif";
	document.getElementById('velocidad').style.display='none';
}