	function MENU()
	{	
		this.arrListData =Array();
		this.arrData = Array();
		this.addListXML = function(xml)
		{
			var child = xml.childNodes;		
			
			for (i = 0; i < child.length; i++)
			{				
				this.add(child[i].getAttribute('id'),(child[i].getAttribute('image') == 'null'?null:'<img style="border:none" src="'+child[i].getAttribute('image')+'"/>'),(child[i].getAttribute('name') == 'null'?'noname':child[i].getAttribute('name')),(child[i].getAttribute('href') == 'null'?null:child[i].getAttribute('href')),(child[i].getAttribute('target') == 'null'?null:child[i].getAttribute('target')),child[i].getAttribute('title'),child[i].getAttribute('level'),child[i].getAttribute('position'));						
			}		
		}
		
		this.add = function(id,image,name,href,target,title,level,position)
		{		
			if (name == "Навигация") this.i++
			this.arrListData.push({
				'id':id,
				'image':image,
				'name':name,
				'href':href,
				'target':target,
				'title':title,
				'level':level,
				'position':position				
			});							
		}
		this.create = function(elementById,nodeProperties,prefix,hideType,expandLevel)
		{
			if (this.arrListData.length > 0)
			{
				var tempArray = new Array();
				for(var i = 0; i < this.arrListData.length; i++)
				{
					if(!tempArray[this.arrListData[i].level]) tempArray[this.arrListData[i].level] = new Array();
					tempArray[this.arrListData[i].level][tempArray[this.arrListData[i].level].length] = this.arrListData[i];
				}			
						
				for(var i = 0; i < tempArray.length; i++) if (tempArray[i]) tempArray[i] = this.sortArray(tempArray[i]);
				this.arrData = this.buildTreeArray(0,tempArray);					
				ctDraw (elementById,this.arrData,nodeProperties,prefix,hideType,expandLevel);
			}
			
			if(ctExposeItem(0,window.location.href))
			{				
				ctExposeItem(0,window.location.href).className = "ThemeXPRowSelected";
			}
		}		
		this.buildTreeArray = function(iIndex,fullArray)
		{	
			var temp = new Array();
			//alert(fullArray[iIndex].length);
			for(var i = 0; i < fullArray[iIndex].length; i++)
			{
				if(fullArray[iIndex][i])
				{		
					temp[temp.length] = new Array(fullArray[iIndex][i].image,fullArray[iIndex][i].name,fullArray[iIndex][i].href,fullArray[iIndex][i].target,fullArray[iIndex][i].title);			
					if(fullArray[fullArray[iIndex][i].id]) temp[temp.length-1] = temp[temp.length - 1].concat(this.buildTreeArray(fullArray[iIndex][i].id, fullArray));				
				}
			}			
			return temp;
		}
		this.sortArray = function(arrData)
		{			
			for(i = 0;i < arrData.length; i++)
			{
				for(j = 0;j < arrData.length;j++)
				{		
					if (parseInt(arrData[i].position) < parseInt(arrData[j].position))
					{
						var _temp = arrData[j];
						arrData[j] = arrData[i] 
						arrData[i] = _temp;														
					}					
				}
			}			
			return arrData;
		}			
	}
