function GlideMenu(name){
	this.name=name;
	this.Node;
	this.activeMenu=null;

	this.init=function(){
		this.Node=(window.Node)? window.Node : {ELEMENT_NODE : 1, TEXT_NODE : 3};

		var menus, menu, text, a, i, img;
		menus = this.getChildrenByElement(document.getElementById("qm0"));
		for(i = 0; i < menus.length; i++){
			menu = menus[i];
			text = this.getFirstChildByText(menu);
			if(!text) continue;
			lnk  = (text&&text.parentNode&&text.parentNode.getAttribute('lnk'))?text.parentNode.getAttribute('lnk'):null;
			if(this.isIE()){
				var onclk=this.name+'.showMenu(this)';
				if(lnk) a = document.createElement('<a href="'+lnk+'" onfocus="this.blur()">');
				else a = document.createElement('<a href="javascript:;" onclick="'+onclk+'" onfocus="this.blur()">');
				menu.replaceChild(a, text);
				a.appendChild(text);
			} else {
				a = document.createElement("a");
				menu.replaceChild(a, text);
				a.appendChild(text);
				a.href = "javascript:;";
				if(lnk) a.setAttribute('onclick',"document.location.href='"+lnk+"'");
				else a.setAttribute('onclick',this.name+'.showMenu(this)');
				a.onfocus = function(){this.blur()};

				img=document.createElement("img");
				img.setAttribute('src','images/tree_main_plus.gif');
			}
		}

		var getVars=this.getUrlVars();
		if(getVars['class']){
			var actItem=document.getElementById('menuitem'+getVars['class']);
			var actLink=this.getFirstLink(actItem);
			var actSubItem=this.getSubMenu(actItem);
			var parent;

			if(actItem){
				actItem.style.background='#97B95E none';
				/*
				if(actItem.getAttribute('lnk')) actLink.style.background='#97B95E none';
				else {
					actLink.style.border='none';
					actLink.style.background='#97B95E';
				}
				*/

				parent=actItem.parentNode;
				while(parent){
					if(parent.tagName=='UL'){
						if(parent.parentNode.parentNode.className=='qmmc'){
							this.activeMenu=this.getFirstLink(parent.parentNode);
							this.activeMenu.className='active';
						}
						parent.style.display='block';
					}
					parent=parent.parentNode;
				}
			}
			if(actSubItem) actSubItem.style.display='block';
		}
	}

	this.showMenu=function(obj) {
		if(this.activeMenu){
			this.activeMenu.className = "";
			if(this.getNextSiblingByElement(this.activeMenu))
				this.getNextSiblingByElement(this.activeMenu).style.display = "none";
		}
		if(obj == this.activeMenu){
			this.activeMenu = null;
		} else {
			obj.className = "active";
			if(this.getNextSiblingByElement(obj))
				this.getNextSiblingByElement(obj).style.display = "block";
			this.activeMenu = obj;
		}
		return false;
	}

	this.getNextSiblingByElement=function(node){
		return this.getNextSibling(node, "ELEMENT_NODE");
	}

	this.getNextSibling=function(node, filter){
		for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
			if(this.checkNode(sibling, filter)) return sibling;
		}
		return null;
	}

	this.getFirstChildByText=function(node){
		return this.getFirstChild(node, "TEXT_NODE");
	}

	this.getFirstLink=function(node){
		var children = node.childNodes;
		for(var i = 0; i < children.length; i++)
			if(children[i].tagName=='A') return children[i];

		return false;
	}

	this.getFirstItem=function(node){
		var children = node.childNodes;
		for(var i = 0; i < children.length; i++)
			if(children[i].tagName=='LI') return children[i];

		return false;
	}

	this.getSubMenu=function(node){
		var children = node.childNodes;
		for(var i = 0; i < children.length; i++)
			if(children[i].tagName=='UL') return children[i];

		return false;
	}

	this.getFirstChild=function(node, filter){
		var child;
		var children = node.childNodes;
		for(var i = 0; i < children.length; i++){
			child = children[i];
			if(this.checkNode(child, filter)) return child;
		}
		return null;
	}

	this.getChildrenByElement=function(node){
		return this.getChildren(node, "ELEMENT_NODE");
	}

	this.getChildren=function (node, filter){
		var result = new Array();
		var children = node.childNodes;
		for(var i = 0; i < children.length; i++){
			if(this.checkNode(children[i], filter)) result[result.length] = children[i];
		}
		return result;
	}

	this.checkNode=function(node, filter){
		return ((filter==null) || (node.nodeType==this.Node[filter]) || (node.nodeName.toUpperCase()==filter.toUpperCase()));
	}

	this.getElementsByClassName=function(className, tag, elm){
		var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
		var tag = tag || "*";
		var elm = elm || document;
		var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
		var returnElements = [];
		var current;
		var length = elements.length;
		for(var i=0; i<length; i++){
			current = elements[i];
			if(testClass.test(current.className)){
				returnElements.push(current);
			}
		}
		return returnElements;
	}

	this.getUrlVars=function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++){
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = (this.strpos(hash[1],'#'))?hash[1].substr(0,this.strpos(hash[1],'#')):hash[1];
		}
		return vars;
	}
	this.isIE=function(){
		return (this.strpos(navigator.userAgent.toLowerCase(),"msie",0)>0);
	}

	this.strpos=function( haystack, needle, offset){
		if(!haystack) return false;
	    var i = haystack.indexOf( needle, offset ); // returns -1
	    return i >= 0 ? i : false;
	}

	this.addInit=function(name){
		var oldQueue = window.onload? window.onload: function() {};
	    window.onload = function() {
	    	eval(name+".init()");
	        oldQueue();
	    }
	}

	this.addInit(this.name);
}
