// ***********************************************************
// JavaScript DHTML common functions

// Bob Osola for Taylor Made Computer Solutions
// Sep 2002 Tel 01329 239900 bobo@tmcs.co.uk

// last amended 09-July-2004

//***************************************************************
// SET THIS VARIABLE ACCORDINGLY

// root-relative path to main CSS file
var cssPath = "/main.css"

//***************************************************************

// If JS is enabled, then write out the main CSS file. 
// Otherwise the default basic one is used.

if (document.getElementById)
   document.write ('<style TYPE="text/css">@import url(' + cssPath + ');</style>')

window.onload = loadFunctions

function loadFunctions()
{
	// functions to run on page load
	hideObj(arSubMenus);
}

function getObj(IDval)
// based on code by Peter Paul Koch
// uses a DOM-sniff rather than the more restrictive browser sniff.

{
   this.goodbrowser = false;
   if (document.getElementById) // latest browsers
   {
	  if (document.getElementById(IDval))
	  {
         this.obj = document.getElementById(IDval);
 	     this.style = document.getElementById(IDval).style;
	     this.goodbrowser = true;
	  }
   }
}

// ***********************************************************

function showHide(IDtoToggle, arKeepHidden, PosY)

// shows or hides IDtoToggle at Y position of mouse
// and keeps hidden all objects in arKeepHidden

{
   var myObj;
   for(var i = 0; i < arKeepHidden.length; i++) 
   {
	  myObj = new getObj(arKeepHidden[i]); 
	  if (myObj.goodbrowser)
	  {
		 // hide all the other objects
		 if (myObj.obj.id != IDtoToggle)  
		    myObj.style.visibility = "hidden";
		 else
		 {
			if (myObj.style.visibility == "visible")
				myObj.style.visibility = "hidden";
			else
			{
			   myObj.style.top = PosY + "px";
			   myObj.style.visibility = "visible";
		    }
	     }
      }
   }
}

// ***********************************************************

function isArray(obj)
{
   return(typeof(obj) == 'object' && obj.constructor == Array)	  
} 

// ***********************************************************

function hideObj(obj)

// hides an object.
// If the object is an array of objects, then hide all them all

{
   var myObj;
   if (isArray(obj))
   {
      for(var i = 0; i < obj.length; i++) 
	  {
	     myObj = new getObj(obj[i]); 
	     if (myObj.style)
	        myObj.style.visibility = "hidden";	 
	  }
   }
   else
   {
      myObj = new getObj(obj)
	  if (myObj.style)
	      myObj.style.visibility = "hidden";
   }
}

function getPosY(obj)
{
	// from www.quirksmode.org
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// ***********************************************************
