
$(document).ready(function () {

    /* https://github.com/ginader/Accessible-Tabs */
    /* build Looking For Something Specific tabs */
    $('.looking-for-something-specific-tabs').accessibleTabs({
        tabhead: 'h3',
        currentClass: 'active',
        wrapperClass: 'tabs-content',
        fx: 'show',
        fxspeed: null
    });

    $(".looking-for-something-specific-tabs").showAccessibleTab($("#ctl00_ContentPlaceHolder1_uctabsearchList_hfSelectedTab").val());
    $(".looking-for-something-specific-tabs").showAccessibleTab
    ($("#ctl00_ContentPlaceHolder1_hfSelectedTab").val());
    $(".looking-for-something-specific-tabs").showAccessibleTab($("#ctl00_ContentPlaceHolder1_ucTabList_hfSelectedTab").val());

    /* set equal heights on Looking For Something Sepcific tabs*/
    $('.looking-for-something-specific-tabs ul.tabs-list li a').height($(".looking-for-something-specific-tabs ul.tabs-list").height() - 22);
    /*Added BG to make active tab alittle taller */
    /*$('.looking-for-something-specific-tabs ul.tabs-list li.active a').height($(".looking-for-something-specific-tabs ul.tabs-list").height() - 28);*/

    $('.looking-for-something-specific-tabs ul.tabs-list li:last-child').addClass('last');

    /* build Our Review Process tabs */
    $('.our-review-process-tabs').accessibleTabs({
        tabhead: 'h3',
        currentClass: 'active',
        wrapperClass: 'tabs-content',
        fx: 'show',
        fxspeed: null
    });

    /* add special classes for styling to Our Review Process tabs */
    $('.our-review-process-tabs ul.tabs-list li:first-child').addClass('first');
    $('.our-review-process-tabs ul.tabs-list li:last-child').addClass('last');
    $(".our-review-process-tabs ul.tabs-list li.active + li").addClass('nextto');

    /* move 'nextto' class when a new Our Review Process tab becomes active */
    $(".our-review-process-tabs ul.tabs-list li a").click(function () {
        $(".our-review-process-tabs ul.tabs-list li").removeClass('nextto');
        $(".our-review-process-tabs ul.tabs-list li.active + li").addClass('nextto');
    });

    /* form input placeholder fix for browsers that do not support placeholder="" */
    $('input, textarea').placeholder();

    /* vertical centering fix for IE7.  IE7 does not support display: table-cell, so the elements are wrapped in
    a table to allow vertical centering. This, and the accompanying css exceptions (which are commented and begin 
    with class 'html.lte7') are unnecessary if only IE8+ support is needed */
    if ($('html').hasClass('lte7')) {
        $('#navigation ul li a').wrap('<table><tr><td></td></tr></table>');
        $('section.box footer .footer-inner').wrapInner('<table><tr><td></td></tr></table>');
        $('section.box footer.page .footer-inner table').addClass('fullwidth');
        $('div.topic-box').wrapInner('<table><tr></tr></table>');
        $('div.topic-box a').wrapInner('<td></td>');
        $('div.process-numeral').wrapInner('<table><tr><td></td></tr></table>');
        $('div.process-desc').wrapInner('<table><tr><td></td></tr></table>');
        $('button.more.toggle').wrapInner('<table><tr><td></td></tr></table>');
    };

    if ($('html').hasClass('lte8')) {
        $('#navigation ul li:last-child').addClass('last');
        $('aside .effectiveness-rating table th:last-child,aside .effectiveness-rating table td:last-child').addClass('last');
    };

    /* heights of local navigation offset border */
    $('#local-navigation-border').height($("#local-navigation").height());
    $('#local-navigation-section').height($("#local-navigation").height() + 12);

    /* set equal heights on all boxes in recently viewed area */
    $('section.box.recently-viewed ul li').height($("section.box.recently-viewed ul").height());
    $('section.box.recently-viewed header').height($("section.box.recently-viewed ul").height() - 35);

    /* buttons that hide/show content */
    $('button.toggle').addClass('closed');
    $('button.toggle').click(function () {
        if ($(this).hasClass('open')) {
            $(this).removeClass('open');
            $(this).addClass('closed');
        } else {
            $(this).removeClass('closed');
            $(this).addClass('open');
        }
        $(this).blur();
    });

    /* Looking For Something Specific advanced filters */
    if (!($('input[id$=hidToggleState]').val() == 'open')) {
        $('.looking-for-something-specific-filters').hide();
        $('input[id$=hidToggleState]').val('closed');
    }
    //	$('#looking-for-something-specific-forms-container .advanced-search').click(function(){
    //		$('#looking-for-something-specific-filters').slideToggle();
    //	});
    $('#looking-for-something-specific-forms-container .advanced-search').click(function () {
        $('.looking-for-something-specific-filters').slideToggle();
        if ($('input[id$=hidToggleState]').val() == 'open')
        { $('input[id$=hidToggleState]').val('closed'); }
        else
        { $('input[id$=hidToggleState]').val('open'); }

    });

    /* toggles non-summary text 
    $('section p.more').hide();
    $('section .more.toggle').click(function(){
    $(this).siblings('p.more').slideToggle();	
    if ($(this).hasClass('open')) {
    $(this).children('span').replaceWith('<span>Less</span>');
    } 
    if ($(this).hasClass('closed')) {
    $(this).children('span').replaceWith('<span>More</span>');
    }
    });*/

    /* toggles non-summary text */
    $('section div.more').hide();
    $('section .more.toggle').click(function () {
        $(this).siblings('div.more').slideToggle();
        if ($(this).hasClass('open')) {

            $(this).removeClass('open');
            $(this).addClass('closed');

            if ($(this).hasClass('fewer')) {
                $(this).children('span.togg').replaceWith('<span class="togg">Fewer</span>');
            }
            else {
                $(this).removeClass('closed');
                $(this).addClass('open');
                $(this).children('span.togg').replaceWith('<span class="togg">Less</span>');
            }

        }
        if ($(this).hasClass('closed')) {
            $(this).children('span.togg').replaceWith('<span class="togg">More</span>');
        }
        return false;
    });


    $('.area:odd').addClass('even');
    $('.area:even').addClass('odd');
    $('.area:first-child').addClass('first');
    $('.area:last-child').addClass('last');

    //IE opens the page at a scroll position below the top. This scrolls it back up.
    if ($('html').hasClass('lte8')) {
        $(this).scrollTop($('div#pagetop').position().top)
    }
});


	

