var UEL;
if (!UEL) UEL = {};

//If not empty the message is displayed whenever UELDirect link is clicked (only when JavaScript is enabled).
UEL.UELDirectMessage = '';

//
/* COF - UEL Direct Error Messages to be used as appropriate */
/* Please Note: We are currently experiencing problems with UEL Direct. IT Services are working to resolve this problem and we apologise for any inconvenience caused. */

/* Please Note: Due to high volume of users attempting to log in you may encounter difficulties logging into UEL Direct, please try again if you should encounter any problems. */

/* Please Note: Due to essential maintenance being carried out on the student records system, access will be restricted to WebCT, Web Mail and ECDL from 21:00 on Wednesday 19th October to 09:00 Monday 24 October 2005. Please accept our apologies for any inconvenience that this may cause. */

UEL.class_Menus =  function () {
	$(document).ready(function () {
		//UEL Direct
		if (UEL.UELDirectMessage != ''){
			$('#menu__UELDirect a').click(function(){
				alert(UEL.UELDirectMessage);
			});
		}
		//
		//var Art = $('#section_Artwork');
		//if (Art.text() == '') Art.click(function(){document.location = String(document.location);});
		//
		$("#menu_Section li:has(ul)").each(function () {
			var $this = $(this);
			if ($this.children('span').size() < 1) {
				this.uel = {
					isOpen: false,
					menu: $this.children('ul')
				};
				this.uel.menu.hide().removeClass('menu_Hidden');
				$this.addClass('CollapsiblePanelClosed').addClass('menu_Closed');
				$this.click(function () {
					var $this = $(this);
					this.uel.isOpen = !this.uel.isOpen;
					if (this.uel.isOpen) {
						this.uel.menu.show("fast");
						$this.removeClass('CollapsiblePanelClosed').removeClass('menu_Closed');
						$this.addClass('CollapsiblePanelOpen').addClass('menu_Open');
					} else {
						this.uel.menu.hide("fast");
						$this.removeClass('CollapsiblePanelOpen').removeClass('menu_Open');
						$this.addClass('CollapsiblePanelClosed').addClass('menu_Closed');
					}
					return true;
				});
			}
		});
		//initialise bookmark toolbar
		try {
			$('#menu__Bookmark').bookmark({
				compact: false,
				icons: '/_artwork/bookmarks.png',
				popup: true,
				addFavorite: true,
				sites: ['facebook', 'delicious', 'myspace', 'digg', 'live', 'google', 'reddit'],
				popupText: '<img src="/_artwork/bookmark_placeholder.gif" width="125" height="16" align="absbottom" alt="Bookmark this page" /> '
			});
		} catch (e) {
		}
		//
		try {
			if (spry_Tabs != null) {
				var Anchor = String(document.location);
				Anchor = Anchor.substr(Anchor.indexOf('#'));
				var parent = $('.TabbedPanelsContent:has(a'+Anchor+')');
				var i = parent.parent().children().index( parent );
				if (i >=0) spry_Tabs.showPanel(i);
			}
		} catch (e) {
		}
	});
}
if (!UEL.Menus) UEL.Menus = new UEL.class_Menus();

