var visible = 0;
var timer = 0;
var visible2 = 0;
var timer2 = 0;
var timer3 = 0;
var timer4 = 0;

var DOM=(document.getElementById)?true:false;
var IE4=(document.all)?true:false;

function showMenu(id)
{
	keepMenu();
	
	if(visible2)
		hideMenu2();

	if(visible)
		hideMenu();
		
	timer3 = setTimeout('showMenu1(' + id + ')', 200);
}

function showMenu1(id)
{
	var drop = (DOM)?document.getElementById('mmd' + id):((IE4)?document.all['mmd' + id]:null);
	
	visible = id;	
	drop.style.visibility = 'visible';
	keepMenu();
}

function showMenu2(id)
{
	keepMenu2();
	if(visible2)
		hideMenu2();
	
	timer4 = setTimeout('showMenu21(' + id + ')', 200);
}

function showMenu21(id)
{
	var drop = (DOM)?document.getElementById('mmd2_' + id):((IE4)?document.all['mmd2_' + id]:null);
	
	visible2 = id;
	drop.style.visibility = 'visible';
	keepMenu2();
}

function keepMenu()
{
	if(timer)
		clearTimeout(timer);
}

function hide()
{
	timer = setTimeout('hideMenu()', 1000);
	if(timer3)
	{
		clearTimeout(timer3);
		if(!visible)
			clearTimeout(timer);
	}
}

function hideMenu()
{
	var drop = (DOM)?document.getElementById('mmd' + visible):((IE4)?document.all['mmd' + visible]:null);
	
	drop.style.visibility = 'hidden';
	visible = 0;
}

function keepMenu2()
{
	if(timer2)
		clearTimeout(timer2);
}

function hide2()
{
	timer2 = setTimeout('hideMenu2()', 1000);
	if(timer4)
	{
		clearTimeout(timer4);
		if(!visible2)
			clearTimeout(timer2);
	}	
}

function hideMenu2()
{
	if (visible2 == 0)
		return;
	var drop = (DOM)?document.getElementById('mmd2_' + visible2):((IE4)?document.all['mmd2_' + visible2]:null);
	
	drop.style.visibility = 'hidden';
	visible2 = 0;
}

function iinfo(id)
{
	var hf = (DOM)?document.getElementById('ii' + id):((IE4)?document.all['ii' + id]:null);
	alert(hf.offsetTop);
}

function imgView(imgLink,Title) {
if (typeof(window.resizeBy)=='undefined') return true;
  imgWndw=window.open('',imgLink.target,'width=550,height=500'+
    ',toolbar=no,menubar=no,location=no,status=no,'+
    'resizable=yes,scrollbars=yes,left='+(screen.width>>>2)+
	',top='+(screen.height>>>4));
  var imgTitle=(Title)?Title:imgLink.href;
  with (imgWndw.document){
    open();
    write('<ht'+'ml><he'+'ad><ti'+'tle>'+imgTitle+'</ti'+'tle>'+
    '</he'+'ad><bo'+'dy leftmargin="0" topmargin="0" '+
    'rightmargin="0" bottommargin="0" marginwidth="0" '+
    'style="margin:0;padding:0;position:fixed;overflow:none;" '+
    'marginheight="0"><img src="'+imgLink.href+'" border="0" '+
    ' alt="'+imgTitle+'" title="'+imgTitle+'"></bo'+'dy></ht'+'ml>');
    close();
  }
  //resId=setInterval('imgResize()',100);
  return false;
}

function imgResize() {
	var w=imgWndw.document.images[0].width;
	var h=imgWndw.document.images[0].height;
	if (w>50 && h>50) {
		var ww=(imgWndw.innerWidth)?imgWndw.innerWidth:((document.body)?
			imgWndw.document.body.clientWidth:null);
		var wh=(imgWndw.innerHeight)?imgWndw.innerHeight:((document.body)?
			imgWndw.document.body.clientHeight:null);
		if (ww && wh) {
			imgWndw.resizeBy(w-ww,h-wh);
		}
		imgWndw.focus();
		clearInterval(resId)
	}
}
