// ==================================================================================================================== //
//                                     Averiguamos que navegador nos está visitando                                     //
// ==================================================================================================================== //

   var NAVEGADOR ='';
        if( window.opera                                       ) { NAVEGADOR = 'Opera';         }
   else if( navigator.appName == 'Konqueror'                   ) { NAVEGADOR = 'Konqueror';     }
   else if( navigator.appName == 'Microsoft Internet Explorer' ) { NAVEGADOR = 'IE';            }
   else if( navigator.userAgent.indexOf('Safari')     != -1    ) { NAVEGADOR = 'Safari';        }
   else if( navigator.userAgent.indexOf('Firebird')   != -1    ) { NAVEGADOR = 'Firebird';      }
   else if( navigator.userAgent.indexOf('Netscape')   != -1    ) { NAVEGADOR = 'Netscape';      }
   else if( navigator.userAgent.indexOf('Gecko')      != -1    ) { NAVEGADOR = 'Firefox';       }
   else if( navigator.appName == 'Netscape'                    ) { NAVEGADOR = 'Communicator';  }

   // Si no es ninguno de los anteriores por cojones tiene que haber entrao con la Game boy esa :-?
   else { NAVEGADOR = 'Game boy'; alert('Torpeo con la Game Boy tenemos poco que hacer'); }

// ==================================================================================================================== //
//                                  Averiguamos algunos datos del documento                                             //
// ==================================================================================================================== //

   // La posición del cursor
   document.onmousedown = getMouseXY;

   // Declaramos globales las variables que van a contener la posición XY del cursor.
   var cursorX = 0;
   var cursorY = 0;


// ==================================================================================================================== //
//                                              F U N C I O N E S                                                       //
// ==================================================================================================================== //

   function getMouseXY( e ) {
      if ( NAVEGADOR =='IE' ) {
         // document.body.scrollTop y Left no funcionan si ponemos un DOCTYPE ( Chapuzas de Microsoft )
         //cursorX = event.clientX + document.body.scrollLeft;
         //cursorY = event.clientY + document.body.scrollTop;
         cursorX = event.clientX + document.documentElement.scrollLeft;
         cursorY = event.clientY + document.documentElement.scrollTop;
      }
      else { cursorX = e.pageX; cursorY = e.pageY; } if ( cursorX < 0 ) { cursorX = 0; } if ( cursorY < 0 ) { cursorY = 0; }
      return true
   }

   function ventana( url, nombre, w, h, scroll ) {
         var winl    = ( screen.width  - w ) / 2;
         var wint    = ( screen.height - h ) / 2;
         propiedades = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable';
         win         = window.open( url, nombre, propiedades )
         if ( parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   }

   function contraer( id ) {
      if ( document.getElementById( id ).style.display =='none' ) {
         document.getElementById( id ).style.display ='block';
      }
      else {
         document.getElementById( id ).style.display ='none';
      }
      // Si se trata de uno del os div principales con pestaña, además setearemos la imagen que le corresponda.
      if (( id =='div_principal_menu' ) || ( id =='div_principal_noticias' ))  {
         cambia_imagenes();
      }
   }

   function cambia_imagenes(  ) {
      if ( document.getElementById( 'div_principal_menu' ).style.display =='none' ) {
         document.getElementById( 'imagen_menu' ).src = '/images/show.gif';   }
      else {
         document.getElementById( 'imagen_menu' ).src = '/images/hide.gif';
      }

      if ( document.getElementById( 'div_principal_noticias' ).style.display =='none' ) {
         document.getElementById( 'imagen_noticias' ).src = '/images/show.gif';   }
      else {
         document.getElementById( 'imagen_noticias' ).src = '/images/hide.gif';
      }
   }



   // Esta función, nos devuelve el valor del radio chequeado
   // document.form.radio.value; devolvería undefined.
   function getRadioValue( oRadio ) {
      for( i=0; i < oRadio.length; i++ )
         if( oRadio[i].checked )
            return oRadio[i].value;
   }


   // Para no repetir insaciablemente document.getElementById
   function objeto( id ) {
      return document.getElementById( id );
   }


   // Constructor de objetos Ajax
   function nuevoAjax(){
      var xmlhttp=false;
      try {
         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
         try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (E) {
            xmlhttp = false;
         }
      }
      if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
         xmlhttp = new XMLHttpRequest();
      }
   return xmlhttp;
   }




