/* 

	CatNav - DOM client side version 1.4 
	// Feb 2005 - updated for Mozilla Firefox 
	
	(c)2005 p21 // Ken McCormack

*/

	var debugMode = false;
		
	var siteName ="RPLA"
	var homeLink = "/"
	var homePagename = "Home"
	var showBCsOnHomePage = false;

	var subFgColor	= "#404040";	// submenu text colour
	var subBgColor	= "#8BDCF1";	// the normal submenu cell colour
	var subHLColor	= "#F3AD5F";	// the rollover cell colour
	//var subWidth	= 280;			// default submenu wudth
	var subHeight	= 20;			// default submenu height		
	var subStyle    = "" 			// additional positioning style (optional)
	
	var bUseParentWidth = true;		//	whether subnav uses the width setting of the parent
	// category script settings
	var showDelay = 100;			// delay in mS before the subnav is displayed
	var hideDelay = 1000;			// delay on roll ou before the subnav is hidden

	// framed / unframed menu positioning offset settings 
	var yOffset = 35; 	var xOffset = 0; // offset position of subnavs on flat page
	var frameyOffset = 0; var framexOffset = -8;  // offset position of subnavs on frame page 
	var refreshRate = 100;  // this menu refresh be called every 500 ms

	/*
		Definition of page category object
	*/

	var subNavArray = new Array();  // this stores the display status of each subnav
	var subNavsActive = false; 		// flags whether subnavs active and CSS needs to be rendered to page
	var isFramePage = false;		// flags whether this is a frameset page
	var subNavsRendered = false;
	var subMenuEvents = new Array(); // logs all events for subnav
	var timoutlog = new Array();
		
	var pageCategory = new Array();
	// pageCategories(catName,catID,CatURL,parentCat)
	pageCategory[pageCategory.length] = new pageCategories("home",1,"/index.htm","");
	
	pageCategory[pageCategory.length] = new pageCategories("about us",2,"/about_continuum_music.htm","");
		//pageCategory[pageCategory.length] = new pageCategories("",37,"/.htm","2");
		//pageCategory[pageCategory.length] = new pageCategories("",21,"/.htm","2");
		//pageCategory[pageCategory.length] = new pageCategories("",39,"/.htm","2");
	
	pageCategory[pageCategory.length] = new pageCategories("about us",3,"/aboutus.asp?Page_ID=60","");
		pageCategory[pageCategory.length] = new pageCategories("history",41,"aboutus.asp?page_id=74","3");
		pageCategory[pageCategory.length] = new pageCategories("corporate structure",4,"aboutus.asp?Page_ID=67","3");
		pageCategory[pageCategory.length] = new pageCategories("corporate profiles",6,"aboutus.asp?page_id=66","3");
		pageCategory[pageCategory.length] = new pageCategories("conduct",7,"aboutus.asp?page_id=64","3");
		pageCategory[pageCategory.length] = new pageCategories("mission &amp; vision",8,"aboutus.asp?page_id=65","3");
		
		//pageCategory[pageCategory.length] = new pageCategories("",9,"/.htm","3");
		//pageCategory[pageCategory.length] = new pageCategories("",35,"/.htm","3");
		
		
	pageCategory[pageCategory.length] = new pageCategories("news",10,"news.asp","");
		pageCategory[pageCategory.length] = new pageCategories("archive",34,"newsarchive.asp","10");
		pageCategory[pageCategory.length] = new pageCategories("email updates",11,"emailupdates.asp","10");
		//pageCategory[pageCategory.length] = new pageCategories("",12,"/.htm","10");
		//pageCategory[pageCategory.length] = new pageCategories("",12,"/.htm","10");
		
		
	pageCategory[pageCategory.length] = new pageCategories("players",14,"players.asp","");
		pageCategory[pageCategory.length] = new pageCategories("member services",15,"players.asp?page_id=90","14");
		//pageCategory[pageCategory.length] = new pageCategories("fun stuff",16,"players.asp?page_id=106","14");
		pageCategory[pageCategory.length] = new pageCategories("legal",38,"players.asp?page_id=88","14");
		pageCategory[pageCategory.length] = new pageCategories("documents",13,"playersdocuments.asp","14");

	pageCategory[pageCategory.length] = new pageCategories("cba &amp; rules",17,"content.asp?page_id=62","");
		pageCategory[pageCategory.length] = new pageCategories("cba downloads",18,"cbadocuments.asp","17");
		//pageCategory[pageCategory.length] = new pageCategories("",19,"/.htm","17");
		//pageCategory[pageCategory.length] = new pageCategories(" ",20,"/.htm","17");
		


	
	pageCategory[pageCategory.length] = new pageCategories("servicing and repairs",36,"/studio_electronics_repair_services.htm","");
		
	pageCategory[pageCategory.length] = new pageCategories("music tuition",43,"/music_tuition_sydney.htm","");
		//next available is 44
		
	pageCategory[pageCategory.length] = new pageCategories("podcasts",42,"/podcasts/index.htm","");

