/**
* jquery functions
*/

/**
* expand/collapse a div.
* The id of the button to expand collapse should end in "Toggle"
* the id of the area to expand/collapse should have the same name but end
* in "Data"
*/
function ExpandCollapse()
{
	// get the id of the div that contains the extended comment
	var blockId = this.id.replace(/Toggle/, "");
	if($("#" + blockId + "Data:visible").length > 0)
	{
		$("#" + blockId + "Data").collapseSection("#" + blockId);
	}
	else
	{
		$("#" + blockId + "Data").expandSection("#" + blockId);
	}
}

/**
* collapse a block using jquery
*/
$.fn.collapseSection = function(id) {
		return this.each(function(){

				if($(id).length > 0)
				{
					$(id).removeClass("activeHeader");
				}

				if($(id + "Toggle").length > 0)
				{
					//alert("toggle length: " + $(id + "Toggle").length);
					$(id + "Toggle").removeClass("menuLinkExpanded");
				}

				if($(id + "Data:visible").length > 0)
				{
					$(id + "Data:visible").slideUp("fast");
				}
		});
};

/**
* expand a block using jquery
*/
$.fn.expandSection = function(id) {
		return this.each(function(){
				if($(id).length > 0)
				{
					$(id).addClass("activeHeader");
				}

				if($(id + "Toggle").length > 0)
				{
					$(id + "Toggle").addClass("menuLinkExpanded");
				}

				if($(id + "Data").length > 0)
				{
					$(id + "Data").slideDown("slow");
				}
		});
};
