﻿(function($) {
$(document).ready(function() {
         $('#botoneraPrincipal .botonTVN').click(function() {
            var selected = jQuery(this).attr("id");
            $(".botoneracen").each(function(i, domEle) {
                if (domEle.id != "sub_" + selected) {
                    $(this).hide();   //ocultar todos los seleccionados             
                }
            });
            $(".botoneracen2").hide("fast"); //ocultar lvl 2 menu
            $('#sub_' + this.id).slideToggle("fast", function() {  //mostrar sub menu lvl 1
                var $thisLvl2 = $(this);
                $(".mlateral", $thisLvl2).find('img').attr("src", "/imagenes/master/flecha_submenu.png"); //re asignar las flechas por defecto
                $(".mlateral", this).unbind("click");  //quitar evento click                  
                $(".mlateral", this).click(function() {//mostrar sub menu lvl 2                            
                    //$(".botoneracen2").hide("fast");
                    var selected2 = jQuery(this).attr("id");
                    $(".botoneracen2").each(function(i, domEle) {
                        if (domEle.id != "sub2_" + selected2) {
                            $(this).hide(); //ocultar todas las seleccionadas                 
                        }
                    });
                    $('#sub2_' + this.id).slideToggle("fast");
                    //cambiar imagen menu lvl 2 
                    if ($(this).find('img').attr("src") == "/imagenes/master/flecha_submenu.png") {
                        $(this).find('img').attr("src", "/imagenes/master/flecha_submenu.png");
                    }
                    else {
                        $(".mlateral", $thisLvl2).find('img').attr("src", "/imagenes/master/flecha_submenu.png");
                        $(this).find('img').attr("src", "/imagenes/master/flecha_submenu.png");
                    }
                });
            });
            //cambiar imagen muno lvl 1
            if ($(this).find('img').attr("src") == "/imagenes/master/flechita_up.gif") {
                $(this).find('img').attr("src", "/imagenes/master/flechita.gif");
            }
            else {
                $('#botoneraPrincipal .botonTVN').find('img').attr("src", "/imagenes/master/flechita.gif"); //reasignar la felchas por defecto
                $(this).find('img').attr("src", "/imagenes/master/flechita_up.gif");
            }
         
        });
        $('#botoneraPrincipal .botonTVN:eq(3)').trigger('click');
        Ads_Publicar();
    });
})(jQuery);
