Delicious.Nav = new Class({
	Implements: [Events, Options],
	Binds: ['navClick'],
	
	options: {
		readyStandardClass: "not-mobile",
		mobileClass: "mobile",
		navId: "navBar",
		showClass: 'show'
	},
	
	initialize: function(o)
	{
		o = o || {};
		this.setOptions(o);
		this.element = $(this.options.navId);
		this.build();
	},
	
	build: function()
	{
		this.element.addEvent('click' , this.navClick);
		if (!this.browserIsMobile)
		{
			this.element.addClass(this.options.readyStandardClass);
		}
	},
	
	browserIsMobile: (function()
	{
		try
		{
			return navigator.userAgent.toLowerCase().match(/(mobile|webos|ios)/) || false;
		}
		catch(e)
		{
			return false;
		}
	})(),
	
	navClick: function(evt)
	{
		var el = $(evt.target);
		if (el.tagName.toLowerCase() == 'a' && !el.get('href'))
		{
			var li = el.getParent(),
				parent = li.getParent();
			parent.getChildren().each(function(ch) {
				if (ch != li && ch.hasClass(this.options.showClass))
				{
					ch.removeClass(this.options.showClass);
				}
			} , this);
			if (li.hasClass(this.options.showClass))
			{
				li.removeClass(this.options.showClass);
			}
			else
			{
				li.addClass(this.options.showClass);
			}
			
		}
	}
});

window.addEvent('domready', function() {
	window.fader = new Delicious.Nav();
});
