// ===========================================
// written by jason law, vantage computing ltd
// ===========================================

obj_to_hide = null;
timeout_id = 0;

function SetImage(Container, Img)
	{
	var Target = FindObject(Container);

	if (Target != null)
		Target.src = eval(Img + ".src");
	}
	
function FindObject(ObjToFind)
	{
  	var Obj;

	if(document.all)
  		Obj = document.all[ObjToFind];

  	if(!Obj && document.getElementById)
  		Obj = document.getElementById(ObjToFind);

	return Obj;
	}

function HideMenu(evt)
	{
 	var Obj,NextObj,Found=false;

	if(document.all && !window.opera)
		{
		Obj = event.srcElement;

		// See if this or parent objects need to hide...
		while(Obj != null)
			{
			if (Obj.NeedToHide)
				break;

			Obj = Obj.parentElement;
			}

		// Only hide if we have not moved to an element in the current object...
		if (Obj != null)
			if(!Obj.contains(event.toElement))
				Obj.style.visibility = "hidden";
	 	}
 	else if(document.getElementById)
		{
		Obj = evt.currentTarget;
		NextObj = evt.relatedTarget;

		while(NextObj != null)
			{
			if(Obj == NextObj)
				{
				Found = true;
				break;
				}
			NextObj = NextObj.parentNode;
			}

		if(!Found)
			Obj.style.visibility="hidden";
		}
	}

function HideOnMouseOut()
	{
	var Obj;
	var args=HideOnMouseOut.arguments;

	Obj = FindObject(args[0]);
	if(Obj != null)
		{
		Obj.onmouseout=HideMenu;
		Obj.NeedToHide=true;
		}
	}

function HandleMouseOver()
	{
	var i,p,Visibility,Obj,args=HandleMouseOver.arguments;

	for (i=0; i < (args.length-1); i+=2)
		{
		Obj = FindObject(args[i]);

		if (Obj != null)
			{
			Visibility = args[i+1];

	    		if (Obj.style)
	    			{
				Obj = Obj.style;
				Visibility=(Visibility=='show') ? 'visible' : (Visibility=='hide') ? 'hidden' : Visibility;
				}

	    		if (Obj.visibility != Visibility )
	    			{
		    		Obj.visibility = Visibility;
		    		
				if (Visibility == "visible")
					{
					if (timeout_id)
						clearTimeout(timeout_id);
						
					obj_to_hide = args[i];
					timeout_id = setTimeout("HideTheMenu()", 1500);
					}
				}	    		
		    	}
		}
	}

function HideTheMenu()
	{
	var Obj;

	if (obj_to_hide != null )
		{
		Obj = FindObject(obj_to_hide);
		if (Obj)
			{
			Obj.style.visibility = "hidden";
			}
		}
	}

function MenuMouseOver()
	{
	obj_to_hide = null;
	}
	