onload = initialise;

function initialise()
{
	debug("initialise");
	//showSubMenus(); // now called explictly
	showBreadCrumbs();
	updateAllNavEvents(); // starts timeout loop
	if (isFramePage) parent.maindoc.goToPage(); // load lhs frame 
	setMenusAsCurrent();
}


////////////////////////////////////// browser detect
var agt		= navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ns  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
var is_ie   = (agt.indexOf("msie") != -1);
var is_safari = (agt.indexOf("safari") != -1);
 
var is_nsLegacy = (is_ns && (is_major <= 4));
// this will also exempt Mac IE
var is_ieLegacy  = (is_ie && (is_major <= 4) && (agt.indexOf("msie 5")==-1) && (agt.indexOf("msie 6")==-1)  && (agt.indexOf("msie 7")==-1));

// if browser is legacy  then we dont use dhtml flyout menus etc.
var is_legacy = (is_nsLegacy || is_ieLegacy);

var isMac = false;
var navPlatform = navigator.platform;
if (navPlatform=="MacPPC" || navPlatform=="Mac68K")  isMac = true;
//alert ("Is legacy? " + is_legacy + "\n" + agt + "\n" + " NS legacy: " + is_nsLegacy + " IE legacy:" + is_ieLegacy + ' ismajor=' + is_major);

////////////////////////////////////// intitialise code

var target = document;

// this detects a main frame called 'maindoc'
// if no frameset is detected here, subnav objected are written into the same window

// detect framed page
if (parent) 
	if (parent.frames) 
		if (parent.frames.maindoc)
			if (target = parent.frames["maindoc"].document)
			{
				isFramePage = true;
				yOffset = frameyOffset;
				xOffset = framexOffset;
				debug("maindoc frame detected");				
			}

////////////////////////////////////////////////////////// category objects + methods

function pageCategories(catName,catID,CatURL,parentCat)
{
	this.catName = catName;
	this.catID = catID;
	this.parentCat = parentCat;
	this.CatURL = CatURL // + "&parentcat_id=" + catID;
}

function getCategoryURLbyName(catName)
{
	debug ("Get category by name called for " + catName);
	for (var i=0; i<pageCategory.length; i++)
		if (pageCategory[i].catName.toLowerCase() == catName.toLowerCase())
			return pageCategory[i].CatURL
	return "";
}

function showSubMenus()
{
	debug("showSubMenus()");
	if (document.layers) return; // not for NS4

	// frame menus are rendered when the content frame calls renderMenu()
	if (isFramePage && !subNavsRendered) return; 
	
	// show sub navs fot top level categories
	for (var i=0; i<pageCategory.length; i++)
		if (pageCategory[i].parentCat == "")
		{
			showSubCategoryNav(pageCategory[i].catID);
		}
	subNavsRendered = true;
}

function renderMenu()
{	
	// render subnavs when in frame mode - this must be called by the main frame 'maindoc' onload event
	target = parent.frames["maindoc"].document;
	subNavsRendered = true;
	showSubMenus();
}

