<!--
if(typeof Array.prototype.push == 'undefined')
	Array.prototype.push = function(element){
		this[this.length] = element;
	}
var DxLightMenuIsIE = (document.all && !window.opera) ? true : false;
	
DxLMItems = new newClass(null,{
	constructor: function(){
		this.Width = undefined;
		this.Height = undefined;
		
		this.Style = new DxLMStyle();
		this.ItemStyle = new DxLMStyle();
		this.SelectedStyle = new DxLMStyle();
		this.ContainerStyle = new DxLMContainerStyle();
		
		this.Items = new Array();
		this.ItemsCount = 0;
		
		this.Container = null;
	},
	AddItem: function(item){
		this.Items.push(item);
		this.ItemsCount = this.Items.length;
	},
	Create: function(parentId, root){
		this.ContainerStyle.MergeStyle(root.ContainerStyle);
		
		if(this.Items.length == 0)
			return;
		var id = parentId + "_container";
		var container = new Array();
		var containerWidth = typeof this.ContainerStyle.Width != 'undefined' ? ";width: " + this.ContainerStyle.Width : "";
		container.push("<div id=\"" + id + "\" style=\"position:absolute;left:-10000px;top:0px; z-index: 99999" + containerWidth + "\"><table style=\"" + containerWidth + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"");
		container.push("><tbody>");
		var i;
		var separatorWidth = this.ContainerStyle.GetSeparatorWidth();
		var separatorColor = this.ContainerStyle.GetSeparatorColor();
		for(i = 0; i < this.Items.length; i++){
			container.push("<tr><td>" + this.Items[i].Create(id, i, root) + "</td></tr>");
			if(separatorWidth > 0 && i != this.Items.length -1)
				container.push("<tr><td bgcolor=\"" + separatorColor + "\"><img src=\"" + root.EmptyImage + "\" width=\"1\" height=\"" + separatorWidth + "\" border=\"0\"></td></tr>");
		}
		container.push("</tbody></table></div>");
		document.write(container.join(""));
		if(DxLightMenuIsIE) {
			var iFrameId = id + "_iframe";
			var iFrameString = "<iframe src=\"javascript:false;\" id=\"" + iFrameId + "\" style=\"position: absolute; left:-10000px;top: 0px; z-index: 99998" + containerWidth +"\"></iframe>";
			document.write(iFrameString);
		}
		
	},
	Assign: function(item, root, container){
		item.SelfContainerId = container.id;
		item.ItemStyle = this.ItemStyle;
		item.SelectedStyle = this.SelectedStyle;
		item.Link = this.Link;
		DxLightMenuUtils.UnHighlight(item);
		var currentItemChildContainer = DxLightMenu.GetObjById(item.id + "_container");
		if(typeof currentItemChildContainer == 'undefined' || currentItemChildContainer == null)
			return;
		this.ContainerStyle.ApplyStyle(currentItemChildContainer);
		currentItemChildContainer.ContainerStyle = this.ContainerStyle;
		currentItemChildContainer.TimerId = root.TimerId;
		
		item.ChildContainerId = currentItemChildContainer.id;
		
		var i;
		for(i = 0; i < this.Items.length;i++){
			var id = currentItemChildContainer.id + "::item_" + i;
			var childItem = DxLightMenuUtils.GetChildById(currentItemChildContainer, id);
			if(childItem == null)
				continue;
			this.Items[i].Assign(childItem, root, currentItemChildContainer);
			childItem.ParentItemId = item.id;
			childItem.TimerId = root.TimerId;
			childItem.SecondsVisible = root.SecondsVisible;
		}
	}
});

DxLMSeparator = newClass(DxLMItems, {
	constructor: function(imageUrl){
		this.ImageUrl = imageUrl;
		this.constructor.prototype.constructor.call(this);
	},
	Create: function(){
		var item = new Array();
		item.push("<img src=\"" + this.ImageUrl + "\" border=\"0\"");
		if(typeof this.Width != 'undefined')
			item.push(" width=\"" + this.Width + "\"");
		if(typeof this.Height != 'undefined')
			item.push(" height=\"" + this.Height + "\"");
		item.push(">");
		return item.join("");
	}
});

