﻿///////////////////////////////////////////////////////////////////////////
/// 			Funciones encargadas de manejar el menú					///
///////////////////////////////////////////////////////////////////////////
function ShowSelectedMenuList(Element)
{
    if((Element != null)&&(Element.parent().is('ul')))
    {
        Element.children('ul').show();
        Element.parent().show();

        if(Element.parent().parent().parent().is('ul'))
            ShowSelectedMenuList(Element.parent().parent());
        else
            ShowSelectedMenuList(null);
    }
}

function initMenuList(name)
{
    $('#' + name + ' ul').hide();

    ShowSelectedMenuList($('#' + ItemShow));
    
    $('#' + name + ' li a').click(
    function()
    {
        var checkElement = $(this).next();

        if (($(this).attr('href') == '#') && (checkElement.is('ul')))
        {
            if(checkElement.is(':visible'))
            {
                if(($(this).parent().parent().parent()).is('li'))
                    checkElement.slideUp('normal');
                else
                    $('#' + name + ' ul:visible').slideUp('normal');
            }
            else
            {
                if(!($(this).parent().parent().parent()).is('li'))
                    $('#' + name + ' ul:visible').slideUp('normal');

                checkElement.slideDown('normal');
            }

            return false;
        }
    }
    );
}

var myLayout;

$(document).ready(function() 
{

//    myLayout = $('body').layout({
//        minSize: 600
//        , west__size: "214"
//		, west__minSize: 214
//		//, west__maxSize: 300
//		, west__resizable: false
//		, west__slidable: false
//		
//		, north__size: 114
//		, north__spacing_open: 0
//		, north__togglerLength_open: 0
//		, north__togglerLength_closed: -1
//		, north__resizable: false
//		, north__slidable: false
//    });

//    myLayout = $('body').layout({

//        //	enable showOverflow on west-pane so popups will overlap north pane
//        west__showOverflowOnHover: true

//        //	reference only - these options are NOT required because are already the 'default'
//		, closable: true	// pane can open & close
//		, resizable: true	// when open, pane can be resized 
//		, slidable: true	// when closed, pane can 'slide' open over other panes - closes on mouse-out

//        //	some resizing/toggling settings
//		, north__slidable: false	// OVERRIDE the pane-default of 'slidable=true'
//		, north__togglerLength_closed: '100%'	// toggle-button is full-width of resizer-bar
//		, north__spacing_closed: 20		// big resizer-bar when open (zero height)
//		, south__resizable: false	// OVERRIDE the pane-default of 'resizable=true'
//		, south__spacing_open: 0		// no resizer-bar when open (zero height)
//		, south__spacing_closed: 20		// big resizer-bar when open (zero height)
//        //	some pane-size settings
//		, west__minSize: 100
//		, east__size: 300
//		, east__minSize: 200
//		, east__maxSize: Math.floor(screen.availWidth / 2) // 1/2 screen width
//    });
		
		//$('.ui-layout-west.ui-layout-pane.ui-layout-pane-west').css('overflow', 'auto');
    initMenuList("MenuListJQ");
});