function showSubCategoryNav(parentCatId)
{
	
	var subWidth	= 140;			// default submenu wudth
	var subHeight	= 20;			// default submenu height		
	var subStyle    = "" 			// additional positioning style (optional)
	
	var bUseParentWidth = true;		//	whether subnav used the width setting of the parent
	
	var templateTop1 	= "<div id=\"submenu[parentCatId]\" style=\"position:absolute; z-index:4; visibility: hidden; " + subStyle + "\" class=\"submenu\">\n";
	//var templateTop1 	= "<div id=\"submenu[parentCatId]\" style=\"position:absolute; z-index:4; " + subStyle + "\" class=\"submenu\">\n";
	var templateTop2 	= "<table width=\"" + subWidth + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
	var templateLoop 	= "<tr><td class=\"subtable\" id=\"row[uniqueRowId]\" onClick=\"[target]goLink('[categoryLink]');\"";
		templateLoop 	+= ' onmouseout="[target]showHide(\'[parentCatId]\',\'\',\'hide\',false,true);"'
		templateLoop 	+= ' onmouseOver="[target]showHide(\'[parentCatId]\',\'\',\'show\',false,true);" '
		templateLoop 	+= " style=\"cursor:hand;\">\n";
		templateLoop 	+= "<div class=\"submenu-row\">[link]</div>";
		templateLoop 	+= '</td></tr>\n\n'
	var templateFoot 	= '</table></div>\n';	

	// NS4 uses onclick for a link
	var linkString = "<a href=\"javascript:[target]goLink('[categoryLink]');\" class=\"submenu-link\">[CategoryName]</a>";
	if (document.layers) 
		linkString = "<a href=\"#\" class=\"submenu-link\" onClick=\"[target]goLink('[categoryLink]');\">[CategoryName]</a>";

	var concatString 	= ""; 	
	
	for (var i=0; i<pageCategory.length; i++)
		if (pageCategory[i].parentCat == parentCatId)
		{   
			if (concatString == "") concatString = templateTop1 + templateTop2;
			
			var loopString = templateLoop.replace(/\[link\]/gi,linkString);
			loopString = loopString.replace(/\[categoryLink\]/gi,pageCategory[i].CatURL);
			loopString = loopString.replace(/\[CategoryName\]/gi,pageCategory[i].catName);
			loopString = loopString.replace(/\[uniqueRowId\]/gi,parentCatId + "_" + i);
			
			concatString += loopString;
		}
	
	if (concatString != "") 
	{   // new sub nav menu must be registered
	
		concatString += templateFoot;
		concatString = concatString.replace(/\[parentCatId\]/gi,parentCatId);

	var targetString = ((isFramePage) ? "parent.menu." : "");
		
		concatString = concatString.replace(/\[target\]/gi,targetString);
		debug(concatString);
		
		if (isFramePage)
		{ // insert into body
			target = parent.frames["maindoc"].document;
			var x = target.body.innerHTML;
			x = x + concatString;
			target.body.innerHTML = x;
			//window.status = 'code written';
		}
		else
		{
			//alert(concatString);
			target.write (concatString); 
		}
		
		subNavArray[subNavArray.length] = new subNavObj(parentCatId);
 
	}
	
	debug("subNavArray.length= " + subNavArray.length);
}

////////////////////////////////////// track submenus

function subNavObj(id)
{
	this.id = id;
	this.display = "none";
}

/////////////////////////////////////////////////////// breadcrumbs

var breadCrumbString = ""; // global passed to recursive reverse lookup
var separator = "";
var defaultSeparator = " &gt; ";
var bookMarkTitle = "";

function showBreadCrumbs()
{
	// CHeck for frame page
	//|| typeof(pageName) == "undefined" 
	if (isFramePage || (!showBCsOnHomePage && pageName =="Home") || (typeof(categoryLabel) == "undefined"))
	{
		return;
	}
	
	// Check for home page 
	//if return; 
	
	if (categoryLabel == "") 
	{
		// this is a document
		breadCrumbString = '<span class="breadcrumb-article">' + pageName + '</span>';
		separator = defaultSeparator;
		// use articles own category to contstruct breadcrumb tree, rather than the category qstring 
		categoryId = pageCatId;
		debug ("setting categoryId = pageCatId ( " + pageCatId.toString() +  " )");
		bookMarkTitle = siteName + " - " + pageName; 
	}
	else
	{
		//debug ("This is a category");
		bookMarkTitle = siteName + " - " + categoryLabel; 
	}
	
	// construct cat tree, concatenating breadCrumbString
	if (typeof(categoryId) != "undefined")
		if (categoryId != "") getCategoryTree(categoryId);
		
	breadCrumbString = '<a href="'+ homeLink +'" class="breadcrumb-home-link">' + homePagename + '</a>' + separator + breadCrumbString;

	if (!document.getElementById) return;
	if (!document.getElementById('breadcrumbs')) return;
	x = document.getElementById('breadcrumbs');
	x.innerHTML = breadCrumbString;
	
	//var wrapper = document.getElementById("menu-bar2");
	//if (wrapper) wrapper.style.display = "block";
}

