jQuery(document).ready(function () { // setup accord jQuery(".fsj div.accord").accord(); // if page is accessed using a # then expand any sections to expose that and ensure its visible try { var hash = window.location.hash; hash = hash.replace("#faq_", ""); var el = jQuery('div[faq_id="' + hash + '"]'); fsj_faqs_show_accordion(el); // better version of scrolling into view needed here! jQuery('html,body').animate({ scrollTop: jQuery('a[name="faq_' + hash + '"]').offset().top }); } catch (e) { } // when expanding an faq, set the # so it can easliy be linked to jQuery('.accord').on('show', function () { var faq = jQuery(this).attr('faq_id'); if (faq) { var hash = '#faq_' + faq; if (history.replaceState) { history.replaceState(undefined, undefined, hash); } else if (history.pushState) { history.pushState(null, null, hash); } } }) // set up expand and contract all buttons jQuery('.fsj_faqs_expand_all').click(function (ev) { ev.preventDefault(); jQuery.Accord.showAll('.fsj'); }); // set up expand and contract all buttons jQuery('.fsj_faqs_close_all').click(function (ev) { ev.preventDefault(); jQuery.Accord.hideAll('.fsj'); }); }); function fsj_faqs_show_accordion(el) { if (el.hasClass('accord')) el.accord("show"); if (el.parent().length > 0) fsj_faqs_show_accordion(el.parent()); }