DxLMRegularItem = newClass(DxLMItems, {
	constructor: function(text, link){
		this.Text = text;
		this.Link = link;
		this.Target = "_self";
		this.constructor.prototype.constructor.call(this);
	},
	Create: function(parentContainerId, selfPosition, root){
		this.Style.MergeStyle(root.Style);
		this.ItemStyle.MergeStyle(this.Style);
		this.ItemStyle.MergeStyle(root.ItemStyle);
		this.SelectedStyle.MergeStyle(root.SelectedStyle);
		this.SelectedStyle.MergeStyle(this.Style);

		var itemId = parentContainerId + "::item_" + selfPosition;
		var item = new Array();
		item.push("<table style=\"cursor: pointer; cursor: hand\" id=\"" + itemId + "\" width=\"100%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"cursor: pointer; cursor: hand\" onmouseover=\"DxLMOver(this)\" onmouseout=\"DxLMOut(this)\" onclick=\"DxLMClick(this)\"><tbody><tr>");
		var isWrap = !this.ItemStyle.WrapText ? "nowrap" : "";
		item.push("<td width=\"100%\" " + isWrap + ">" + this.Text + "</td>");
		if(this.ItemStyle.GetExpImage() != null && this.Items.length > 0){
			var expImage = this.ItemStyle.GetExpImage();
			if(expImage != null)
				item.push("<td><img src=\"" + expImage + "\"/></td>");
		}
		item.push("</tr></tbody></table>");
		this.constructor.prototype.Create.call(this, itemId, root);
		return item.join("");
	}
});