function getCategoryTree(id)
{ // this function concatenates a breadcrumb tree in the global variable breadCrumbString
	debug ("Getting cat tree for " + id);
	debug ("pageCategory.length = " + pageCategory.length);
	
	for (var i=0; i<pageCategory.length; i++)
	{
		if (pageCategory[i].catID == id)
		{
			debug("comparing pageCategory[i].catID == id " + pageCategory[i].catID + " == " + id)
			// if parent Category has no parent, use no link (top level cats have no pages) 
			//if (pageCategory[i].parentCat == "" && !is_legacy)
			//{
			//	breadCrumbString = pageCategory[i].catName + separator + breadCrumbString;
			//	separator = defaultSeparator;
			//}
			//else
			//{	// else use a link
				// detect current category - no link is required, we're on the page
				var loc = document.location.href.toString();
				if (loc.indexOf(pageCategory[i].CatURL) == -1)
					breadCrumbString = '<a href="'+ pageCategory[i].CatURL +'" class="breadcrumb-link">' + pageCategory[i].catName + '</a>' + separator + breadCrumbString;
					else
						breadCrumbString = '<span class="breadcrumb-article">' + pageCategory[i].catName + '</span>' + separator + breadCrumbString;
				separator = defaultSeparator;
			//}
			
			//debug ("Category tree now " + breadCrumbString);
			
			if (pageCategory[i].parentCat != "")
				getCategoryTree(pageCategory[i].parentCat);  // recursive call
		}
	}
}

