var ultimo_estereotipo='';
var marca_activada ='';
var estilo_activo='home';
var lang='es';
var logotipos_pie;
var seguridad;
function 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=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];}}
}
//===================== funciones trim que limpian espacios en blanco y saltos de linea ==============
function Trim(sString){
    //----------------- left Trim ---------------------
    while (sString.substring(0,1) == ' ' || sString.substring(0,1) == '\n' ||  sString.substring(0,1) == '\t'){
        sString = sString.substring(1, sString.length);
    }
    //----------------- right Trim ---------------------
    while (sString.substring(sString.length-1, sString.length) == ' ' || sString.substring(sString.length-1, sString.length) == '\n' || sString.substring(sString.length-1, sString.length) == '\t'){
        sString = sString.substring(0,sString.length-1);
    }
return sString;
}
//===================== funcion para sustituir innerHTML haciendo el agregado con appenchild de DOM ==============
function ponHTML(id,miHTML){
    var nuevoDiv = document.createElement("div");
    var contenido = document.getElementById(id);
    contenido.innerHTML="";
    nuevoDiv.innerHTML= miHTML;
    contenido.appendChild(nuevoDiv);
}
//================= hace el fade en el contenedor principal un color a otro ================
function cambia_color(color_final){
    color_inicial= Fat.get_bgcolor('mi_seccion')
    if (!color_inicial){color_inicial=='#FFFFFF'}
    Fat.fade_element('contenedor_contenido', 100, 800, color_inicial, color_final)
    Fat.fade_element('contenedor_menu', 100, 800, color_inicial, color_final)
    Fat.fade_element('contenedor_marcas', 100, 800, color_inicial, color_final)
    Fat.fade_element('mi_seccion', 100, 800, color_inicial, color_final)
}
//================= busca y devuelve el primer nodo de texto en un elemento dado ==============
function buscaTexto($id,$objeto){
    if($id){var $objeto = document.getElementById($id);}
    var $hijos= $objeto.childNodes;
    for (var i=0; i<$hijos.length;i++) {
        if($hijos[i].nodeName == '#text'){
            $texto= $hijos[i].nodeValue;
        }
        if ($hijos[i].childNodes.length > 0){
            buscaTexto(null,$hijos[i])
        }
        //typewriter($hijos[i],$texto);
        return $texto;
    }
    
}
//================= enseña/oculta el bloque del menu y titulo de la seccion en que te encuentras ================
function mostrar_navegacion(opcion,titulo,url){
    
    var mi_seccion = document.getElementById('mi_seccion');
    var contenedor_menu = document.getElementById('contenedor_menu');
    var contenedor_contenido = document.getElementById('contenedor_contenido');
    var contenido = document.getElementById('contenido');
    var contenedor_marcas = document.getElementById('contenedor_marcas');
    //------------- si no existe ninguna opcion, oculta los bloques
    if(!opcion){
        mi_seccion.style.display='none';
        contenedor_menu.style.display='none';
        contenedor_contenido.style.backgroundImage = 'url(/img/00_home/hall.jpg)';
        contenedor_marcas.style.backgroundImage = 'url(/img/00_home/hall.jpg)';
        contenedor_marcas.style.backgroundPosition = '0px 43px';
        //contenedor_contenido.style.backgroundColor='transparent';
        //contenedor_marcas.style.backgroundColor='transparent';
    //------------- si existe la opcion muestra los bloques y escribe el titulo
    }else{
        contenido.innerHTML='';
        mi_seccion.style.display='block';
        contenedor_menu.style.display='block';
        contenedor_contenido.style.backgroundImage = 'none';
        contenedor_marcas.style.backgroundImage = 'none';

        //Jose 10/01/2007 Añadimos un espacio blanco. Si no lo hacemos, tiene problemas con los &
        mi_seccion.innerHTML = titulo+' ';
        mi_seccion.onclick= function(){
            CargarContenido("contenido",url,null,null);
        }
        //mi_seccion.innerHTML='<a>'
        //var texto = mi_seccion.getElementsByTagName('a');
        //texto[0].style.backgroundColor='transparent';
        
    }
}

//================== pinta de blanco el fondo de los enlaces ================
function desmarca_opcion(){
    //---------- botonera es el contenedor de las opciones
    var botonera = document.getElementById('botonera');
    //---------- opciones es el conjunto de opciones dentro de la botonera
    var enlaces = botonera.getElementsByTagName('a');
    //-------- recorro la botonera para desmarcar todas las opciones 
    for (var i = 0; i < enlaces.length-1; i++){
        //opciones[i].style.backgroundColor='#FFFFFF';
        //if (enlaces[i].style.backgroundColor == '#eeeeee') 
        enlaces[i].style.backgroundColor = '#FFFFFF';
    }
    //var mi_seccion = document.getElementById('mi_seccion');
    //enlaces = mi_seccion.getElementsByTagName('a');
    //enlaces[0].style.backgroundColor = 'transparent';
}

