$(document).ready(function () {
    // open image
    $('.accordian').live('click', function () {

        if ($(this).children('.innerBox').is(":hidden")) {

            //show the selected submenu
            

            $(this).children('.innerBox').slideDown('slow', function () {

                // change text to show closed
                $(this).parent().children('.openClosePrompt').text("click to close");
                $(this).parent().children('.openClosePrompt').addClass("closeAccordian");

                //catch these ones to refresh the scroll panels
                if ($(this).parent("#facebook")) {
                    $('#fbPane').jScrollPane();
                }
                if ($(this).parent("#twitter")) {
                    $('#homeTweetHolder').jScrollPane();
                };



                if ($(this).parent("#menuCalculator").length > 0) {
                    menuCalculator.init();

                };
                $('html,body').animate({ scrollTop: $(this).parent().offset().top - 150 }, 500);


                return false;
            });
            return false;

        } else {


            if ($(this).attr('id') == 'always_open') {
                $(this).children('.openClosePrompt').text("Sorry, Always Open!");
            } else {
                if ($(this).attr('id') == 'menuCalculator') {
                    menuCalculator.init();
                }
                $('.accordian > .openClosePrompt, .accordian > .line, .accordian > .line_big').click(function () {
                    // hide box
                    $(this).parent().children('.innerBox').slideUp('slow');

                    // change text to show closed
                    $(this).parent().children('.openClosePrompt').text("click to open");

                    // remove class to identify open page
                    $(this).parent().children('.openClosePrompt').removeClass("closeAccordian");
                    $(this).parent().removeClass("accordianOpen");
                    $(this).parent().addClass("accordian");
                });
            }
        }
    });
});

