$(document).ready(function () {

    // Tipografia
    Cufon.replace('.type');

    // transparencias en IE6
    $(document).pngFix();

    //Agrega el _gaq.push en el boton ubicado en Inversiones - Te ayudamos - Cuentas mandantesdcv
    $("#ctl00_PH_LinksAyuda_SitefinityHyperLink1").attr("onclick", "_gaq.push(['_trackEvent', 'Inversiones', 'Click Botón - cuentas mandantes dcv', '', '']);");

    //Agrega el _gaq.push en el boton ubicado en Inversiones - Te ayudamos - folleto fondos mutuos
    $("#ctl00_PH_LinksAyuda_SitefinityHyperLink3").attr("onclick", "_gaq.push(['_trackEvent', 'Inversiones', 'Click Botón - folleto fondos mutuos', '', '']);");

    //Agrega el _gaq.push en el boton ubicado en Inversiones - Te ayudamos -  análisis técnico
    //$("#").attr("onclick", "_gaq.push(['_trackEvent', 'Inversiones', 'Click Botón - análisis técnico', '', '']);");

    //$(".btn_ver_memoria").colorbox({ width: "800px", height: "530px", iframe: true, scrolling: false }); //lightbox
    $("#ctl00_PlaceHolderLogin_ctl00_lnkOlvidoClave").colorbox({ width: "450px", height: "350px", iframe: true, scrolling: false }); //lightbox
    $("#ctl00_ContentPrincipal_ctl00_lnkOlvidoClave").colorbox({ width: "450px", height: "400px", iframe: true, scrolling: false }); //lightbox
    $(".btn_enviar_amigo").colorbox({ width: "860px", height: "360px", iframe: true, scrolling: false }); //lightbox
    $("#clickToCall").colorbox({ width: "780px", height: "360px", iframe: true, scrolling: false }); //lightbox
    $(".lightboxLink").colorbox({ width: "690px", height: "415px", iframe: true, scrolling: true }); //lightbox (Ocupada en: Solicita un ejecutivo)
    $(".clickToCall_l").colorbox({ width: "775px", height: "360px", iframe: true, scrolling: false }); //lightbox
    $(".contactanos_l").colorbox({ width: "800px", height: "426px", iframe: true, scrolling: false }); //lightbox
    $(".rentabilidad_l").colorbox({ width: "830px", height: "600px", iframe: true, scrolling: true }); //lightbox

    //    $('.rut_user').keyup(function () {
    //        if (this.value.match(/[^0-9kK-]/g)) {
    //            this.value = this.value.replace(/[^0-9kK-]/g, '');
    //        }
    //    });

    $(".lanza_tooltip").mouseover(function () {
        $(this).parent().parent().find(".tooltip").fadeIn();
        //$(".tooltip").fadeIn();
    });
    $(".lanza_tooltip").mouseleave(function () {
        $(".tooltip").hide();
    });

    // Transversal, Input Super Cleaner.
    $(".clean").each(function () {
        var value = $(this).val();
        $(this).focusin(function () { if ($(this).val() == value) { $(this).val(""); }; });
        $(this).focusout(function () { if ($(this).val() == '') { $(this).val(value); }; });
    });

    //tabs
    $("ul.tabs").tabs("div.panes > div");

    // MENU
    $(".li_quienes_somos").mouseover(function () {
        $(".li_quienes_somos div").show();
    });
    $(".li_quienes_somos").mouseleave(function () {
        $(".li_quienes_somos div").hide();
    });

    $(".li_prod_servicios").mouseover(function () {
        $(".li_prod_servicios div").show();
    });
    $(".li_prod_servicios").mouseleave(function () {
        $(".li_prod_servicios div").hide();
    });

    //new login
    $(".tipo_cliente a").click(function () {
        $(".tipo_cliente a").removeClass("activo");
        $(this).addClass("activo");
        id = $(this).attr("id");
        if (id == "lnkEmpresas") {
            $("#falso").fadeOut(0);
            $("#empresa").fadeIn(0);
            $(".solicita_clave_per").fadeOut(0);
            $(".solicita_clave_emp").fadeIn(0);
            $("#ctl00_PlaceHolderLogin_ctl00_hdnTipoCliente").val("MFE");

            $(".olvido_clave").fadeOut(0);
            $(".btnHazteClienteBig").css("padding-top", "45px");
            $(".solicita_clave_emp").css("padding-right", "130px");

            var tipo1 = $(".select_servicio").val();

            if (tipo1 == "EU") {
                $(".olvido_clave").show();
                $(".solicita_clave_emp").css("padding-right", "20px");
            }

            if ($(".select_servicio").val() == 'MFE') {
                $(".rut_user").val("Usuario");
                $(".rutEjemplo").html("");
            }
            else {
                $(".rut_user").val("Rut");
                $(".rutEjemplo").html("Ej: 15790161-3");
            }
        }
        else {
            $("#falso").fadeIn(0);
            $("#empresa").fadeOut(0);
            $(".solicita_clave_per").fadeIn(0);
            $(".solicita_clave_emp").fadeOut(0);
            $(".olvido_clave").fadeIn(0);
            $("#ctl00_PlaceHolderLogin_ctl00_hdnTipoCliente").val("MFP");
            $(".btnHazteClienteBig").css("padding-top", "45px");
            $(".solicita_clave_emp").css("padding-right", "22px");
            $(".rut_user").val("Rut");
            $(".rutEjemplo").html("Ej: 15790161-3");
        }

    });
    $(".tipo_cliente_lng a").click(function () {

        $(".tipo_cliente_lng a").removeClass("activo");
        $(this).addClass("activo");
        id = $(this).attr("id");
        if (id == "lnkEmpresas") {

            $("#empresa").fadeIn(0);
            $(".solicita_clave_per").fadeOut(0);
            $(".solicita_clave_emp").fadeIn(0);
            $(".olvido_clave").fadeOut(0);

            $("#selTipoAcceso option[value=MFE]").attr("selected", true);
            $(".rut_user").val("Usuario");
            $(".rutEjemplo").html("");

            $("#selOculto option:eq(1)").attr("selected", "selected");
            $("#ctl00_ContentPrincipal_ctl00_hdnTipoCliente").val("MFE");
        }
        else {
            $("#selOculto option:eq(0)").attr("selected", "selected");
            $(".contentTipoIngreso").html("MFP");
            $("#ctl00_ContentPrincipal_ctl00_hdnTipoCliente").val("MFP");
            $("#empresa").fadeOut(0);
            $(".solicita_clave_per").fadeIn(0);
            $(".solicita_clave_emp").fadeOut(0);
            $(".olvido_clave").fadeIn(0);
            $(".rut_user").val("Rut");
            $(".rutEjemplo").html("Ej: 15790161-3");
        }

        $("#ctl00_ContentPrincipal_ctl00_txtTipoIngreso").val($("#selOculto").val());

        // alert($("#ctl00_ContentPrincipal_ctl00_hdnTipoCliente").val());

    });

    $(".botonesdobles a").click(function () {

        id = $(this).attr("id");
        if (id == "btnIngreso") {


            $("#lnkPersonas").addClass("activo");
            $("#lnkEmpresas").removeClass("activo");

            $(".bgIzquierdo").show();
            $("#divloginGeneric").show();
            $(".bgDerecho").show();
            $("#selTipoAcceso option[value=MFE]").attr("selected", true);
            $(".rut_user").val("Rut");
            $(".rutEjemplo").html("Ej: 15790161-3");

            $(".loginGeneric").css("width", "510px");
            $(".divPrimeraLinea").css("width", "542px");
            $(".cerrarVentana").css("left", "510px");
            $(".solicita_clave_per").show();
            $(".olvido_clave_lng").show();
            $(".solicita_clave_emp_long").hide();
            $(".contentLoginNew").css("width", "522px");
            $(".imgseguridad").css("left", "435px");

            $("#empresa").fadeOut(0);
            $(".botonesdobles").hide();
            $("#selOculto option:eq(0)").attr("selected", "selected");

            $("#ctl00_ContentPrincipal_ctl00_txtTipoIngreso").val($("#selOculto").val());
        }
    });

    $(".select_servicio").change(function () {
        $(".olvido_clave").fadeOut(0);


        if ($(".select_servicio").val() == 'EU') {
            $(".olvido_clave").fadeIn(0);
            $(".solicita_clave_emp").css("padding-right", "22px");
            $(".btnHazteClienteBig").css("padding-top", "45px");

            $(".rut_user").val("Rut");
            $(".rutEjemplo").html("Ej: 15790161-3");
        }
        else if ($(".select_servicio").val() == 'MFE') {
            $(".rut_user").val("Usuario");
            $(".rutEjemplo").html("");
        }
        else {
            $(".rut_user").val("Rut");
            $(".rutEjemplo").html("Ej: 15790161-3");
        }

        $("#ctl00_PlaceHolderLogin_ctl00_hdnTipoCliente").val($(".select_servicio").val());
        $("#ctl00_ContentPrincipal_ctl00_hdnTipoCliente").val($(".select_servicio").val());

    });

    //carrusel home
    $(".banners").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: true
    }).navigator({ navi: '.tab_top' }).autoscroll(8000);

    $('.kwicks').kwicks({
        min: 42,
        spacing: 0,
        sticky: true,
        defaultKwick: 0,
        event: 'click'
    });


    //carrusel home media center
    $("#opc_media_center").scrollable({
        size: '1',
        items: ".items_top",
        prev: ".prev_mc",
        next: ".next_mc",
        clickable: false,
        circular: true
    }).autoscroll(4000);

    //carrusel home media center
    $("#opc_media_center_FFMM").scrollable({
        size: '1',
        items: ".items_top",
        prev: ".prev_mc",
        next: ".next_mc",
        clickable: false,
        circular: true
    }).autoscroll(4000);


    //carrusel productos y sevicios
    $(".carru_principal_ps").scrollable({
        size: '1',
        items: ".items_top",
        prev: ".prev_ps",
        next: ".next_ps",
        clickable: false,
        circular: true
    }).autoscroll(4000);

    //carrusel inversiones
    $("#opc_inversiones").scrollable({
        size: '1',
        items: ".items_top",
        prev: ".prev",
        next: ".next",
        clickable: false,
        circular: true
    }).navigator({ navi: '.tab_top' }).autoscroll(8000);

    // carrusel memorias 
    $(".carru_memorias").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: false
    });

    // tabs de memorias
    $("ul.annos_memorias li").click(function () {
        $("ul.annos_memorias li").removeClass("active");
        $(this).addClass("active");
    });

    // carrusel premios
    $(".carru_premios").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: true
    }).navigator({ navi: '.tab_top' });

    // tabs de premios
    $("ul.annos_premios li").click(function () {
        $("ul.annos_premios li").removeClass("active");
        $(this).addClass("active");
	var anno = $(this).find("a").html();
        $(".premiosOculto").hide();
        $(".premios_" + anno).show();
    });
    // minicarrusel noticias
    $(".carru_mininoticias").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: true
    }).autoscroll(4000);

    // carrusel ciclos de vida	
    $(".ciclos").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: false
    });


    // carrusel noticias media center
    $(".banners_noticia").scrollable({
        size: '1',
        items: ".items_top",
        clickable: false,
        circular: true
    }).navigator("#main_navi").autoscroll(4000);

    // tabs de noticias
    $("ul.paginas_noticias li").click(function () {
        $("ul.paginas_noticias li").removeClass("active");
        $(this).addClass("active");
    });

    //objeto carrusel para llamar funciones
    var scrollCiclos = $(".ciclos").data("scrollable");

    //ciclo inferior
    $(".ciclos .items_top .item_top").click(function () {

        relId = $(this).find("a").attr("rel");

        $('#' + relId + ' a').removeClass("active");
        $('#' + relId + ' a:first').addClass("active");
        $('#' + relId + ' a:first').click();


        $(".ciclos .items_top .item_top").removeClass("active");
        $(this).addClass("active");

        $(".ciclo_superior ul li a").removeClass("activo");
        var clase = $(this).children("a").attr("class");
        var arrClase = clase.split(" ");
        $("." + arrClase[1] + " a").addClass("activo");

        var num = 0;
        var itemN = 0;
        $(".ciclos .items_top .item_top").each(function () {
            claseActiva = $(this).attr('class');
            claseActiva = claseActiva.replace("r1", "");
            claseActiva = claseActiva.replace("r2", "");
            claseActiva = claseActiva.replace("r3", "");
            claseActiva = claseActiva.replace("r4", "");
            claseActiva = claseActiva.replace("r5", "");

            if (claseActiva == 'item_top  active') {
                itemN = num;
            }
            num++;
        });
        itemN = itemN * 806; // 806 es el ancho del contenedor
        $(".items_topX").animate({
            left: "-" + itemN + "px"
        });

    });

    //ciclo sup mod
    $(".ciclo_superior ul li").click(function () {

        $(".ciclo_superior ul li a").removeClass("activo");
        contenidoClickeado = $(this).attr("class");

        $(this).children().addClass("activo");
        var num = 0;
        var itemN = 0;
        var sum = 0;

        /*** eliminamos pestañas no asociadas al item ***/
        $(".ciclos .items_top .item_top .contentCV").each(function () {
            var clases = $(this).attr("class");
            var arrClase = clases.split(" ");

            if (contenidoClickeado != arrClase[1]) {
                $(this).parent().hide();
            }
            else {
                $(this).parent().show();
            }
        });
        /**************************************/

        $(".ciclos .items_top .item_top .contentCV").each(function () {
            var clases = $(this).attr("class");
            var arrClase = clases.split(" ");

            if (contenidoClickeado == arrClase[1] && itemN == 0 && sum == 0) {
                itemN = num;
                $(".ciclos .items_top .item_top").removeClass("active");
                $(this).parent().addClass("active");

                relId = $(this).attr("rel");
                $('#' + relId + ' a').removeClass("active");
                $('#' + relId + ' a:first').addClass("active");
                $('#' + relId + ' a:first').click();

                sum++;
            }

            num++;
        });

        scrollCiclos.seekTo(itemN, 300);
        itemN = itemN * 806; // 806 es el ancho del contenedor
        $(".items_topX").animate({
            left: "-" + itemN + "px"
        });
    });


    //menu inicial ciclo de vida
    $('.etapa_cv').click(function () {
        $('#bienvenida_cv').hide();
        $('#interior_cv').show();
    });

    $('#comenzando').click(function () {
        $('.ciclo_superior .btn_comenzando').click();
    });
    $('#familia').click(function () {
        $('.ciclo_superior .btn_vida').click();
    });
    $('#desafios').click(function () {
        $('.ciclo_superior .btn_desafios').click();
    });
    $('#retiro').click(function () {
        $('.ciclo_superior .btn_retiro').click();
    });
    $('#patrimonio').click(function () {
        $('.ciclo_superior .btn_patrimonio').click();
    });


    $('#recomendar_btn').click(function () {
        if ($('#recomienda').css("display") == "none") {
            $('#recomienda').slideDown('slow', function () {
            });
        }
        else {
            $('#recomienda').slideUp('slow', function () {
            });
        }
    });

    $('#facebook').click(function () {
        $("#cv_fb_share").css("display", "block");
        $("#cv_textarea").css("display", "none");
        $("#enviar").css("display", "none");
        $("#ta_mailto").css("display", "none");
        $('#facebook').css("background", "url(Images/cv_facebook.jpg) 0px -43px no-repeat");
        $('#twitter').css("background", "url(Images/cv_twitter.jpg) no-repeat");
        $('#correo').css("background", "url(Images/cv_correo.jpg) no-repeat");
    });

    $('#twitter').click(function () {
        $("#cv_fb_share").css("display", "none");
        $("#cv_textarea").css("display", "block");
        $("#enviar").css("display", "block");
        $("#ta_mailto").css("display", "none");
        $("#ta_compartir").val("Recomiendanos en Twitter...");
        $('#facebook').css("background", "url(Images/cv_facebook.jpg) no-repeat");
        $('#twitter').css("background", "url(Images/cv_twitter.jpg) 0px -43px no-repeat");
        $('#correo').css("background", "url(Images/cv_correo.jpg) no-repeat");
    });
    $('#twitter').blur(function () {
        $("#ta_compartir").val("");
    });
    $('#cv_mailto').click(function () {
        $("#ta_mailto").val("");
    });
    $('#cv_textarea').click(function () {
        $("#ta_compartir").val("");
    });
    $('#correo').click(function () {
        $("#cv_fb_share").css("display", "none");
        $("#cv_textarea").css("display", "block");
        $("#ta_mailto").css("display", "block");
        $("#ta_compartir").val("");
        $("#enviar").css("display", "block");
        $("#ta_mailto").val("Para...");
        $("#ta_compartir").val("Recomiendanos por E-Mail...");
        $('#facebook').css("background", "url(Images/cv_facebook.jpg) no-repeat");
        $('#twitter').css("background", "url(Images/cv_twitter.jpg) no-repeat");
        $('#correo').css("background", "url(Images/cv_correo.jpg) 0px -43px no-repeat");
    });

    $('#enviar').click(function () {
        if ($('#twitter').css("background-position") == "0px -43px") {
            var texto = $("#ta_compartir").val();
            $('#enviar').attr({
                'target': '_blank',
                'class': 'twitter-share-button',
                'href': 'http://twitter.com/share?_=1299763126614&count=none&text=' + texto + ' - Ciclo de Vida en EuroAmerica&url=http%3A%2F%2Fwww.euroamerica.cl&via=MundoFinanciero'
            });
            $('#recomienda').slideUp('slow', function () {
            });
        }
        if ($('#correo').css("background-position") == "0px -43px") {
            var texto = $("#ta_compartir").val();
            $('#enviar').attr({
                'target': '',
                'href': '#'
            });
            $('#recomienda').slideUp('slow', function () {
            });
        }
    });

    $('#cancelar').click(function () {
        $('#recomienda').slideUp('slow', function () {
        });
    });

    //================ menu colgante productos y servicios ====================================	
    $(".menu_colgante ul.nivel_1 li a.btn").click(function () {

        var clase = $(this).attr("class");

        $(".open").parent().find(".nivel_2").slideUp(400, function () {
            $(this).parent().find(".btn").removeClass("open");
            $(this).parent().find(".btn").addClass("close");
        });

        if (clase == 'btn open') {
            $(this).removeClass("open");
            $(this).addClass("close");
            $(this).parent().find(".nivel_2").slideUp(400);
        }
        else if (clase == 'btn close') {
            $(this).removeClass("close");
            $(this).addClass("open");
            $(this).parent().find(".nivel_2").slideDown(400);
        }

    });

    $(".menu_colgante ul.nivel_1 li ul.nivel_2 li a.btn_n2").click(function () {

        if ($(this).parent().find(".nivel_3").length) {

            $(".btn_n2").removeClass("activo");
            $(".btn_n2").parent().removeClass("active");
            $(".nivel_3").slideUp(400);


            if (!$(this).parent().find(".nivel_3").attr("style") || $(this).parent().find(".nivel_3").attr("style") == "display: none;" || $(this).parent().find(".nivel_3").attr("style") == "DISPLAY: none") {

                $(this).addClass("activo");
                $(this).parent().addClass("active");
                $(this).parent().find(".nivel_3").slideDown(400);
            }
            else {
                $(this).removeClass("activo");
                $(this).parent().removeClass("active");
                $(this).parent().find(".nivel_3").slideUp(400);
            }
        }

    });

    $(".menu_colgante ul.nivel_1 li ul.nivel_2 li ul.nivel_3 li a.btn_n3").click(function () {

        if ($(this).parent().find(".nivel_4").length) {

            $(".btn_n3").removeClass("activo");
            $(".btn_n3").parent().removeClass("active");
            $(".nivel_4").slideUp(400);

            if (!$(this).parent().find(".nivel_4").attr("style") || $(this).parent().find(".nivel_4").attr("style") == "display: none;" || $(this).parent().find(".nivel_4").attr("style") == "DISPLAY: none") {

                $(this).addClass("activo");
                $(this).parent().addClass("active");
                $(this).parent().find(".nivel_4").slideDown(400);
            }
            else {
                $(this).removeClass("activo");
                $(this).parent().removeClass("active");
                $(this).parent().find(".nivel_4").slideUp(400);
            }
        }

    });



    try {
        isset(paginaActual);
    }
    catch (Error) {
        paginaActual = '';
    }

    if (paginaActual != '') {
        var estadoMenu = 'OFF';
        var arrPagina = paginaActual.split("/");
        pagina = arrPagina[arrPagina.length - 1];

        $(".nivel_4 li a").each(function () {

            try {
                arr = $(this).attr("href").split("/");
            }
            catch (Error2) {
                arr = "";
            }

            pag = arr[arr.length - 1];
            if (pag == pagina) {
                estadoMenu = 'ON';
                $(this).addClass("activo");
                $(this).parent().parent().css("display", "block");
                $(this).parent().parent().parent().find("a.btn_n3").addClass("activo");
                $(this).parent().parent().parent().addClass("active");
                $(this).parent().parent().parent().parent().css("display", "block");
                $(this).parent().parent().parent().parent().parent().addClass("active");
                $(this).parent().parent().parent().parent().parent().find("a.btn_n2").addClass("activo");
                $(this).parent().parent().parent().parent().parent().parent().css("display", "block");
                classFinal = $(this).parent().parent().parent().parent().parent().parent().parent().find("a.btn").attr("class");
                if (classFinal == "btn close") {
                    $(".btn").removeClass("open");
                    $(".btn").addClass("close");
                    $(".nivel_2").css("display", "none");
                    $(this).parent().parent().parent().parent().parent().parent().parent().find("a.btn").removeClass("close");
                    $(this).parent().parent().parent().parent().parent().parent().parent().find("a.btn").addClass("open");
                    $(this).parent().parent().parent().parent().parent().parent().parent().find(".nviel_2").css("display", "block");
                }
            }
        });

        if (estadoMenu == 'OFF') {

            $(".nivel_3 li a").each(function () {

                try {
                    arr = $(this).attr("href").split("/");
                }
                catch (Error2) {
                    arr = "";
                }

                pag = arr[arr.length - 1];

                if (pag == pagina) {
                    estadoMenu = 'ON';
                    $(this).addClass("activo");
                    $(this).parent().parent().css("display", "block");
                    $(this).parent().parent().parent().addClass("active");
                    $(this).parent().parent().parent().find("a.btn_n2").addClass("activo");
                    $(this).parent().parent().parent().parent().css("display", "block");

                    classFinal = $(this).parent().parent().parent().parent().parent().find("a.btn").attr("class");
                    if (classFinal == "btn close") {
                        $(".btn").removeClass("open");
                        $(".btn").addClass("close");
                        $(".nivel_2").css("display", "none");
                        $(this).parent().parent().parent().parent().parent().find("a.btn").removeClass("close");
                        $(this).parent().parent().parent().parent().parent().find("a.btn").addClass("open");
                        $(this).parent().parent().parent().parent().parent().find(".nivel_2").css("display", "block");
                    }

                    if ($(this).parent().find(".nivel_4").attr("class") == "nivel_4") {

                        $(this).parent().find(".nivel_4").css("display", "block");
                    }

                }
            });
        }

        if (estadoMenu == 'OFF') {

            $(".nivel_2 li a").each(function () {

                try {
                    arr = $(this).attr("href").split("/");
                }
                catch (Error2) {
                    arr = "";
                }

                pag = arr[arr.length - 1];

                if (pag == pagina) {
                    estadoMenu = 'ON';
                    $(this).addClass("activo2");
                    $(this).parent().parent().css("display", "block");

                    classFinal = $(this).parent().parent().parent().find("a.btn").attr("class");
                    if (classFinal == "btn close") {
                        $(".btn").removeClass("open");
                        $(".btn").addClass("close");
                        $(".nivel_2").css("display", "none");
                        $(this).parent().parent().parent().find("a.btn").removeClass("close");
                        $(this).parent().parent().parent().find("a.btn").addClass("open");
                        $(this).parent().parent().parent().find(".nivel_2").css("display", "block");
                    }

                    if ($(this).parent().find(".nivel_3").attr("class") == "nivel_3") {

                        $(this).parent().find(".nivel_3").css("display", "block");
                    }
                }
            });

        }

    }
    //================ FIN menu colgante productos y servicios ====================================



    // detalles de productos y servicios
    $(".ps_detalles .item a").click(function () {

        if ($(this).parent().find("a").attr("class") == "activo") {

            $(this).parent().find(".activo").removeClass("activo");
            $(this).parent().find(".listado").css("height", "35px");
        }
        else {

            $(this).addClass("activo");
            $(this).parent().find(".listado").animate({ height: "100%" }, { duration: 500 });
        }

    });


    // botones prod y servicios 
    $(".btns_ps a").click(function () {
        $(".btns_ps a").removeClass("activo");
        $(this).addClass("activo");
    });


    $(".mercados .nivel_1 li a").click(function () {
        var clase = $(this).attr("class");
        clase = clase.replace("btn", "");
        clase = clase.replace("open_2", "");
        clase = clase.replace("close_2", "");
        clase = trim(clase);

        $(".open_2").parent().find(".nivel_2").hide(0, function () {

            $(this).parent().find(".btn").removeClass("open_2");
            $(this).parent().find(".btn").addClass("close_2");
            $("." + clase).removeClass("close_2");
            $("." + clase).addClass("open_2");
            $("." + clase).parent().find(".nivel_2").show();
        });

    });

    $(".cont_cifras .nivel__1 li a").click(function () {
        var clase = $(this).attr("class");

        $(".open__2").parent().find(".nivel__2").slideUp(400, function () {
            $(this).parent().find(".btn").removeClass("open__2");
            $(this).parent().find(".btn").addClass("close__2");
        });

        if (clase == 'btn open__2') {
            $(this).removeClass("open__2");
            $(this).addClass("close__2");
            $(this).parent().find(".nivel__2").slideUp(400);
        }
        else if (clase == 'btn close__2') {
            $(this).removeClass("close__2");
            $(this).addClass("open__2");
            $(this).parent().find(".nivel__2").slideDown(400);
        }

    });


    //boton de login ingreso cliente
    $(".login_long_btn").click(function () {
        $(this).fadeOut(300, function () { $(".login_long").fadeIn(300) });
    });



    // botones de Directorio
    $(".gris").click(function () {

        $(".gris").parent().find(".cont_oculto").slideUp(310, function () {
            $(this).parent().find(".gris").removeClass("abierto");
            $(this).parent().find(".gris").addClass("cerrado");
        });

        $(".dc").hide(); $(".sv").hide(); $(".cb").hide(); $(".agf").hide(); $(".sf").hide();

        if ($(this).attr("class") == "gris type cerrado") {

            $(this).removeClass("cerrado");
            $(this).addClass("abierto");
            $(this).parent().find(".cont_oculto").slideDown(300);

            contacto = $(this).attr("id").replace("h", "");
            $("." + contacto).show();

            $(".inf").show();
        }
        else if ($(this).attr("class") == "gris type abierto") {

            $(this).removeClass("abierto");
            $(this).addClass("cerrado");
            $(this).parent().find(".cont_oculto").slideUp(300);

            contacto = $(this).attr("id").replace("h", "");
            $("." + contacto).hide();

            $(".inf").hide();
        }

        $(document).ready(function () {
            if ($(this).attr("class") == "gris type abierto") {
                $(".inf").show();
            }
        });
    });


    // botones premios
    $(".btn_expandir").click(function () {

        $(this).parent().parent().find(".txt").hide(0, function () {

            $(this).parent().removeClass("abierto");
            $(this).parent().addClass("cerrado");
            $(this).parent().find(".btn_expandir").removeClass("menos");
            $(this).parent().find(".btn_expandir").addClass("mas");

        });

        if ($(this).attr("class") == "btn_expandir mas") {

            $(this).removeClass("mas");
            $(this).addClass("menos");
            $(this).parent().removeClass("cerrado");
            $(this).parent().addClass("abierto");
            $(this).parent().find(".txt").show(230);

        }
        else if ($(this).attr("class") == "btn_expandir menos") {

            $(this).removeClass("menos");
            $(this).addClass("mas");
            $(this).parent().removeClass("abierto");
            $(this).parent().addClass("cerrado");
            $(this).parent().find(".txt").hide(230);

        }

    });

    // botones Preguntas frecuentes
    $(".btn_faq").click(function () {

        $(".btn_faq").parent().find(".cont_oculto").slideUp(310, function () {
            $(this).parent().find(".btn_faq").removeClass("abierto");
            $(this).parent().find(".btn_faq").addClass("cerrado");
        });

        if ($(this).attr("class") == "type btn_faq cerrado") {

            $(this).removeClass("cerrado");
            $(this).addClass("abierto");
            $(this).parent().find(".cont_oculto").slideDown(300);
        }
        else if ($(this).attr("class") == "type btn_faq abierto") {

            $(this).removeClass("abierto");
            $(this).addClass("cerrado");
            $(this).parent().find(".cont_oculto").slideUp(300);
        }
    });


    $(".cRadios input[type=radio]").click(function () {
        id = $(this).val();
        if (id == "Email") {
            $("#formaContacto1").hide();
            $("#formaContacto2").fadeIn();
        } else {
            $("#formaContacto2").hide();
            $("#formaContacto1").fadeIn();
        }
    });

    // paginador ciclo de vida 

    $(".navi .sig").click(function () {
        var estilo = $(".items").attr("style");
        ancho = estilo.replace("left: -", "");
        ancho = ancho.replace("LEFT: -", "");
        ancho = ancho.replace("px", "");
        ancho = ancho.replace("PX", "");
        ancho = ancho.replace(";", "");
        ancho = parseInt(ancho);
        tt = (ancho * 1) + 402;

        if (isNaN(tt)) tt = 402;
        total = 0;
        $(this).parent().find("a").each(function () {

            if (total == tt) {
                $(this).click();
            }
            total += 402;
        });

    });

    $(".navi .ant").click(function () {
        var estilo = $(".items").attr("style");
        ancho = estilo.replace("left: -", "");
        ancho = ancho.replace("LEFT: -", "");
        ancho = ancho.replace("px", "");
        ancho = ancho.replace("PX", "");
        ancho = ancho.replace(";", "");
        ancho = parseInt(ancho);
        tt = (ancho * 1) - 402;
        if (isNaN(tt)) tt = 0;
        total = 0;
        $(this).parent().find("a").each(function () {

            if (total == tt) {
                $(this).click();
            }
            total += 402;
        });
    });


    $("#01 a").click(function () {
        $("#01 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#01 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });

    $("#02 a").click(function () {
        $("#02 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#02 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#03 a").click(function () {
        $("#03 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#03 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#04 a").click(function () {
        $("#04 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#04 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#05 a").click(function () {
        $("#05 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#05 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#06 a").click(function () {
        $("#06 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#06 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#07 a").click(function () {
        $("#07 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#07 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#08 a").click(function () {
        $("#08 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#08 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#09 a").click(function () {
        $("#09 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#09 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#10 a").click(function () {
        $("#10 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#10 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#11 a").click(function () {
        $("#11 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#11 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#12 a").click(function () {
        $("#12 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#12 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#13 a").click(function () {
        $("#13 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#13 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#14 a").click(function () {
        $("#14 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#14 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#15 a").click(function () {
        $("#15 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#15 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#16 a").click(function () {
        $("#16 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#16 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#17 a").click(function () {
        $("#17 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#17 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    $("#18 a").click(function () {
        $("#18 a").removeClass("active");
        $(this).addClass("active");

        if ($(this).attr("rel") == "first") {
            $(this).parent().find(".ant").css("color", "#FFF");
            $(this).parent().find(".sig").css("color", "#999");
        }
        else if ($(this).attr("rel") == "last") {
            $(this).parent().find(".sig").css("color", "#FFF");
            $(this).parent().find(".ant").css("color", "#999");
        }
        else {
            $(this).parent().find(".ant").css("color", "#999");
            $(this).parent().find(".sig").css("color", "#999");
        }

        var tt = 0;
        var total = 0;
        $("#18 a").each(function () {
            if ($(this).attr("class") == "active" && total == 0) {
                total = tt;
            }
            tt += 402;
        });

        $(".items").animate({
            left: "-" + total + "px"
        });
    });
    //paginador


    /** CONTACTANOS **/
    $(".rdT").click(function () {
        $(".xcorreo").fadeOut(300, function () {
            $(".xtelefono").fadeIn();
        });
    });
    $(".rdC").click(function () {
        $(".xtelefono").fadeOut(300, function () {
            $(".xcorreo").fadeIn();
        });
    });



    /** LINKEA FAQS **/
    ttC = 0;
    $("#boxFaqs .categoria_faq").each(function () {
        ttC++;
        ttP = 0;
        $(this).find("h3").each(function () {
            $(this).attr("id", "c" + ttC + "_p" + ttP);
            ttP++;
        });
        ttP = 1;
        $(this).find("a").each(function () {
            if ($(this).attr("target") != "_blank") {
                $(this).attr("href", "#c" + ttC + "_p" + ttP);
                $(this).css("display", "block");
                ttP++;
            }
        });

    });

    if (!$(".planes_material_asociado div").length) {
        $("#titPlanesRelacionados").hide();
    }

    (function ($) {
        var cache = [];
        // Arguments are image paths relative to the current page.
        $.preLoadImages = function () {
            var args_len = arguments.length;
            for (var i = args_len; i--; ) {
                var cacheImage = document.createElement('img');
                cacheImage.src = arguments[i];
                cache.push(cacheImage);
            }
        }
    })(jQuery)




});
