Effect.QueueThis = Class.create();
Object.extend( Object.extend( Effect.QueueThis.prototype, Effect.Base.prototype ), {
    initialize: function(element) {
        this.element = $(element);
        this.func = arguments[1];
        this.start(arguments[2]);
    },
    finish: function(position){
        this.func(this.element);
    }
});

function toggleBar(parent) {
	if ($(parent).style.display == "") {
		$('toggleButton').innerHTML = '+';
		$('toggleButton').title = 'Show Navigation Menu...';
		new Effect.SlideUp(parent, { duration: 0.3, queue: { position: "end", scope: "myQueue" } } );
		new Effect.QueueThis( 
			parent, 
			function () {
				$(parent).style.display = 'none';
			},
			{ queue: {position: "start", scope: "myQueue"} }
		);	
	} else {
		$('toggleButton').innerHTML = '-';
		$('toggleButton').title = 'Hide Navigation Menu...';
		new Effect.SlideDown(parent, { duration: 1, queue: { position: "end", scope: "myQueue" } } );
		new Effect.QueueThis( 
			parent, 
			function () {
				$(parent).style.display = '';
			},
			{ queue: {position: "start", scope: "myQueue"} }
		);	
	}
}

function subMenuToggle(parent, child) {
	child = parent+'-'+child;
	new Effect.BlindUp(parent, { queue: { position: "end", scope: "myQueue" } } );
	new Effect.QueueThis(
		parent,
		function () {
			var parentNodes = $(parent).getElementsByTagName('div');
			var nodeList = $A(parentNodes);
			nodeList.each(
					function(node) {
						if ( node.style.display == "" ) {
							node.style.display = "none";
						}
					}
				);
			$(child).style.display = '';
			new Effect.BlindDown(parent);
		},
		{ queue: {position: "start", scope: "myQueue"} }
	);
}