//================= implementa la funcion getElementsByClass ================
function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}
//================ define el comportamiento del menu ================
function menu_2(){  
    var  menu = document.getElementById('contenedor_menu');
    //--------------------------------asigno comportamiento a los enlaces ----------------
    var enlaces = menu.getElementsByTagName('a');
    for (var i = 0; i < enlaces.length; i++){
            var url = enlaces[i].href;
            if (enlaces[i].target!='_blank'){
                enlaces[i].href = 'javascript:CargarContenido("contenido","'+url+'",null,null)';
            }else{return;}
    }
    var opcion_nivel1 = getElementsByClass('opcion_nivel1');
    var opcion_nivel2 = getElementsByClass('opcion_nivel2');
    var opcion_nivel3 = getElementsByClass('opcion_nivel3');
    var nivel2 = getElementsByClass('nivel2');
    for (var i = 0; i < nivel2.length; i++){
        //alert(nivel2[i].childNodes.length);
        nivel2[i].parentNode.hijo = nivel2[i];
        nivel2[i].parentNode.altura = nivel2[i].offsetHeight;
        nivel2[i].onclick =function(evt){
            //------- hago sonar la musica--------------------
            doSubseccion();
            //------- paro el burbujeo de eventos -----------------
            var e = (window.event) ? window.event : evt;
            e.cancelBubble = true; 
        }
        //--------cuando haces click en el nodo ----------
        nivel2[i].parentNode.onclick = function (){
            //if(this.offsetHeight > 23) return;
            var flecha;
            var despliegue;
            var enlace_nivel1 = this.getElementsByTagName('a');
            var subnivel2_selected = getElementsByClass('opcion_nivel2_selected');
            var subnivel3_selected = getElementsByClass('opcion_nivel3_selected');
            //-----------------pone flecha mirando hacia arriba ----------------------
            enlace_nivel1[0].style.backgroundPosition='225px 4px';
            enlace_nivel1[0].style.backgroundRepeat = 'no-repeat';
            switch (getActiveStyleSheet()){
                case 'compania':{flecha='/img/flechas/flecha_compania_up.gif';break;}
                case 'clientes':{flecha='/img/flechas/flecha_clientes_up.gif';break;}
                case 'marcas':{flecha='/img/flechas/flecha_marcas_up.gif';break;}
                case 'personas':{flecha='/img/flechas/flecha_personas_up.gif';break;}
                default:{flecha='/img/flechas/flecha_compania_up.gif';break;}
            }
            enlace_nivel1[0].style.backgroundImage= 'url('+flecha+')';
            //--------------- limpiamos subnivel2 y subnivel3 --------------------------
            if (subnivel2_selected.length>0) {
                var mi_clase=subnivel2_selected[0].className;
                var espacio_sup = mi_clase.indexOf('espacio_sup');
                var espacio_inf = mi_clase.indexOf('espacio_inf');
                var linea_sup = mi_clase.indexOf('confiletesuperior');

                subnivel2_selected[0].className ='opcion_nivel2';
                if(espacio_sup>0){subnivel2_selected[0].className ='opcion_nivel2 espacio_sup';}
                if(espacio_inf>0){subnivel2_selected[0].className = 'opcion_nivel2 espacio_inf';}
                if(linea_sup > 0){
                    subnivel2_selected[0].className += ' confiletesuperior';
                }
            }
            if (subnivel3_selected.length>0) {
                var mi_clase=subnivel3_selected[0].className;
                subnivel3_selected[0].className ='opcion_nivel3';
            }
            //--------------- animacion de despliegue del menu ------------------------
            despliegue = new Accelimation(this.hijo.style, "height", this.altura, 400, 0.3);
            despliegue.start();
            despliegue.onend = new Function('null');
        }
        //--------cuando haces onmouseOver en el nodo ----------
        nivel2[i].parentNode.onmouseover = function (){
            //return;
            var flecha;
            var enlace_nivel1 = this.getElementsByTagName('a');
            enlace_nivel1[0].style.backgroundRepeat='no-repeat';
            if(enlace_nivel1[0].style.backgroundImage)return;
            switch (getActiveStyleSheet()){
                case 'compania':{flecha='/img/flechas/flecha_compania.gif';break;}
                case 'clientes':{flecha='/img/flechas/flecha_clientes.gif';break;}
                case 'marcas':{flecha='/img/flechas/flecha_marcas.gif';break;}
                case 'personas':{flecha='/img/flechas/flecha_personas.gif';break;}
                default:{flecha='/img/flechas/flecha_compania.gif';break;}
            }
            enlace_nivel1[0].style.backgroundImage= 'url('+flecha+')';
            enlace_nivel1[0].style.backgroundPosition='225px 4px';
        }
        //--------cuando haces onmouseOut en el nodo ----------
        nivel2[i].parentNode.onmouseout = function (){
            return;
            var enlace_nivel1 = this.getElementsByTagName('a');
            enlace_nivel1[0].style.backgroundImage= 'none'; 
        }
        //-------------------- si he llegado a la pagina de forma normal ----------
        if(nivel2[i].id != marca_activada || !nivel2[i].id){
            nivel2[i].style.height='0px';
        //-------------------- si he llegado a la pagina por un logo del pie ----------
        }else{
            //---------- dejo la opcion sin plegar y le cambio la clase al enlace ----
            var enlace_temporal = nivel2[i].parentNode.getElementsByTagName('a');
            enlace_temporal[0].className = 'opcion_over';
            marca_activada='';
        }
    }
    for (var i = 0; i < opcion_nivel1.length; i++){
        //-------------------obtengo el enlace de cada opcion ---------------------
        var enlace = opcion_nivel1[i].getElementsByTagName('a');
        enlace[0].onclick = function(){
        	
            //----------------------- pliego todo lo desplegado --------------------
            plegar();
            //----------------------- desmarco todas las opciones ---------------
            limpiar();
            //----------------------- pongo la musica --------------------------
            doSubseccion();
            //----------------------- marco la opcion correspondiente -----------
            this.className = 'opcion_over';            
        }
    }
    //------------- acciones para cuando se clickee el subnivel2 ------------
    for (var i = 0; i < opcion_nivel2.length; i++){
        opcion_nivel2[i].onclick = function(){
            //------------------- limpia todo el nivel 3 -----------------------
            for (var j = 0; j < opcion_nivel2.length; j++){
                var mi_clase=opcion_nivel2[j].className;
                if(mi_clase.indexOf('opcion_nivel2_selected')>=0){
                    var espacio_sup = mi_clase.indexOf('espacio_sup');
                    var espacio_inf = mi_clase.indexOf('espacio_inf');
                    var linea_sup = mi_clase.indexOf('confiletesuperior');
                    opcion_nivel2[j].className = 'opcion_nivel2';
                    if(espacio_sup>0){opcion_nivel2[j].className = opcion_nivel2[j].className+' espacio_sup';}
                    if(espacio_inf>0){opcion_nivel2[j].className = opcion_nivel2[j].className+' espacio_inf';}
                    if(linea_sup > 0){
                        opcion_nivel2[j].className += ' confiletesuperior';
                    }                   
                }
            }
            //------------------- limpia todo el nivel 3 -----------------------
            for (var j = 0; j < opcion_nivel3.length; j++){
                var mi_clase=opcion_nivel3[j].className;
                if(mi_clase.indexOf('opcion_nivel3_selected')>=0){
                    var espacio_sup = mi_clase.indexOf('espacio_sup');
                    var espacio_inf = mi_clase.indexOf('espacio_inf');
                    opcion_nivel3[j].className = 'opcion_nivel3';
                    if(espacio_sup>0){opcion_nivel3[j].className = opcion_nivel3[j].className+' espacio_sup';}
                    if(espacio_inf>0){opcion_nivel3[j].className = opcion_nivel3[j].className+' espacio_inf';}
                }
            }
            var mi_clase=this.className;
            var espacio_sup = mi_clase.indexOf('espacio_sup');
            var espacio_inf = mi_clase.indexOf('espacio_inf');  
            var linea_sup = mi_clase.indexOf('confiletesuperior');
            this.className = 'opcion_nivel2_selected';
            if(espacio_sup>0){this.className = this.className+' espacio_sup';}
            if(espacio_inf>0){this.className = this.className+' espacio_inf';}
            if(linea_sup > 0){
                this.className += ' confiletesuperior';
            }               
        }
    }
    //------------- acciones para cuando se clickee el subnivel3 ------------
    for (var i = 0; i < opcion_nivel3.length; i++){
        opcion_nivel3[i].onclick = function(){
            //------------------- limpia todo el nivel 2 -----------------------
            for (var j = 0; j < opcion_nivel2.length; j++){
                var mi_clase=opcion_nivel2[j].className;
                if(mi_clase.indexOf('opcion_nivel2_selected')>=0){
                    var espacio_sup = mi_clase.indexOf('espacio_sup');
                    var espacio_inf = mi_clase.indexOf('espacio_inf');
                    if (opcion_nivel2[j].className != 'opcion_nivel2') opcion_nivel2[j].className = 'opcion_nivel2';
                    if(espacio_sup>0){opcion_nivel2[j].className = opcion_nivel2[j].className+' espacio_sup';}
                    if(espacio_inf>0){opcion_nivel2[j].className = opcion_nivel2[j].className+' espacio_inf';}
                }
            }
            //------------------- limpia todo el nivel 3 -----------------------
            for (var j = 0; j < opcion_nivel3.length; j++){
                var mi_clase=opcion_nivel3[j].className;
                if(mi_clase.indexOf('opcion_nivel3_selected')>=0){
                    var espacio_sup = mi_clase.indexOf('espacio_sup');
                    var espacio_inf = mi_clase.indexOf('espacio_inf');
                    if(opcion_nivel3[j].className != 'opcion_nivel3') opcion_nivel3[j].className = 'opcion_nivel3';
                    if(espacio_sup>0){opcion_nivel3[j].className = opcion_nivel3[j].className+' espacio_sup';}
                    if(espacio_inf>0){opcion_nivel3[j].className = opcion_nivel3[j].className+' espacio_inf';}
                }
            }
            
            var mi_clase=this.className;
            var espacio_sup = mi_clase.indexOf('espacio_sup');
            var espacio_inf = mi_clase.indexOf('espacio_inf');  
            this.className = 'opcion_nivel3_selected';
            if(espacio_sup>0){this.className = this.className+' espacio_sup';}
            if(espacio_inf>0){this.className = this.className+' espacio_inf';}
        }
    }
    efecto_menu();
}
function plegar(){
    var nivel2 = getElementsByClass('nivel2');
    for (var i = 0; i < nivel2.length; i++){
        if (nivel2[i].style.height != '0px'){
            var pliegue;
            pliegue = new Accelimation(nivel2[i].style, "height", 0, 200, 0.3);
            pliegue.start();
            pliegue.onend = new Function('null');
        }
    }
}
function limpiar(){;
    var nivel1 = getElementsByClass('nivel1');
    var enlaces = nivel1[0].getElementsByTagName('a');
    for (var i = 0; i < enlaces.length; i++){
        if(enlaces[i].className == 'opcion_over') enlaces[i].className='';
        enlaces[i].style.backgroundImage='';
    }
}
//================ hace crecer/decrecer las capas con easing ================
var funcionando=false;
function crecer(id,w,h,velocidad,funcion){
    var elemento = document.getElementById(id);
    var margen_error = 2;
    funcionando=true;
    var ws=(elemento.offsetWidth <w)?1:-1
    var hs=(elemento.offsetHeight <h)?1:-1
    wI=Math.ceil(Math.abs(w-elemento.offsetWidth )/(11-velocidad))
    hI=Math.ceil(Math.abs(h-elemento.offsetHeight )/(11-velocidad))
    elemento.style.width = elemento.offsetWidth +(ws*wI) + "px"
    elemento.style.height  = elemento.offsetHeight +(hs*hI) + "px"
    if(Math.abs(elemento.offsetWidth-w)<margen_error && Math.abs(elemento.offsetHeight-h)<margen_error){
        elemento.style.width=w;
        elemento.style.height=h;
        return
    }
    if(elemento.offsetWidth  != w || elemento.offsetHeight != h){
        setTimeout("crecer(\""+ id +"\","+ w +","+ h +","+ velocidad +","+funcion+")",50)
    } else {
        eval(funcion);
        funcionando=false;
    }
}
//================ añade un estilo al documento =========================
function addCss(url){
    var obj = document.createElement('link');
    obj.rel = 'stylesheet';
    obj.type = 'text/css';
    obj.media = 'screen,projection';
    obj.href = url;
    document.getElementsByTagName('head')[0].appendChild(obj);
}
//============== funcion parrafos desplegables =======================
function parrafos_des(){
    var parrafos = getElementsByClass('desplegable');
    var flecha_up, flecha_down;
    var animacion;
    //------------- selecciono las imagenes que iran en los parrafos ----------------------------
    switch (getActiveStyleSheet()){
        case 'compania':{flecha_up='/img/flechas/flecha_compania_up.gif';flecha_down='/img/flechas/flecha_compania_down.gif';break;}
        case 'clientes':{flecha_up='/img/flechas/flecha_clientes_up.gif';flecha_down='/img/flechas/flecha_clientes_down.gif';break;}
        case 'marcas':{flecha_up='/img/flechas/flecha_marcas_up.gif';flecha_down='/img/flechas/flecha_marcas_down.gif';break;}
        case 'personas':{flecha_up='/img/flechas/flecha_personas_up.gif';flecha_down='/img/flechas/flecha_personas_down.gif';break;}
        default:{flecha_up='/img/flechas/flecha_compania_up.gif';flecha_down='/img/flechas/flecha_compania_down.gif';break;}
    }
    for (var i = 0; i < parrafos.length; i++){
        if(parrafos[i].plegado != undefined) return;
        var cabeceras = parrafos[i].getElementsByTagName('h3');
        var cabecera =cabeceras[0];
        parrafos[i].altura = parrafos[i].offsetHeight;
        parrafos[i].altura_titular = cabecera.offsetHeight;
        parrafos[i].colorfondo = parrafos[i].style.backgroundColor;
        parrafos[i].style.backgroundColor='transparent';
        parrafos[i].style.height = cabecera.offsetHeight+'px';
        parrafos[i].style.overflow ='hidden';
        parrafos[i].style.backgroundImage = 'url('+flecha_down+')';
        parrafos[i].plegado = true;
        
        parrafos[i].onclick = function (){
            //------------- si es un parrafo que esta plegado ---------------
            if(this.plegado == true){
                //------------ cierro todos los parrafos ------------------
                for (var i = 0; i < parrafos.length; i++){
                    parrafos[i].style.height = parrafos[i].altura_titular+'px';
                    parrafos[i].plegado = true;
                    parrafos[i].style.backgroundColor='transparent';
                    parrafos[i].style.backgroundImage = 'url('+flecha_down+')';
                }
                //------------ depliego el parrafo correspondiente ------------------------
                this.style.backgroundColor=this.colorfondo;
                animacion = new Accelimation(this.style, "height", this.altura, 200, 0.3);
                animacion.start();
                animacion.onend = new Function('update_scroll("cuerpo","v");');
                this.plegado = false;
                this.style.backgroundImage = 'url('+flecha_up+')';
                //------------ si el parrafo esta deplegado ----------------
            }else{
                this.style.backgroundColor='transparent';
                
                animacion = new Accelimation(this.style, "height", this.altura_titular, 200, 0.3);
                animacion.start();
                animacion.onend = new Function('update_scroll("cuerpo","v");');
                
                this.style.height = '1.4em';
                this.plegado = true;
                this.style.backgroundImage = 'url('+flecha_down+')';
            }
            update_scroll("cuerpo","v");
        }
    }
}
//================= funcion popups internos =======================
function mi_popup(){
    //----------- obtengo todos los popups y los recorro ----------------
    var pop_ups = getElementsByClass('mi_popup');
    for (var i = 0; i < pop_ups.length; i++){
        //----------- obtengo el cuerpo donde esta todo el texto ----------------
        var cuerpo = document.getElementById('texto');
        var texto_cuerpo = cuerpo.innerHTML;
        //----------- obtengo el texto que corresponde al enlace ----------------
        var enlace = getElementsByClass('texto_enlace_popup',pop_ups[i]);
        var texto_enlace = enlace[0].innerHTML;
        //alert('longitud de la cadena antes: '+texto_enlace.length+' y despues: '+Trim(texto_enlace).length);
        texto_enlace = Trim(texto_enlace);
        //----------- encuentro la posicion del texto en el cuerpo ----------------
        var posicion_enlace = texto_cuerpo.indexOf(texto_enlace);
        //----------- obtengo el id del popup en el que estoy realicando las operaciones -----------
        var id_popup=pop_ups[i].id
        //----------- añado la etiqueta <a> en el cuerpo del texto al pedazo de texto correspondiente ------
        texto_cuerpo=inserta_cadena('</a>',texto_cuerpo,posicion_enlace+texto_enlace.length);
        texto_cuerpo=inserta_cadena('<a href="#" class="enlace_popup" id="enlace_'+ id_popup+'">',texto_cuerpo,posicion_enlace);
        //alert(texto_cuerpo);
        //---------- vuelvo a escribir el contenido modificado dentro del cuerpo ----------------------------
        cuerpo.innerHTML= texto_cuerpo;
        pop_ups[i].style.zIndex = 2000;
        //----------------- oculto el popup ---------------------------------------------
        pop_ups[i].style.display = 'none';
        //----------------- asigno funcion de cerrar a los botones de los pop-ups ----------------
        var boton_cerrar=getElementsByClass('cerrar_popup',pop_ups[i]);
        boton_cerrar[0].padre = pop_ups[i];
        boton_cerrar[0].onclick =function(){
            this.padre.style.display = 'none';
        }
    }
    //-------------- obtengo todos los enlaces añadidos previamente
    var enlaces = getElementsByClass('enlace_popup');
    //----------------- asigno funcion de mostrar a los enlaces ----------------
    for (var i = 0; i < enlaces.length; i++){
        enlaces[i].onclick = function(){
            //----- hago el substr para quitar la palabra 'enlace_'
            var mi_pop_up = document.getElementById(this.id.substr(7));
            mi_pop_up.style.display = 'block';
        }
    }
}
function inserta_cadena(aguja,pajar,posicion){
    var parte1 = pajar.substr(0,posicion);
    var parte2 = pajar.substr(posicion,pajar.length)
    return( parte1 + aguja +parte2);
}
//============== muestra/oculta la descripcion de los productos =======================
function muestras_producto(numero){
    var descripciones = getElementsByClass('descripcion');
    for (var i = 0; i < descripciones.length; i++){
        descripciones[i].style.display ='none';
    }
    descripciones[numero].style.display ='block';
    update_scroll('descripciones','v');
}
function oculta_logo_marcas(id){
 var mi_marca= document.getElementById(id);

 var imagenes= mi_marca.getElementsByTagName('img');
 if(!imagenes[1].style.marginTop) imagenes[1].style.marginTop = '-60px';
    despliegue = new Accelimation(imagenes[1].style, "marginTop", 0, 400, 0.1);
    despliegue.start();
    despliegue.onend = new Function('null');
}
function abrir_popup(url,ancho,alto){
    x=(screen.width-440)/2;
    y=(screen.height-516)/2;
    window.open(url,'','scrollbars=no,menubar=no,height='+alto+',width='+ancho+',left='+x+',top='+y+',resizable=no,toolbar=no,location=no,status=no');
}
function inicio(){

    var comprobacion = document.getElementById('flag_inicio');
    if(comprobacion){
        comprobacion.id='';
        var musica=document.getElementById('musica');
        var inicio =document.getElementById('inicio');
        var enlace=inicio.getElementsByTagName('a');
        var contenedor_efectos=document.getElementById('contenedor_efectos');
        var objecto_flash='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" name="movie_musica" width="20" height="11" style="float:left; ">'
        objecto_flash=objecto_flash+'<param name="movie" value="/swf/soundtrack/dosound2.swf" />'
        objecto_flash=objecto_flash+'<param name="quality" value="high" />'
        objecto_flash=objecto_flash+'<param name="swliveconnect" value="true">'
        objecto_flash=objecto_flash+'<param name="wmode" value="transparent" />'
        objecto_flash=objecto_flash+'<param name="allowScriptAccess" value="sameDomain" />'
        objecto_flash=objecto_flash+'<embed src="/swf/soundtrack/dosound2.swf" width="20" height="11" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="movie_musica" swLiveConnect="true" allowScriptAccess="sameDomain" wmode="transparent"></embed>'
        objecto_flash=objecto_flash+'</object>'
        musica.innerHTML= objecto_flash;
        var mi_flash=document.getElementsByTagName('object');
        mi_flash[0].id='movie_musica';
            
        enlace[0].style.backgroundColor = '#eeeeee';
        var mi_seccion = document.getElementById('mi_seccion');
        mi_seccion.style.display = 'none';
        estilo_activo='home';
        //return;
        //doHome();
        //------------ transcurridos 600 milisegundos llamo al flash ------------
        setTimeout(function(){
            var inicio = document.getElementById('inicio'); 
            var enlace = inicio.getElementsByTagName('a');
            var url = enlace[0].href;
            //---------- cuando lo he llamado hago un reemplazo de los flash y llamo a la musica ---------
            seguridad = document.getElementById('seguridad');
            CargarContenido('contenido',url,null,'seguridad.style.display = "none"');
            contenedor_efectos.style.display="none";
        },600);
        
        
        var elms = document.getElementsByTagName('*');
        for (var i = elms.length; i--;){
            if (elms[i].className && elms[i].className == 'logo_pie'){
                elms[i].style.visibility = 'visible';
            }
        }
        
        
    }
}
//============== inicia el estereotipo/plantilla 1 =======================
function estereotipo1(){
    var comprobacion = document.getElementById('estereotipo1');
    if(comprobacion){
        addCss('/css/estereotipo_1.css');
        var alt = document.getElementById('alt');
        var main = document.getElementById('main');
        var boton_menos = document.getElementById('boton_menos_vertical');
        var contenedor = document.getElementById('contenedor_principal');
        //if(main) main.style.display = 'block';
        if(alt) alt.style.display = 'none';
        if(boton_menos) boton_menos.style.display = 'none';
    }
}
//============== inicia el estereotipo/plantilla 2 =======================
function estereotipo2(){
    var comprobacion = document.getElementById('estereotipo2');
    if(comprobacion){
        addCss('/css/estereotipo_2.css');
        scrollea('cuerpo',448,348,'v');
        mi_popup();
        parrafos_des();
        update_scroll('cuerpo','v');
        efecto_cuerpo();
        /*
        if (ultimo_estereotipo != 'estereotipo2'){
            ultimo_estereotipo = 'estereotipo2';
            efecto_cuerpo();
        }*/
    }
}
//============== inicia el estereotipo/plantilla 3 =======================
function estereotipo3(){
    var comprobacion = document.getElementById('estereotipo3');
    if(comprobacion){
        addCss('/css/estereotipo_3.css');
        var izq = document.getElementById('izq');
        var alt = document.getElementById('alt');
        var main = document.getElementById('main');
        var contenedor_main = document.getElementById('contenedor_main');
        var boton_mas = document.getElementById('boton_mas_horizontal');
        izq.style.width = '262px';
        
        //scrollea('cuerpo',459,348,'v');
        main.style.display= 'block';
        main.style.height = '418px';
        //mi_popup();
        //alt.innerHTML= alt.innerHTML;
        //parrafos_des();
        //setTimeout("update_scroll('cuerpo','v');",2000);
        //update_scroll('cuerpo','v');
        
        

        alt.style.display = 'none';
        //alt.style.visibility = 'hidden';
        main.style.position = 'relative';
        contenedor_main.style.position = 'absolute';
        contenedor_main.style.bottom = '10px';
        efecto_cuerpo();
        
    }
}
//============== inicia el estereotipo/plantilla 4 =======================
function estereotipo4(){
    var comprobacion = document.getElementById('estereotipo4');
    if(comprobacion){
        
        addCss('/css/estereotipo_4.css');
        var izq = document.getElementById('izq');
        var alt = document.getElementById('alt');
        var main = document.getElementById('main');
        var contenedor_main = document.getElementById('contenedor_main');
        var boton_mas = document.getElementById('boton_mas_horizontal');
        izq.style.width = '262px';
        scrollea('cuerpo',450,348,'v');
        main.style.display= 'block';
        main.style.height = '418px';
        mi_popup();
        alt.innerHTML= alt.innerHTML;
        parrafos_des();
        update_scroll('cuerpo','v');
        
        

        alt.style.display = 'none';
        //alt.style.visibility = 'hidden';
        main.style.position = 'relative';
        contenedor_main.style.position = 'absolute';
        contenedor_main.style.bottom = '10px';
        efecto_cuerpo();
        
    }
}
//============== inicia el estereotipo/plantilla 5 =======================
function estereotipo5(){
    var comprobacion = document.getElementById('estereotipo5');
    addCss('/css/estereotipo_5.css');
    if(comprobacion){
        var contenedor = document.getElementById('contenedor_principal');
        var productos = document.getElementById('productos');
        var descripciones = document.getElementById('descripciones');
        //----------------------------- averiguo el numero de td's de la tabla y asi calculo el ancho que debe tener, cada td debe medir 130px (para que no me haga cosas raras en explorer) -------------
        var tabla = productos.getElementsByTagName("TABLE");
        tabla[0].width = (tabla[0].getElementsByTagName("TD").length/2)*130
        
        ancho = contenedor.offsetWidth-244;
        productos.style.width = ancho +'px'
        descripciones.style.width = ancho +'px'
        
        scrollea('productos',ancho,225,'h');
        scrollea('descripciones',ancho-12,129,'v');
        var foto_productos = getElementsByClass('foto_producto');
        
        //---------------- recorro los enlaces del producto y sustituyo su href por llamada js -----------
        var enlaces = tabla[0].getElementsByTagName('a');
        for (var i = 0; i < enlaces.length; i++){
                var url = enlaces[i].href;
                enlaces[i].href = 'javascript:CargarContenido("contenido","'+url+'",null,null)';
        }
        
        /*for (var i = 0; i < foto_productos.length; i++){
            foto_productos[i].numero=i;
            foto_productos[i].onclick = function(){
                muestras_producto(this.numero);
            }
        }*/
        //muestras_producto(0);
    }
    efecto_cuerpo();
}

