var CT;
if (!CT) CT = {};

//If not empty the message is displayed whenever CTG Direct link is clicked (only when JavaScript is enabled).
CT.CTGMessage = '';

//
/* CT Direct Error Messages to be used as appropriate */

CT.class_Menus =  function () {
	$(document).ready(function () {
		//CT Direct
		if (CT.CTGMessage != ''){
			$('#menu_CTGDirect a').click(function(){
				alert(CT.CTGMessage);
			});
		}
		
		$("#institution_menu li:has(.institution_menu_sub)").each(function () {
			var $this = $(this);
			if ($this.children('.Current').size() < 1) {
				this.ctg = {
					isOpen: true,
					menu: $this.children('.institution_menu_sub')
				};
				this.ctg.menu.hide().removeClass('menu_Hidden');
				$this.addClass('CollapsiblePanelClosed').addClass('menu_Closed');
				$this.click(function () {
					var $this = $(this);
					this.ctg.isOpen = !this.ctg.isOpen;
					if (this.ctg.isOpen) {
						this.ctg.menu.show("fast");
						$this.removeClass('CollapsiblePanelClosed').removeClass('menu_Closed');
						$this.addClass('CollapsiblePanelOpen').addClass('menu_Open');
					} else {
						this.ctg.menu.hide("fast");
						$this.removeClass('CollapsiblePanelOpen').removeClass('menu_Open');
						$this.addClass('CollapsiblePanelClosed').addClass('menu_Closed');
					}
					return true;
				});
			}
		});
	
	});
}
if (!CT.Menus) CT.Menus = new CT.class_Menus();
