/* 
	MyMenu 2 (2008.2)
	Carsten Ruppert
	2008/04/10
	
	Copyright 2008 by HEAD. MARKETING-PARTNER
	http://www.headmarketing.de/
	
	>>> This software is not Open Source or Public Domain. You are not allowed to use, modify or redistribute this software without the permission of HEAD. MARKETING-PARTNER! <<<

	Revision 2008/04/14
	- Set the css classname of the dropdown container to "mymenuDropdown" to avoid css conflicts
	
*/

function myMenuNode(node){
	// the menu Object
	
	var mynode = this;
	
	// Object Properties:
	
	this.align = undefined;
	this.dir = undefined; // unused
	this.dropnode = undefined;
	this.w = 0;
	this.h = 0;
	
	this.x = 0;
	this.y = 0;
	
	// Object Methods:
	
	this.engage = function(){
		// show the dropdown div
		mynode.dropnode.style.display = 'block';
		if(mynode.align == 'horizontal'){
			mynode.dropnode.style.left = mynode.w + 'px';
			mynode.dropnode.style.top = 0;
			}else{
			mynode.dropnode.style.left = 0;
			mynode.dropnode.style.top = "100%";
			//mynode.dropnode.style.top = mynode.h + 'px';
			}
		return;
		}
	this.disengage = function(){
		// Hide the dropdown div
		mynode.dropnode.style.display = 'none';	
		return;
		}
	this.getDropdown = function(){
		// Get the "div" element to show on mouseover
		var child;
		for(i = 0; i < this.node.childNodes.length; i++){
			child = this.node.childNodes[i];
			if(child && child.nodeName.toLowerCase() == 'div'){
				this.dropnode = child;
				return true;
				}
			/*if(child && child.nodeName.toLowerCase() == 'table'){
				this.dropnode = child;
				return true;
				}
			*/
			}
		return false;
		}
	this.setEventListeners = function(){
		if(this.node.attachEvent){
			this.node.attachEvent('onmouseover',this.engage);
			this.node.attachEvent('onmouseout',this.disengage);
			return true;
			}
		else if(this.node.addEventListener){
			this.node.addEventListener('mouseover',this.engage,false);
			this.node.addEventListener('mouseout',this.disengage,false);
			return true;
			}
		else{
			return false;
			}
		}

	// "Constructor":
	if(node){
		this.node = node;
		
		this.w = this.node.offsetWidth; // width for horizontal align
		this.h = this.node.offsetHeight; // height
		this.x = this.node.offsetLeft; // x axis from top left corner
		this.y = this.node.offsetTop; // y axis from top left corner

		this.node.className = 'mymenuContainer';
		this.align = this.node.getAttributeNode('menualign');
		if(this.align){
			this.align = this.align.nodeValue;
			}
		this.dir = this.node.getAttribute('menudir');
		if(this.dir){
			this.dir = this.dir.nodeValue;
			}
		if(this.getDropdown()){
			this.dropnode.className = 'mymenuDropdown';
			void(this.setEventListeners());
			}
		}
	}


function myMenu(){
	// The menu initializer object

	var mymen = this;
	this.nodes = new Array();
	void(this.getNodes());
	}
	myMenu.prototype.getNodes = function(){
			var c = 0; var div = null;
			// Init myMenuNodes:
			while(div = document.getElementsByTagName('div')[c]){
				var ismenu = div.getAttributeNode('mymenu');
				if(ismenu && ismenu.nodeValue == 'yes'){
					this.nodes[this.nodes.length] = new myMenuNode(div);
					}
				++c;
				}
			for(i = 0; i < this.nodes.length; i++){
				// Hide all myMenuNodes
				this.nodes[i].disengage();
				}
			}