function getTopLevelParentId(navCategoryId)
{ // NOT TESTED 
  // This is to display the top level nav rollover 
  // aim is to feed in the current category id and this function will return its top level category 
  
	for (var i=0; i<pageCategory.length; i++)
		if (pageCategory[i].catID == navCategoryId)
			if (pageCategory[i].parentCat == "") return pageCategory[i].catID;
				else
					return getTopLevelParentId(pageCategory[i].catID);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	fuzzy logic / real time nav model - not dependent on the browser storing multiple timeouts
//	events are logged in the subMenuEvents array
//
//////////////////////////////////////////////////////////////////////////////////////////////////////

// globals
var statusString = "";  // this string used only for debugging
var arrayPointer = 0;


function navEvent(navId,eventType,timeRemaining)
{ // this object stores a show / hide event for a submenu item
//alert("creating new nav event - id=" + navId + " type = " + eventType + " time Remaining = " + timeRemaining);
	this.navId = navId;			// id of subnav being shown / hidden
	this.eventType = eventType;	// show or hide
	this.timeRemaining = timeRemaining;  // refresh time in ms - see refreshRate
	this.updateEvent = updateNavEvent;	// increment time value and show / hide / delete as applicable
}

function updateAllNavEvents()
{ // loop function to continually update status of all events
	if (is_legacy) return; // not for NS4, IE4 etc

	statusString = ""; arrayPointer = 0; // global
	
	while (arrayPointer < subMenuEvents.length)
	{
		subMenuEvents[arrayPointer].updateEvent(arrayPointer);
	}

	 showNavArray();
	
	window.setTimeout("updateAllNavEvents()",refreshRate);
}

function updateNavEvent(index)
{
	this.timeRemaining = this.timeRemaining - refreshRate;
	if (this.timeRemaining < 1) 
	{
		showHideUniqueMenu(this.navId,this.eventType);
		removeElement(subMenuEvents,index);
		// array pointer does not move - as we've chopped the array element! 
	}
	else
	{
		arrayPointer++; // show next element
	}
	return true; // event will not be removed
}

function removeElement(array,elementIndex)
{	// this function removes index elementIndex from array - array must be global // ie 6 // ns 4+

	//window.status = "390 removing element "  + arrayPointer + " id=" + array[elementIndex].navId + " type=" + array[elementIndex].eventType;

	if (!array.length) return false;
	if (array.length <= elementIndex) return;
	var indexCounter = 0;
	for (var i=0; i < array.length; i++)
		if (i != elementIndex) 
		{
			array[indexCounter] =array[i];
			indexCounter++;
		}
	array.length = array.length - 1;
}

function clearSubMenuHideEvents(navId)
{ 	// clear all hide events for navId - when you roll over, you need to kill hide events,
	// as the hide delay is longer than the show delay
	//alert("404 clearSubMenuHideEvents " + navId)
	var arrayPointer = 0;
	
	// need to use a while loop as size of array is reduced and arrayPointer is not incremented 
	// every time (a for loop will skip an element after deletion)
	while (arrayPointer < subMenuEvents.length)
	{
		if (subMenuEvents[arrayPointer].navId == navId && subMenuEvents[arrayPointer].eventType == "hide")
		{
			removeElement(subMenuEvents,arrayPointer);
		}
			 else
			 	arrayPointer++;
	}
}

function clearAllOtherSubMenuShowEvents(navId)
{ 	// this 'brick wall' is called when the mouse hits a submenu (the showHide function will be called
	// by the subnav with isSubNavLanding set true)
	// this funcion clear all SHOW events for other navs, 
	// and clears all HIDE events for this NAV 
	//alert("423 clearAllOtherSubMenuShowEvents " + navId)
	var j = 0;
	while (j < subMenuEvents.length)
	{
		if ((subMenuEvents[j].navId != navId && subMenuEvents[j].eventType == "show") || (subMenuEvents[j].navId == navId && subMenuEvents[j].eventType == "hide"))
		{
			removeElement(subMenuEvents,j);
		}
		else
		j++;
	}
	j = null;
}

function showNavArray()
{
	// exit gracefully for IE 4 
	if (is_legacy) return; // not for NS4, IE4 etc
	
	logString = "";
	for (var i=0; i < subMenuEvents.length; i++)
		logString += i + "		id:	" + subMenuEvents[i].navId + "		type: " + subMenuEvents[i].eventType + "		time: " + subMenuEvents[i].timeRemaining + "\n";
	
	if (document.getElementById("debug"))
	{
		x = document.getElementById("debug")
		x.value = logString;
	}
	//else
	//debug(logString);
}

///////////////////////////////////////////////////////////////////////  DHTML showhide
function showHide(name,n,action,reposition,isSubNavLanding)
{
	debug("showHide name = " + name + ", action = " + action + ", reposition = " + reposition + ", isSubNavLanding = " + isSubNavLanding + " subNavsRendered:" + subNavsRendered);
	
	if (!subNavsRendered) return;
	
	if (is_legacy) return; // not for NS4, IE4 etc
	
	if (typeof(reposition) == "undefined") reposition = false;
		else reposition = true;
	
	if (!isSubNavLanding || typeof(isSubNavLanding) == "undefined") 
	{
		//alert ("471 Setting isSubNavLanding false");
		isSubNavLanding = false;
	}
		else isSubNavLanding = true;

	var positionerImgName = 'menubutton' + name; 
	name = 'submenu' + name;
	
	//var index = getLogID(name);
	
	if (action == "show")
	{
		if (reposition) translateDHTMLPositions(name,positionerImgName);
		// set to to pop up
		//alert ("call to MM_showHideLayers('"+name+"','','show')");
		subMenuEvents[subMenuEvents.length] = new navEvent(name,"show",showDelay);
		debug ("subMenuEvents[subMenuEvents.length] = " + subMenuEvents.length + " id=" + subMenuEvents[subMenuEvents.length-1].navId);
	
		showNavArray();
		
		// if we have hit the target, cancel all other show instructions
		if (isSubNavLanding) 
		{
			debug("clearAllOtherSubMenuShowEvents(" + name + ")");
			clearAllOtherSubMenuShowEvents(name);
		}
		else
		{
			debug("clearSubMenuHideEvents(" + name + ")");
			clearSubMenuHideEvents(name);
		}
	}
	else
	{
		// new - all we have to do is log event and let time take care of it
		subMenuEvents[subMenuEvents.length] = new navEvent(name,"hide",hideDelay);
		showNavArray();
	}
	return false; // don't let browser jump to #top
}

// final show hide

function showHideUniqueMenu(menuId, eventType)
{
	//alert ("showHideUniqueMenu for " + 	menuId + " => " + eventType);
	if (eventType == "show")
	{
		MM_showHideLayers(menuId,'','show');
		for (var i=0; i<subNavArray.length; i++)
			if ('submenu' + subNavArray[i].id != menuId)
			{
				MM_showHideLayers('submenu'+ subNavArray[i].id,'','hide');
			}
		
	}
	else
		MM_showHideLayers(menuId,'','hide');
}


/////////// DHTML positioning code /////////////////////////////////////////////
// this code positions the submenu to the right of the trigger image
// this code adapted from (c) http://www.dagblastit.com/
/////////////////////////////////////////////////////////////////////////////////

// overly simplistic test for IE
isIE = (document.all ? true : false);
// both IE5 and NS6 are DOM-compliant
isDOM = (document.getElementById ? true : false);

// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
 iPos = 0;
 while (elt != null) {
  iPos += elt["offset" + which];
  elt = elt.offsetParent;
 }
 return iPos;
}

