var ns4;
var ns6;
var ie4;

function DetectaNavegador(){
    ns4=(document.layers)? true:false;
    ns6=(document.getElementById)? true:false;
    ie4=(document.all)? true:false;
	
	var navegador = navigator.appName;
	if (navegador=="Netscape") {
	   this.navegador = "ns";
    }else if (navegador=="Microsoft Internet Explorer") {
	   this.navegador = "ie";
    }else {
	   this.navegador = navegador;
	}
	this.version = parseInt(navigator.appVersion);
	this.ns = (this.navegador=="ns" && this.version>=4);
	this.ns4 = (this.navegador=="ns" && this.version==4);
	this.ns5 = (this.navegador=="ns" && this.version==5);
	this.ie = (this.navegador=="ie" && this.version>=4);
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0);
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0);
	this.ie6 = (navigator.userAgent.indexOf('MSIE 6')>0);
	if (this.ie5) this.version = 5;
}

var Navegador = new DetectaNavegador();
var ancho=0;
function CentrarContenido(numcapas,desvio){
   var WVentana;
   if (document.layers){
      WVentana = window.innerWidth;
   } else {
      WVentana = document.body.clientWidth;
   }
   ancho=parseInt((WVentana-desvio)/2);
   if (screen.availWidth >= 780 && WVentana >= desvio){
      if (ns4){
         for (i=0; i<=numcapas.length-1; i++){
	        document.layers[capas[i]].left=document.layers[capas[i]].left+ancho
         }
      }else if (ie4){
        for (i=0; i<=numcapas.length-1; i++){
            margen=document.all[capas[i]].style.left.split("px")
	        suma=Number(margen[0])+Number(ancho)
            document.all[capas[i]].style.left=suma
         }
      }else if (ns6){
         for (i=0; i<=numcapas.length-1; i++){
	        margen=document.getElementById(capas[i]).style.left.split("px")
		    suma=Number(margen[0])+Number(ancho)
	        document.getElementById(capas[i]).style.left=suma
         }
      }
   }
}

function MostrarCapa(capa){
   if (ns4){
      document.layers[''+capa].visibility="visible"
   }else if (ie4){
      document.all[capa].style.visibility="visible"
   }else if (ns6){
      document.getElementById(capa).style.visibility="visible"
   }
}

function OcultarCapa(capa){
   if (ns4){
      document.layers[''+capa].visibility="hide"
   }else if (ie4){
      document.all[capa].style.visibility="hidden"
   }else if (ns6){
      document.getElementById(capa).style.visibility="hidden"
   }
}

function CapturarClick() {
	if (ns4) {document.captureEvents(Event.MOUSEUP)}
    document.onmouseup = top.barranavegacion.OcultarMenu
}

function CambiaColor(capa,color){
   if (ie4) document.all[capa].style.color=color;
   else if (ns6) document.getElementById(capa).style.color=color;
}
function CambiaFondo(capa,color){
   if (ie4) document.all[capa].style.backgroundColor=color;
   else if (ns6) document.getElementById(capa).style.backgroundColor=color;
}
var Auxiliar=document.lastModified.split(" ")
var fechaDocumento=Auxiliar[0].split("/")
   switch (fechaDocumento[0]){
      case "1": fechaDocumento[0]="Enero";break;
	  case "2": fechaDocumento[0]="Febrero";break;
	  case "3": fechaDocumento[0]="Marzo";break;
	  case "4": fechaDocumento[0]="Abril";break;
	  case "5": fechaDocumento[0]="Mayo";break;
	  case "6": fechaDocumento[0]="Junio";break;
	  case "7": fechaDocumento[0]="Julio";break;
	  case "8": fechaDocumento[0]="Agosto";break;
	  case "9": fechaDocumento[0]="Septiembre";break;
	  case "10": fechaDocumento[0]="Octubre";break;
	  case "11": fechaDocumento[0]="Noviembre";break;
	  case "12": fechaDocumento[0]="Diciembre";break;
   }
   
// Calcula el ancho y alto de ventana disponible en px.
// Llamar despues del body.
function WHVentana() {
	VentanaW = (Navegador.ns)? window.innerWidth : document.body.offsetWidth-20;
	VentanaH = (Navegador.ns)? window.innerHeight : document.body.offsetHeight-4;
}
function Redimensionar() {
	if ((Navegador.ns && (winW!=window.innerWidth || winH!=window.innerHeight)) || Navegador.ie){
	   history.go(0);
	}
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator){
     if ((appName=="Netscape")&&(parseInt(appVersion)==4)){
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
     }
  }else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH){
     location.reload();
  }
}
MM_reloadPage(true);

function ValidarEmail(correo){
   var expresion = /(^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*((\.\w{2,3})+$|(\.\w{2,3}\.\w{2,3})+$))/;
   return expresion.test(correo);
}
function ValidarTelefono(telefono){
   telefono.value = telefono.value.replace(/ /g,'');
   var EsValido = !isNaN(telefono.value);
   if (EsValido){
      var longn = telefono.value.length;
    if (longn < 9 || longn > 12){
	     EsValido = false;
	  }else{
	     if (longn == 9) telefono.value = telefono.value;
	  }
   }
   return EsValido;
}
function EliminarEtiquetas(cadena){
   cadena = cadena.replace(/\x3C/g,'&lt;');//< 60
   cadena = cadena.replace(/\x3E/g,'&gt;');//> 62
   return cadena;
}
function Idioma(es,en,fr){
   this.es = es;
   this.en = en;
   this.fr = fr;
   this.Traduce = Traduce;
}
function Traduce(Idiom){
      if (Idiom == "en"){
	     return this.en;
	  }else if (Idiom == "fr"){
	     return this.fr;
	  }else{
	     return this.es;
	  }
   }
var Alerta = new Array();

