userAgent = function() {

        var numberfy = function(s) {
            var c = 0;
            return parseFloat(s.replace(/\./g, function() {
                return (c++ == 1) ? '' : '.';
            }));
        },

        nav = navigator,

        o = {

        /**
         * Internet Explorer version number or 0.  Example: 6
         * @property ie
         * @type float
         */
        ie: 0,

        /**
         * Opera version number or 0.  Example: 9.2
         * @property opera
         * @type float
         */
        opera: 0,

        /**
         * Gecko engine revision number.  Will evaluate to 1 if Gecko
         * is detected but the revision could not be found. Other browsers
         * will be 0.  Example: 1.8
         * <pre>
         * Firefox 1.0.0.4: 1.7.8   <-- Reports 1.7
         * Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
         * Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
         * Firefox 3 alpha: 1.9a4   <-- Reports 1.9
         * </pre>
         * @property gecko
         * @type float
         */
        gecko: 0,

        /**
         * AppleWebKit version.  KHTML browsers that are not WebKit browsers
         * will evaluate to 1, other browsers 0.  Example: 418.9.1
         * <pre>
         * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
         *                                   latest available for Mac OSX 10.3.
         * Safari 2.0.2:         416     <-- hasOwnProperty introduced
         * Safari 2.0.4:         418     <-- preventDefault fixed
         * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
         *                                   different versions of webkit
         * Safari 2.0.4 (419.3): 419     <-- Tiger installations that have been
         *                                   updated, but not updated
         *                                   to the latest patch.
         * Webkit 212 nightly:   522+    <-- Safari 3.0 precursor (with native SVG
         *                                   and many major issues fixed).
         * 3.x yahoo.com, flickr:422     <-- Safari 3.x hacks the user agent
         *                                   string when hitting yahoo.com and
         *                                   flickr.com.
         * Safari 3.0.4 (523.12):523.12  <-- First Tiger release - automatic update
         *                                   from 2.x via the 10.4.11 OS patch
         * Webkit nightly 1/2008:525+    <-- Supports DOMContentLoaded event.
         *                                   yahoo.com user agent hack removed.
         *
         * </pre>
         * http://developer.apple.com/internet/safari/uamatrix.html
         * @property webkit
         * @type float
         */
        webkit: 0,

        /**
         * The mobile property will be set to a string containing any relevant
         * user agent information when a modern mobile browser is detected.
         * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
         * devices with the WebKit-based browser, and Opera Mini.
         * @property mobile
         * @type string
         */
        mobile: null,

        /**
         * Adobe AIR version number or 0.  Only populated if webkit is detected.
         * Example: 1.0
         * @property air
         * @type float
         */
        air: 0,

        /**
         * Google Caja version number or 0.
         * @property caja
         * @type float
         */
        caja: nav.cajaVersion,

        /**
         * Set to true if the page appears to be in SSL
         * @property secure
         * @type boolean
         * @static
         */
        secure: false,

        /**
         * The operating system.  Currently only detecting windows or macintosh
         * @property os
         * @type string
         * @static
         */
        os: null

    },

    ua = navigator && navigator.userAgent,

    loc = window && window.location,

    href = loc && loc.href,

    m;

    o.secure = href && (href.toLowerCase().indexOf("https") === 0);

    if (ua) {

        if ((/windows|win32/i).test(ua)) {
            o.os = 'windows';
        } else if ((/macintosh/i).test(ua)) {
            o.os = 'macintosh';
        }

        // Modern KHTML browsers should qualify as Safari X-Grade
        if ((/KHTML/).test(ua)) {
            o.webkit=1;
        }

        // Modern WebKit browsers are at least X-Grade
        m=ua.match(/AppleWebKit\/([^\s]*)/);
        if (m&&m[1]) {
            o.webkit=numberfy(m[1]);

            // Mobile browser check
            if (/ Mobile\//.test(ua)) {
                o.mobile = "Apple"; // iPhone or iPod Touch
            } else {
                m=ua.match(/NokiaN[^\/]*/);
                if (m) {
                    o.mobile = m[0]; // Nokia N-series, ex: NokiaN95
                }
            }

            m=ua.match(/AdobeAIR\/([^\s]*)/);
            if (m) {
                o.air = m[0]; // Adobe AIR 1.0 or better
            }

        }

        if (!o.webkit) { // not webkit
            // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
            m=ua.match(/Opera[\s\/]([^\s]*)/);
            if (m&&m[1]) {
                o.opera=numberfy(m[1]);
                m=ua.match(/Opera Mini[^;]*/);
                if (m) {
                    o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
                }
            } else { // not opera or webkit
                m=ua.match(/MSIE\s([^;]*)/);
                if (m&&m[1]) {
                    o.ie=numberfy(m[1]);
                } else { // not opera, webkit, or ie
                    m=ua.match(/Gecko\/([^\s]*)/);
                    if (m) {
                        o.gecko=1; // Gecko detected, look for revision
                        m=ua.match(/rv:([^\s\)]*)/);
                        if (m&&m[1]) {
                            o.gecko=numberfy(m[1]);
                        }
                    }
                }
            }
        }
    }

    return o;
}();

