var timers=new Array();
var active=null;

function openMenu(id){
	if(timers[id]){
		clearTimeout(timers[id]);
		timers[id]=null;
	}

	if(active) closeMenu2(active);

	document.getElementById(id+'_sub').style.visibility='visible';
	var tmp=document.getElementById(id);
	tmp.style.background="url(images/menu.gif) repeat-x";

	var img1=document.createElement("img");
	img1.src="images/menu_left.gif";
	img1.style.position="absolute";
	img1.style.left="0px"; img1.style.top="0px";
	img1.style.width="10px"; img1.style.height="37px";

	var img2=document.createElement("img");
	img2.src="images/menu_right.gif";
	img2.style.position="absolute";
	img2.style.right="0px"; img2.style.top="0px";
	img2.style.width="10px"; img2.style.height="37px";

	tmp.appendChild(img1); tmp.appendChild(img2);
	img1=null; img2=null;

	active=id;
}

function closeMenu(id){
	timers[id]=setTimeout("closeMenu2('"+id+"');",500);
}

function closeMenu2(id){
	if(timers[id]){
		clearTimeout(timers[id]);
		timers[id]=null;
	}

	var tmp=document.getElementById(id+'_sub');
	if(tmp.className.indexOf("open")>0) return false;

	tmp.style.visibility='hidden';
	var tmp=document.getElementById(id);
	tmp.style.background="none";

	var imgs=tmp.getElementsByTagName('img');
	if(imgs[1]) tmp.removeChild(imgs[1]);
	if(imgs[0]) tmp.removeChild(imgs[0]);

	active=null;
}