//============== inicia el estereotipo/plantilla 7 =======================
function estereotipo7(){
    var comprobacion = document.getElementById('estereotipo7');
    if(comprobacion){
        addCss('/css/estereotipo_7.css');
        //scrollea('cuerpo',450,348,'v');
        var izq = document.getElementById('izq_ofi');
        var alt = document.getElementById('alt');
        var main = document.getElementById('main');
        var contenedor_main = document.getElementById('contenedor_main');
        var boton_mas = document.getElementById('boton_mas_horizontal');
        izq.style.width = '262px';
        alt.style.display = 'none';
        main.style.display = 'block';
        main.style.height = '418px';
        main.style.position = 'relative';
        contenedor_main.style.position = 'absolute';
        contenedor_main.style.bottom = '10px';
        
    }
}
function estereotipo6(){
    var comprobacion = document.getElementById('estereotipo6');
    if(comprobacion){
        addCss('/css/estereotipo_3.css');
        var izq = document.getElementById('izq');
        var alt = document.getElementById('alt');
        var main = document.getElementById('main');
        var contenedor_main = document.getElementById('contenedor_main');
        var boton_mas = document.getElementById('boton_mas_horizontal');
        izq.style.width = '262px';
        
        //scrollea('cuerpo',459,348,'v');
        main.style.display= 'block';
        main.style.height = '418px';
        //mi_popup();
        //alt.innerHTML= alt.innerHTML;
        //parrafos_des();
        //setTimeout("update_scroll('cuerpo','v');",2000);
        //update_scroll('cuerpo','v');
        
        

        alt.style.display = 'none';
        //alt.style.visibility = 'hidden';
        main.style.position = 'relative';
        contenedor_main.style.position = 'absolute';
        contenedor_main.style.bottom = '10px';
        efecto_cuerpo();
        
    }
}

