﻿
var evokeFaqAccordionControl = {
    openAll: function() {
        $("a.accordionHdrLink").each(
            function() {

                $(this).siblings("div").slideDown('slow');
                $(this).addClass("open");

                var h = $(this).siblings(".accordionContent").html();
                $(this).siblings(".accordionContentFix").html(h);
            }
        );
    }
};

jQuery(document).ready(function() {
    $('#accordion a.accordionHdrLink').click(function() {
        if ($(this).hasClass("open")) {
            delayClose(this);
        } else {
            $.getJSON(faqAccoridonProps.faqClick, { id: this.id, rand: new Date().getTime() });
            tracker.trackFAQ({ id: this.id });
            $(this).toggleClass("open");
            var top = $(this).parent().get(0).offsetTop;
            $(window).scrollTo(top + 150, 800);
        }

        var h = $(this).siblings(".accordionContent").html();
        $(this).siblings(".accordionContentFix").html(h);

        $(this).siblings("div").slideToggle(400);
        return false;
    });

    var delayClose = function(hdrLink) {
        setTimeout(function() { $(hdrLink).removeClass("open"); }, 350);
    }

    $('#btnOpenAll').click(function() {
        $("a.accordionHdrLink").each(
            function() {

                $(this).siblings("div").slideDown('slow');
                $(this).addClass("open");

                var h = $(this).siblings(".accordionContent").html();
                $(this).siblings(".accordionContentFix").html(h);
            }
        );

        return false;
    });

    $('#btnCloseAll').click(function() {
        $('a.accordionHdrLink').siblings("div").slideUp('slow');
        setTimeout(function() { $('#accordion a.accordionHdrLink').removeClass("open"); }, 500);
        return false;
    });

    $('.btnHideThis').click(function() {
        $(this + 'div.accordionContent').slideUp('slow');
    });
});
function recordFaqClick(faqID) {
    $.getJSON(faqAccoridonProps.faqClick, { id: faqID, rand: new Date().getTime() });
}
function expandOnOpen(hid) {
    var hdr = '.' + hid + ' a.accordionHdrLink';
    $(hdr).toggleClass("open");
    var h = $(hdr).siblings(".accordionContent").html();
    $(hdr).siblings(".accordionContentFix").html(h);
    $(hdr).siblings("div").slideToggle(400);
    var top = $(hdr).parent().get(0).offsetTop;
    setTimeout(function() { $(window).scrollTo(top + 150, 800); }, 100);
}