//------------------------------------------------------------------------------------
// Indice de funciones
//
// function EsN()
// function menuclick(id)
// function inicializarMenu()
// function trim(s)
// function disableObject(obj)
// function enableObject(obj)
// function disableEnableObject(obj)
// function getContexPathApplicationJs(form)
// function setAccion(form, idAccion)
// function goNow(form)
// function selected(cal, date)
// function closeHandler(cal)
// function showCalendar(id, format)
// function isDisabled(date)
// function flatSelected(cal, date)
// function showFlatCalendar()
// function getPosWindowInObj(width, height){
// function removeSelectedOptions(from)
// function hasOptions(obj)
// function sortSelect(obj)
// function moveSelectedOptions(from,to)
// function copySelectedOptions(from,to)
// function copyAllOptions(from,to)
// function removeSelectedOptions(from)
// function removeAllOptions(from)
// function selectAllOptions(obj)
//------------------------------------------------------------------------------------





//------------------------------------------------------------------------------------
// Objeto Navegaror
//------------------------------------------------------------------------------------

// var is = new EsN();

  function EsN(){
    // alert("Nav[" + navigator.appName + "] Vers[" + navigator.appVersion + "]Parse ver[" +  parseInt(navigator.appVersion) + "]");
    var agt=navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);
    this.nav62 =  (navigator.userAgent.indexOf("Netscape6/6.2") != -1)

    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);

    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
  }

//------------------------------------------------------------------------------------
// Gestion de menu
//------------------------------------------------------------------------------------
	function menuclick(id) {
		obj = document.getElementById(id);
		//Cerramos el resto de las opciones de menu
		var colMenu=document.getElementsByTagName("ul");
        for (var i=0;i<colMenu.length;i++) {
            if (colMenu[i].attributes["name"]!=null) {
                if (colMenu[i].attributes["name"].value=="menu" && id.search(colMenu[i].id)<0) {
                    colMenu[i].style.display = "none";
                }
            }
        }
        if (obj!=null)
			  obj.style.display = "";

			//Cerramos el resto de opciones de menu
			/*if (nivel == 1) {
				if (id != 'auxiliares') {
					document.getElementById('auxiliares').style.display = "none";
				}
				if (id != 'cualificaciones') {
					document.getElementById('cualificaciones').style.display = "none";
				}
				if (id != 'observatorios') {
					document.getElementById('observatorios').style.display = "none";
				}
				if (id != 'expertos') {
					document.getElementById('expertos').style.display = "none";
				}
				if (id != 'suplementos') {
					document.getElementById('suplementos').style.display = "none";
				}
			}*/
	}
    function inicializarMenu() {
        var strMenu;
        if (this.menu!=null){
            strMenu=this.menu;
        }else {
              var arrAux=document.URL.split('/');
              strMenu=arrAux[arrAux.length-1];
              strMenu=strMenu.split(".")[0];
         }
        var colMenu=document.getElementsByTagName("a");
        for (var i=0;i<colMenu.length;i++) {
            if (colMenu[i].href.search(strMenu)>=0 && colMenu[i].href.search('#')<0) {
              menuclick(colMenu[i].parentNode.parentNode.id);
              colMenu[i].parentNode.className="menuSeleccionado";
              return;
            }
        }
        menuclick('');
    }
//------------------------------------------------------------------------------------
// implementa function trim(" PEPE ") => "PEPE"
//------------------------------------------------------------------------------------

 function trim(s) {
      return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
  }

//------------------------------------------------------------------------------------
// deshabilita el objeto
//------------------------------------------------------------------------------------

function disableObject(obj) {
	obj.disabled = true;
	var z = (obj.disabled) ? 'disabled' : 'enabled';
	// alert(obj.type + ' now ' + z);
}

//------------------------------------------------------------------------------------
// habilita el objeto
//------------------------------------------------------------------------------------

function enableObject(obj) {
	obj.disabled = false;
	var z = (obj.disabled) ? 'disabled' : 'enabled';
	// alert(obj.type + ' now ' + z);
}

//------------------------------------------------------------------------------------
// deshabilita habilita el objeto
//------------------------------------------------------------------------------------

function disableEnableObject(obj) {
	obj.disabled = !(obj.disabled);
	var z = (obj.disabled) ? 'disabled' : 'enabled';
	// alert(obj.type + ' now ' + z);
}


//------------------------------------------------------------------------------------
// Obtiene el ContexPath del form
// var cntPath = getContexPathApplicationJs(document.forms[0]);
//------------------------------------------------------------------------------------

function getContexPathApplicationJs(form){
  var cadena=form.action;
  if (cadena.lastIndexOf("/") == 0)
    cadena=document.location.href;
  var n=cadena.lastIndexOf("/") ;
  var cadenafinal=cadena.substr(0,n) ;
  // document.write(cadenafinal);
  return cadenafinal;
}