//======================== efecto1 ==============================
var fx_altura,fx_altura_bis, fx_altura_2, fx_altura_3, fx_altura_marcas, fx_anchura,fx_anchura_bis, fx_anchura_2, fx_anchura_3, fx_menu, fx_contenedor, fx_contenido, fx_marcas, fx_contenedor_2,fx_panel_1, fx_panel_2, panel_bis,fader, alt, main, animacion_contenedor_marcas;

var panel1,despliegue,despliegue_2;
function efecto_menu(){
    if(!document.all) return;
    fx_menu = document.getElementById('contenedor_menu');
    fx_contenedor = document.getElementById('contenedor_efectos');
    panel = document.getElementById('panel_menu');
    panel_bis = document.getElementById('panel_menu_bis');
    var menu = getElementsByClass('nivel1');
    fx_contenedor.style.display='block';    
    fx_menu.style.visibility = 'hidden';
    panel.style.border='none';
    panel.style.height= '10px';
    panel.style.width= '10px';
    panel_bis.style.height= '0px';
    panel_bis.style.width= '0px';
    panel_bis.style.marginTop = (menu[0].offsetHeight*1)+ 'px';
    //456
    //-------------------------efecto para primera parte del menu -----------------------
    fx_altura = new Accelimation(panel.style, "height", menu[0].offsetHeight-8, 300, 0.1);
    fx_anchura = new Accelimation(panel.style, "width", 236, 300, 0.1);
    fx_altura.onend= new Function('fx_anchura.start()');
    //fx_anchura.onend= new Function("fx_menu.style.visibility = 'visible';fx_contenedor.style.display='none'");
    fx_anchura.onend= new Function('panel_bis.style.width= "10px";fx_altura_bis.start()');
    fx_altura.start();
    //-------------------------efecto para segunda parte del menu -----------------------
    fx_altura_bis = new Accelimation(panel_bis.style,"height",456-menu[0].offsetHeight,500, 0.1 );
    fx_anchura_bis = new Accelimation(panel_bis.style, "width", 236, 300, 0.1);
    fx_altura_bis.onend =new Function('fx_anchura_bis.start()');
    fx_anchura_bis.onend = new Function("fx_menu.style.visibility = 'visible';fx_contenedor.style.display='none'");
    //-------------------------efecto para el contenedor de marcas -----------------------
    fx_panel_marcas.style.display='none';
    return;
    fx_marcas.style.visibility='hidden';
    fx_panel_marcas.style.display='block';
    fx_panel_marcas.style.height = '1px';
    fx_altura_marcas=new Accelimation(fx_panel_marcas.style, "height", 44, 1200, 0.3);
    fx_altura_marcas.onend =  new Function('fx_marcas.style.visibility="visible"');
    fx_altura_marcas.start();
}

