// JavaScript Document


function menu()
{
	this.nodes=new Array();
	this.bgId="";
	this.useLinks=true;
	
	this.setHovImageReplaceString=function setReplStr(search_str,replace_str)
	{
		this.search_str=search_str;
		this.replace_str=replace_str;
		this.replaceObj=new RegExp(search_str);
	}
	
	this.setBackgroundReplaceString=function setReplStr(id,search_str,replace_str)
	{
		this.bgId=id;
		this.bgImgOld=document.getElementById(id).src;
		this.bgReplace_str=replace_str;
		this.bgReplaceObj=new RegExp(search_str);
	}
	
	this.build=function build(container_id)
	{
		topmenu=document.getElementById(container_id).getElementsByTagName("a");
		for (var i = 0; i < topmenu.length; i++) {
  			this.add(topmenu[i]);
		}
	}
	
	this.buildGallery=function build(container_id)
	{
		var items=document.getElementById(container_id).getElementsByTagName("img");
		for (var i = 0; i < items.length; i++) {
  			this.add(items[i]);
		}
	}
	
	this.add_single=function add_single(node_id,search_str,replace_str)
	{
		node=document.getElementById(node_id);
			
		node.image=node;
		node.image_src=node.image.src;
		replaceObj=new RegExp(search_str)
		node.image_hov_src=node.image_src.replace(replaceObj,replace_str);
		
		node.preload=new Image();
		node.preload.src=node.image_hov_src;
		
		node.onmouseover=this.hover;
		node.onmouseout=this.dehov;
		node.selected=false;
	}
	
	this.select=function select(id)
	{
		node=this.nodes[id];
		node.image.src=node.image_hov_src;
		node.selected=true;
	}
	
	this.add=function add(node)
	{
		if(!this.useLinks)
		{
			node.image_src=node.src;
			node.image_hov_src=node.image_src.replace(this.replaceObj,this.replace_str);
		}
		else
		{
			node.image=node.getElementsByTagName("img")[0];
			node.image_src=node.image.src;
			node.image_hov_src=node.image_src.replace(this.replaceObj,this.replace_str);
		}
		
	
		if(this.bgId!="")
		{
			node.bg={};
			node.bg.bg=document.getElementById(this.bgId);
			node.bg.bg_src=document.getElementById(this.bgId).src;
			node.bg.bg_hov_src=node.image_src.replace(this.bgReplaceObj,this.bgReplace_str);
			
			node.bg.preload=new Image();
			node.bg.preload.src=node.bg.bg_hov_src;
		}
		
		node.preload=new Image();
		node.preload.src=node.image_hov_src;
		
		node.onmouseover=this.hover;
		node.onmouseout=this.dehov;
		
		check=new RegExp(node.href)
		
		node.selected=false;
		if(node.className=="selected") node.selected=true;
		
		this.nodes[this.nodes.length]=node;
	}
	
	this.hover=function hover()
	{
		if(this.selected==false) 
		{
			if(this.image)this.image.src=this.preload.src;
			else if(this.src) this.src=this.preload.src;
		}
		
		if(this.bg && this.selected==false)
		{
			this.bg.bg_old_src=this.bg.bg.src;
			this.bg.bg.src=this.bg.preload.src;
		}
	}
	
	this.dehov=function dehov()
	{
		if(this.selected==false) 
		{
			if(this.image)this.image.src=this.image_src;
			else if(this.src) this.src=this.image_src;
		}
	
		if(this.bg && this.selected==false)
		{
			this.bg.bg.src=this.bg.bg_old_src;
		}
	}
}



function textmenu()
{
	this.nodes=new Array();
	
	this.build=function build(container_id)
	{
		topmenu=document.getElementById(container_id).getElementsByTagName("a");
		for (var i = 0; i < topmenu.length; i++) {
  			this.add(topmenu[i],i);
		}
	}
	
	this.select=function select()
	{
		this.old_style=this.style;
		if(this.style)
		{
			this.style.fontWeight="bold";
			this.style.color="#FFFFFF";
		}
		
		document.getElementById("m_cont_"+this.i).style.display="block";
		
		//node=this.nodes[id];
		//node.image.src=node.image_hov_src;
		this.selected=true;
		if(this.parent_menu.selected) 
		{
			this.parent_menu.selected.style.fontWeight="normal";
			this.parent_menu.selected.style.color="#CCCCCC";
			document.getElementById("m_cont_"+this.parent_menu.selected.i).style.display="none";
		}
		this.parent_menu.selected=this;
	}
	
	this.add=function add(node,i)
	{
		node.i=i;
		node.onclick=this.select;
		node.selected=false;
		node.parent_menu=this;
		
		this.nodes[this.nodes.length]=node;
	}
	
	this.hover=function hover()
	{
		//if(this.selected==false) this.image.src=this.preload.src; //this.image.src=this.image_hov_src;
	}
	
	this.dehov=function dehov()
	{
		//if(this.selected==false) this.image.src=this.image_src;
	}
}




