//<!--
// This script is used to control the navigation
// options of Clayton Utz menu

//The absolute path to the public/images folder. Do not include the images folder in the path.
//This is used in the menuHighlight() function.
//DEPLOYMENT CHANGE - change path to virtual root of public website
//DEVELOPMENT
//var ABSOLUTE_PATH_TO_IMAGES = "/7843-claytonutz-corporate/web/public/";
//STAGING
//var ABSOLUTE_PATH_TO_IMAGES = "/claytonutz/public/";
//UAT
//var ABSOLUTE_PATH_TO_IMAGES = "/cu/public/";
//LIVE
var ABSOLUTE_PATH_TO_IMAGES = "http://www.cchmping.com/client/ae0155a/";
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
<!--
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
//-->


// Cross browser find object - Thanks MacroMedia!
function MM_findObj(n, d) { //v4.0
  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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

// Simple find and replace
function replace(string,text,by)
{
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
		
		alert(newstr);
}

// Should be called in OnLoad event of page
function menuHighlight()
{
/*	if(whereAmI() == "/")
	{
		theObject = MM_findObj("/");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/home_down.gif";

		theObject.src=theSrc;

		theDiv = document.all.MHome;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "Home_over", "Home_down");
	}
	else if(whereAmI() == "private")
	{
		theObject = MM_findObj("private");
		
		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/globe.jpg";

		theObject.src=theSrc;

		theDiv = document.all.MHome;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "globe.jpg", "globe.jpg");
	}
	else if(whereAmI() == "news")
	{
		theObject = MM_findObj("news");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/news_down.gif";

		theObject.src=theSrc;

		theDiv = document.all.MNews;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "news_over", "news_down");
	}
	else if(whereAmI() == "publications")
	{
		theObject = MM_findObj("publications");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/publications_down.gif";

		theObject.src=theSrc;

		theDiv = document.all.MPublications;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "publications_over", "publications_down");
	}
	else if(whereAmI() == "training")
	{
		theObject = MM_findObj("training");
		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/training_down.gif";
		theObject.src=theSrc;
		theDiv = document.all.MWhatsOn;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "training_over", "training_down");
	}
	else if(whereAmI() == "careers")
	{
		theObject = MM_findObj("careers");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/careers_down.gif";

		theObject.src=theSrc;

		theDiv = document.all.MCareers;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "careers_over", "careers_down");
	}
	else if(whereAmI() == "aboutus")
	{
		theObject = MM_findObj("aboutus");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/about_us_down.gif";

		theObject.src=theSrc;

		theDiv = document.all.MAboutUs;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "about_us_over", "about_us_down");
	}
	else if(whereAmI() == "international")
	{
		theObject = MM_findObj("international");

		theSrc = getAbsoluteUrl();
		theSrc += "images/buttons/main_nav/international_down.gif";
		theObject.src=theSrc;

		theDiv = document.all.MInternational;
		theHTML = theDiv.innerHTML;
		theDiv.innerHTML = replace(theHTML, "international", "international_down");
	}

	*/
}


// Should be called in the onLoad event
// of any pages requiring the side menu.
// This handles highlighting of the correct
// sections in the side menu.
function sideMenuHighlight()
{
	// Get the parts of the path
	var path = getPathTokens();

	// For each piece of the path,
	// highlight the relevant menu item
	// by finding the item with the
	// right id, (prefixed with MENUITEM_)
	// and apply a <span> with the highlighted
	// style
	path_prefix = "MENUITEM_";

	for(x = 0; x < path.length; x++)
	{
		objName = path_prefix + path[x];
		theObject = MM_findObj(objName);
		if(theObject != null)
		{
			theObject.innerHTML = "<span class='menuHighlight'>" + theObject.innerHTML + "</span>";
		}
		theObject = null;
	}
}

// Used to get the current section
function whereAmI()
{
	var theLocation = location.toString();

	// Find the section based on the location
	// and use that to highlight the correct menu item
	if(theLocation.toLowerCase().indexOf("/home") != -1)
	{
		return "home";
	}
	else if(theLocation.toLowerCase().indexOf("/private") != -1)
	{
		return "private";
	}
	else if(theLocation.toLowerCase().indexOf("/news") != -1)
	{
		return "news";
	}
	else if(theLocation.toLowerCase().indexOf("/publications") != -1)
	{
		return "publications";
	}
	else if(theLocation.toLowerCase().indexOf("/training") != -1)
	{
		return "training";
	}
	else if(theLocation.toLowerCase().indexOf("/careers") != -1)
	{
		 return "careers";
	}
	else if(theLocation.toLowerCase().indexOf("/about_us") != -1)
	{
		return "aboutus";
	}
	else if(theLocation.toLowerCase().indexOf("/international") != -1)
	{
		return "international";
	}
}

// Used to get all pieces of the path
// to show the whole structure all the
// way down the tree
// Returns an Array containing all the tokens
// of the path
function getPathTokens()
{
	thePath = location.pathname.toString();

	// trim off leading /
	thePath = thePath.substring(1, thePath.length);

	return pieces = thePath.split("/");
}

// Used to get absolute url
// to the end of clayton_utz
function getAbsoluteUrl()
{
	//startOfUtz = location.toString().toLowerCase().indexOf("/clayton_utz/");
	//theSrc = location.toString().substring(0, startOfUtz + 13);
	//return theSrc;
	return ABSOLUTE_PATH_TO_IMAGES;
}

// Used to get the page name
function getPage()
{
	thisPage = location.pathname.toString();

	// Trim the location until
	// just the page is left
	while(thisPage.indexOf("/") != -1)
	{
		thisPage = thisPage.substring(1, thisPage.length);
	}
}

//-->