//------------------------------------------------------------------------------------
// Asigna accion a un formulario
//  <input type='hidden' nam='accion' value='XXXXX'>
//------------------------------------------------------------------------------------
function setAccion(form, idAccion) {
  form.accion.value = idAccion;
  // alert( "form.accion.value: " + form.accion.value + " document.forms[0].accion.value: " + document.forms[0].accion.value);
}

//------------------------------------------------------------------------------------
// sube foruolario al servidor
// document.forms[XXXX].submit();
//------------------------------------------------------------------------------------
function goNow(form) {
  // document.forms[0].submit();
  form.submit();
}

//----------------------------------------------
// Código javascript para el Calendario
//----------------------------------------------
	// This function gets called when the end-user clicks on some date.
	function selected(cal, date) 
	{
	  cal.sel.value = date; // just update the date in the input field.
	  cal.hide();
	  if (cal.sel.id == "sel1" || cal.sel.id == "sel3")
		// if we add this call we close the calendar on single-click.
		// just to exemplify both cases, we are using this only for the 1st
		// and the 3rd field, while 2nd and 4th will still require double-click.
		cal.callCloseHandler();
	}

	// And this gets called when the end-user clicks on the _selected_ date,
	// or clicks on the "Close" button.  It just hides the calendar without
	// destroying it.
	function closeHandler(cal) {
	  cal.hide();                        // hide the calendar
	}

	// This function shows the calendar under the element having the given id.
	// It takes care of catching "mousedown" signals on document and hiding the
	// calendar if the click was outside.
	function showCalendar(id, format) {
	  var el = document.getElementById(id);
	  if (calendar != null) {
		// we already have some calendar created
		calendar.hide();                 // so we hide it first.
	  } else {
		// first-time call, create the calendar.
		var cal = new Calendar(true, null, selected, closeHandler);
		// uncomment the following line to hide the week numbers
		// cal.weekNumbers = false;
		calendar = cal;                  // remember it in the global var
		cal.setRange(1900, 2070);        // min/max year allowed.
		cal.create();
	  }
	  calendar.setDateFormat(format);    // set the specified date format
	  calendar.parseDate(el.value);      // try to parse the text in field
	  calendar.sel = el;                 // inform it what input field we use
	  calendar.showAtElement(el);        // show the calendar below it
		  return false;
	}

	var MINUTE = 60 * 1000;
	var HOUR = 60 * MINUTE;
	var DAY = 24 * HOUR;
	var WEEK = 7 * DAY;

	// If this handler returns true then the "date" given as
	// parameter will be disabled.  In this example we enable
	// only days within a range of 10 days from the current
	// date.
	// You can use the functions date.getFullYear() -- returns the year
	// as 4 digit number, date.getMonth() -- returns the month as 0..11,
	// and date.getDate() -- returns the date of the month as 1..31, to
	// make heavy calculations here.  However, beware that this function
	// should be very fast, as it is called for each day in a month when
	// the calendar is (re)constructed.
	function isDisabled(date) {
	  var today = new Date();
	  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
	}

	function flatSelected(cal, date) {
	  var el = document.getElementById("preview");
	  el.innerHTML = date;
	}

	function showFlatCalendar(){
	  var parent = document.getElementById("display");

     //construct a calendar giving only the "selected" handler.
	  var cal = new Calendar(false, null, flatSelected);

     //hide week numbers
	  cal.weekNumbers = false;

	  // We want some dates to be disabled; see function isDisabled above
	  cal.setDisabledHandler(isDisabled);
	  cal.setDateFormat("DD, M d");

	  // this call must be the last as it might use data initialized above; if
	  // we specify a parent, as opposite to the "showCalendar" function above,
	  // then we create a flat calendar -- not popup.  Hidden, though, but...
	  cal.create(parent);

	  // ... we can show it here.
	  cal.show();
	}


//----------------------------------------------
//  Calcula las posiciones de ventana
//	Uso en jsp:
//	var width=760;
//	var height=549;
//	var posWindowObj = getPoswindowInObj(width, height);
// 	var ventana = window.open(pagina, "", "width="+posWindowObj.width+",height=" + posWindowObj.height+ ", left=" + posWindowObj.left + ", top="+posWindowObj.top + ", etc ....
//----------------------------------------------
	function getPosWindowInObj(width, height){
      var posWindow = new Object();
      posWindow.width = width;
      posWindow.height = height;
		  posWindow.left = (screen.width - width)/2;
      posWindow.top = (screen.height - height)/2;

      return posWindow;
	}