DxLightMenu = newClass(DxLMItems, {
	constructor: function(placeholderId){
		// public
		this.SecondsVisible = 0.6;
		this.KeepHighlighted = false;
		this.WrapText = true;
		this.EmptyImage = "/i/s.gif";
		
		this.RootContainerStyle = new DxLMContainerStyle();
		// internal
		this.PlaceholderId = placeholderId;
		this.constructor.prototype.constructor.call(this);
		this.Root = this;
	},
	Create: function(){
		this.RootContainerStyle.MergeStyle(this.ContainerStyle);
		var rcId = this.PlaceholderId;
		var rootContainer = new Array();
		rootContainer.push("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"");
		if(typeof this.Width != 'undefined')
			rootContainer.push(" width=\"" + this.Width + "\"");
		if(typeof this.Height != 'undefined')
			rootContainer.push(" height=\"" + this.Height + "\"");
		rootContainer.push("><tbody><tr>");
		var i;
		var separatorWidth = this.RootContainerStyle.GetSeparatorWidth();
		var separatorColor = this.RootContainerStyle.GetSeparatorColor();
		for(i = 0; i < this.Items.length; i++){
			var itemWidth = typeof this.Items[i].Width == 'undefined' ? "" : "width=\"" + this.Items[i].Width + "\"";
			rootContainer.push("<td " + itemWidth + ">" + this.Items[i].Create(rcId, i, this) + "</td>");
			if(separatorWidth > 0 && i < this.Items.length -1)
				rootContainer.push("<td bgcolor=\"" + separatorColor + "\"><img src=\"" + this.EmptyImage + "\" width=\"" + separatorWidth + "\" height=\"1\" border=\"0\"></td>");
		}
		rootContainer.push("</tr></tbody></table>");
		return rootContainer.join("");
	},
	Init: function(){
		var container = DxLightMenu.GetObjById(this.PlaceholderId);
		if(container == null)
			return;
		// setting up hacks
		if(window.navigator.userAgent.indexOf("Netscape6/6.0") > 0)
			Netscape60Hack = true;
		else
			Netscape60Hack = false;

		if(typeof DxLMTimers == 'undefined')
			DxLMTimersCollection = new Array();

		container.innerHTML = this.Create();

		this.TimerId = container.id + "_Timer";
		DxLMTimersCollection[this.TimerId] = null;
		container.TimerId = this.TimerId;

		// building hierarchy, assigning styles
		this.RootContainerStyle.ApplyStyle(container);
		var i;
		for(i = 0; i < this.Items.length; i++){
			var id = this.PlaceholderId + "::item_" + i;
			var item = DxLightMenuUtils.GetChildById(container, id);
			if(item == null) continue;

			this.Items[i].Assign(item, this, container);

			item.IsRoot = true;
			item.ParentItemId = null;
			item.TimerId = this.TimerId;
			item.SecondsVisible = this.SecondsVisible;
		}
	}
});

DxLightMenu.GetObjById = function(objId){
	if(document.all)
		return document.all(objId);
	if(document.getElementById)
		return document.getElementById(objId);
	if(document.layers)
		return document.layers[objId];
	return null;
}

function DxLMStyle(){
	var nothing;
	this.Font = nothing;
	this._Font = "Arial";
	this.FontSize = nothing;
	this._FontSize = "12px";
	this.FontBold = nothing;
	this._FontBold = false;
	this.FontItalic = nothing;
	this._FontItalic = false;
	this.FontUnderline = nothing;
	this._FontUnderline = false;
	this.Align = nothing;
	this._Align = "left";

	this.Color = nothing;
	this._Color = "black";
	this.BGColor = nothing;
	this._BGColor = "white";
	
	this.ExpImage = nothing;
	this.Padding = nothing;
	this._Padding = 2;
	
	this.WrapText = nothing;
	this._WrapText = true;
	
	this.ApplyStyle = function(el){
	el.style.backgroundColor = "green";
		with(el.style){
			if(fontFamily == "")
				fontFamily = typeof this.Font == 'undefined' ? this._Font : this.Font;
			fontSize = typeof this.FontSize == 'undefined' ? this._FontSize : this.FontSize;
			fontWeight = typeof this.FontBold == 'undefied' ? (this._FontBold ? "bold" : "normal") : (this.FontBold ? "bold" : "normal");
			fontStyle = typeof this.FontItalic == 'undefined' ? (this._FontItalic ? "italic" : "normal") : (this.FontItalic ? "italic" : "normal");
			textDecoration = typeof this.FontUnderline == 'undefined' ? (this._FontUnderline ? "underline" : "none") : (this.FontUnderline ? "underline" : "none");
			color = typeof this.Color == 'undefined' ? this._Color : this.Color;
			backgroundColor = typeof this.BGColor == 'undefined' ? this._BGColor : this.BGColor;
			padding = typeof this.Padding == 'undefined' ? this._Padding : this.Padding;
			textAlign = typeof this.Align == 'undefined' ? this._Align : this.Align;
			whiteSpace = typeof this.WrapText == 'undefined' ? (this._WrapText ? "normal" : "nowrap") : (this.WrapText ? "normal" : "nowrap");
		}
	}
	
	this.GetExpImage = function(){
		if(typeof this.ExpImage == 'undefined')
			return null;
		else
			return this.ExpImage;
	}
	
	this.MergeStyle = function(parent){
		this.Font = typeof this.Font == 'undefined' ? parent.Font : this.Font;
		this.FontSize = typeof this.FontSize == 'undefined' ? parent.FontSize : this.FontSize;
		this.FontBold = typeof this.FontBold == 'undefined' ? parent.FontBold : this.FontBold;
		this.FontItalic = typeof this.FontItalic == 'undefined' ? parent.FontItalic : this.FontItalic;
		this.FontUnderline = typeof this.FontUnderline == 'undefined' ? parent.FontUnderline : this.FontUnderline;
		
		this.Color = typeof this.Color == 'undefined' ? parent.Color : this.Color;
		this.BGColor = typeof this.BGColor == 'undefined' ? parent.BGColor : this.BGColor;
		
		this.Padding = typeof this.Padding == 'undefined' ? parent.Padding : this.Padding;
		this.ExpImage = typeof this.ExpImage == 'undefined' ? parent.ExpImage : this.ExpImage;
		
		this.Align = typeof this.Align == 'undefined' ? parent.Align : this.Align;
		this.WrapText = typeof this.WrapText == 'undefined' ? parent.WrapText : this.WrapText;
	}
}

function DxLMContainerStyle(){
	var nothing;
	this.BorderWidth = nothing;
	this._BorderWidth = 0;
	
	this.BorderColor = nothing;
	this._BorderColor = "black";
	
	this.BorderStyle = nothing;
	this._BorderStyle = "solid";
	this.SeparatorWidth = nothing;
	this._SeparatorWidth = 0;
	this.SeparatorColor = nothing;
	this._SeparatorColor = "black";
	this.HorizOffset = nothing;
	this._HorizOffset = 0;
	this.VertOffset = nothing;
	this._VertOffset = 0;
	this._Width = undefined;
	this.Width = undefined;
	
	this.ApplyStyle = function(element){
		with(element.style){
			borderWidth = typeof this.BorderWidth == 'undefined' ? this._BorderWidth : this.BorderWidth;
			borderColor = typeof this.BorderColor == 'undefined' ? this._BorderColor : this.BorderColor;
			borderStyle = typeof this.BorderStyle == 'undefined' ? this._BorderStyle : this.BorderStyle;
		}
	}
	
	this.MergeStyle = function(parent){
		if(typeof this.BorderWidth == 'undefined')
			this.BorderWidth = parent.BorderWidth;
		if(typeof this.BorderStyle == 'undefined')
			this.BorderStyle = parent.BorderStyle;
		if(typeof this.BorderColor == 'undefined')
			this.BorderColor = parent.BorderColor;

		if(typeof this.SeparatorWidth == 'undefined')
			this.SeparatorWidth = parent.SeparatorWidth;
		if(typeof this.SeparatorColor == 'undefined')
			this.SeparatorColor = parent.SeparatorColor;

		if(typeof this.HorizOffset == 'undefined')
			this.HorizOffset = parent.HorizOffset;
		if(typeof this.VertOffset == 'undefined')
			this.VertOffset = parent.VertOffset;
		if(typeof this.Width == 'undefined')
			this.Width = parent.Width;

	}
	
	this.GetBorderWidth = function(){
		if(typeof this.BorderWidth == 'undefined')
			return this._BorderWidth;
		else
			return this.BorderWidth;
	}
	this.GetSeparatorWidth = function(){
		if(typeof this.SeparatorWidth == 'undefined')
			return this._SeparatorWidth;
		else
			return this.SeparatorWidth;
	}
	this.GetSeparatorColor = function(){
		if(typeof this.SeparatorColor == 'undefined')
			return this._SeparatorColor;
		else
			return this.SeparatorColor;
	}
	this.GetHorizOffset = function(){
		if(typeof this.HorizOffset == 'undefined')
			return this._HorizOffset;
		else
			return this.HorizOffset;
	}
	this.GetVertOffset = function(){
		if(typeof this.VertOffset == 'undefined')
			return this._VertOffset;
		else
			return this.VertOffset
	}
}



function DxLMOver(e){
	if(DxLMTimersCollection[e.TimerId] != null)
		window.clearTimeout(DxLMTimersCollection[e.TimerId]);
	if(typeof e.Link != 'undefined')
		window.status = e.Link;
	DxLightMenuUtils.Highlight(e);
}

function DxLMOut(e){
	DxLightMenuUtils.UnHighlight(e);
	window.status = "";
	DxLMTimersCollection[e.TimerId] = window.setTimeout(function(){DxLightMenuUtils.HideAll(e);}, e.SecondsVisible * 1000);
}

function DxLMClick(item){
	if(typeof item.Link != 'undefined')
		document.location = item.Link;
}

function DxLightMenuUtils(){}
DxLightMenuUtils.FindPosX = function(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
		curleft += obj.offsetLeft;
	}else
		curleft += obj.offsetLeft;
	if (obj.x)
		curleft += obj.x;
	return curleft;
}

