createClass(
	'Menu.Main',
	function(options){

		var me 			= this;
		var defOptions 	= { timeout	: 2000 };
		this.options 	= $.extend(defOptions, options);
		
		//console.log('Menu options', this.options);
		
		$(this.options.submenu).each(function(idx, el){
			me.submenus.push(new Menu.Submenu(me, el));
		});
		
		//$('.sub_hld', this.options.submenu).bgiframe();
		//$('body').click(function(ev){return me.onClickOutside(this, ev);});
	},
	{
		timer			: null,
		options			: null,// timeout, submenu
		submenus		: [],
		onClickOutside					: function(sender, ev){
			this.rollUpAll();
		},
		rollUpAll						: function(){
			for(i in this.submenus){
				var s = this.submenus[i];
				s.rollUpAll();
			}
		}
	}
);

createClass(
	'Menu.Submenu',
	function(parentObj, el){
		var me 				= this;
		this.submenuElement = $(el); 
		this.timer			= null;
		this.timeout		= parentObj.options.timeout;
		
		$('.item, .item_spec', this.submenuElement ).each(function(idx, el){
			me.subElements.push(new Menu.SubmenuItem(me, el));
		});
		
	},
	{
		parent			: null,		
		submenuElement	: null,
		subElements		: [],
		
		rollUpAll		: function(){
			for(i in this.subElements){
				this.subElements[i].rollUp();
			}
		}
	}
);

createClass(
	'Menu.SubmenuItem',
	function(parent, el){
		
		var me 			= this;
		this.container 	= parent;
		this.element 	= $(el);
		
		var config = {    
		     sensitivity	: 2,    
		     interval		: 0,    
		     over			: function(ev){return me.rollDown(this, me);},    
		     timeout		: parent.timeout,    
		     out			: function(ev){return me.rollUp(this, me);}    
		};

		this.element.hoverIntent( config );

	},
	{
		rollDown			: function(){
			this.container.rollUpAll();
			$('.sub_hld', this.element).show();
		},
		rollUp			: function(){
			$('.sub_hld', this.element).hide();
		}
	}
);
/*
$(function(o){
	window.hmenu = new Menu.Main({
		submenu				: $('#submenu, #quickmenu'),
		timeout				: 1000
	});
});*/
//	console.log(window.hmenu);
