var resizeCheck_hrzAccordion = null;


function init_hrzAccordion(selectPanel) {

    JQ('.handle3').click(function() {
        var handle = JQ(this);
        if(handle.attr('rel') == 'selected')
            return;

        var parent = handle.parent().get(0);
        var toOpen = JQ('.panel_wrapper', parent);

        // Unselect all
        JQ('.handle3')
            .removeAttr('rel')
            .removeClass('handleSelected3');

        // Close all
        JQ('.panel_wrapper').each(function(index){
            // Get the currently selected panel
            if(JQ(this).attr('rel') != 'selected')
                return;
            
            JQ(this)
                .css('overflow', 'hidden')
                .animate({ width: "0px" }, 200, 'linear', function(){
                    // Hide the previously selected panel
                    JQ(this).removeAttr('rel')
                            .hide()
                            .css('overflow', '');

                    // Select the desired handle
                    handle.addClass('handleSelected3');
                    // Open the desired panel
                    toOpen.attr('rel', 'selected')
                          .show()
                          .css('overflow', 'hidden')
                          .animate({ width: "692px" }, 400, 'linear', function(){
                                JQ(this).css('overflow', '');
                                load_left_menu(handle.attr('id'));

                                if(resizeCheck_hrzAccordion) {
                                    clearInterval(resizeCheck_hrzAccordion);
                                }
                                resizeCheck_hrzAccordion = setInterval(function() {
                                    var lheight = toOpen.height();
                                    if(lheight < 600)
                                        lheight = 600;

                                    JQ('.handle3').each(function(index) {
                                        JQ(this).height(lheight);
                                    });
                                }, 100);
                          });
                });
        })
        return false;
    });

    // Select the item, or it will never be opened as we need an opened panel
    JQ('.panel_wrapper:eq('+(selectPanel-1)+')').attr('rel', 'selected');

    JQ('.handle3').each(function(index){
        JQ(this).attr('id', index+1);
    });
    JQ('.handle3:eq('+(selectPanel-1)+')').click();
}

function closeall_hrzAccordion() {
}

function animate_hrzAccordion(panel) {
    JQ('.panel_wrapper', parent)
        
}