function Init() {
}

var menu_obj = null;

/**
	
	@param	PosPic		Annak a kepnek a neve amihez kepest a menut igazitani kell.
	@param	w			A menu szelessege.
	@param	h			A menu magassaga.
	@param	ex			A menu eltolasa a pozicionalashoz kepest.
	@param	ey			A menu eltolasa a pozicionalashoz kepest.
	@param	nev			A menu neve.
	@param	tartalom	tartalom.
*/
function CreateMenu(nev,PosPic,w,ex,ey,menupontok, parent, index) {

	this.parent = parent;
	this.index = index;
	this.nev = nev;

	this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	this.isOPERA = (navigator.appName == "Opera");

	this.addEvent = addEvent;

	this.PosPic = PosPic;

	this.eltolasx = ex;
	this.eltolasy = ey;

	this.menu_num = 0;
	this.tartalom = "";
	this.submenu = new Array();
	for(menupont in menupontok) {
		if (menupont=="") continue;
		if (typeof(menupontok[menupont])=="string") {
			if (parent) {
				this.tartalom += "<tr onMouseOver='"+this.parent.nev+".submenu["+this.index+"].Show();'><td width='10' valign='top' style='height: 18px; color: #000000; font-size: 11pt; text-decoration: none;'>-</td><td><a href='"+menupontok[menupont]+"' style='color: black; text-decoration: none;'><font size='2'><font face='Verdana'>"+menupont+"</font></font></a></td></tr>";
			} else {
				this.tartalom += "<tr onMouseOver='"+nev+".Show();'><td width='10' valign='top' style='height: 18px; color: #000000; font-size: 11pt; text-decoration: none;'>-</td><td><a href='"+menupontok[menupont]+"' style='color: black; text-decoration: none;'><font size='2'><font face='Verdana'>"+menupont+"</font></font></a></td></tr>";
			}
		} else if (typeof(menupontok[menupont])=="object") {
			menupont_neve = menupont;
			this.menu_num++;
			this.submenu[this.menu_num] = new CreateMenu("submenu_"+this.menu_num,nev+"_"+this.menu_num+"_pos",120,w-20,20,menupontok[menupont], this, this.menu_num);
			this.tartalom += "<tr onMouseOver='"+nev+".Show();'><td width='10' valign='top' style='height: 18px; color: #000000; font-size: 11pt; text-decoration: none;'>-<img border='0' width='0' height='0' style=\"position: absolute;\" name=\""+nev+"_"+this.menu_num+"\" id=\""+nev+"_"+this.menu_num+"_pos\"></td><td><a href='#submenu' OnMouseOver=\"if (typeof("+nev+")!='undefined') "+nev+".submenu["+this.menu_num+"].Show();\" OnMouseOut=\"if (typeof("+nev+")!='undefined') "+nev+".submenu["+this.menu_num+"].Hide2();\" style='color: black; text-decoration: none;'><font size='2'><font face='Verdana'>"+menupont_neve+" ...</font></font></a></td></tr>";
		}
	}
	this.tartalom = "<table width='100%' cellpadding=0 cellspacing=0 >"+this.tartalom+"</table>";

	x = 0;
	y = 0;
	this.x = x;
	this.y = y;

	if (parent) {
		zindex = 200;
	} else {
		zindex = 100;
	}
	document.writeln("<div id=\""+nev+"\" name=\""+nev+"\" style=\"visibility: hidden; background-color: #D97D1A; color: #FFFFFF;position: absolute; width: "+w+"px; top: "+y+"px; left: "+x+"px;z-index: "+zindex+";border-style:solid; border-width: 1px; border-color: #333333; font-weight: bold;filter:alpha(opacity=90);-moz-opacity: 0.9; padding: 3px;\">"+this.tartalom+"</div>");
	document.writeln("<div id=\""+nev+"_arnyek\" name=\""+nev+"_arnyek\" style=\"visibility: hidden; background-color: #000000; color: #000000;position: absolute; width: "+w+"px; top: "+y+"px; left: "+x+"px;z-index: "+(zindex-10)+";border-style:solid; border-width: 1px; border-color: #3E484B; font-weight: bold;filter:alpha(opacity=10);-moz-opacity: 0.1;padding: 3px;\">"+this.tartalom+"</div>");
	
	this.w = w;
	this.h = (document.getElementById(nev)).clientHeight;
	
	this.Show = Show;
	this.Hide = Hide;
	this.Hide2 = Hide2;

	this.HideNow = Hide_;
	x = new getObj(nev);
	y = new getObj(nev+"_arnyek");

	this.Menu = x;
	this.Arnyek = y;

	this.Menu.obj.alap = this;

	//this.MouseListener2 = MouseListener2;
	this.addEvent(x.obj,"mouseout",MouseListener2);
}

function Show() {
	if (this.parent) {
		this.parent.Show();
		this.x = this.eltolasx+this.parent.x+document.getElementById(this.PosPic).offsetLeft;
		this.y = this.eltolasy+this.parent.y+document.getElementById(this.PosPic).offsetTop;
	} else {
		for (elem in this.submenu) {
			this.submenu[elem].hide_all = false;
		}
		this.x = this.eltolasx+document.getElementById(this.PosPic).offsetLeft;
		this.y = this.eltolasy+document.getElementById(this.PosPic).offsetTop;
	}
	this.Menu.style.visibility="visible";
	this.Arnyek.style.visibility="visible";
	this.Menu.style.left = this.x+this.eltolasx;
	this.Menu.style.top = this.y+this.eltolasy;
	this.Arnyek.style.left = this.x+this.eltolasx+5;
	this.Arnyek.style.top = this.y+this.eltolasy+5;
	if (this.timeout!="nincs")
		clearTimeout(this.timeout);
	this.timeout = "nincs";
	menu_obj = this;
}

function Hide_() {
	if ( (this.parent) && (this.hide_all) ) {
		this.parent.HideNow();
	}
	this.Menu.style.visibility="hidden";
	this.Arnyek.style.visibility="hidden";
}

function Hide() {
	this.hide_all = true;
	if (this.timeout=="nincs") {
		if (this.parent) {
			this.timeout = setTimeout(this.parent.nev+".submenu["+this.index+"].HideNow()",500);
		} else {
			this.timeout = setTimeout(this.nev+".HideNow()",500);
		}
	}
}

function Hide2() {
	this.hide_all = false;
	if (this.timeout=="nincs") {
		if (this.parent) {
			this.timeout = setTimeout(this.parent.nev+".submenu["+this.index+"].HideNow()",200);
		} else {
			this.timeout = setTimeout(this.nev+".HideNow()",200);
		}
	}
}

function MouseListener2(e) {
	var event_obj;
	if (document.all)  {
		event_obj = event;
	} else {
		event_obj = e;
	}

	if (menu_obj) menu_obj.Hide();
}

function addEvent(obj, name, handler) {
	if ( (this.isMSIE) || (this.isOPERA) )
		obj.attachEvent("on" + name, handler);
	else
		obj.addEventListener(name, handler, false);
}
