﻿$(document).ready(function() {
    $(".clickArea").click(function(event) {

        //Search for all visible accordion box contents then slide them up and on callback add the box closed class
        $('.accordion .contentSurround:visible').slideUp('fast', function() { $(this).parent("div.listItem").toggleClass("closed"); });

        if ($(this).parent("div.listItem").hasClass("closed")) {
            $(this).parent("div.listItem").toggleClass("closed");
            $(this).next().slideDown('fast');
            return false;
        };
        
        // when we click on a close scroll to the pageTop div
        $('html,#pageTop').animate({scrollTop:0},1000)
    });

    // when we click on a backTop area scroll to the pageTop div
    $(".backTop").click(function(event) {

        $('html,#pageTop').animate({ scrollTop: 0 }, 1000)
    });

    // when we click on a FAQ list item we activate the click on the lower header to open it up
    $('#pageMenu li a').click(function() {
        var strLen = $(this).attr('href').toString().length
        var strLastHash = $(this).attr('href').toString().lastIndexOf('#') + 1
        var catName = $(this).attr('href').toString().substr(strLastHash, strLen)
        $('#' + catName + " h3.clickArea").click()
    });

});

