var loaded = false;

function Loaded() {
	loaded = true;
}

function Init() {
			left_posi=document.getElementById('page').offsetLeft+document.getElementById('leftside').offsetLeft+document.getElementById('header').offsetLeft+document.getElementById('topmenu').offsetLeft;
			top_posi=document.getElementById('page').offsetTop+document.getElementById('leftside').offsetTop+document.getElementById('termekek').offsetHeight+7;
}

var menu_obj = null;
var left_posi;
var top_posi;

/**
	
	@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;
	
	if ( (this.isMSIE) || (this.isOPERA) )
	{
		this.eltolasx = ex;
		this.eltolasy = ey+57;
	}
	else
	{
		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 onMouseOut=\"this.style.backgroundColor='#6ba7dd';\" onMouseOver=\""+this.parent.nev+".submenu["+this.index+"].Show(); this.style.backgroundColor='#0051AC';\"><td width='5' valign='top' style='height: 18px; color: #F8FFD4; font-size: 11pt; text-decoration: none;'></td><td><a href='"+menupontok[menupont]+"' style='color: #F8FFD4; font-size: 10pt; text-decoration: none;'><b>"+menupont+"</b></a></td></tr>";
			} else {
				this.tartalom += "<tr onMouseOut=\"this.style.backgroundColor='#6ba7dd';\" onMouseOver=\""+nev+".Show(); this.style.backgroundColor='#0051AC';\"><td width='5' valign='top' style='height: 18px; color: #F8FFD4; font-size: 11pt; text-decoration: none;'></td><td><a href='"+menupontok[menupont]+"' style='color: #F8FFD4; font-size: 10pt; text-decoration: none;'><b>"+menupont+"</b></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",w,w,0,menupontok[menupont], this, this.menu_num);
			this.tartalom += "<tr onMouseOut=\"this.style.backgroundColor='#6ba7dd';\" onMouseOver=\""+nev+".Show(); this.style.backgroundColor='#0051AC';\"><td width='5' valign='top' style='height: 18px; color: #F8FFD4; 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: #F8FFD4; font-size: 10pt; text-decoration: none;'><b>"+menupont_neve+"</b></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: #6ba7dd; 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: #000000; 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 (left_posi != 'undefined' && loaded) {
		if (this.parent) {
			this.parent.Show();
			this.x = this.parent.x+document.getElementById(this.PosPic).offsetLeft;
			this.y = this.parent.y+document.getElementById(this.PosPic).offsetTop;
			/*this.x = this.parent.x+left_posi;
			this.y = this.parent.y+top_posi;*/
		} else {
			for (elem in this.submenu) {
				this.submenu[elem].hide_all = false;
			}
			/*this.x = document.getElementById(this.PosPic).offsetLeft;
			this.y = document.getElementById(this.PosPic).offsetTop;*/
			this.x = left_posi;
			this.y = document.getElementById(this.PosPic).offsetTop+top_posi;
		}
		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()",800);
		} else {
			this.timeout = setTimeout(this.nev+".HideNow()",800);
		}
	}
}

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

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);
}