function DropMenu(_Settings){

	this.X = 0
	this.Y = 0
	this.Id = _Settings['id']
	this.PId = _Settings['pid']
	this.PointStyle = _Settings['PointStyle']
	this.PointOverStyle = _Settings['PointOverStyle']
	this.Settings = _Settings
	this.Points = new Array()
	this.Delay = 1000;
	this.TimoutCounter = 0
	
	if(this.Settings['GroupID']){
		
		if(!window.DropMenuActiveInGroup){
			
			window.DropMenuActiveInGroup = new Array(0)
		}
	}
	
	this.ParentObj = document.getElementById(_Settings['pid'])
	
	this.ParentObj.DropMenuID = this;
	if(_Settings['show']=='onclick'){
		
		this.ParentObj.onclick = function(){
			
			this.DropMenuID.display(true)
		}
	}else{
		this.ParentObj.onmouseover = function(){
			
			this.DropMenuID.display(true)
		}
	}
	this.ParentObj.onmouseout = function(){
		
		this.DropMenuID.delayedHide()
	}

	if(!window.dropMenuCollection){
		
		window.dropMenuCollection = new Array(0)
	}
	window.dropMenuCollection[this.Id] = this
	
	/*
		добавление пункта меню
			_title 		- отображаемое имя пункта
			_href		- ссылка для перехода при клике на пункте
	*/
	this.addPoint = function(_Point){
		
		var NewInd = this.Points.length
//		_Point['title'] = _Point['title'].replace(/ /g,'&nbsp;')
		this.Points[NewInd] = _Point
		return NewInd
	}
	
	this.setPointAttribute = function(_PointInd, _AttributeName, _AttributeValue){
		
		this.Points[_PointInd][_AttributeName] = _AttributeValue
	}
	
	/*
		инициализирует меню, т.е. создает его
	*/
	this.init = function(){
		
		var obj = document.createElement('div')
		document.body.appendChild(obj)
		obj.id = this.Id
		obj.className = this.Settings['StyleClass'];
		obj.style.position = "absolute"
		obj.style.visibility = "hidden"
		obj.style.top = '-1000px';
		obj.style.left = '-1000px';
		obj.style.cursor = 'default'
		
		obj.DropMenuID = this
		obj.onmouseover = function(){
			
			this.DropMenuID.display(true)
		}
		obj.onmouseout = function(){
			
			this.DropMenuID.display(false);
//			this.DropMenuID.delayedHide()
		}

		for(i=0; i<this.Points.length; i++){
			
			var point = document.createElement('div')
			obj.appendChild(point)
			point.innerHTML = this.Points[i].title;
			point.setAttribute('redirect', this.Points[i].href);
			if(this.Points[i].onclick){
				
				point.setAttribute('pointonclick', this.Points[i].onclick);
			}
			point.setAttribute('pointstyle', this.PointStyle);
			point.setAttribute('pointoverstyle', this.PointOverStyle);
			point.onclick = function(){
				
				if(this.getAttribute('pointonclick')){
					
					var v_return = true;
					eval(this.getAttribute('pointonclick'))
					if(!v_return)return false
				}
				document.location.href = this.getAttribute('redirect');
				return false;
			}
			point.onmouseover = function(){
				
				this.className = this.getAttribute('pointoverstyle')
			}
			point.onmouseout = function(){
				
				this.className = this.getAttribute('pointstyle')
			}
			point.className = point.getAttribute('pointstyle')
			
			if((i+1)<this.Points.length){
				
				var divider = document.createElement('div')
				obj.appendChild(divider)
				divider.className = this.Settings['PointsDivider'];
			}
		}
	}
	
	this.getLeftTop = function (p){
		
		gx=0;gy=0;
		while (p&&p.offsetParent){
			gx+=p.offsetLeft;
			gy+=p.offsetTop;
			p=p.offsetParent;
		}
		gx+=p.offsetLeft;
		gy+=p.offsetTop;
		coord=Array(gx,gy);
		return coord;
	}
	/*
		отображение или скрытие меню
			_state = true 	- показывает меню
			_state = false 	- скрывает меню
	*/
	this.display = function(_state){
		
		var obj = document.getElementById(this.Id);
		
		if(!obj){
			this.init();
			obj = document.getElementById(this.Id);
		}
		
			var pobj = document.getElementById(this.PId);
			coord=this.getLeftTop(this.ParentObj);
			obj.style.left = coord[0]+'px';
			obj.style.top = (coord[1]+pobj.offsetHeight-1)+'px';
			this.X = obj.style.left
			this.Y = obj.style.top
		
		if(_state){
			
			this.TimoutCounter++
			obj.style.visibility = 'visible';
			if(window.DropMenuActiveInGroup[this.Settings['GroupID']]){
				
				if(window.DropMenuActiveInGroup[this.Settings['GroupID']].Id != this.Id)
					window.DropMenuActiveInGroup[this.Settings['GroupID']].display(false);
			}
			window.DropMenuActiveInGroup[this.Settings['GroupID']] = this
		}else{
			
			obj.style.visibility = 'hidden';
		}
	}

	/*
		скрывает меню с задержкой
	*/
	this.delayedHide = function(){
		
		window.setTimeout('window.HideByID(\''+this.Id+'\')', this.Delay)
	}
	
	window.HideByID = function(_ID){
		
		_OBJ = window.dropMenuCollection[_ID]
		if(_OBJ.TimoutCounter<=1){
			
			_OBJ.display(false)
		}
		_OBJ.TimoutCounter--
	}
}