// JavaScript Document
function position(event){
	var x = event.clientX+document.body.scrollLeft;
	var y = event.clientY+document.body.scrollTop+document.documentElement.scrollTop;
	document.getElementById('CajaEnMapa').style.top= (y-64)+'px';
	document.getElementById('CajaEnMapa').style.left= (x-180)+'px';  
}
	
function MostrarInformacion(IdMapa) {
	document.getElementById('CajaEnMapa').style.display = 'block';
	document.getElementById('TextoCajaEnMapa').innerHTML  = document.getElementById(IdMapa).alt;
}
	
function OcultarInformacion(Valor) {
	document.getElementById('CajaEnMapa').style.display = 'none';
}	

// 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 + "\');\"></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 MostrarSubMenu(IdAMostrar) {
	document.getElementById("SubMenu"+IdAMostrar).style.display="block";
	document.getElementById(IdAMostrar).style.backgroundImage="url(/img/fondo_MenuPrincipalOn.gif)";
	document.getElementById(IdAMostrar).style.color="#CC071F";	
}

function OcultarSubMenu(IdAMostrar) {
	document.getElementById("SubMenu"+IdAMostrar).style.display="none";
	document.getElementById(IdAMostrar).style.backgroundImage="none";
	document.getElementById(IdAMostrar).style.color="#58585a";		
}


/*------------------------------------------------------*/
function VerificarMail(strMail) {
	var patMail = /^(.+)@(.+)$/;
	var patUser = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*$/;
	var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var patDomain = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)+$/;
	var matchArray = strMail.match(patMail);
	if(matchArray == null){return false;}
	var user = new String(matchArray[1]);
	var domain = new String(matchArray[2]); 
	if(user.match(patUser) == null){return false;}
	var IPArray = domain.match(patDomainIP);
	if(IPArray != null){ 
		 for (var i=1;i<=4;i++) {
		  if(IPArray[i]>255){return false;}
		 }
		 return true; 
	}
	var domainArray = domain.match(patDomain);
	if(domainArray == null) {return false;}
	if(domainArray[domainArray.length - 1].length < 3 || domainArray[ domainArray.length - 1].length > 5) { return false;}
	return true;
}


// PopUp
function openw(foto, ancho, alto)
{	
	var centroy=((screen.availHeight - alto)/2);
	var centrox=((screen.availWidth - ancho)/2);
	window.open(foto,"PupUp","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+ancho+",height="+alto+",title=no,titlebar=no,left="+centrox+",top="+centroy)
}