﻿// FUNCIONES COMUNES A TODO EL PORTAL MAPFRE

// Aumentamos y disminuimos el texto
var txtSz = 0.7;
function textSize(signo) {
    var cuerpo = document.getElementsByTagName("BODY")
    txtSz = (signo=="plus") ? txtSz+0.10 : txtSz-0.10;
    if (txtSz>1.1) txtSz = 1.1;
    if (txtSz<0.5) txtSz = 0.5;
    ts = txtSz+"em";
    cuerpo[0].style.fontSize = ts;
}

// abre href de objeto en nueva ventana
function openPopup(obj){
    url      = obj.href;
    //obj.href = "#"
    window.open(url,'','width=660,height=640,scrollbars=auto,menubar=no,toolbar=no,location=no');
    return false;
}

// Cookie management functions
function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}

function recolocarPestanyas(otros){
	var vieneHome = readCookie("home");
	var deHome = readCookie("pestanya");
	var vieneAnteriorHome = readCookie("anteriorHome");
	if(vieneAnteriorHome!=null && otros!=null){
		vieneHome = vieneAnteriorHome;
		createCookie("home",vieneHome);
		deHome = "otros";
	}
	// vieneHome == N cuando no hay cmabios de pestañas
	if(vieneHome){
		if(vieneHome == "accionistas"){
			/*document.getElementById("particulares").style.display = "none";
			document.getElementById("profesionales").style.display = "none";
			document.getElementById("empresas").style.display = "none";*/
			document.getElementById("pestanyas").innerHTML =
			"<li id='accionistas'><a href='/corporativo/accionistas/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"accionistas\")' title='Accionistas e Inversores'>Accionistas e Inversores</a></li>" +
			"<li id='acerca'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' onclick='createCookie(\"pestanya\",\"fundacion\")' title='FUNDACI&Oacute;N MAPFRE'>Fundaci&oacute;n</a></li>" +
			"<li id='prensa'><a href='http://www.mapfre.com/salaprensa/es/principal/index.shtml' target='new' title='Prensa'>Prensa</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros\")' title='Otros sitios MAPFRE'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
			//document.getElementById("otros").href="/seguros/es/docs/html/otrosSitesTotal.shtml";
		}else if(vieneHome == "acerca"){
			/*document.getElementById("particulares").style.display = "none";
			document.getElementById("profesionales").style.display = "none";
			document.getElementById("empresas").style.display = "none";*/
			document.getElementById("pestanyas").innerHTML =
			"<li id='acerca'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='accionistas'><a href='/corporativo/accionistas/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"accionistas\")' title='Accionistas e Inversores'>Accionistas e Inversores</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' onclick='createCookie(\"pestanya\",\"fundacion\")' title='FUNDACI&Oacute;N MAPFRE'>Fundaci&oacute;n</a></li>" +
			"<li id='prensa'><a href='http://www.mapfre.com/salaprensa/es/principal/index.shtml' target='new' title='Prensa'>Prensa</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' title='Otros sitios MAPFRE' onclick='createCookie(\"pestanya\",\"otros\")'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}else if(vieneHome == "fundacion"){
			/*document.getElementById("particulares").style.display = "none";
			document.getElementById("profesionales").style.display = "none";
			document.getElementById("empresas").style.display = "none";
			document.getElementById("accionistas").style.display = "none";*/
			document.getElementById("pestanyas").innerHTML =
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' onclick='createCookie(\"pestanya\",\"fundacion\")' title='FUNDACI&Oacute;N MAPFRE'>Fundaci&oacute;n</a></li>" +
			"<li id='acerca_es_internacional'><a href='/corporativo/grupomapfre/es/general/index.shtml' title='Acerca de MAPFRE' onclick='createCookie(\"pestanya\",\"acerca_es_internacional\")'>Acerca de MAPFRE</a></li>" +
			"<li id='responsabilidad_social_es'><a href='/responsabilidad-social/es/general/responsabilidad-social-mapfre.shtml' onclick='createCookie(\"pestanya\",\"responsabilidad_social\")' title='Responsabilidad Social'>Responsabilidad Social</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' title='Otros sitios MAPFRE' onclick='createCookie(\"pestanya\",\"otros\")'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}else if(vieneHome == "mapfrere"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='mapfrere'><a href='/mapfrere/es/general/inicio.shtml' onclick='createCookie(\"home\",\"mapfrere\");createCookie(\"pestanya\",\"mapfrere\")' title='MAPFRE RE'>MAPFRE RE</a></li>" +
			"<li id='acerca'><a href='/corporativo/grupomapfre/es/general/index.shtml' title='Acerca de MAPFRE' onclick='createCookie(\"home\",\"mapfrere\");createCookie(\"pestanya\",\"acerca\")'>Acerca de MAPFRE</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' onclick='createCookie(\"home\",\"mapfrere\");createCookie(\"pestanya\",\"fundacion\")' title='FUNDACI&Oacute;N MAPFRE'>Fundaci&oacute;n</a></li>";
		}
		else if(vieneHome == "acerca_es_internacional"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='acerca_es_internacional'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_es_internacional\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='accionistas_es_internacional'><a href='/corporativo/accionistas/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"accionistas\")' title='Accionistas e Inversores'>Accionistas e Inversores</a></li>" +
			"<li id='prensa'><a href='http://www.mapfre.com/salaprensa/es/principal/index.shtml' target='new' title='Prensa'>Prensa</a></li>" +
			"<li id='responsabilidad_social_es'><a href='/responsabilidad-social/es/general/responsabilidad-social-mapfre.shtml' onclick='createCookie(\"pestanya\",\"responsabilidad_social\")' title='Responsabilidad Social'>Responsabilidad Social</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' title='FUNDACI&Oacute;N MAPFRE' onclick='createCookie(\"pestanya\",\"fundacion\")'>Fundaci&oacute;n</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros\")' title='Otros sitios MAPFRE'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}
		else if(vieneHome == "acerca_en_internacional"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='acerca_en_internacional'><a href='/corporativo/grupomapfre/en/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_en_internacional\")' title='About MAPFRE'>About MAPFRE</a></li>" +
			"<li id='accionistas_en_internacional'><a href='/corporativo/accionistas/en/general/index.shtml' title='Institutional Inverstors' onclick='createCookie(\"pestanya\",\"accionistas_en_internacional\")'>Institutional Inverstors</a></li>" +
			"<li id='responsabilidad_social_en'><a href='/responsabilidad-social/en/general/mapfre-social-responsibility.shtml' title='Social Responsability' onclick='createCookie(\"pestanya\",\"responsabilidad_social_en\")'>Social Responsability</a></li>" +
			"<li id='otros'><a href='/seguros/en/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros_en_internacional\")' title='Other MAPFRE Sites'>Other MAPFRE Sites</a></li>";
		}else if(vieneHome == "accionistas_en_internacional"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='accionistas_en_internacional'><a href='/corporativo/accionistas/en/general/index.shtml' title='Institutional Inverstors' onclick='createCookie(\"pestanya\",\"accionistas_en_internacional\")'>Institutional Inverstors</a></li>" +
			"<li id='acerca_en_internacional'><a href='/corporativo/grupomapfre/en/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_en_internacional\")' title='About MAPFRE'>About MAPFRE</a></li>" +
			"<li id='responsabilidad_social_en'><a href='/responsabilidad-social/en/general/mapfre-social-responsibility.shtml' title='Social Responsability' onclick='createCookie(\"pestanya\",\"responsabilidad_social_en\")'>Social Responsability</a></li>" +
			"<li id='otros'><a href='/seguros/en/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros_en_internacional\")' title='Other MAPFRE Sites'>Other MAPFRE Sites</a></li>";
		}else if(vieneHome == "accionistas_es_internacional"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='accionistas_es_internacional'><a href='/corporativo/accionistas/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"accionistas_es_internacional\")' title='Accionistas e Inversores'>Accionistas e Inversores</a></li>" +
			"<li id='acerca_es_internacional'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_es_internacional\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='prensa'><a href='http://www.mapfre.com/salaprensa/es/principal/index.shtml' target='new' title='Prensa'>Prensa</a></li>" +
			"<li id='responsabilidad_social_es'><a href='/responsabilidad-social/es/general/responsabilidad-social-mapfre.shtml' onclick='createCookie(\"pestanya\",\"responsabilidad_social\")' title='Responsabilidad Social'>Responsabilidad Social</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' title='FUNDACI&Oacute;N MAPFRE' onclick='createCookie(\"pestanya\",\"fundacion\")'>Fundaci&oacute;n</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros\")' title='Otros sitios MAPFRE'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}else if(vieneHome == "salud"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='salud'><a href='/salud/es/general/salud.shtml' onclick='createCookie(\"home\",\"salud\");createCookie(\"pestanya\",\"salud\")' title='Canal Salud'>Canal Salud</a></li>" +
			"<li id='acerca'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"home\",\"salud\");createCookie(\"pestanya\",\"acerca\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' title='FUNDACI&Oacute;N MAPFRE' onclick='createCookie(\"home\",\"salud\");createCookie(\"pestanya\",\"fundacion\")'>Fundaci&oacute;n</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' onclick='createCookie(\"home\",\"salud\");createCookie(\"pestanya\",\"otros\")' title='Otros sitios MAPFRE'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}else if(vieneHome == "responsabilidad_social_es"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='responsabilidad_social_es'><a href='/responsabilidad-social/es/general/responsabilidad-social-mapfre.shtml' onclick='createCookie(\"pestanya\",\"responsabilidad_social\")' title='Responsabilidad Social'>Responsabilidad Social</a></li>" +
			"<li id='acerca_es_internacional'><a href='/corporativo/grupomapfre/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_es_internacional\")' title='Acerca de MAPFRE'>Acerca de MAPFRE</a></li>" +
			"<li id='accionistas_es_internacional'><a href='/corporativo/accionistas/es/general/index.shtml' onclick='createCookie(\"pestanya\",\"accionistas_es_internacional\")' title='Accionistas e Inversores'>Accionistas e Inversores</a></li>" +
			"<li id='prensa'><a href='http://www.mapfre.com/salaprensa/es/principal/index.shtml' target='new' title='Prensa'>Prensa</a></li>" +
			"<li id='fundacion'><a href='/fundacion/es/home-fundacion-mapfre.shtml' title='FUNDACI&Oacute;N MAPFRE' onclick='createCookie(\"pestanya\",\"fundacion\")'>Fundaci&oacute;n</a></li>" +
			"<li id='otros'><a href='/seguros/es/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros\")' title='Otros sitios MAPFRE'>Otros&nbsp;sitios&nbsp;MAPFRE</a></li>";
		}else if(vieneHome == "responsabilidad_social_en"){
			document.getElementById("pestanyas").innerHTML =
			"<li id='responsabilidad_social_en'><a href='/responsabilidad-social/en/general/mapfre-social-responsibility.shtml' title='Social Responsability' onclick='createCookie(\"pestanya\",\"responsabilidad_social_en\")'>Social Responsability</a></li>" +
			"<li id='acerca_en_internacional'><a href='/corporativo/grupomapfre/en/general/index.shtml' onclick='createCookie(\"pestanya\",\"acerca_en_internacional\")' title='About MAPFRE'>About MAPFRE</a></li>" +
			"<li id='accionistas_en_internacional'><a href='/corporativo/accionistas/en/general/index.shtml' title='Institutional Inverstors' onclick='createCookie(\"pestanya\",\"accionistas_en_internacional\")'>Institutional Inverstors</a></li>" +
			"<li id='otros'><a href='/seguros/en/docs/html/otrosSites.shtml' onclick='createCookie(\"pestanya\",\"otros_en_internacional\")' title='Other MAPFRE Sites'>Other MAPFRE Sites</a></li>";
		}
		if(deHome && vieneHome != "N"){
			document.getElementById(deHome).className = "on";
		}
		
		if(otros){
			if(vieneHome == "N"){
				if(document.getElementById("o_particulares")!=null)
					document.getElementById("o_particulares").style.display = "none";
				if(document.getElementById("o_profesionales")!=null)
					document.getElementById("o_profesionales").style.display = "none";
				if(document.getElementById("o_empresas")!=null)
					document.getElementById("o_empresas").style.display = "none";
				//document.getElementById("o_accionistas").style.display = "none";
				if(document.getElementById("o_prensa")!=null)
					document.getElementById("o_prensa").style.display = "none";
			}else if(vieneHome == "salud"){
				if(document.getElementById("o_canalsalud")!=null)
					document.getElementById("o_canalsalud").style.display = "none";
			}else if (vieneHome!="fundacion"){
				//document.getElementById("o_accionistas").style.display = "none";
				if(document.getElementById("o_prensa")!=null)
					document.getElementById("o_prensa").style.display = "none";
			}
			
			if(vieneHome == "acerca_es_internacional" || vieneHome == "acerca_en_internacional"){
				document.getElementById("linksTop").style.display = "none";
			}
		}
	}
}

function iniciarCookiePestanya(pestanya){
	var vieneHome = readCookie("home");
	
	if(vieneHome == null){
		createCookie("home", pestanya);
		createCookie("pestanya", pestanya);
	}
}
// Cookie management functions - END

// Some util methods
//String.prototype.startsWith = function(s) { return this.indexOf(s)==0; }

// Node search functions
function findChildNode(theNode,childName) {
    if(theNode.childNodes) {
        var idx;
        for(idx=0;idx<theNode.childNodes.length;idx++) {
            if(theNode.childNodes[idx].nodeName==childName) return theNode.childNodes[idx];
        }
    }
    return null;
}
function findParentNode(theNode,parentName){
    if(theNode.nodeName==parentName) return theNode;
    if(theNode.parentNode) return findParentNode(theNode.parentNode,parentName);
    return null;
}
// Node search functions - END

// Funciones par el CONTROL DE MENU
var liActual=null;
function findSubmenuDiv(theLi) {
    var idx=0;
    for(idx=0;idx<theLi.childNodes.length;idx++) {
        if(theLi.childNodes[idx].nodeName=="DIV") 

            return theLi.childNodes[idx];
    }
    return null;
}
function menu( theLi ) {
    if(theLi) {
        liActual = theLi;
        var theDiv=findSubmenuDiv(theLi);
        if(theDiv!=null) {
            theDiv.style.display="block"
            if (theLi.className == "smOn") theLi.className = "smOnCl";
            else if (theLi.className == "sm") theLi.className = "smCl";
        }
    }
    if(liActual && liActual!=theLi) {
        theDivActual=findSubmenuDiv(liActual);
        if(theDivActual!=null) {
            theDivActual.style.display = "none";
            if (liActual.className == "smOnCl") liActual.className = "smOn";
            else if (liActual.className == "smCl") liActual.className = "sm";		
        }
    }
    liActual=theLi;
}

function initTopSecondMenu(topmenuId) {
    var theMenuDiv=document.getElementById("menuR");
    if(theMenuDiv && theMenuDiv.childNodes) {
        var idxChildNode;
        var bFirst=true;
        for(idxChildNode=0;idxChildNode<theMenuDiv.childNodes.length;idxChildNode++) {
            var theNode=theMenuDiv.childNodes[idxChildNode];
            if(theNode.nodeName=='DIV'){
                if(topmenuId==null){
                    if(bFirst) bFirst=false;
                    else theNode.style.display='none';
                }
                else {
                    if ( theNode.attributes.item("objectId").value == topmenuId ) theNode.style.display='block';
                    else theNode.style.display='none';
                }
            }
        }
    }
}

function findBreadcrumbSpanForMenu(theBreadcrumb,idMenu) {
    if(idMenu==null) return null;
    if ( theBreadcrumb ) {
        var children = theBreadcrumb.childNodes;
        for( var i=0; i<children.length; i++ ) {
            if( children[i].nodeName.charAt(0) != "#" ) {
                if ( children[i].getAttribute("menuid") == idMenu ) return children[i];
            }
        }
    }
    return null;
}

function locateBreadcrumbTopmenuMatch(theBreadcrumb,topmenuId) {
    var theMenuDiv=document.getElementById("menuR");
    if(theMenuDiv && theMenuDiv.childNodes) {
        for(var idxChildNode=0;idxChildNode<theMenuDiv.childNodes.length;idxChildNode++) {
            if(theMenuDiv.childNodes[idxChildNode].nodeName=='DIV'){
                if ( theMenuDiv.childNodes[idxChildNode].attributes.item("objectId").value == topmenuId ){
                    var theULFmNode=findChildNode(theMenuDiv.childNodes[idxChildNode],"UL");
                    for(var idxUlFmLis=0;idxUlFmLis<theULFmNode.childNodes.length;idxUlFmLis++){
                        if(theULFmNode.childNodes[idxUlFmLis].nodeName=="LI"){
                            var theVertSubmenuDiv=findChildNode(theULFmNode.childNodes[idxUlFmLis],"DIV");
                            if(theVertSubmenuDiv!=null) {
                                var theVertSubmenuUl=findChildNode(theVertSubmenuDiv,"UL");
                                if(theVertSubmenuUl!=null) {
                                    for(var idxVertSubmenuLis=0;idxVertSubmenuLis<theVertSubmenuUl.childNodes.length;idxVertSubmenuLis++){
                                        if(theVertSubmenuUl.childNodes[idxVertSubmenuLis].nodeName=="LI" && theVertSubmenuUl.childNodes[idxVertSubmenuLis].id) {
                                            var theBreadcrumbSpan = findBreadcrumbSpanForMenu(theBreadcrumb,theVertSubmenuUl.childNodes[idxVertSubmenuLis].id);
                                            if ( theBreadcrumbSpan != null ) return theBreadcrumbSpan;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}

function getFirstBreadcrumbSpanNode(theBreadcrumb) {
    var children = theBreadcrumb.childNodes;
    for( var i=0; i<children.length; i++ ) {
        if( children[i].nodeName.charAt(0) != "#" ) return children[i];
    }
    return null;
}

function locateBreadcrumbSpan(theBreadcrumb,topmenuId,idCookie) {
    var theFirstBreadcrumbNode = null;
    if ( theBreadcrumb ) {
        if(idCookie!=null) {
            var children = theBreadcrumb.childNodes;
            for( var i=0; i<children.length; i++ ) {
                if( children[i].nodeName.charAt(0) != "#" ) {
                    if ( children[i].getAttribute("menuid") == idCookie && idCookie != null ) return children[i];
                    if ( theFirstBreadcrumbNode == null ) theFirstBreadcrumbNode = children[i];
                }
            }
        }
        else theFirstBreadcrumbNode = locateBreadcrumbTopmenuMatch(theBreadcrumb,topmenuId);
        if ( theFirstBreadcrumbNode == null ) theFirstBreadcrumbNode = getFirstBreadcrumbSpanNode(theBreadcrumb);
    }
    return theFirstBreadcrumbNode;
}

function locateTopmenuLi(liId,topmenuId){
    if(topmenuId==null) return document.getElementById( liId );
    var theMenuDiv=document.getElementById("menuR");
    if(theMenuDiv && theMenuDiv.childNodes) {
        for(var idxChildNode=0;idxChildNode<theMenuDiv.childNodes.length;idxChildNode++) {
            if(theMenuDiv.childNodes[idxChildNode].nodeName=='DIV'){
                if ( theMenuDiv.childNodes[idxChildNode].attributes.item("objectId").value == topmenuId ){
                    var theULFmNode=findChildNode(theMenuDiv.childNodes[idxChildNode],"UL");
                    for(var idxUlFmLis=0;idxUlFmLis<theULFmNode.childNodes.length;idxUlFmLis++){
                        if(theULFmNode.childNodes[idxUlFmLis].nodeName=="LI"){
                            var theVertSubmenuDiv=findChildNode(theULFmNode.childNodes[idxUlFmLis],"DIV");
                            if(theVertSubmenuDiv!=null) {
                                var theVertSubmenuUl=findChildNode(theVertSubmenuDiv,"UL");
                                if(theVertSubmenuUl!=null) {
                                    for(var idxVertSubmenuLis=0;idxVertSubmenuLis<theVertSubmenuUl.childNodes.length;idxVertSubmenuLis++){
                                        if(theVertSubmenuUl.childNodes[idxVertSubmenuLis].nodeName=="LI" && theVertSubmenuUl.childNodes[idxVertSubmenuLis].id==liId) return theVertSubmenuUl.childNodes[idxVertSubmenuLis];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return document.getElementById( liId );
}
var topsecondMenuId=null;
function initTopMenu() {
    var topmenuId=readCookie("topmenuId");
    if(topmenuId!=null){
        var theFirstMenuDiv=document.getElementById("menuF");
        if(theFirstMenuDiv!=null) {
            var theUL=findChildNode(theFirstMenuDiv,"UL");
            if(theUL!=null) {
                for(var idxChild=0;idxChild<theUL.childNodes.length;idxChild++){
                    if(theUL.childNodes[idxChild].nodeName=='LI' && theUL.childNodes[idxChild].attributes.item("objectId").value==topmenuId) {
                        theUL.childNodes[idxChild].className="on";
                    }
                }
            }
        }
    }
    var idCookie = readCookie("secondMenuId");
    var theBreadcrumbDivNode = document.getElementById("breadCrumb");
    var theSpanNode = locateBreadcrumbSpan(theBreadcrumbDivNode,topmenuId,idCookie);
    
    if ( theSpanNode != null ) {
        var nodeMenu;
        var nodeMenuVert;
        var idSubMenuVert;
        var idMenu;
        
        var valor = theSpanNode.getAttribute("menuid");
        var nodeLi = locateTopmenuLi(valor,topmenuId);
        if(nodeLi != null) {
            topsecondMenuId=valor;
            nodeSubMenuVert = nodeLi.parentNode.parentNode.parentNode; // sera el li con onmouseover
            nodeSubMenuVert.className="smOn";

            nodeMenu = nodeLi.parentNode.parentNode.parentNode.parentNode.parentNode; // div id="menu"

            // Nombre del menú vertical
            //var valorNuevo = nodeMenu.firstChild.firstChild.firstChild.firstChild.innerHTML;
            var valorNuevo = findChildNode(nodeSubMenuVert,"A").innerHTML;
            // Nombre del menú superior
            idMenu = nodeMenu.getAttribute( "menu" ); 
            var theMenuF = document.getElementById( "menuF" ).getElementsByTagName( "li" );

            var nombreMenuSup;
            var urlMenuSup;
            for( var z=0; z<theMenuF.length; z++ ) {
                var childMenuF = theMenuF[z];
                if( nodeMenu.getAttribute("objectId") == 
                childMenuF.getAttribute("objectId") ) {
                    var theANode = findChildNode(childMenuF,"A");
                    nombreMenuSup = theANode.getAttribute("title");
                    urlMenuSup = theANode.getAttribute("href");
                    childMenuF.className = "on";
                } else {
                    childMenuF.className = "";
                }
            }
		

            for( var prevSibling = theSpanNode.previousSibling; prevSibling != null; ) {
                if ( prevSibling.nodeName == "SPAN" ) {
                    var deleteNode = prevSibling;
                    prevSibling = prevSibling.previousSibling;
                    if ( deleteNode.nextSibling.nodeName.indexOf( "#" ) == 0 ) deleteNode.parentNode.removeChild( deleteNode.nextSibling );
                    deleteNode.parentNode.removeChild( deleteNode );
                }
                else prevSibling = prevSibling.previousSibling;
            }
            var temp = theBreadcrumbDivNode.innerHTML;
            theBreadcrumbDivNode.innerHTML = "<a href='" + urlMenuSup + "'>" +
            nombreMenuSup + "</a>" + "&nbsp;&gt;&nbsp;" +
            valorNuevo + "&nbsp;&gt;&nbsp;" + temp;

            initTopSecondMenu(nodeMenu.getAttribute("objectId"));
            return;
        }
    }
    initTopSecondMenu(readCookie("topmenuId"));
}

function onclickTopMenu(theA) {
    var objectId=theA.parentNode.attributes.item("objectId").value;
    createCookie("topmenuId",objectId,1);
    eraseCookie("secondMenuId");
    return true;
}

function onclickTopMenuVert(theA) {
    var theLI = findParentNode(theA,"LI");
    if ( theLI != null ) {
        var theThirdMenuId = theLI.id;
        if ( theThirdMenuId != null ) createCookie("secondMenuId",theThirdMenuId,1);
    }
    return true;
}

/* Dado un objeto y un className, comprimimos todos los objetos con dicho class */
function inicio(objeto,clase,posicion) {
    
    var capas = document.getElementsByTagName(objeto);
    var nCapas = capas.length;
    for (i=0;i<nCapas;i++) {	
        if (capas[i].className == clase) {
            capas[i].style.position = posicion;
            capas[i].style.display = "none";
        }
    }
}

/* Función que controla el Menú Lateral izquierdo */
/* Version que se ligaba con div's
function subMenuLat(num)
{
        var sm = eval("document.getElementById('smLat"+num+"')");
        eval("document.getElementById('sml"+num+"').style.position = 'static'");
        switch (sm.className)
        {
                case "mLat on":
                sm.className = "mLat onZip";
                eval("document.getElementById('sml"+num+"').style.display = 'none'");
                break;
                case "mLat onZip":
                sm.className = "mLat on";
                eval("document.getElementById('sml"+num+"').style.display = 'block'");
                break;
                case "mLat":
                sm.className = "mLat noZip";
                eval("document.getElementById('sml"+num+"').style.display = 'block'");
 
                break;
                case "mLat noZip":
                sm.className = "mLat";
                eval("document.getElementById('sml"+num+"').style.display = 'none'");	
                break;
        }
}*/

/* Función que controla el Menú Lateral izquierdo
 * recibe como parametro el nodo HTML donde se produjo el click y aprovecha
 * el arbol HTML DOM para acceder a los sub-elementos
 */
function subMenuLat(theA) {
    var idx=0;
    var theDl=findChildNode(theA.parentNode,"DL");
    if(theDl!=null) {
        theDl.style.position="static";
        switch (theA.className) {
            case "mLat on":
                theA.className = "mLat onZip";
                theDl.style.display='none';
                break;
            case "mLat onZip":
                theA.className = "mLat on";
                theDl.style.display='block';
                break;
            case "mLat":
                theA.className = "mLat noZip";
                theDl.style.display='block';
                break;
            case "mLat noZip":
                theA.className = "mLat";
                theDl.style.display='none';
                break;
        }
    }
}

var theDlSelected=null;

function replaceLeftMenu(theSideDiv, theLINode) {
    var theDlNode = null;
    if ( theLINode != null ) theDlNode = findChildNode(theLINode,"DL");
    if ( theDlNode != null ) {
        var newInnerHtml = "<UL>";
        for(var dlIdx = 0; dlIdx < theDlNode.childNodes.length; dlIdx ++) {
            if(theDlNode.childNodes[dlIdx].nodeName.indexOf("#")!=0) {
                var theANode = findChildNode(theDlNode.childNodes[dlIdx],"A");
                if( theANode != null ) {
                    newInnerHtml+="<LI";
                    if ( theDlNode.childNodes[dlIdx].attributes.item("objectId") ) newInnerHtml += " objectId='" + theDlNode.childNodes[dlIdx].attributes.item("objectId").value + "'";
                    newInnerHtml += "><A href='" + theANode.href + "' title='" + theANode.title + "' class='mLat noSM'>" + theANode.innerHTML + "</A></LI>";
                }
            }
        }
        newInnerHtml+="</UL>";
        theSideDiv.innerHTML=newInnerHtml;
        theDlSelected = findChildNode(theSideDiv,"UL");
    }
    else {
        theSideDiv.style.display="none";
        var theSideImageDiv = document.getElementById( "lateralLeft" );
        if( theSideImageDiv == null ) {
            theSideImageDiv = document.createElement("DIV");
            theSideImageDiv.id="lateralLeft";
            theSideImageDiv.innerHTML='<img alt="'+ document.title + '" src="/fundacion/img/generico/sembrar.JPG" title="'+ document.title + '"/>'
            theSideDiv.parentNode.insertBefore(theSideImageDiv,theSideDiv);
        }
        else theSideImageDiv.style.display="block";
    }
}

function selectLeftFirstMenu(menuObjectId) {
    var theSideDiv = document.getElementById("menuLateral");
    if(theSideDiv) {
        var theULNode=findChildNode(theSideDiv,"UL");
        if(theULNode!=null) {      
            var liidx;			
            // ocultamos todos los DL
            for(liidx=0;liidx<theULNode.childNodes.length;liidx++) {
                var theChildNode = theULNode.childNodes[liidx];
                if ( theChildNode.nodeName == "LI" && topsecondMenuId != null ) {
                    if( theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value == topsecondMenuId ) {
                        replaceLeftMenu(theSideDiv, theChildNode);
                        return;
                    }
                }
                var theDlNode=findChildNode(theChildNode,"DL");	
                if(theDlNode!=null) {
                    theDlNode.style.display='none';	
                }
            }
            for(liidx=0;liidx<theULNode.childNodes.length;liidx++) {
                var theChildNode = theULNode.childNodes[liidx];
                if(theChildNode.nodeName=='LI' && theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value==menuObjectId) {
                    var theANode=findChildNode(theChildNode,"A");
                    var theDlNode=findChildNode(theChildNode,"DL");
                    if(theDlNode!=null) {
                        theDlNode.style.display='block';
                        theDlNode.style.position='static';
                        theANode.className = "mLat on";
                        theDlSelected = theDlNode;
                    }
                    else {
                        theANode.className = "mLat noSMon";
                    }
                    return;
                }
            }
        }
    }
}

function selectLeftSecondMenu(menuObjectId) {
    if(theDlSelected!=null) {		
        var liidx;
        for(liidx=0;liidx<theDlSelected.childNodes.length;liidx++) {
            var theChildNode = theDlSelected.childNodes[liidx];				
            /* if(theChildNode.nodeName=='DT' && theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value==menuObjectId) */
            if(theChildNode.nodeName.indexOf("#") != 0 && theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value==menuObjectId) {
                if ( theChildNode.nodeName=="LI") {
                    var theANode = findChildNode(theChildNode,"A");
                    if( theANode != null ) theANode.className+="on";
                }
                else theChildNode.className+="on";
                return;
            }
        }
    }
}

function selectTopMenu(menuObjectId) {
    var theULNode=document.getElementById("menusuperior")
    if(theULNode!=null) {
        if ( topsecondMenuId != null && theULNode.attributes.item("objectId") && topsecondMenuId == theULNode.attributes.item("objectId").value ) {
            var newInnerHtml = "<UL>";
            for(var liidx=0;liidx<theULNode.childNodes.length;liidx++) {
                var theChildNode = theULNode.childNodes[liidx];
                if(theChildNode.nodeName=='LI') {
                    var theANode = findChildNode(theChildNode,"A");
                    if( theANode != null ) {
                        newInnerHtml+="<LI";
                        if ( theChildNode.attributes.item("objectId") ) newInnerHtml += " objectId='" + theChildNode.attributes.item("objectId").value + "'";
                        newInnerHtml += "><A href='" + theANode.href + "' title='" + theANode.title + "' class='mLat noSM"
                        if ( theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value == menuObjectId ) newInnerHtml += "on";
                        newInnerHtml +="'>" + theANode.innerHTML + "</A></LI>";
                    }
                }
            }
            newInnerHtml+="</UL>";
            var theSideDiv = document.getElementById("menuLateral");
            theSideDiv.innerHTML=newInnerHtml;
            theSideDiv.style.display="block";
            var theImgDiv = document.getElementById("lateralLeft");
            if ( theImgDiv != null ) theImgDiv.style.display="none";
            theULNode.style.display="none";
            return;
        }
        for(var liidx=0;liidx<theULNode.childNodes.length;liidx++) {
            var theChildNode = theULNode.childNodes[liidx];				
            if(theChildNode.nodeName=='LI' && theChildNode.attributes.item("objectId") && theChildNode.attributes.item("objectId").value==menuObjectId) {				
                theChildNode.className="on";
                return;
            }
        }
    }
}

/* Función para las FAQ del lateral derecho */
function menuFAQ(num) {
    var m = eval("document.getElementById('mFAQ"+num+"')");
    eval("document.getElementById('mFAQ"+num+"').style.position = 'static'");
    switch (m.className) {
        case "mFAQ":
            m.className = "mFAQ displayNone";
            eval("document.getElementById('mFAQ"+num+"').style.display = 'block'");
            break;
        case "mFAQ displayNone":
            m.className = "mFAQ";
            eval("document.getElementById('mFAQ"+num+"').style.display = 'none'");	
            break;
    }	
}

/* Abrir Ventana */

function abrirVentana(url,ancho,alto,nombre)
{
	var entrada = document.location.href;
	var entorno = entrada.substring(0,entrada.indexOf("/seguros"))
	
	if(url.indexOf("/buzones/generar")!=-1 && entorno.indexOf("http://")!=-1){	
		url = entorno.replace("http://","https://") + url.substring(url.indexOf("/buzones"));
	}
	
	if(url.indexOf("/tarifMutua5")!=-1 && entorno.indexOf("http://")!=-1){	
		url = entorno.replace("http://","https://") + url.substring(url.indexOf("/tarifMutua5"));
	}
	
	if(nombre)
		eval("window.open(url, '"+nombre+"', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes, width="+ancho+", height="+alto+"')"); 
	else
		eval("window.open(url, 'ventana', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes, width="+ancho+", height="+alto+"')"); 
}

/*function abrirVentana(url,ancho,alto) {
    eval("window.open(url, 'ventana', 'toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes, width="+ancho+", height="+alto+"')"); 
}*/

function irCombo() {
    alert("Enviando selección...")
}

/* Activar capas de los servicios telefónicos */
var srvActiv = 0;
function srv(num) {
    if (srvActiv != 0) {
        eval("document.getElementById('ser"+srvActiv+"').style.display = 'none'");
        if (srvActiv%2 == 0) {
            eval("document.getElementById('srv"+srvActiv+"').className = 'par'");	
        }
        else {
            eval("document.getElementById('srv"+srvActiv+"').className = ''");
        }
        
    }	
    eval("document.getElementById('ser"+num+"').style.display = 'block'");
    eval("document.getElementById('srv"+num+"').className = 'activo'");
    srvActiv = num;
}

/* Colocamos los linsk de zoom según el navegador. */
// La última línea (window.onresize=colocarZoom;) debe descomentarse en caso que se elija esta opción.
function colocarZoom() {
    var winW = 630, winH = 460;
    
    if (parseInt(navigator.appVersion)>3) {
        if (navigator.appName=="Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft")!=-1) {
            winW = document.body.offsetWidth;
            winH = document.body.offsetHeight;
        }
    }
    var ancho = document.body.clientWidth;
    //var anchoP = document.getElementById("principal").clientWidth;
    if (ancho > 920) {
        document.getElementById("tipo").className = "sup";			
    }
    else {
        document.getElementById("tipo").className = "";			
    }
}

//window.onresize=colocarZoom;
function mostrar_numeros_revista(anyo) {
    // ocultamos todos
    for (i = 0; i < anyo.length; i++) {		
        anyo_a_ocultar = anyo.options[i].value;
        document.getElementById(anyo_a_ocultar).style.display = 
                (anyo.value == anyo_a_ocultar) ? "block" : "none";
    }
}
//  mostramos TODOS los contenidos del AÑO seleccionado
function mostrar_numeros_del_anyo(anyo,tematica) {
    var anyo_seleccionado     = anyo.value;
    var tematica_seleccionada = 0;
    if ( tematica && tematica.value ) tematica_seleccionada = tematica.value;
    // ocultamos todos
    for (i = 0; i < anyo.length; i++) {		
        anyo_a_ocultar = anyo.options[i].value;
        document.getElementById(anyo_a_ocultar).style.display = "none";
    }
    //mostramos los contenidos del año seleccionado
    document.getElementById(anyo_seleccionado).style.display = "block";
    if (anyo_seleccionado != 0){	
        if ( tematica ) tematica.disabled = false;
        var theULNode = document.getElementById(anyo_seleccionado);	
        
        //alert(theULNode.innerHTML);
        if(theULNode != null) { 
            // ocultamos todos los LI
            for(var liidx=0;liidx<theULNode.childNodes.length;liidx++) {
                var theLINode = theULNode.childNodes[liidx];				
                if ( theLINode.nodeName=="LI" ) {
                    if (tematica_seleccionada != 0){
                        //alert("theLINode:\n" + theLINode.innerHTML);
                        if( theLINode!=null && theLINode.attributes.item("tematica").value != tematica_seleccionada && tematica_seleccionada != 0)  {
                            theLINode.style.display='none';	
                        }
                        else theLINode.style.display='block';
                    }
                    else theLINode.style.display='block';
                }				
            }
        }
    }
    else if ( tematica ) tematica.disabled = true;
}

function mostrar_institutos(instituto,becapremio) {
    
    instituto_selected  = instituto.value;
    becapremio_selected = becapremio.value;
    
    var theULNode = document.getElementById("searchrc");
    
    if ( instituto_selected != '' ) {
        array_instituto = instituto_selected.split(",");
        for(var liidx=0; liidx<theULNode.childNodes.length; liidx++) {
            var theLINode = theULNode.childNodes[liidx];
            if ( theLINode.nodeName=="LI" ) {
                for (var i=0; i < array_instituto.length; i++){
                    if( theLINode != null && theLINode.attributes.item("a_category").value == array_instituto[i])  {                            							
                        theLINode.style.display='block';
                        break;
                    }
                    else {
                        theLINode.style.display='none';	
                    }
                }				
            }
        }
        theULNode.style.display='block';
    }
    else theULNode.style.display = 'none';
}

// CURSOS
function mostrar_combo_level_2(nivel_1) {
    
    if(nivel_1.value == "*"){
        oculta_combo_level_2();
        mostrar_lista_completa();
    }	
    else if(nivel_1.value == ""){
        oculta_combo_level_2();
        oculta_lista();
    }			
    else{	// mostrar combo nivel 2 correspondiente
        oculta_lista();
        for (var i = 0; i < document.formacionBuscador.elements.length; i++) {
            if(document.formacionBuscador.elements[i].type == 'select-one' && document.formacionBuscador.elements[i].id == "level2"){
                if(document.formacionBuscador.elements[i].attributes.item("applyfor").value == nivel_1.value){
                    document.formacionBuscador.elements[i].style.display="block";
                }
                else{
                    document.formacionBuscador.elements[i].style.display="none";
                }
            }	
        }
    }
    
}

function mostrar_lista_cursos(nivel_2) {
    
    if(nivel_2.value == "*"){		// mostrar todas las listas de la categoria (a_category)	
        var theULNode = document.getElementById("searchrc");		
        for(var liidx=0; liidx<theULNode.childNodes.length; liidx++) {
            var theLINode = theULNode.childNodes[liidx];
            if ( theLINode.nodeName=="LI" ) {			
                if( theLINode != null && theLINode.attributes.item("a_category").value == document.getElementById("level1").value){    
                    theLINode.style.display='block';				
                }
                else {
                    theLINode.style.display='none';	
                }			
            }
        }
        theULNode.style.display='block';		
    }	
    else if(nivel_2.value == ""){
        oculta_lista();
    }		
    else{	// mostrar todas las listas del y parent_id
        var theULNode = document.getElementById("searchrc");		
        for(var liidx=0; liidx<theULNode.childNodes.length; liidx++) {
            var theLINode = theULNode.childNodes[liidx];
            if ( theLINode.nodeName=="LI" ) {			
                if( theLINode != null && theLINode.attributes.item("parent_id").value == nivel_2.value)  {    
                    theLINode.style.display='block';				
                }
                else {
                    theLINode.style.display='none';	
                }			
            }
        }
        theULNode.style.display='block';
    }
}

function oculta_combo_level_2(){
    for (var i = 0; i < document.formacionBuscador.elements.length; i++) {
        if(document.formacionBuscador.elements[i].type == 'select-one' && document.formacionBuscador.elements[i].id == "level2"){
            document.formacionBuscador.elements[i].style.display="none";
        }			
    }
}

function oculta_lista(){
    var theULNode = document.getElementById("searchrc");
    for(var liidx=0; liidx<theULNode.childNodes.length; liidx++) {
        var theLINode = theULNode.childNodes[liidx];
        if ( theLINode.nodeName=="LI" ) {			
            theLINode.style.display='none';							
        }
    }
    theULNode.style.display='none';
}

function mostrar_lista_completa(){
    var theULNode = document.getElementById("searchrc");		
    for(var liidx=0; liidx<theULNode.childNodes.length; liidx++) {
        var theLINode = theULNode.childNodes[liidx];
        if ( theLINode.nodeName=="LI" ) {			
            theLINode.style.display='block';				
        }	        
    }		
    theULNode.style.display='block';
}

function showMesAgenda(form){
    var mes=form.mes.value;
    var documentDivs=document.getElementsByTagName("DIV");
    if(documentDivs!=null && documentDivs.length>0) {
        for(var idx=0;idx<documentDivs.length;idx++) {
            if(documentDivs[idx].id=="eventos") {
                documentDivs[idx].style.display = (documentDivs[idx].attributes.item("mes").value==mes) ? "block" : "none";
            }
        }
    }
}

function showFirstLetra() {
    var theLetrasUl=document.getElementById("abc");
    for(var idx=0; idx<theLetrasUl.childNodes.length; idx++) {
        if(theLetrasUl.childNodes[idx].nodeName=="LI"){
            var theLINode=theLetrasUl.childNodes[idx];
            for(var idxli=0; idxli<theLINode.childNodes.length; idxli ++ ) {
                if( theLINode.childNodes[idxli].nodeName=="A" ) {
                    showLetraIndice(theLINode.childNodes[idxli]);
                    return;
                }
            }
        }
    }
}

function showLetraIndice(theA) {
    var letra=theA.attributes.item("letra").value;
    var documentDivs=document.getElementsByTagName("DIV");
    if(documentDivs && documentDivs.length) {
        for( var idx=0; idx < documentDivs.length; idx++ ) {
            if ( documentDivs[idx].id=="secABC" ) {
                documentDivs[idx].style.display = 
                        ((documentDivs[idx].attributes.item("letra") && documentDivs[idx].attributes.item("letra").value==letra)
                                || (documentDivs[idx].attributes.letra && documentDivs[idx].attributes.letra.value)==letra) ? 
                        "block" : "none";
            }
        }   
    }
}

function hiddenLis()
{
	var liElements = new Array();
	liElements = document.getElementById("listaImgHE").getElementsByTagName("li");

	if (liElements.length > 10)
	{
		for (var i = 10; i < liElements.length; i++)
		{
			liElements[i].style.display = "none";
			
			if (i > 10 && i % 10 == 0 )
			{
				document.getElementById("pageText" + i / 10).style.display = "none";
			}
		}
		
		if (liElements.length % 10 > 0)
		{
			document.getElementById("pageText" + (Math.floor(liElements.length / 10 ) + 1)).style.display = "none";
		}
		
		document.getElementById("pageLink1").style.display = "none";
	}
	else
	{
		document.getElementById("nextButton").style.display = "none";
	} 
	
	document.getElementById("previousButton").style.display = "none";
}

function showPreviowsLis()
{
	var firtsLiPosition = 0;
	var lastLiPosition = 0;
	var liElements = new Array();
	liElements = document.getElementById("listaImgHE").getElementsByTagName("li");
	
	while (liElements[firtsLiPosition].style.display == "none")
	{
		firtsLiPosition++;
	}
	
	for (var i = firtsLiPosition - 1; i >= firtsLiPosition - 10; i--)
	{
		liElements[i].style.display = "";
	}
	
	if ( firtsLiPosition + 10 < liElements.length - 1)
	{
		lastLiPosition = firtsLiPosition + 10;
	}
	else
	{
		lastLiPosition = liElements.length - 1;
	}
	
	for (var i = firtsLiPosition; i <= lastLiPosition; i++)
	{
		liElements[i].style.display = "none";
	}	

	if (document.getElementById("nextButton").style.display == "none")
	{
		document.getElementById("nextButton").style.display = "";
	}
	
	if (firtsLiPosition == 10)
	{
		document.getElementById("previousButton").style.display = "none";
	}
	
	document.getElementById("pageLink" + (firtsLiPosition / 10 + 1)).style.display = "";
	document.getElementById("pageText" + (firtsLiPosition / 10 + 1)).style.display = "none";
	document.getElementById("pageLink" + (firtsLiPosition / 10)).style.display = "none";
	document.getElementById("pageText" + (firtsLiPosition / 10)).style.display = "";
}

function showNextLis()
{
	var firtsLiPosition = 0;
	var lastLiPosition = 0;
	var liElements = new Array();
	liElements = document.getElementById("listaImgHE").getElementsByTagName("li");
	
	while (liElements[firtsLiPosition].style.display == "none")
	{
		firtsLiPosition++;
	}
	
	for (var i = firtsLiPosition; i < firtsLiPosition + 10; i++)
	{
	
		liElements[i].style.display = "none";
	}
	
	if ( firtsLiPosition + 19 < liElements.length -1)
	{
		lastLiPosition = firtsLiPosition + 19;
	}
	else
	{
		lastLiPosition = liElements.length - 1;
		document.getElementById("nextButton").style.display = "none";
	}
	
	for (var i = firtsLiPosition + 10; i <= lastLiPosition; i++)
	{
		liElements[i].style.display = "";
	}	

	if (document.getElementById("previousButton").style.display == "none")
	{
		document.getElementById("previousButton").style.display = "";
	}
	
	document.getElementById("pageLink" + (firtsLiPosition / 10 + 1)).style.display = "";
	document.getElementById("pageText" + (firtsLiPosition / 10 + 1)).style.display = "none";
	document.getElementById("pageLink" + (firtsLiPosition / 10 + 2)).style.display = "none";
	document.getElementById("pageText" + (firtsLiPosition / 10 + 2)).style.display = "";
}

function showPageNumber(page)
{
	var firtsLiToHidden = 0;
	var firtsLiPosition = (page - 1) * 10;
	var lastLiPosition;
	var lastLiToHidden;
	var liElements = new Array();
	liElements = document.getElementById("listaImgHE").getElementsByTagName("li");


	while (liElements[firtsLiToHidden].style.display == "none")
	{
		firtsLiToHidden++;
	}	
	
	if (firtsLiToHidden + 10 < liElements.length)
	{
		lastLiToHidden = firtsLiToHidden + 10;
	}
	else
	{
		lastLiToHidden = liElements.length - 1;
	}
	
	for (var i = firtsLiToHidden; i <= lastLiToHidden; i++)
	{
		liElements[i].style.display = "none";
	}
	
	if (firtsLiPosition + 10 < liElements.length)
	{
		lastLiPosition = firtsLiPosition + 10;
	}
	
	if (firtsLiPosition == 0)
	{
		document.getElementById("previousButton").style.display = "none";
	}
	else if(document.getElementById("previousButton").style.display == "none")
	{
		document.getElementById("previousButton").style.display = "";
	}
	
	if (firtsLiPosition + 10 < liElements.length)
	{
		lastLiPosition = firtsLiPosition + 9;
		
		if (document.getElementById("nextButton").style.display == "none")
		{
			document.getElementById("nextButton").style.display = "";
		}
	}
	else
	{
		lastLiPosition = liElements.length - 1;
		document.getElementById("nextButton").style.display = "none";
	}
	
	for (var i = firtsLiPosition; i <= lastLiPosition; i++)
	{
		liElements[i].style.display = "";
	}	
	
	document.getElementById("pageLink" + (firtsLiToHidden / 10 + 1)).style.display = "";
	document.getElementById("pageText" + (firtsLiToHidden / 10 + 1)).style.display = "none";
	document.getElementById("pageLink" + page).style.display = "none";
	document.getElementById("pageText" + page).style.display = "";
}