function efecto_cuerpo(){
	
    setActiveStyleSheet(estilo_activo);
    var estereotipo1 = document.getElementById('estereotipo1');
    var estereotipo2 = document.getElementById('estereotipo2');
    var estereotipo3 = document.getElementById('estereotipo3');
    var estereotipo4 = document.getElementById('estereotipo4');
    var estereotipo5 = document.getElementById('estereotipo5');
    var estereotipo6 = document.getElementById('estereotipo6');
    var fondo_blanco = document.getElementById('panel_contenido_2');
    fx_contenedor_2 = document.getElementById('contenedor_efectos_2');
    fx_panel_1 = document.getElementById('fx_panel_1');
    fx_panel_2 = document.getElementById('fx_panel_2');
    fx_contenido = document.getElementById('contenedor_contenido');
    //fx_contenedor_2.style.backgroundColor='red';
    fx_marcas = document.getElementById('contenedor_marcas');
    fx_panel_marcas = document.getElementById('panel_marcas_2');
        
    fader = new Fadomatic(fx_contenedor_2, 10, 100, 0);
    //fader2 = new Fadomatic(fx_contenido, 10, 0, 0,100);
    if(fx_contenedor_2.style.display == 'block') return;
    
    if ( checkIE8Version() ) {
 		fondo_blanco.style.top  = '-44px';
    	fondo_blanco.style.left = (fx_contenido.offsetLeft + 25) + 'px';
    }
    
    if (estereotipo1 || estereotipo5){
        
        fx_contenido.style.visibility = 'hidden';
        
        fx_contenedor_2.style.display='block';
        
        fondo_blanco.style.width =fx_contenedor_2.offsetWidth-236 + 'px';
        
        fx_panel_1.style.height = '10px';
        fx_panel_1.style.width = '0px';
        fx_panel_2.style.width = '0px';
        fx_panel_2.style.height = '10px';
        fx_panel_2.style.position = 'absolute';
        fx_panel_2.style.top = '313px';
        fx_panel_2.style.left = '0px';
        //----------------------- disparo la animacion del primer panel --------------------------------
        fx_altura_2 = new Accelimation(fx_panel_1.style, "height", 305, 400, 0.1);
        fx_anchura_2 = new Accelimation(fx_panel_1.style, "width", fx_contenedor_2.offsetWidth-244, 300, 0.1);
        fx_anchura_2.onend = new Function('fx_altura_2.start()');
        //fx_altura_2.onend =  new Function('fx_anchura_3.start()');
        fx_altura_2.onend = new Function(null);
        fx_anchura_2.start();
        //----------------------- disparo la animacion del segundo panel --------------------------------
        fx_anchura_3 = new Accelimation(fx_panel_2.style, "width", fx_contenedor_2.offsetWidth-244, 400, 0.1);
        fx_altura_3 = new Accelimation(fx_panel_2.style, "height", 143, 300, 0.1);
        setTimeout('fx_anchura_3.start()',500)
        //fx_anchura_3.start();
        fx_anchura_3.onend = new Function('fx_altura_3.start()');
        fx_altura_3.onend = new Function("fx_contenido.style.visibility = 'visible';fader.fadeOut();");
    }
    if (estereotipo2){
        fx_contenido.style.visibility = 'hidden';
        fx_contenedor_2.style.display='block';
        fondo_blanco.style.width =fx_contenedor_2.offsetWidth-236 + 'px';
        fx_panel_1.style.width = '0px';
        fx_panel_1.style.height = '10px';
        fx_panel_2.style.position = 'absolute';
        fx_panel_2.style.top = '0px';
        fx_panel_2.style.left = '467px';
        fx_panel_2.style.width = '0px';
        fx_panel_2.style.height = '10px';
        //----------------------- disparo la animacion del primer panel --------------------------------
        fx_altura_2 = new Accelimation(fx_panel_1.style, "height", 456, 400, 0.1);
        fx_anchura_2 = new Accelimation(fx_panel_1.style, "width", 461, 300, 0.1);
        fx_anchura_2.onend = new Function('fx_altura_2.start()');
        fx_altura_2.onend =  new Function(null);
        //fx_altura_2.onend =  new Function('fx_anchura_3.start()');
        fx_anchura_2.start();
        //----------------------- disparo la animacion del segundo panel --------------------------------
        setTimeout('fx_anchura_3.start()',400);
        fx_anchura_3 = new Accelimation(fx_panel_2.style, "width", fx_contenedor_2.offsetWidth-711, 400, 0.1);
        fx_altura_3 = new Accelimation(fx_panel_2.style, "height", 456, 300, 0.1);
        fx_anchura_3.onend = new Function('fx_altura_3.start()');
        fx_altura_3.onend = new Function("fx_contenido.style.visibility = 'visible';fader.fadeOut();")
    }
    if (estereotipo3 || estereotipo4){
        fx_contenido.style.visibility = 'hidden';
        
        fx_contenedor_2.style.display='block';
        fondo_blanco.style.width =fx_contenedor_2.offsetWidth-236 + 'px';
        fx_panel_1.style.width = '0px';
        fx_panel_1.style.height = '10px';
        fx_panel_2.style.position = 'absolute';
        fx_panel_2.style.top = '0px';
        fx_panel_2.style.left = '268px';
        fx_panel_2.style.width = '0px';
        fx_panel_2.style.height = '10px';
        //----------------------- disparo la animacion del primer panel --------------------------------
        fx_altura_2 = new Accelimation(fx_panel_1.style, "height", 456, 400, 0.1);
        fx_anchura_2 = new Accelimation(fx_panel_1.style, "width", 262, 300, 0.1);
        fx_anchura_2.onend = new Function('fx_altura_2.start()');
        //fx_altura_2.onend =  new Function('fx_anchura_3.start()');
        fx_altura_2.onend =  new Function(null);
        fx_anchura_2.start();
        //----------------------- disparo la animacion del segundo panel --------------------------------
        setTimeout('fx_anchura_3.start()',400)
        fx_anchura_3 = new Accelimation(fx_panel_2.style, "width", fx_contenedor_2.offsetWidth-512, 400, 0.1);
        fx_altura_3 = new Accelimation(fx_panel_2.style, "height", 456,300, 0.1);
        fx_anchura_3.onend = new Function('fx_altura_3.start()');
        fx_altura_3.onend = new Function("fx_contenido.style.visibility = 'visible';fader.fadeOut();"); 
    }
}
//-------------------------------- botones del flash ------------------------------------------------
function botonflash1(){
    //alert("boton1")
    var marcas = document.getElementById('marcas');
    var enlace = marcas.getElementsByTagName('a');
    var url = enlace[0].href;
    var url_menu = enlace[1].href;
    mostrar_navegacion(true,enlace[0].childNodes[1].nodeValue,url);
    desmarca_opcion();
    enlace[0].style.backgroundColor='#EEEEEE';
    var funcion = 'menu_2();CargarContenido("contenido","'+url+'",null,null)';
    estilo_activo='marcas';
    CargarContenido('contenedor_menu',url_menu,null,funcion);
}
function botonflash2(){
    //alert("boton2")
    var personas = document.getElementById('personas');
    var enlace = personas.getElementsByTagName('a');
    var url = enlace[0].href;
    var url_menu = enlace[1].href;
    mostrar_navegacion(true,enlace[0].childNodes[1].nodeValue,url);
    desmarca_opcion();
    enlace[0].style.backgroundColor='#EEEEEE';
    var funcion = 'menu_2();CargarContenido("contenido","'+url+'",null,null)';
    estilo_activo='personas';
    CargarContenido('contenedor_menu',url_menu,null,funcion);
}

