$().ready(function(){
			
	$("table[id^='submenu']").each(function(){
		this.style.display ="none";
		this.style.position="absolute";
		this.style.zIndex="100";
		this.style.top="0";
		this.style.left="0";
		menu_id    = this.id.substr(7,1);
		aux        = this.id.split('_')
		submenu_id = aux[1];
		
		
		menu        = $("#menu" + menu_id);

		var td      = $("table#menu"+menu_id+" td").get(submenu_id -1 );
		
		
		//var submenu = $("table[id^='submenu"+menu_id+"']").get(submenu_id -1)
		var submenu = this;
		
		//ADJUST
		top_adjust  = 0;
		left_adjust = -10;
		//END
		
		$(td).mouseenter(function(){
			off_td = $(this).offset();
			w_table = $(menu).width();
			h_table = $(menu).height();	

			$(submenu).css({display:"block", 
						   top:off_td.top + h_table + top_adjust ,
						   left: off_td.left + left_adjust })
			
		})
		
		$(submenu).mouseenter(function(){
			off_td = $(td).offset();
			w_table = $(menu).width();
			h_table = $(menu).height();			
			$(submenu).css({display:"block",
						   top:off_td.top + h_table + top_adjust,
						   left: off_td.left + left_adjust})
			
		})
		
		
		$(td).mouseleave(function(){
			off_td = $(this).offset();
			w_table = $(menu).width();
			h_table = $(menu).height();			
			$(submenu).css({display:"none",
						   top:0,
						   left: w_table + off_td.left-5})
			
		})
		
		$(submenu).mouseleave(function(){
			off_td = $(td).offset();
			w_table = $(menu).width();
			h_table = $(menu).height();			
			$(submenu).css({display:"none",
						   top:0,
						   left: w_table + off_td.left-5})
			
		})				
	})	
})




