/**
 * The Syn.Nav Component Class 
 */
/**
 * Create a Syn.Nav component instance 
 * @constructor
 */
Syn.Nav = Syn.Component.extend(
{
	/**
	 * Initialize the component class. This is called automatically by the default constructor.
	 * @member Syn.Nav
	 * @param {Object} config The configuration data structure
	 */
	init: function(config)
	{
		this._super(config);
		this.find('.sub_nav > li').connect("mouseover", this, "overSecondaryNav");
		this.find('.sub_nav > li').connect("mouseout", this, "outSecondaryNav");
		this.find('.ter_nav').connect("mouseover", this, "overTerNav");
		this.find('.ter_nav').connect("mouseout", this, "outTerNav");
		this.uniqueElmt('morelabel').connect("mouseover", this, "moreLabelOver");
		this.uniqueElmt('morelabel').find('a').connect("click", this, function(){return false;});
		this.uniqueElmt('morelabel').connect("mouseout", this, "moreLabelOut");
		this.uniqueElmt('morecontainer').connect("mouseover", this, "overMoreContainer");
		this.uniqueElmt('morecontainer').connect("mouseout", this, "outMoreContainer");
		this.find('.noaction').click(function()
		{
			return false;
		});
	},
	
	overSecondaryNav: function(dom, event)
	{
		this.showTerNav($(dom).find('>a').next());
	},
	
	outSecondaryNav: function(dom, event)
	{
		this.hideTerNav($(dom).find('>a').next());
	},
	
	overTerNav: function(dom, event)
	{
		this.showTerNav(dom);
	},
	
	outTerNav: function(dom, event)
	{
		this.hideTerNav(dom);
	},
	
	moreLabelOver: function(dom, event)
	{
		this.showMoreNav();
	},
	
	moreLabelOut: function(dom, event)
	{
		this.hideMoreNav();
	},

	overMoreContainer: function(dom, event)
	{
		this.showMoreNav();
	},
	
	outMoreContainer: function(dom, event)
	{
		this.hideMoreNav();
	},
	
	showTerNav: function(dom)
	{
		if (this.terNavTimer)
		{
			clearTimeout(this.terNavTimer);
		}
		this.find('.sub_nav .ter_nav').hide();
		$(dom).show();
	},

	hideTerNav: function(dom)
	{
		this.terNavTimer = setTimeout(function()
		{
			$(dom).hide();
		}, 200);		
	},

	showMoreNav: function()
	{
		if (this.moreNavTimer)
		{
			clearTimeout(this.moreNavTimer);
		}
		this.uniqueElmt("morelabel").addClass('on');
		this.uniqueElmt('morecontainer').show();		
	},

	hideMoreNav: function()
	{
		var self = this;
		this.moreNavTimer = setTimeout(function()
		{
			self.uniqueElmt("morelabel").removeClass('on');
			self.uniqueElmt('morecontainer').hide();
		}, 200);	
	}
});
;
