function TMClass()
{
	this.ImgPath="/img/";
	this.ItemsId='tmi';
	this.ItemsContId='tmc';
	this.ItemsAId='tma';

	this.MenuItemsColor_out="";
	this.MenuItemsColor_over="";
	this.MenuItemsBgColor_out="";
	this.MenuItemsBgColor_over="";
	this.MenuItemsBgImg_over="bgmenua.gif";
	this.MenuItemsBgImg_out="";

	/*this.MenuSubItemsColor_out="#002D80";
	this.MenuSubItemsColor_over="#FFFFFF";
	this.MenuSubItemsBgColor_out="#EEEEEE";
	this.MenuSubItemsBgColor_over="#040468";*/
	this.MenuSubItemsColor_out="";
	this.MenuSubItemsColor_over="";
	this.MenuSubItemsBgColor_out="";
	this.MenuSubItemsBgColor_over="";

    //this.MenuItemsRmargin=20;
	this.MenuItemsLeftSpace=0;
	this.MenuItemsTopSpace=-1;
	this.MenuItemsWfix=2;
	this.activeItem=null;
	this.tmhide=null;
	this.delay=500;

	this.UNKNOWN=false;
	this.IE=(navigator.appName.indexOf("Internet Explorer")!=-1);
	this.NE=(navigator.appName.indexOf("Netscape")!=-1);
	this.GECKO=(navigator.userAgent.indexOf("Gecko")!=-1);
	this.OP=(navigator.userAgent.indexOf("Opera")!=-1);
	this.OP5=(navigator.userAgent.indexOf("Opera 5")!=-1);
	this.OP6=(navigator.userAgent.indexOf("Opera 6")!=-1);
	this.OP7=(navigator.userAgent.indexOf("Opera 7")!=-1);
	this.KO=(navigator.userAgent.indexOf("Konqueror")!=-1);
	if(this.OP) this.IE=false;
	this.isDOM=Boolean(document.getElementById);
	this.isALL=Boolean(document.all);
	this.isOPERA=Boolean(window.opera);
	this.isLAYERS=Boolean(document.layers);
	this.UNKNOWN=!(this.IE||this.NE||this.OP);
	this.Ver=parseFloat(navigator.appVersion);
	this.FullVer=0;
	this.MajorVer=0;
	this.MinorVer=0;
	if(this.GECKO)
	{
		this.FullVer=new String(navigator.userAgent.match(/[0-9.]*$/));
		this.MajorVer=parseInt(this.FullVer);
		var t=this.FullVer.split(".");
		if(t.length>1)
		{
			this.MinorVer="";
			for(var i=1; i<t.length; i++)
			{
				if(i>1) this.MinorVer+=".";
				this.MinorVer+=t[i];
			}
		}
	}
	else if(this.IE)
	{
		this.MajorVer=navigator.appVersion.match(/MSIE (.)/)[1];
		this.MinorVer=navigator.appVersion.match(/MSIE .\.(.)/)[1];
		this.FullVer=this.MajorVer+"."+this.MinorVer;
	}
	else if(this.OP)
	{
		this.MajorVer=navigator.userAgent.match(/Opera (.)/)[1];
		this.MinorVer=navigator.userAgent.match(/Opera .\.(.)/)[1];
		this.FullVer=this.MajorVer+"."+this.MinorVer;
	}

	this.getE = function(iid)
	{
		return document.getElementById(iid)||null;
	}

	this.isE = function(e)
	{
		return ("object"==typeof(e)&&null!=e);
	}

	this.getEwidth = function(iid)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		if(e.clientWidth)
		{
			return e.clientWidth;
		}
		else if(e.offsetWidth)
		{
			return e.offsetWidth;
		}
		else if(e.style.width)
		{
			return e.style.width;
		}
	}

	this.getEheight = function(iid)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		if(e.clientHeight)
		{
			return e.clientHeight;
		}
		else if(e.style.height)
		{
			return e.style.height;
		}
	}

	this.getEleft = function(iid)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		if(e.offsetParent)
		{
			x = e.offsetLeft;
			t = e.offsetParent;
			while (t != null)
			{
				x += t.offsetLeft;
				t = t.offsetParent;
			}
	    return x;
		}
		else if(e.style.left)
		{
			return e.style.left;
		}
	}

	this.getEtop = function(iid)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		if(e.offsetParent)
		{
			y = e.offsetTop;
			t = e.offsetParent;
			while (t != null)
			{
				y += t.offsetTop;
				t = t.offsetParent;
			}
	    return y;
		}
		else if(e.style.top)
		{
			return e.style.top;
		}
	}

	this.setEvis = function(iid, s)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		e.style.visibility = s?"visible":"hidden";
	}

	this.setEpos = function(iid, x, y)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		e.style.left = x+"px";
		e.style.top = y+"px";
	}

	this.setEwidth = function(iid, w)
	{
		var e=this.getE(iid);
		if(e==null) return null;
		e.style.width = w;
	}

	this.setEcolor = function(iid, color)
	{
		var e=this.getE(iid);
		if(e!=null)
		{
			e.style.color = color;
			return true;
		}
		return false;
	}

	this.setEbgColor = function(iid, color)
	{
		var e=this.getE(iid);
		if(e!=null)
		{
			e.style.backgroundColor = color;
			return true;
		}
		return false;
	}

	this.mVis = function(ii, st)
	{
		var iist=ii.split('_');
		var si="";
		var sp="";
		var it=null;
		var ita=null;
		var itp=null;
		for(var i=0; i<iist.length; i++){
			if(i>0){//2+ level
				itp=this.getE(this.ItemsId+si);
				sp=si;
				si+="_";si+=iist[i];
				it=this.getE(this.ItemsId+si);
				if(!this.isE(it)) return;
				if(this.MenuSubItemsBgColor_over){
					it.style.backgroundColor=((st)?this.MenuSubItemsBgColor_over:this.MenuSubItemsBgColor_out);
				}
				it=this.getE(this.ItemsAId+si);
				if(!this.isE(it)) return;
				if(this.MenuSubItemsColor_over){
					it.style.color=((st)?this.MenuSubItemsColor_over:this.MenuSubItemsColor_out);
				}
				it=this.getE(this.ItemsContId+si);
				if(!this.isE(it)) return;
				it.style.display=((st)?"block":"none");
				if(st){
					var y=parseInt(this.getEtop(this.ItemsId+si));
					var x=parseInt(this.getEleft(this.ItemsId+si));
					var w=parseInt(this.getEwidth(this.ItemsId+si));
					var h=parseInt(this.getEheight(this.ItemsId+si));
					it.style.left=x+w+"px";
					it.style.top=y+"px";
					var wp=0;
					var j=0;
					do{
						j++;
						ita=this.getE(this.ItemsAId+si+"_"+j);
						if(!this.isE(ita)) break;
						wp=parseInt(this.getEwidth(this.ItemsAId+si+"_"+j));
						if(wp+this.MenuItemsRmargin>w){w=wp+this.MenuItemsRmargin;j=0;}
						if(j>99){j=0;}
					}while(j>0);
					it.style.width=w+"px";
				}

			}else{//1 level
				si+=iist[i];
				it=this.getE(this.ItemsId+si);
				if(!this.isE(it)) return;
				it.style.backgroundColor=(st)?this.MenuItemsBgColor_over:this.MenuItemsBgColor_out;
				if(this.MenuItemsBgImg_over){
					it.style.backgroundRepeat="repeat-x";
					//it.style.backgroundPosition="center";
					it.style.backgroundImage="url("+this.ImgPath+((st)?this.MenuItemsBgImg_over:this.MenuItemsBgImg_out)+")";
				}
				it=this.getE(this.ItemsAId+si);
				if(!this.isE(it)) return;
				if(this.MenuItemsColor_over){
					it.style.color=((st)?this.MenuItemsColor_over:this.MenuItemsColor_out);
				}
				it=this.getE(this.ItemsContId+si);
				if(!this.isE(it)) return;
				it.style.display=((st)?"block":"none");
				if(st){
					var y=parseInt(this.getEtop(this.ItemsId+si));
					var h=parseInt(this.getEheight(this.ItemsId+si));
					var x=parseInt(this.getEleft(this.ItemsId+si));
					var w=parseInt(this.getEwidth(this.ItemsId+si));
					var j=0;
					do{
						j++;
						ita=this.getE(this.ItemsAId+si+"_"+j);
						if(!this.isE(ita)) break;
						if(j>99){j=0;}
					}while(j>0);
					it.style.left=x+this.MenuItemsLeftSpace+"px";
					it.style.top=y+h+this.MenuItemsTopSpace+"px";
					it.style.width=w+"px";
				}
			}
		}
	}

	this.mHide = function()
	{
		if(this.activeItem){
			this.mVis(this.activeItem,0);
			this.activeItem="";
		}
	}

	this.mOver=function(){
		if(!arguments.length) return;
		var ii="";
		for(var i=0; i<arguments.length; i++){if(i>0)ii+="_";ii+=arguments[i];}
		clearTimeout(this.tmhide);
		if(this.activeItem && this.activeItem!=ii){
			this.mHide();
		}
		this.mVis(ii,1);
		this.activeItem=ii;
	}

	this.mOut=function(iid){		clearTimeout(this.tmhide);
		this.tmhide = setTimeout("FMT.mHide()", this.delay);
	}

	this.fixMpos = function()
	{
		//
	}

	this.onResize = function()
	{
		FMT.fixMpos();
	}

	this.onLoad = function()
	{
	}

	this.init = function()
	{
		window.onload=this.onLoad;
		window.onresize=this.onResize;
	}
}

var FMT = new TMClass;
FMT.init();