function getDivStyle(divname) {
 var style;
 // handle frame errors and/or missing submenus
 if (!target) return false;
 if (!target.getElementById) return false;
 if (!target.getElementById(divname)) return false;
 
 if (isDOM) { style = target.getElementById(divname).style; }
 else { style = isIE ? target.all[divname].style
                     : target.layers[divname]; } // NS4
 return style;
}


function hideElement(divname) {
 getDivStyle(divname).visibility = 'hidden';
}

// annoying detail: IE and NS6 store elt.top and elt.left as strings.
function moveBy(elt,deltaX,deltaY) {
 elt.left = parseInt(elt.left) + deltaX;
 elt.top = parseInt(elt.top) + deltaY;
}

function toggleVisible(divname,positionerImgName) 
{
	//alert ("command for " + divname + " position to " + positionerImgName);
	// first move DIV to position target
 	// translateDHTMLPositions(divname,positionerImgName);
	 divstyle = getDivStyle(divname);
	 
	 if (divstyle.visibility == 'visible' || divstyle.visibility == 'show') 
	 	divstyle.visibility = 'hidden';
	 		else 
				divstyle.visibility = 'visible';
	 
}

function setPosition(divname,positionername)
{

 var elt = getDivStyle(divname);
 if (!elt) return;
 
 var positioner;
 if (isIE) 
   	positioner = document.all[positionername];
 		else 
  			if (isDOM) 
    			positioner = document.getElementById(positionername);
	 				else 
					positioner = document.images[positionername];
					// not IE, not DOM (probably NS4)
					// if the positioner is inside a netscape4 layer this will *not* find it.
					// I should write a finder function which will recurse through all layers
					// until it finds the named image...

 
	 var scrollOffset = ((isFramePage) ? frameScrollTop() : pageScrollTop());
	 //alert ("scrollOffset = " + scrollOffset);
	 var targetx = (getAbsX(positioner) + xOffset) + "px";
	 
	 // calculate target move position..... 
	 var targety = (getAbsY(positioner) + yOffset);
	 // we only need an offet for non xhtml compliant browsers 
	 if (!document.getElementById) 
	 {
		debug("is non dom browser - adding non xhtml scroll offet");
		targety -= scrollOffset;
	 }
	 targety += "px";
	 
	 elt.left = targetx; //(getAbsX(positioner) + xOffset) + "px";
	 elt.top = targety; //(getAbsY(positioner) + yOffset - scrollOffset)  + "px";
	 debug (positionername + " x and y  = " + getAbsX(positioner) + " " + getAbsY(positioner) + "\nmoving to " + (getAbsX(positioner) + xOffset) +" "+ targety);

}

function translateDHTMLPositions(divname,positionerImgName)
{ // move subnav layer to (x,y) of positionerImgName image (+ offsets)
	setPosition(divname,positionerImgName); 
}


///////////////////////////////////// restyle table td for subnav rollovers
// (c) 2003 P21 

