﻿// only fire event when document has finished loading
$(document).ready(function() {



    /*
    *   Appointment Register report listing
    */
    if ($(".toggle")) {
        // set default hr in sub listing to hide
        $(".toggle .pad .toggleshow div.hr").hide();
        $(".archivedate .toggleshow div.hr").hide();
    }

    if ($("a.arrow_expand")) {
        $("a.arrow_expand").click(function() {
            $(this).parent().parent().next(".toggle").toggle();

            // swap class to change arrow
            $(this).toggleClass("arrow_expand");
            $(this).toggleClass("arrow_close");

            if ($(this).hasClass("arrow_expand")) {
                $(this).text(" [expand] "); //change text on arrow changed
                $(this).parent().prev("div.hr").hide();
                $(this).parent().next("h3").toggleClass("jobs-expand");
                $(this).parent().next("h3").toggleClass("jobs");
            }
            else if ($(this).hasClass("arrow_close")) {
                $(this).text(" [close] "); //change text on arrow changed
                $(this).parent().prev("div.hr").show();
                $(this).parent().next("h3").toggleClass("jobs-expand");
                $(this).parent().next("h3").toggleClass("jobs");
            }
        });
    }

});
