   var strExplorador=navigator.appName;

   function openWindow_2(url, w, h, t, l, valores, nombre){
     var hWnd = window.open (url, nombre, "width=" + w + ",height="+ h + ",top=" + t + ",left=" + l + "," + valores);
        if ((document.window != null) && (!hWnd.opener))
          hWnd.opener = document.window;
   }
      
   function closeWindow(actFth){
     if (actFth){
       if (window.opener && !window.opener.closed)
         window.opener.document.location.reload();
     }
     window.close();       
   }
    
   function soloNumeros(evento,campo,tipo){
     var Tecla;
     var bolReg=false;
     if (strExplorador.indexOf("Explorer",0) != -1){
       Tecla = evento.keyCode;
     } 
     else{
       document.onkeydown = keyDown;document.captureEvents(Event.KEYDOWN);Tecla=evento.which;
     }
           	
     if ((Tecla > 47) && (Tecla < 58)){
       bolReg=true;
     } 
         
     if (tipo == "d"){
       if((Tecla > 47) && (Tecla < 58) || (Tecla == 46))
         bolReg=true;
     }
          
     if (strExplorador.indexOf("Explorer",0) != -1){
       if (!bolReg) {
         evento.keyCode = "";
       }
     }
     else{
       if (!bolReg){
         alert("el campo contiene caracteres invalidos.");
         document.forms[0].elements[campo.name].value="";
       }
     }
          
     return bolReg;
   }    

   /*Verifica que el contenido del campo realmente sean numeros*/        
   function validaNumeros(campo,tipo){
     var txtTmp;
     var bolReg = false;
     
     txtTmp = campo.value
      
     if (tipo == "i"){
       idx = txtTmp.indexOf(".")
       if (idx == -1){  
         if (isNaN(txtTmp) ){
           alert("El valor del campo no es numerico!!");
           campo.value = "";
           bolReg=false;    
           campo.focus();  
         }
       }
       else{
         alert("Introduzca valores enteros!!");
         campo.value = "";
         bolReg=false;    
         campo.focus();  
       }
     }
          
     else if (tipo == "d"){
       if (isNaN(txtTmp) ){
         alert("El valor del campo no es numerico!!");
         campo.value = "";
         bolReg=false;    
         campo.focus();  
       }  
     }
           
     else bolReg=true;
     return bolReg;
   } 

   /* Obtiene la longitud de un campo y lo compara con el valor de limite inferior */
   function limiteCampo(campo, limite){
     var bolReg=false;
     var longitud;
     var txtTmp;
        
     txtTmp = campo.value
     longitud = txtTmp.length
     
     if (txtTmp != '') {  
       if (longitud < limite){
         alert("El texto es menor a " + limite + " caracteres.")
         campo.focus();
         campo.select();
         bolReg=false;
       } 
       else 
         bolReg=false;
     }
     
     return bolReg;
   }
     
   //2006-08-31 Contador de caracteres en un elemento texto textarea
   function textCounter (field, cntfield, maxlimit){
     if (field.value.length > maxlimit)
        // if too long...trim it! 
       field.value = field.value.substring(0, maxlimit);
       // otherwise, update 'characters left' counter
     else
       cntfield.value = maxlimit - field.value.length;
   }
    
   //2006-08-31 Remplaza el caracter salto de linea por <BR>
   function reemplazaEnter(txtCad, codAscii){
     var temp = ''
     var texto 
           
     texto = txtCad
                
     for (i=0; i < texto.length; i++){
        if (texto.charCodeAt(i) != codAscii) 
          temp = temp + texto.charAt(i)
        else
          temp = temp + "<BR>" 
     }
     return temp;
   }
    
   //2006-09-14 Revisa si el campo esta vacio
   function estaVacio(objForma, msj){
     if (objForma.value == ""){
       alert(msj)
       objForma.focus()
       return false;
     }
     else
       return true;  
   }
       
   function emailCheck(emailStr) {
     var checkTLD=1;
     var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
     var emailPat=/^(.+)@(.+)$/;
     var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
     var validChars="\[^\\s" + specialChars + "\]";
     var quotedUser="(\"[^\"]*\")";
     var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
     var atom=validChars + '+';
     var word="(" + atom + "|" + quotedUser + ")";
     var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
     var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
     var matchArray=emailStr.match(emailPat);

     if (matchArray==null) {
       alert("La dirección de correo esta incorrecta. (falta @ y .'s)");
       return false;
     }
      
     var user=matchArray[1];
     var domain=matchArray[2];

     for (i=0; i<user.length; i++) {
        if (user.charCodeAt(i)>127) {
          alert("El nombre de usuario de su direccion de email contiene caracteres invalidos.");
          return false;
        }
     }
            
     for (i=0; i<domain.length; i++) {
        if (domain.charCodeAt(i)>127) {
          alert("El nombre de dominio de su direccion de email contiene caracteres invalidos.");
          return false;
        }
     }

     if (user.match(userPat)==null) {
       alert("El nombre de usuario de su direccion de email no es valido.");
       return false;
     }

     var IPArray=domain.match(ipDomainPat);
     if (IPArray!=null) {
       for (var i=1;i<=4;i++) {
          if (IPArray[i]>255) {
            alert("La direccion IP es invalida!!");
            return false;
          }
       }
       return true;
     }
               
     var atomPat=new RegExp("^" + atom + "$");
     var domArr=domain.split(".");
     var len=domArr.length;
     for (i=0;i<len;i++) {
        if (domArr[i].search(atomPat)==-1) {
          alert("El nombre de dominio de su direccion de email no es valido.");
          return false;
        }
     } 

     if (checkTLD && domArr[domArr.length-1].length!=2 && 
         domArr[domArr.length-1].search(knownDomsPat)==-1) {
       alert("La direccion de email debe finalizar con un dominio conocido o dos letras del pais.");
       return false;
     }

     if (len<2) {
       alert("En esta direccion esta perdido el hostname!");
       return false;
     }

     return true;
   }
     
   function borrar(url){
     if (confirm("Esta seguro de borrar el registro?")){
       window.location = url 
     } 
   }

   function borrar_2(url, mensaje){
     if (confirm(mensaje)){
       window.location = url 
     } 
   }

   function MM_swapImgRestore() { //v3.0
     var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
   }
     
   function MM_preloadImages() { //v3.0
     var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
   }
     
   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_swapImage() { //v3.0
     var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
     if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
   }
   
   function despliegaImagen(imagen, lw, lh, flagw, flagh){
     var ancho = imagen.width
     var alto = imagen.height
     var nancho
     var nalto
     var proporcion  
          
     if (flagw){
       if (ancho > lw){
         proporcion = lw / ancho
         nancho =  ancho * proporcion
         nalto = alto * proporcion
         imagen.width = nancho
         imagen.height = nalto
       }
     }
         
     if (flagh){
       if (alto > lh){
         proporcion = lh / alto
         nancho =  ancho * proporcion
         nalto = alto * proporcion
         imagen.width = nancho
         imagen.height = nalto
       }
     }
   }   
      
   function despliegaImagen2(imagen, lw, lh, flagw, flagh, alinea){
     var nancho
     var nalto
     var proporcion
     var ancho
     var alto

     myimage = new Image()
     myimage.src = imagen

     ancho = myimage.width
     alto = myimage.height     

     //alert(myimage.width + ' ' + myimage.height)        
          
     if (flagw){
       if (ancho > lw){
         proporcion = lw / ancho
         nancho =  ancho * proporcion
         nalto = alto * proporcion
       }
     }
         
     if (flagh){
       if (alto > lh){
         proporcion = lh / alto
         nancho =  ancho * proporcion
         nalto = alto * proporcion
       }
     }
      
     document.write('<img src=' + myimage.src + ' width=' + nancho +' height=' + nalto + ' border=0 align=' + alinea + '>')
   }
     
   //Funciones para cookies
   function CojerValorCookie(indice) {
     //indice indica el comienzo del valor
     var galleta = document.cookie
     //busca el final del valor, dado por ;, a partir de indice
     var finDeCadena = galleta.indexOf(";", indice)
     //si no existe el ;, el final del valor lo marca la longitud total de la cookie
     if (finDeCadena == -1)
       finDeCadena = galleta.length
          
     return unescape(galleta.substring(indice, finDeCadena))
   }
        
   function CojerCookie(nombre) {
     var galleta = document.cookie
     //construye la cadena con el nombre del valor
     var arg = nombre + "="
     var alen = arg.length			//longitud del nombre del valor
     var glen = galleta.length		//longitud de la cookie
          
     var i = 0
     while (i < glen) {
       var j = i + alen			//posiciona j al final del nombre del valor
       if (galleta.substring(i, j) == arg)	//si en la cookie estamo ya en nombre del valor		
         return CojerValorCookie(j)	//devuleve el valor, que esta a partir de j
            
       i = galleta.indexOf(" ", i) + 1		//pasa al siguiente
       if (i == 0)
         break				//fin de la cookie
     }
     return null					//no se encuentra el nombre del valor
   }
        
   function GuardarCookie (nombre, valor, caducidad) {
     if (!caducidad)
       caducidad = Caduca(0)
                 
     //crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
     //cada valor esta separado por ; y un espacio
          
     document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
   }
     
   function Caduca(dias) {
     var hoy = new Date()										//coge la fecha actual
     var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000	//pasa los dias a mseg.
         
     hoy.setTime(hoy.getTime() + msEnXDias)			//fecha de caducidad: actual + caducidad
     return (hoy.toGMTString())
   }
        
   function BorrarCookie(nombre) {
     //para borrar la cookie, se le pone una fecha del pasado mediante Caduca(-1)
     document.cookie = nombre + "=; expires=" + Caduca(-1) + "; path=/"
   }   

   function getURLParam(name){
     var regexS = "[\?&]"+name+"=([^&#]*)";
     var regex = new RegExp ( regexS );
     var tmpURL = window.location.href;
     var results = regex.exec( tmpURL );
     var valparam
       
     if (results == null)
       valparam = "";
     else{
       //alert(results[1]) 
       valparam = results[1];
     }        
      
     return valparam;
   }

   function goToURL(pagina){
     var usrid_ = getURLParam('usrid')
     var sitio_ = getURLParam('sitio')     
     var url_
       
     url_ = pagina + '?usrid=' + usrid_ + '&sitio=' + sitio_
     window.location.href = url_;
   }
    
   function goToPrincipal(){
     var usrid_ = getURLParam('usrid')
     var sitio_ = getURLParam('sitio')     
     var url_
       
     if (sitio_ == 'club')
       pagina = "/ad-index.asp"
     else if(sitio_ == 'empieza')
       pagina = "/ade-index.asp"
              
     url_ = pagina + '?usrid=' + usrid_ + '&sitio=' + sitio_
     window.location.href = url_;
   }

   function abrirMinisitio(url){
     var hWnd = window.open(url,"","leftmargin=0,topmargin=0,marginwidth=0,marginheight=0,width=710,height=430,top=50,left=50,status=no,resizable=no,scrollbars=no");
   }

   function validaEntrada(url){
     var usuario = getURLParam('usrid')
     var sitio_ = getURLParam('sitio')
     if (usuario == ''){
       location.href = 'http://' + location.hostname + '/' + url + "&sitio=" + sitio_
     }
   }
    
   function revisaSelect(objForma){
     var flg = false
     for (i=0; i<objForma.length; i++){
        if (objForma.options[i].selected){
          if (objForma.options[i].value == "" || objForma.options[i].value == "?" || objForma.options[i].value == "undefined"){
            alert('La opcion seleccionada no tiene valor.')
            flg= false
            break;
          } 
          else{
            flg = true
            break;
          } 
        }
     }
     return flg
   }
   
   function goAdmon(forma, objSelect){
     var i = objSelect.selectedIndex
     acction_  = objSelect.options[i].value
     if (acction_ != ''){
       forma.action = acction_
       forma.submit() 
     }  
   }
     
   function Submit_seguro(forma){
     for (i=1; i < forma.elements.length; i++) {
        if (forma.elements[i].type == 'submit') {
          forma.elements[i].disabled = true
        }
     }
               
     forma.submit()
           
     Submit_seguro = Submit_off	//reasinga la funcion de envio a una funcion dummy
     return false
   }
    
   function Submit_off(forma ) {
     return false
   }