
// Corrector de Bug PNG para Explorer. Opera y Mozilla funcionan correctamente sin este JS
function correctPNG() 
   {
   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;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		 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='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }

   }
var ua = navigator.userAgent.toLowerCase();
function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
}

if (detect('opera')) {
	 
 } else if (detect('firefox')){
	 
} else if (detect('msie')){
	 window.attachEvent("onload", correctPNG);	
}	 

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openw(foto) { window.open("/popup.php?imagen=/noticias/galerias/grandes/"+foto,"IWIN","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no")
}

function Ir(canal) {
	parent.top.location = canal;
} 

function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    alert("La direcci&oacute;n de email es incorrecta.");
    return (false);
  }
}
	function validar(form){
		if(form.Nombre.value==''){
			alert('Debe escribir su nombre');
			return false;
		}
		if(form.EMail.value==''){
			alert('Debe escribir su e-mail');
			return false;
		}
		if(!validarEmail(form.EMail.value)){
			return false;
		}
		if(form.Asunto.value==''){
			alert('Debe escribir un Asunto');
			return false;
		}
		if(form.Texto.value==''){
			alert('Debe escribir un Mensaje');
			return false;
		}
		return true;
	}

	
function mostrarFoto(NombreFoto,TextoFoto){
	if (detect('msie')){ 	
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
		var TotalPantalla =  window.document.documentElement.scrollBottom;
	}else{
		var ScrollDePantalla =  window.pageYOffset;	
	}	
	document.getElementById('FotoPopUp').src=NombreFoto;
	document.getElementById('FotoPopUp').alt=TextoFoto;
	if (TextoFoto!="") {
		document.getElementById('TextoFotoPopUp').style.display = 'block';
	}
	document.getElementById('TextoFotoPopUp').innerHTML=TextoFoto;
	document.getElementById('Cubrepaginas').style.marginTop=(ScrollDePantalla)+"px";	
	document.getElementById('Cubrepaginas').style.display = 'block';
	
	if (detect('msie')){ 
		document.getElementById('Cuerpo').scroll = 'no';
		document.getElementById('Cubrepaginas').style.filter= "alpha(opacity=93)";
	}else{	
		document.getElementById('Cubrepaginas').style.opacity = '0.93';
		document.getElementById('Cuerpo').style.overflow = 'hidden';
	}	
	
	document.getElementById('PopUpFoto').style.display = 'block';	
	centradoEnPagina();
}

function ocultarCubrepaginasFoto(){
	document.getElementById('FotoPopUp').src="/img/Loader.gif";
	document.getElementById('FotoPopUp').alt="";
	document.getElementById('Cubrepaginas').style.display = 'none';
	document.getElementById('PopUpFoto').style.display = 'none';
	document.getElementById('TextoFotoPopUp').style.display = 'none';
	document.getElementById('EnlaceFoto').style.marginTop= "0px";
	
	if (detect('msie')){ 
		document.getElementById('Cuerpo').scroll = 'yes';	
	}else{	
		document.getElementById('Cuerpo').style.overflow = 'auto';
	}
	
}

function centradoEnPagina() {
	setTimeout("CalcularCentradodeFoto()",700);
}


function CalcularCentradodeFoto() {
	var altoImagen = document.getElementById('FotoPopUp').clientHeight;
	if (detect('msie')){ 	
		var altoDePantalla = document.body.clientHeight;
		var altoDePantalla = document.documentElement.clientHeight;
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
	}else{
		var altoDePantalla =  window.innerHeight;	
		var ScrollDePantalla =  window.pageYOffset;	
	}

	if (altoDePantalla-altoImagen>0) {
		var margenImagen = ((altoDePantalla-altoImagen)/3);
	}else{
		var margenImagen = 0;
	}
	var espaciadoSuperior=parseInt(ScrollDePantalla)+parseInt(margenImagen)-100;
	document.getElementById('PopUpFoto').style.marginTop= ""+espaciadoSuperior+"px";
}	