function botonflash3(){
    //alert("boton3")
    var clientes = document.getElementById('clientes');
    var enlace = clientes.getElementsByTagName('a');
    var url = enlace[0].href;
    var url_menu = enlace[1].href;
    mostrar_navegacion(true,enlace[0].childNodes[1].nodeValue,url);
    desmarca_opcion();
    enlace[0].style.backgroundColor='#EEEEEE';
    var funcion = 'menu_2();CargarContenido("contenido","'+url+'",null,null)';
    estilo_activo='clientes';
    CargarContenido('contenedor_menu',url_menu,null,funcion);
}
function botonflash4(){
    //alert("boton4")
    var compania = document.getElementById('compania');
    var enlace = compania.getElementsByTagName('a');
    var url = enlace[0].href;
    var url_menu = enlace[1].href;
    mostrar_navegacion(true,enlace[0].childNodes[1].nodeValue,url);
    desmarca_opcion();
    enlace[0].style.backgroundColor='#EEEEEE';
    var funcion = 'menu_2();CargarContenido("contenido","'+url+'",null,null)';
    estilo_activo='compania';
    CargarContenido('contenedor_menu',url_menu,null,funcion);
}

function botonEnviaTuCv(){
    //alert("boton2")
    var personas = document.getElementById('personas');
    var enlace = personas.getElementsByTagName('a');
    //var url = enlace[0].href;
	var url = '/servlets/show/es/'+lang+'/personasaa/curriculum.xml';
    var url_menu = enlace[1].href;
    mostrar_navegacion(true,enlace[0].childNodes[1].nodeValue,url);
    desmarca_opcion();
    enlace[0].style.backgroundColor='#EEEEEE';
    var funcion = 'menu_2();CargarContenido("contenido","'+url+'",null,null)';
    estilo_activo='personas';
    CargarContenido('contenedor_menu',url_menu,null,funcion);
}

