function showMenu(){this.init.apply(this,arguments)};
showMenu.prototype = {
	init:function(nav,sub){
		var menus = this.getId(nav).getElementsByTagName('li');
		var _this = this;
		menus[8].className = 'nobg'; //=======	
		
		for(var i=0,len=menus.length; i<len; i++){
			(function(i){
				menus[i].onmouseover = function(){
				 // _this.addClass(this,'over');
				  menus[i].className ='over'
				  if(i>=1){
				  menus[i-1].className = 'nobg'; //=======	
				  }
				  menus[8].className = 'nobg'; //=======	
					var index = menus[i].getAttribute('id').replace(/[^\d]+/,'');
					var submenu = _this.getId(sub+index);
					var it = this;
					if(!submenu) return;
					submenu.style.display = 'block';
					submenu.style.left = this.offsetLeft + 'px';
				 // _this.addClass(this,'over');
				  menus[i].className ='over'
					submenu.onmouseover = function(){
						_this.addClass(it,'over');
				 		menus[i-1].className = 'nobg'; //=======	
						this.style.display = 'block';
					}
					submenu.onmouseout = function(){
						_this.removeClass(it,'over');
						 menus[i-1].className = ''; //=======	
						this.style.display = 'none';
					}
				}
				menus[i].onmouseout = function(){
					  
					  menus[i].className = ''; //=======	
				  if(i>=1){
					  menus[i-1].className = ''; //=======	
				  }
				      menus[8].className = 'nobg'; //=======	
					  
					var index = menus[i].getAttribute('id').replace(/[^\d]+/,'');
					_this.removeClass(this,'over');
					var submenu = _this.getId(sub+index);
						if(!submenu) return;
						submenu.style.display = 'none';
				}
			})(i);
		}
	},
	getId:function(el){
		return typeof el == 'string' ? document.getElementById(el) : el;
	},
	addClass:function(el,oClass){
		var old = el.className;
		el.className = old ?  old + ' ' + oClass : oClass;
	},
	removeClass:function(el,oClass){
		var old = el.className;
		el.className = (' ' + old + ' ').replace(' '+oClass+' ','');
	}
}
function skyaddEvent(el,type,fn){
	if(el.addEventListener){
		el.addEventListener(type,fn,false);
	}else if(el.attachEvent){
		el.attachEvent('on'+type,function(){
			fn.call(el,window.event);
		});
	}
}

skyaddEvent(window,'load',function(){
	var showSub = new showMenu('navigator','sub');
})