var DOM    = (document.getElementById ? 1 : 0);
var IE4DOM = (document.all ? 1 : 0);
var NS4    = (document.layers ? 1 : 0);
function GetStyle(id) {
   // var idHandle = (DOM ? document.getElementById(id) : (IE4DOM ? document.all[id] : false));
	var idHandle = (DOM ? target.getElementById(id) : (IE4DOM ? target.all[id] : false));
    return (idHandle ? idHandle.style : false);
}

function RestyleElementId(elementId, color, backgroundColor) {
    styleHandle = GetStyle(elementId);
                if (styleHandle) {
        styleHandle.color = color;
        styleHandle.backgroundColor = backgroundColor;
    }
}


///////////////////////////////////// workhorse functions
// (c) Macromedia 

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  {
	  	var findObjValue = args[i];
		if (isFramePage) findObjValue += "?maindoc";
		//alert ("Call to find object " + findObjValue);
		
	  	if ((obj=MM_findObj(findObjValue))!=null) 
		{ 
			v=args[i+2];
			if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
			obj.visibility=v; 
		}
	}
}

// (c) 2003 P21 
function frameScrollTop() 
{
	if (document.layers || navigator.product == 'Gecko')
	{ // the browser is Netscape
		return parent.maindoc.pageYOffset; 
	} 
	else
	{ // ie	
		if (parent.maindoc.document.documentElement && parent.maindoc.document.documentElement.scrollTop)	return parent.maindoc.document.documentElement.scrollTop;
		if (document.body) return parent.maindoc.document.body.scrollTop
	}
}

function pageScrollTop() 
{ // NOTE 050201 //

		if (document.layers || navigator.product == 'Gecko')
	{ // the browser is Netscape
		return window.pageYOffset; 
	} 
	else
	{ // ie	
		if (document.documentElement && document.documentElement.scrollTop)	return document.documentElement.scrollTop;
		if (document.body) return document.body.scrollTop; //IE6
	}
}

function goLink(url)
{ 	
// subnavs and main navs use this function to provide link functionality
 	//	this cures the Mac frame link problem
	if (isFramePage)
	{
		if (parent.frames.maindoc)
		{
			parent.location.href = url;
			//return false; // dont jump to top!
		}
	}
	else
	{
		document.location.href = url;
		//return false; // dont jump to top!
	}
}

function debug(debugString)
{
	if (debugMode) alert (debugString);
}



// ------------------------------------------------------------------------------------------------- Mailing list 
function MailingListSubscribe()
{
	alert("Not yet deployed!");
	return;
}


// ------------------------------------------------------------------------------------------------- CSS import
//if (is_ie) { document.write("<link href=\"asset/ie.css\" rel=\"stylesheet\" type=\"text/css\" />"); }

// (c) 2005 P21 
function setMenusAsCurrent()
{
	var par = document.getElementById("lhs-header");
	if (par) 
	{
		// the menu links are a tags nested within divs, so we have a dual tier of type 1 childNodes
		for (i=0; i<par.childNodes.length;i++)
			if (par.childNodes[i].nodeType == 1)
			{
				// within each wrapper div, grab child elements
				for (j=0; j<par.childNodes[i].childNodes.length;j++)
					if (par.childNodes[i].childNodes[j].nodeType == 1)
					{
						var attrib = par.childNodes[i].childNodes[j].getAttribute('href');
						if (document.location.href.toString().indexOf(attrib) != -1)
						{
							//alert('136 set attrib for =' + attrib);
							par.childNodes[i].childNodes[j].className+=" selected";
						}
					}
			}
	}
	
	var par = document.getElementById("menu-bar");
	if (par)
	{
		// the main menu links are a tags within the main div
		for (i=0; i<par.childNodes.length;i++)
			if (par.childNodes[i].nodeType == 1)
			{
				var attrib = par.childNodes[i].getAttribute('href');
				if (document.location.href.toString().indexOf(attrib) != -1)
				{
					//alert('145 set attrib for =' + attrib);
					if (par.childNodes[i].className == "menu-button-home") 
						par.childNodes[i].className = "menu-button-home-selected";
					else
						par.childNodes[i].className+=" selected";
				}
			
			}
	}
}

