﻿/*expandable faq modules*/   
$('.content dl.faq').each(function(idx)
{
    $('dt a', this).click(function(evt)
    {
        evt.preventDefault();
        
        var elm = $(this);
        var nextElm = elm.parent().next();
        if (!nextElm.hasClass('show'))
        {
            nextElm.addClass('show').show('fast');
        }
        else
        {
            nextElm.removeClass('show').hide('fast');
        }
        
        elm.parent().find('> a').each(function(idx)
        {
            if (!$(this).parent().next().hasClass('show'))
            {		    
                $(this).removeClass('selected'); 
            }
            else
            {		               
                $(this).addClass('selected');
            }		           
        });
    });
    
    //setup faq expand/collapse buttons
    $('.expand', this).click(function(evt)
    {	        
        evt.preventDefault();

        var section = $(this).parent().parent().parent();
        section = ($(section).attr('class') === 'faq')? $(section).children() : $(section).parent().children();
        $(section).each(function(idx)
        {		                
            var elm = $(this);
            if (elm.hasClass('a'))
            {
                elm.addClass('show');		                    
            }
            else if ($(this).hasClass('q'))
            {
                elm.children().addClass('selected');
            }
        });
    });

    $('.collapse', this).click(function(evt)
    {	        
        evt.preventDefault();
        
        var section = $(this).parent().parent().parent();
        section = ($(section).attr('class') === 'faq')? $(section).children() : $(section).parent().children();
        $(section).each(function(idx)
        {
            var elm = $(this);
            if (elm.hasClass('a'))
            {
                elm.removeClass('show');		                    
            }
            else if (elm.hasClass('q'))
            {
                elm.children().removeClass('selected');
            }
        });
    });
});

if (window.faqId)
{
    location.hash = "#" + window.faqId;
    $('.q a[name="'+window.faqId+'"]').click();
}

