var SubmenuLayer = Class.create (
{
	moving:false,
	visible:false,
	layerId:'submenuLayer',
	currentContentId : '',
	newContentId : '',
	swapContent : false,
	initialize: function()
	{

	},
	show : function (newContentId)
	{
		
		if (!$(this.layerId)) return;
		
			
		if (this.visible) return;	 

		this.visible = true;
		this.moving = true;

		
	
	/*
	//schovanie active-x komponentov v IE6, aby neboli stale zobrazene
	isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	if (isIE6)
	{
		$$('#product_list_filter select').each(function(e) {e.style.visibility='hidden';});	
	}
	*/
	
	
	Effect.SlideDown(this.layerId,{ duration: 0.4, afterFinish: function() {
				  this.moving = false;				
				  }.bind(this)});
	
	
	},
	hide : function (newContentId)
	{
		if (!this.visible) return;
		this.moving = true;
		
		
		Effect.SlideUp(this.layerId,{ duration: 0.4, afterFinish: function() {
					  this.visible = false;	
					  this.moving = false;	
						 /* //zobrazenie active-x komponentov v IE6, aby neboli stale zobrazene
						  isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
						  if (isIE6)
						  {
								$$('#product_list_filter select').each(function(e) {e.style.visibility='visible';});
						  }*/
					 this.callback();	  
					  }.bind(this)});
	
	
	},
	toggle :function (newContentId)
	{
		if (!this.moving && !this.visible)
		{
			if (this.currentContentId == '' || this.currentContentId != newContentId) 
			{
				this.currentContentId = newContentId;				
				$(this.currentContentId).show();
			}
			
			this.show(newContentId);
		}
		if (!this.moving && this.visible)
		{
			if (newContentId != this.currentContentId)
			{
				this.swapContent = true;
				this.newContentId = newContentId;
			}
			
			this.hide(newContentId);
			
		}
	},
   	callback: function()
	{
		if (this.swapContent) 
		{
			//schovat aktivny zobrazit novy
			$(this.currentContentId).hide();
			$(this.newContentId).show();
			this.swapContent = false;
			this.toggle(this.newContentId);
		}
		else
		{
			if($(this.currentContentId)) $(this.currentContentId).hide();
			this.currentContentId = '';
			if($(this.newContentId)) $(this.newContentId).hide();
			this.newContentId = '';
		}
	}
	
	
});




var submenuLayer;

Event.observe(window, 'load', function() 
	{
		submenuLayer = new SubmenuLayer();
	}
);
