var UEL;
if (!UEL) UEL = {};

//If not empty the message is displayed whenever UELDirect link is clicked (only when JavaScript is enabled).
UEL.UELDirectMessage = '';

//
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(.menu_Subsection)").each(function () {
				var $this = $(this);
				if ($this.children('.Current').size() < 1) {
					this.uel = {isOpen: false, menu: $this.children('.menu_Subsection')};
					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" />&nbsp;'
				});
			} 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();
