/**
* Menu Toogle class. Displays and hides menus.
* 
* @author Stickerei Stoiber <info@stickerei-stoiber.de>
* @copyright Stickerei Stoiber <info@stickerei-stoiber.de>
*/

/**
* Menu toogle class.
*/
Toogle = {
	/*
	* The name of the container to be toogled
	*/
	TOOGLE_CONTENT_NAME : 'toogleContent',
	
	/*
	* The name of the element with the 'onclick' event handler to initiate the toogle operation
	*/
	TOOGLE_CONTROL_NAME : 'toogleControl',

	/*
	* Toogles the container visibility
	*/
	toogle : function(){
		switch($(this.TOOGLE_CONTENT_NAME).getStyle('display')){
			case 'none' :
				/*
				* Show the container
				*/
				Effect.toggle(this.TOOGLE_CONTENT_NAME, 'slide');
				break;
			case 'block' :		
				/*
				* Hide the container
				*/
				Effect.toggle(this.TOOGLE_CONTENT_NAME, 'slide');
				break;
		}
		
	},
		
	/*
	* Hides the container
	*/
	hide : function(){
		$(this.TOOGLE_CONTENT_NAME).setStyle({display: none});	
	},
	/*
	* Shows the container
	*/
	show : function(){
		$(this.TOOGLE_CONTENT_NAME).setStyle({display: block});
	},
	/**
	* The Drop menu toogle functions
	*/
	DropMenu : {
		/**
		* Holds the status of the TShirts menu 
		*/
		TShirtsMenuVisible : true,
		
		/**
		* Used to mark the menu controls for further reference
		*/
		markControls : function(){
			$$('a.mainlevel').each(function(s){
				if(s.innerHTML == '[+] T-Shirts'){
					s.writeAttribute('id', 'tShirtsMenuMarker');
					s.observe('click', function(){Toogle.DropMenu.toogleMenu('tshirts')});	
				}
			});
		},
		/**
		* Toogles the menu visibility
		*/
		toogleMenu : function(name){
			switch(name){
				case 'tshirts' :
					if(this.TShirtsMenuVisible == true){
						$('tShirtsMenuMarker').siblings().each(function(s){Effect.Fade(s,{duration: 1.0})});
						$('tShirtsMenuMarker').innerHTML = '[+] T-Shirts';
						this.TShirtsMenuVisible = false;
					} else {
						$('tShirtsMenuMarker').siblings().each(function(s){Effect.Appear(s,{duration: 1.0})});
						$('tShirtsMenuMarker').innerHTML = '[&#8722;] T-Shirts';
						this.TShirtsMenuVisible = true;
					}
					break;
			}
		}		
	},
	/**
	* Initiates the TShirtsMenu tooglers
	*/
	initDropMenus : function(){
		Toogle.DropMenu.markControls();
		Toogle.DropMenu.toogleMenu('tshirts');
	}
}