//----------------------------------------------
//  Operaciones para deslegables dinamicos
// realizaciones de borrado, seleccion,  anadido, etc ...
//----------------------------------------------

    function removeSelectedOptions(from) {
      if (!hasOptions(from)) { return; }
      if (from.type=="select-one") {
        from.options[from.selectedIndex] = null;
      } else {
        for (var i=(from.options.length-1); i>=0; i--) {
          var o=from.options[i];
          if (o.selected) {
            from.options[i] = null;
          }
        }
      }
      from.selectedIndex = -1;
    }

    function hasOptions(obj) {
      if (obj!=null && obj.options!=null) { return true; }
      return false;
    }


    function sortSelect(obj) {
      var o = new Array();

      if (!hasOptions(obj)) { return; }

      for (var i=0; i<obj.options.length; i++) {
        o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
    }

      if (o.length==0) { return; }

      o = o.sort(
        function(a,b) {
          if ((a.text+"") < (b.text+"")) { return -1; }
          if ((a.text+"") > (b.text+"")) { return 1; }
          return 0;
          }
        );

        for (var i=0; i<o.length; i++) {
          obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
        }
    }


    function moveSelectedOptions(from,to) {
      // Unselect matching options, if required
      if (arguments.length>3) {
        var regex = arguments[3];
        if (regex != "") {
          unSelectMatchingOptions(from,regex);
          }
        }
      // Move them over
      if (!hasOptions(from)) { return; }
      for (var i=0; i<from.options.length; i++) {
        var o = from.options[i];
        if (o.selected) {
          if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
          to.options[index] = new Option( o.text, o.value, false, false);
          }
        }
      // Delete them from original
      for (var i=(from.options.length-1); i>=0; i--) {
        var o = from.options[i];
        if (o.selected) {
          from.options[i] = null;
          }
        }
      if ((arguments.length<3) || (arguments[2]==true)) {
        sortSelect(from);
        sortSelect(to);
        }
      from.selectedIndex = -1;
      to.selectedIndex = -1;
    }

  function copySelectedOptions(from,to) {
    var options = new Object();
    if (hasOptions(to)) {
      for (var i=0; i<to.options.length; i++) {
        options[to.options[i].value] = to.options[i].text;
        }
      }
    if (!hasOptions(from)) { return; }
    for (var i=0; i<from.options.length; i++) {
      var o = from.options[i];
      if (o.selected) {
        if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) {
          if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
          to.options[index] = new Option( o.text, o.value, false, false);
          }
        }
      }
    if ((arguments.length<3) || (arguments[2]==true)) {
      sortSelect(to);
      }
    from.selectedIndex = -1;
    to.selectedIndex = -1;
  }


  function copyAllOptions(from,to) {
    selectAllOptions(from);
    if (arguments.length==2) {
      copySelectedOptions(from,to);
      }
    else if (arguments.length==3) {
      copySelectedOptions(from,to,arguments[2]);
      }
    }

  function removeSelectedOptions(from) {
    if (!hasOptions(from)) { return; }
    if (from.type=="select-one") {
      from.options[from.selectedIndex] = null;
      }
    else {
      for (var i=(from.options.length-1); i>=0; i--) {
        var o=from.options[i];
        if (o.selected) {
          from.options[i] = null;
          }
        }
      }
    from.selectedIndex = -1;
  }

  function removeAllOptions(from) {
    if (!hasOptions(from)) { return; }
    for (var i=(from.options.length-1); i>=0; i--) {
      from.options[i] = null;
      }
    from.selectedIndex = -1;
  }

  function selectAllOptions(obj) {
    if (!hasOptions(obj)) { return; }
    for (var i=0; i<obj.options.length; i++) {
      obj.options[i].selected = true;
      }
    }

//----------------------------------------------
//  FIN Operaciones para deslegables dinamicos
//----------------------------------------------


//----------------------------------------------
//  Acceso directo a foros.
//----------------------------------------------

/*
*   Función encargada de desplazar el scrooll del navegador hasta la imagen cuyo id le hemos pasado
*		id El identificador de la imagen a la que queremos llegar.
*/
function goNumber(id){
	var imagenes = document.getElementsByTagName('img');
	for (var i2=0; i2 < imagenes.length; i2++) {
		if(imagenes[i2].id==id) {
			var imagenBuena = imagenes[i2];
		}
	}
	window.scrollTo(0,findPosY(imagenBuena)-10);
}
<!-- inicio
function aniadirFavoritos()
{
   var direccion = location.href;
   var titulo="Extranet Incual ver. 1.0";
   document.title = titulo;
   var ns = "Para añadir esta página a tu libreta de Favoritos, pulsa [Ctrl] + [ D ] ";
   var op = "Para añadir esta página a tus Preferidos de Opera, pulsa: [Ctrl] + [Mays] + [T]";
   if (navigator.userAgent.indexOf("Opera")!=-1) 
   {
     alert(op);
     //document.write(op);
   }
   else 
   { 
       if (navigator.appName == "Netscape")
       {
         alert(ns);
         //document.write(ns);
       }
       else 
       {
         window.external.AddFavorite(direccion, titulo); 
       }
     }
}

function accesoForos()  {
	location.replace("http://foroincual.mec.es/foroincual");
}
     
// final -->





