﻿ /* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Konstantin Jagello | http://javascript-array.com/ */

var TimeOut = 300;
var currentLayer = null;
var currentitem = null;
var currentLayerNum = 0;
var noClose = 0;
var closeTimer = null;
var n_num = 1;
var menuflg = 0;
var submenuflg = 0;
var id;
var entry_hov_num;
var no_entry = 0;
var baseObj;
var liObj;
var lnln;
var onazi_num;
var strong_num;
var strongObj = new Array ();
function mopen (n)
{
	var l = document.getElementById ("menu" + n);
	var mm = document.getElementById ("mmenu" + n);
	/////////////
	baseObj = document.getElementById ("globalnav");
	liObj = baseObj.getElementsByTagName ("li");
	var lnln = liObj.length;
	for (w = 0; w < lnln; w ++)
	{
		strongObj [w] = liObj [w].getElementsByTagName ("strong")[0];
		if (strongObj [w] == undefined)
		{
			//alert(strongObj[w])
			
		}else
		{
			strong_num = w;
		}
	}
	strong_num = strong_num + 1;
	//////////////////
	menuflg = 1;
	//alert("aa")
	if (n != n_num)
	{
			var number_che = num_che(n_num);
			
			var func1 = kesu (number_che);
	}
	n_num = n;
	if (n_num != strong_num)
	{
		var number_che = num_che(n_num);
		//alert(number_che)
		Element.addClassName (liObj [number_che] , "ichi");
		//alert(n_num)
			}
	if (l)
	{
		mcancelclosetime ();
		l.style.visibility = 'visible';
		if (currentLayer && (currentLayerNum != n))
		currentLayer.style.visibility = 'hidden';
		currentLayer = l;
		currentitem = mm;
		currentLayerNum = n;
	} else if (currentLayer)
	{
		currentLayer.style.visibility = 'hidden';
		currentLayerNum = 0;
		currentitem = null;
		currentLayer = null;
		
			var number_che = num_che(n_num);
			var func1 = kesu (number_che);
			
		var fff = mopen (strong_num);
		no_entry = 1;
	}
}
function mclosetime ()
{
	closeTimer = window.setTimeout (mclose, TimeOut);
}
function mcancelclosetime ()
{
	if (closeTimer)
	{
		window.clearTimeout (closeTimer);
		closeTimer = null;
	}
}
function mclose ()
{
	if (currentLayer && noClose != 1)
	{
		currentLayer.style.visibility = 'hidden';
		currentLayerNum = 0;
		currentLayer = null;
		currentitem = null;
		//var func = kesu(n_num);
			var number_che = num_che(n_num);
			var func1 = kesu (number_che);
			
		//var func = kesu (n_num);
		var fff = mopen (strong_num);
		menuflg = 0;
		submenuflg = 0;
	} else 
	{
		noClose = 0;
	}
	currentLayer = null;
	currentitem = null;
	//alert("dddd")
}
function kesu (nnn)
{
	//alert("kesu")

	if (n_num != strong_num)
	{

		
		Element.removeClassName (liObj [nnn] , "ichi")
		//num_nnn++;
		
	}
}
document.onclick = mclose;
function outout ()
{
	//alert("outout"+no_entry)
	menuflg = 0;
	if (no_entry == 0)
	{
		id = setTimeout ("time_out()", TimeOut);
	}
	else
	{
		no_entry = 0;
		//var func= time_out();
		
		
			var number_che = num_che(n_num);
			var func1 = kesu (number_che);
			
			var func = mclose ();
	}
}
function time_out ()
{
	window.clearTimeout (id);
	if (menuflg == 0)
	{
		if (submenuflg == 0)
		{
			
			var number_che = num_che(n_num);
			var func1 = kesu (number_che);
			
			var func = mclose ();
			//var fff = mopen(strong_num);
			
		} else if (submenuflg == 1)
		{
		}
	}
}
function sub_over ()
{
	submenuflg = 1;
}
function sub_out ()
{
	submenuflg = 0;
}
////////////////////////////////
window.onload = function ()
{
	var strong_num;
	baseObj = document.getElementById ("globalnav");
	liObj = baseObj.getElementsByTagName ("li");
	var lnln = liObj.length;
	for (w = 0; w < lnln; w ++)
	{
		strongObj [w] = liObj [w].getElementsByTagName ("strong")[0];
		if (strongObj [w] == undefined)
		{
			//alert(strongObj[w])
			
		}else
		{
			strong_num = w;
		}
	}
	strong_num = strong_num + 1;
	var fff = mopen (strong_num);
	//alert(strong_num)
	//Event.observe(liObj[0],"mouseover",xxx);
var lnln = liObj.length;

	for (w = 1; w < lnln; w ++){
	Event.observe (liObj [w] , "mouseout", outout);
	}


	Event.observe ($ ("sub") , "mouseover", sub_over);
	Event.observe ($ ("sub") , "mouseout", sub_out);
}

function num_che(num_moto){
	
	var numnumnum = num_moto;
	numnumnum--;
	return numnumnum;
}

function mout(num_num){
		var number_che = num_che(n_num);
		var func1 = kesu (number_che);
}