gPic=function(id,img,text)
{
	this.id=id;
	this.img=img;
	this.text=text;
}
gCat=function(id)
{	
	this.id=id;
	this.pic=new Array();
}
gCat.prototype.has=function(id)
{
}
var active_menu = null;
var active_pic = null;
var active_catalog = null;
var _gallery=new Array()

//e-mail címek elrejtése SPAMBot-ok elől
function email_cim(user,domain)
{
var kukac = "@"
document.write("<" + "a" + " " + "href=" + "mail" + "to:" + user + kukac + domain + ">" + user + kukac + domain + "<\/a>");
}
function addPic(path,label,reference,text)
{
	g=path.split("_");
	if(g==null)
		return;
	var m=document.getElementById("menu_"+g[0]);
	if(m==null)						//create menu item
	{
		var mr = document.getElementById("menu").insertRow(-1);
		mr.id="menu_"+g[0];
		m = mr.insertCell(-1);
		m.insertBefore(document.createTextNode(g[0]),null);
		m.className="menu";
		m.colSpan="5";
		m.onmouseover=function(){ menuOver(this) }
		m.onmouseout=function(){ menuOut(this) }
		if(g.length>1)					// with submenu
		{
			m.onclick=function(){ shSub(this) }
			m.style.height="12px";
			ms=document.getElementById("menu").insertRow(-1);
			ms.style.visibility="hidden";
		}
		else						// no submenu
		{
			m.onclick=function(){ showGallery(this,path) };
			m.style.height="32px";
		}
	}
	
	if(g.length>1)
	{
		var m=document.getElementById("menu_"+path);
		if(m==null)
		{
			ms=document.getElementById("menu_"+g[0]);
			m=ms.nextSibling.insertCell(-1);
			m.id="menu_"+path;
			m.insertBefore(document.createTextNode(g[1]),null);
			m.className="menu";
			m.onmouseover=function(){ menuOver(this) }
			m.onmouseout=function(){ menuOut(this) }
			m.onclick=function(){ showGallery(this,path) }
			m.style.height="20px";
			m.style.fontSize="10px";
			m.style.paddingLeft="8px";
		}
	}

	if(label!="")
	{
		var _cat=null;
		for(i=0;i<_gallery.length;i++)
			if(_gallery[i].id==path)
				_cat=_gallery[i]
		if(_cat==null)
		{
			_cat=new gCat(path)
			_gallery.push(_cat)
		}
		_pic=null;
		for(i=0;i<_cat.pic.length;i++)
			if(_cat.pic[i].id==label);
				_pic=_cat.pic[i];
		if(_pic==null)
			_cat.pic.push(new gPic(label,reference,text))
	}

}
function menuOver(caller)
{
	caller.className="menuhigh";
}
function menuOut(caller)
{
	if(caller!=active_menu)
		caller.className="menu";
}
function deactivateMenu()
{
	if(active_menu!=null)
		active_menu.className="menu";
}
function nextPic()
{
	var g=document.getElementById("gallery").rows[0];
	if(active_pic+1<g.cells.length-1)
	{
		active_pic++;
		g.cells[active_pic].onclick();
	}
}
function prevPic()
{
	var g=document.getElementById("gallery").rows[0];
	if(active_pic-1>0)
	{
		active_pic--;
		g.cells[active_pic].onclick();
	}
}
function showPic(caller)
{
	active_pic=caller.cellIndex;
	g=document.getElementById("gallery").rows[0];
	for(i=0;i<g.cells.length;i++)
		g.cells[i].className="nav";
	caller.className="navhigh";
	for(i=0;i<active_catalog.pic.length;i++)
		if(active_catalog.pic[i].id==caller.firstChild.nodeValue)
		{
			document.getElementById("portfolio").style.backgroundImage="url(img/portfolio_gray.jpg)"
			document.getElementById("view").src=active_catalog.pic[i].img;
			t=active_catalog.pic[i].text.split("%n");
			with(document.getElementById("textview"))
			{
				while(hasChildNodes())
					removeChild(lastChild);
				for(j=0;j<t.length;j++)
				{
					if(j>0)
						appendChild(document.createElement("BR"));
					appendChild(document.createTextNode(t[j]));
				}
			}
		}
}
function shSub(caller)
{
	with(caller.parentNode.nextSibling)
		if(style.visibility=="hidden")
		{
			style.visibility="visible";
		}
		else
		{
			style.visibility="hidden";
			for(i=0;i<cells.length;i++)
				if(cells[i]==active_menu)
				{
					cells[i].className="menu";
					active_menu=null;
					hideGallery();
					document.getElementById("portfolio").style.backgroundImage="url(img/portfolio.jpg)"
				}
		}

}
function hideGallery()
{
	with(document.getElementById("gallery"))
	{
		style.display="none"
		while(rows[0].cells.length>2)
			rows[0].deleteCell(1)
	}
	document.getElementById("view").style.display="none";
	with(document.getElementById("textview"))
			while(hasChildNodes())
					removeChild(lastChild);
}

function showGallery(caller,gal)
{
	deactivateMenu();
	active_menu=caller;
	caller.className="menuhigh"
	hideGallery();

	active_catalog=null
	for(i=0;i<_gallery.length;i++)
	{
		if(_gallery[i].id==gal)
		{
			active_catalog=_gallery[i]
		}
	}
	if(active_catalog==null)
		return;
	var g=document.getElementById("gallery");
	for(i=0;i<active_catalog.pic.length;i++)
	{
		var n=document.createElement("TD");
		n.className="nav";
		n.onclick=function(){ showPic(this) };
		n.insertBefore(document.createTextNode(active_catalog.pic[i].id),null);
		g.rows[0].insertBefore(n,g.rows[0].cells[g.rows[0].cells.length-1]);
	}
	g.style.display="";
	active_pic=1;
	g.rows[0].cells[active_pic].onclick();
	document.getElementById("view").style.display="";
}