DxLightMenuUtils.FindPosY = function(obj){
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
		curtop += obj.offsetTop;
	}else
		curtop += obj.offsetTop;
	if (obj.y)
		curtop += obj.y;
	return curtop;
}

DxLightMenuUtils.KeepInWindow = function(item, child){
	var windowWidth = null;
	if(windowWidth == null && document.body){
		if(document.body.clientWidth)
			windowWidth = document.body.clientWidth;
	}

	if(windowWidth == null && document.body){
		if(document.body.offsetWidth)
			windowWidth = document.body.offsetWidth;
	}
	if(windowWidth == null)
		return;
	var parentRight = this.FindPosX(item) + item.offsetWidth + child.ContainerStyle.GetBorderWidth();
	var objX = this.FindPosX(child);
	var objWidth = document.all ? child.offsetWidth : child._width;
	if(objX + objWidth > windowWidth){
		objX = parentRight - objWidth;
		if(objX < parentRight && typeof item.IsRoot == 'undefined')
			objX = this.FindPosX(item) - objWidth + child.ContainerStyle.GetBorderWidth();
		child.style.left = objX;
		if(DxLightMenuIsIE){
			var childIframe = DxLightMenu.GetObjById(item.ChildContainerId + "_iframe");
			childIframe.style.left = objX;
		}
	}
}

DxLightMenuUtils.GetChildById = function(element, id){
	if(element.all){
		return element.all[id];
	}
	else{
		var nodes = element.childNodes;
		var i;
		for(var i = 0; i < nodes.length; i++){
			if(nodes[i].id == id) 
				return nodes[i];
		}
		for(var i = 0; i < nodes.length; i ++){
			var ret = DxLightMenuUtils.GetChildById(nodes[i], id);
			if(ret != null) return ret;
		}	
		return null;
	}
}

