﻿$(document).ready(function() {
    /***********************
    Collapsible panels 
    ***********************/
    
    // Site map
    $('#sitemap_cols').masonry({
        singleMode: true,
        columnWidth: 170,
        itemSelector: '.box'
    });

    $('h2.trigger').collapser({
        target: '#sitemap_toggle_container',
        targetOnly: '#sitemap_toggle_container',
        changeText: false,
        effect: 'fade'
    }, function() {
        if ($("#sitemap_toggle_container:visible").length === 0) {
            $("h2.trigger > img").attr("src", "/assets/images/buttons/sitemap.gif");
        }
        else {
            $("h2.trigger > img").attr("src", "/assets/images/buttons/sitemap_across.gif");
        }
    }, function() {
    });

    // Counties
    $('#countylinks_cols').masonry({
        singleMode: true,
        columnWidth: 225,
        itemSelector: '.countybox'
    });

    $('h2.county_trigger').collapser({
        target: '#countylinks_toggle_container',
        targetOnly: '#countylinks_toggle_container',
        changeText: false,
        effect: 'fade'
    }, function() {
        if ($("#countylinks_toggle_container:visible").length === 0) {
            $("h2.county_trigger > img").attr("src", "/assets/images/buttons/counties_down.gif");
        }
        else {
            $("h2.county_trigger > img").attr("src", "/assets/images/buttons/counties_up.gif");
        }
    }, function() {
    });

    $("#countylinks_toggle_container").hide();

    // Towns
    $('#townlinks_cols').masonry({
        singleMode: true,
        columnWidth: 225,
        itemSelector: '.townbox'
    });

    $('h2.town_trigger').collapser({
        target: '#townlinks_toggle_container',
        targetOnly: '#townlinks_toggle_container',
        changeText: false,
        effect: 'fade'
    }, function() {
        if ($("#townlinks_toggle_container:visible").length === 0) {
            $("h2.town_trigger > img").attr("src", "/assets/images/buttons/towns_down.gif");
        }
        else {
            $("h2.town_trigger > img").attr("src", "/assets/images/buttons/towns_up.gif");
        }
    }, function() {
    });

    $("#townlinks_toggle_container").hide();

});