/*
function menu()
{
	this.nodes=new Array();
	
	this.setHovImageReplaceString=function setReplStr(search_str,replace_str)
	{
		this.search_str=search_str;
		this.replace_str=replace_str;
		this.replaceObj=new RegExp(search_str)
	}
	
	this.build=function build(container_id)
	{
		topmenu=document.getElementById(container_id).getElementsByTagName("a");
		for (var i = 0; i < topmenu.length; i++) {
  			this.add(topmenu[i]);
		}
	}
	
	this.buildGallery=function(container_id,img_xl)
	{
		var menu=document.getElementById(container_id).getElementsByTagName("img");
		for (var i = 0; i < menu.length; i++) {
  			this.addGallery(menu[i],img_xl);
		}
	}
	
	this.addGallery=function(node)
	{
		
		node.image_src=node.src;
		node.image_hov_src=node.image_src.replace(this.replaceObj,this.replace_str);
		
		node.preload=new Image();
		node.preload.src=node.image_hov_src;
		
		node.onmouseover=this.hover;
		node.onmouseout=this.dehov;
		
		check=new RegExp(node.href)
		
		
		node.selected=false;
		
		this.nodes[this.nodes.length]=node;
	}
	
	
	
	
	this.add_single=function add_single(node_id,search_str,replace_str)
	{
		node=document.getElementById(node_id);
		
			
		node.image=node;
		node.image_src=node.image.src;
		replaceObj=new RegExp(search_str)
		node.image_hov_src=node.image_src.replace(replaceObj,replace_str);
		
		node.preload=new Image();
		node.preload.src=node.image_hov_src;
		
		
		this.hover=function hover()
		{
			if(this.selected==false) this.image.src=this.preload.src; //this.image.src=this.image_hov_src;
		}
		
		this.dehov=function dehov()
		{
			if(this.selected==false) this.image.src=this.image_src;
		}
		
		
		node.onmouseover=this.hover;
		node.onmouseout=this.dehov;
		node.selected=false;
	}
	
	this.select=function select(id)
	{
		node=this.nodes[id];
		node.image.src=node.image_hov_src;
		node.selected=true;
	}
	
	this.add=function add(node)
	{
		node.image=node.getElementsByTagName("img")[0];
		node.image_src=node.image.src;
		node.image_hov_src=node.image_src.replace(this.replaceObj,this.replace_str);
		
		node.preload=new Image();
		node.preload.src=node.image_hov_src;
		
		node.onmouseover=this.hover;
		node.onmouseout=this.dehov;
		
		check=new RegExp(node.href)
		
		
		node.selected=false;
		
		this.nodes[this.nodes.length]=node;
	}
	
	this.hover=function hover()
	{
		if(this.selected==false) this.image.src=this.preload.src; //this.image.src=this.image_hov_src;
	}
	
	this.dehov=function dehov()
	{
		if(this.selected==false) this.image.src=this.image_src;
	}
}



function textmenu()
{
	this.nodes=new Array();
	
	this.build=function build(container_id)
	{
		topmenu=document.getElementById(container_id).getElementsByTagName("a");
		for (var i = 0; i < topmenu.length; i++) {
  			this.add(topmenu[i],i);
		}
	}
	
	this.select=function select()
	{
		this.old_style=this.style;
		if(this.style)
		{
			this.style.fontWeight="bold";
			this.style.color="#FFFFFF";
		}
		
		document.getElementById("m_cont_"+this.i).style.display="block";
		
		//node=this.nodes[id];
		//node.image.src=node.image_hov_src;
		this.selected=true;
		if(this.parent_menu.selected) 
		{
			this.parent_menu.selected.style.fontWeight="normal";
			this.parent_menu.selected.style.color="#CCCCCC";
			document.getElementById("m_cont_"+this.parent_menu.selected.i).style.display="none";
		}
		this.parent_menu.selected=this;
	}
	
	this.add=function add(node,i)
	{
		node.i=i;
		//node.image=node.getElementsByTagName("a")[0];
		//node.image_src=node.image.src;
		//node.image_hov_src=node.image_src.replace(this.replaceObj,this.replace_str);
		
		//node.preload=new Image();
		//node.preload.src=node.image_hov_src;
		
		//node.onmouseover=this.hover;
		//node.onmouseout=this.dehov;
		node.onclick=this.select;
		node.selected=false;
		node.parent_menu=this;
		
		this.nodes[this.nodes.length]=node;
	}
	
	this.hover=function hover()
	{
		//if(this.selected==false) this.image.src=this.preload.src; //this.image.src=this.image_hov_src;
	}
	
	this.dehov=function dehov()
	{
		//if(this.selected==false) this.image.src=this.image_src;
	}
}

function open_album(url)
{
        var left = (screen.availWidth - 549  ) / 2;
        var top = (screen.availHeight - 549 ) / 2;
		
		album_window=window.open(url,"album_window","width=549,height=549,left="+left+",top="+top+",status=no");
		album_window.focus();
}
*/