DxLightMenuUtils.ShowChild = function(item){
	if(typeof item.ChildContainerId == 'undefined')
		return;
	var child = DxLightMenu.GetObjById(item.ChildContainerId);
	if(DxLightMenuIsIE)
		var childIframe = DxLightMenu.GetObjById(item.ChildContainerId + "_iframe");
	child._width = child.offsetWidth;
	
	var childBorderWidth = child.ContainerStyle.GetBorderWidth();
	var childHorizOffset = child.ContainerStyle.GetHorizOffset();
	child.style.left = DxLightMenuUtils.FindPosX(item) + childHorizOffset - childBorderWidth;
	child.style.top = DxLightMenuUtils.FindPosY(item) + item.offsetHeight;
	if(DxLightMenuIsIE){
		childIframe.style.left = child.style.left;
		childIframe.style.top = child.style.top;
		childIframe.style.width = child.offsetWidth;
		childIframe.style.height = child.offsetHeight;
	}
	
	var xOffset = 0;
	var yOffset = 0;

	// netscape 6.0 hack
	if(Netscape60Hack){
		xOffset = childBorderWidth;
		yOffset = childBorderWidth;
	}
	
	if(typeof item.IsRoot == 'undefined'){
		child.style.left = DxLightMenuUtils.FindPosX(item) + item.offsetWidth + childHorizOffset + childBorderWidth - xOffset;
		child.style.top = DxLightMenuUtils.FindPosY(item) - yOffset;
		if(DxLightMenuIsIE){
			childIframe.style.left = child.style.left;
			childIframe.style.top = child.style.top;
			childIframe.style.width = child.offsetWidth;
			childIframe.style.height = child.offsetHeight;
		}
	}
	this.KeepInWindow(item, child);
}

DxLightMenuUtils.HideChild = function(item){
	var childContainer = null;
	if(typeof item.ChildContainerId != 'undefined'){
		childContainer = DxLightMenu.GetObjById(item.ChildContainerId);
		if(childContainer.style.left == "-10000")
			return;
		childContainer.style.left = "-10000px";
		if(DxLightMenuIsIE) {
			var childIFrame = DxLightMenu.GetObjById(item.ChildContainerId + "_iframe");
			childIFrame.style.left = "-100000px";
		}
	}
	else
		return;
	var items = this.GetItemsByContainer(childContainer.id);
	var i;
	for(i = 0; i < items.length; i++)
		this.HideChild(items[i]);
}

DxLightMenuUtils.Highlight = function(item){
	var i;
	var tds = item.getElementsByTagName("TD");
	for(i = 0; i < tds.length; i++)
		item.SelectedStyle.ApplyStyle(tds[i]);
	this.ShowChild(item);
	var items = this.GetItemsByContainer(item.SelfContainerId);
	for(i = 0; i < items.length; i++)
		if(items[i].id != item.id)
			this.HideChild(items[i]);
}

DxLightMenuUtils.UnHighlight = function(item){
	var i;
	var tds = item.getElementsByTagName("TD");
	for(i = 0; i < tds.length; i++)
		item.ItemStyle.ApplyStyle(tds[i]);
}

DxLightMenuUtils.HideAll = function(item){
	this.HideChild(item);
	this.UnHighlight(item);
	var i;
	while(item.ParentItemId != null){
		item = DxLightMenu.GetObjById(item.ParentItemId);
		var items = this.GetItemsByContainer(item.SelfContainerId);
		for(i = 0; i < items.length; i++){
			this.UnHighlight(items[i]);
			this.HideChild(items[i]);
		}
	}
}

DxLightMenuUtils.GetItemsByContainer = function(containerId){
	var container = DxLightMenu.GetObjById(containerId);
	var tables = container.childNodes[0].getElementsByTagName("TABLE");
	var i;
	var items = new Array();
	for(i = 0; i < tables.length; i++)
		items.push(tables[i]);
	return items;
}

function newClass(parent, prop) {
  var clazz = function() {
    if (clazz.preparing) return delete(clazz.preparing);
    if (clazz.constr) {
      this.constructor = clazz;
      clazz.constr.apply(this, arguments);
    }
  }
  clazz.prototype = {};
  if (parent) {
    parent.preparing = true;
    clazz.prototype = new parent;
    clazz.prototype.constructor = parent;
    clazz.constr = parent;
  }
  if (prop) {
    var cname = "constructor";
    for (var k in prop) {
      if (k != cname) clazz.prototype[k] = prop[k];
    }
    if (prop[cname] && prop[cname] != Object)
      clazz.constr = prop[cname];
  }
  return clazz;
}

var DxLightMenuLoaded = true;