function changeLanguage(language){
    lang = language;
}
//---------------------------------------------------musica -----------------------------------------

function thisMovie(movieName)
 {
  // IE y Netscape se refieren a la pelicula objeto de distinta forma
  // Esta función retorna la sintaxis apropiada dependiendo del navegador
  if (navigator.appName.indexOf ("Microsoft") !=-1) 
  {
    return window[movieName]
  } 
  else
  {
    return document[movieName]
  }
}

function doHome(){
    var IE = document.all?true:false
    //var movie = window.document.movie;
    if(IE){
        var pepe = thisMovie('movie_musica');//document.getElementById('movie');
        //alert(movie);
        pepe.SetVariable("val","1");
    }
}
function doSeccion(){
    var IE = document.all?true:false
    if(IE){
        //var movie = window.document.movie;
        //var movie = document.getElementById('movie_musica');
        var pepe = thisMovie('movie_musica');
        pepe.SetVariable("val","2");
        //alert("2");
    }
}
function doSubseccion(){
    var IE = document.all?true:false
    if(IE){
        //var movie = window.document.movie;
        //var movie = document.getElementById('movie_musica');
        var pepe = thisMovie('movie_musica');
        pepe.SetVariable("val","3");
        //alert("3");
    }
}


function updateIframeHeight(_height){
    var frame = window.document.getElementById('contentIframe');
    frame.style.height = (_height + 15)+'px';
    var ascensor = window.document.getElementById('cuerpo_thumb');
    if(ascensor){
        update_scroll('cuerpo','v');
    }
}

function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        
        if (re.exec(ua) != null) {
            rv = parseFloat(RegExp.$1);
		}
    }
    return rv;
}

function checkIE8Version() {
    var msg = "You're not using Windows Internet Explorer.";
    var ver = getInternetExplorerVersion();
    
    if (ver > -1) {
        if (ver >= 8.0 && ver < 9.0)
            return true;
        else
            return false;
    }

}