﻿//
// CollapsableContent.js
//

function initCollapse()
{   
        //hide the all of the element with class msg_body
        $(".msg_body").hide();
        $(".msg_body").addClass("collapsed_body");
        $(".msg_head").addClass("collapsed_head");
}

// controls the collapsable content boxes throughout the site
$(document).ready(function(){
    if ($(".msg_body") != null && $(".msg_head") != null){
        //hide the all of the element with class msg_body
        $(".msg_body").hide();
        $(".msg_body").addClass("collapsed_body");
        $(".msg_head").addClass("collapsed_head");
	    
        //toggle the componenet with class msg_body
        $(".msg_head").click(function(){
            if ($(this).next(".msg_body").hasClass("collapsed_body"))
            {
                $(this).next(".msg_body").slideToggle(100);
                $(this).next(".msg_body").removeClass("collapsed_body");
	            $(this).next(".msg_body").addClass("expanded_body");
	            $(this).removeClass("collapsed_head");
	            $(this).addClass("expanded_head");
            } 
            else
            {
                $(this).next(".msg_body").slideToggle(100);
	            $(this).next(".msg_body").addClass("collapsed_body");
	            $(this).next(".msg_body").removeClass("expanded_body");
	            $(this).removeClass("expanded_head");
	            $(this).addClass("collapsed_head");
            }
        });
    }
});