var classAttribute = ((userAgent.ie > 0 && userAgent.ie <= 7) ? 'className' : 'class');

	var menuWeb = new Array();
	function refreshMenu() {

		var ul = document.createElement("ul");
		ul.setAttribute("id","menucontainer");
		for (var i=0;i<menuWeb.length;i++) {
			var li = menuWeb[i].nodo;
			ul.appendChild(li);
			if (li.getAttribute(classAttribute)=="opcionprincipalmarca") {
				// hijos
				for (var j=0;j<menuWeb[i].hijos.length;j++) {
					ul.appendChild(menuWeb[i].hijos[j]);
				}
			}
		}
		var div = document.getElementById("menusupercontainer");
		var ulold = document.getElementById("menucontainer");
		if (ulold == null) {
			div.appendChild(ul);
		}
		else {
			div.replaceChild(ul, ulold);
		}
		var flash = document.createElement("div");
		flash.setAttribute("id","bannerportada");
		flash.style.marginLeft = "5px";
		flash.style.marginTop = "25px";
		flash.style.display = "none";
		flash.innerHTML = '<map name="curso"><area shape="rect" coords="6,151,80,166" href="http://www.fabis.org/aula/" target="_blank" /></map><img src="../imagenes/portada/banner_curso2.jpg" width="158" height="173" alt="Curso de MetodologÃ­a de la InvestigaciÃ³n en Ciencias de la Salud" border="0" style="margin-bottom:1.5em;" usemap="#curso" /><br /><a href="/actividades/seminarios/proximos/index.php"><img src="/imagenes/banner_v_aadea.png" alt="V Curso de Actualización en patología autoinmune de la Asociación Andaluza de Enfermedades Autoinmunes (AADEA)" style="margin-bottom:1.5em;"/></a><br /><a href="http://www.gaditha.com/" target="_blank"><img src="/imagenes/portada/banner_gaditha_sello.gif" width="140" height="90" alt="Gaditha" border="0" /></a>';
  		div.appendChild(flash);

/*
		flash.innerHTML = '<map name="curso"><area shape="rect" coords="6,151,119,166" href="http://www.shmedical.es/Inscripciones/index.html?id_congreso=31" target="_blank" /><area shape="rect" coords="6,176,80,191" href="http://www.fabis.org/aula/" target="_blank" /></map><img src="../imagenes/portada/banner_curso2.jpg" width="158" height="173" alt="Curso de MetodologÃ­a de la InvestigaciÃ³n en Ciencias de la Salud" border="0" style="margin-bottom:1.5em;" usemap="#curso" /> <br /><a href="http://www.gaditha.com/" target="_blank"><img src="/imagenes/portada/banner_gaditha_sello.gif" width="140" height="90" alt="Gaditha" border="0" /></a>';
*/

	}

	function addOpcionMenu(enlace, texto, marcado) {
		var at;
		var li = document.createElement("li");
		if (arguments.length > 3) {
			li.setAttribute("style", arguments[3]);
		}
		if (marcado == 1) {
			li.setAttribute(classAttribute,"opcionprincipalmarca");
		}
		else {
			li.setAttribute(classAttribute,"opcionprincipal");
		}
		if (arguments.length > 3 && arguments[3].li) {
			for (at in arguments[3].li) {
				li.style[at] = arguments[3].li[at];
			}
		}
		var div = document.createElement("div");
		if (arguments.length > 3 && arguments[3].div) {
			for (at in arguments[3].div) {
				div.style[at] = arguments[3].div[at];
			}
		}
		li.appendChild(div);
		var a = document.createElement("a");
		if (arguments.length > 3 && arguments[3].a) {
			for (at in arguments[3].a) {
				a.style[at] = arguments[3].a[at];
			}
		}
		if (enlace != null && enlace != '') {
			a.setAttribute("href", enlace);
		}
		else {
			// Ã±apa
			if (texto == 'XXVI Congreso SADEMI') {
				a.setAttribute("href",'http://congreso.sademi.com/');
//				a.onclick = new Function("location.href='http://congreso.sademi.com"("+menuWeb.length+");this.style.backgroundImage = 'none';return false;");
			}
			else if (texto == 'Registro') {
				a.onclick = new Function("openOpcionMenu("+menuWeb.length+");this.style.backgroundImage = 'none';return false;");
				a.setAttribute("id", "opcionregistro");
				a.setAttribute("href",'#');
			}
			else {
				a.onclick = new Function("openOpcionMenu("+menuWeb.length+");(document.getElementById('opcionregistro')).style.backgroundImage='url(/imagenes/esquina_menu.gif)';return false;");
				a.setAttribute("href",'#');
			}
		}

		div.appendChild(a);
		var t = document.createTextNode(texto);
		a.appendChild(t);
		menuWeb[menuWeb.length] = {nodo:li, hijos:new Array()};
	}
	function addOpcionSubMenu(numMenu, enlace, texto, marcado) {
		var li = document.createElement("li");
		if (marcado == 1) {
			li.setAttribute(classAttribute,"opcionsecundariamarca");
		}
		else {
			li.setAttribute(classAttribute,"opcionsecundaria");
		}
		if (arguments.length > 4 && arguments[4].li) {
			var at;
			for (at in arguments[4].li) {
				li.style[at] = arguments[4].li[at];
			}
		}
		var div = document.createElement("div");
		li.appendChild(div);
		var a = document.createElement("a");
		a.setAttribute("href",enlace);
		div.appendChild(a);
		var t = document.createTextNode(texto);
		a.appendChild(t);
		menuWeb[numMenu].hijos[menuWeb[numMenu].hijos.length] = li;
	}
	function collapseAll() {
		var ul = document.createElement("ul");
		ul.setAttribute("id","menucontainer");
		for (var i=0;i<menuWeb.length;i++) {
			var li = menuWeb[i].nodo;
			ul.appendChild(li);
		}
		var div = document.getElementById("menusupercontainer");
		var ulold = document.getElementById("menucontainer");
		if (ulold == null) {
			div.appendChild(ul);
		}
		else {
			div.replaceChild(ul, ulold);
		}
	}
	function openOpcionMenu(numMenu) {
		var flash = document.getElementById("flash");
		if (flash != null)
			flash.style.visibility = "hidden";
		collapseAll();
		var ul = document.getElementById("menucontainer");;
		var menu = menuWeb[numMenu];
		var nextNodo = menu.nodo.nextSibling;
		for (var i=0;i<menu.hijos.length;i++) {
			var submenu = menu.hijos[i];
			if (nextNodo != null) {
				ul.insertBefore(submenu, nextNodo);
			}
			else {
				ul.appendChild(submenu);
			}
		}
		if (flash != null)
			window.setTimeout(function() {flash.style.visibility = "visible";}, 50);
	}

	addBodyOnload(refreshMenu);
