// These array variables define the navigation structure of the site
var rootprefix = "";
var firstentryhome = 0;
var beforebreadcrumb = "";
var level1 = new Array();
var level2 = new Array();
var level3 = new Array();
var level4 = new Array();

// Helper Functions.  DO NOT TOUCH
function addlevel1(label, link) { level1[level1.length] = [label,link]; }
function addlevel2(label, link) { level2[level2.length] = [label,link]; }
function addlevel3(label, link) { level3[level3.length] = [label,link]; }
function addlevel4(label, link) { level4[level4.length] = [label,link]; }

// Other Global Variables
var uri;
var uridocroot;
var urielements = new Array();

//
// Navigation Functions
//

// buildlevel4
// dir - the current directory hierarchy to search and build
function buildlevel4(dir) {

	var i;
	
	document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"10\" height=\"1\" border=\"0\"/></td>\n<td>\n<table width=\"150\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<td colspan=\"2\">\n<img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"3\" border=\"0\"></td>\n</tr>\n");
	
	// Search the level 4 array for this level of navigation
	for (i=0; i < level4.length; i++)
	{
		// Check if this level 4 navigation element belongs under the level 3
		if( level4[i][1].indexOf(dir) == 0)
		{
		  if (level4[i][1] == uridocroot)
		  {
		  	document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"10\" height=\"1\" border=\"0\"></td>\n<td>\n");
		  	document.write("<div class=\"lnavDivHang\">\n<a href=\""+level3[i][1]+"\" class=\"lnavLinkRed\">" + level3[i][0] + "</a>\n</div>\n</td>\n</tr>");
		  } else {
			document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"10\" height=\"1\" border=\"0\"></td>\n<td>\n");
			document.write("<div class=\"lnavDivHang\">\n<a href=\""+level4[i][1]+"\" class=\"lnavLink\">"+ level4[i][0] + "</a>\n</div>\n</td>\n</tr>\n");
		  }
		}
	}
	document.write("<tr>\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"3\" border=\"0\">\n</td>\n</tr>\n</table>\n</td>\n</tr>");

}

// buildlevel3
// dir - the current directory hierarchy to search and build
function buildlevel3(dir) {

	var i;
	
	document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"25\" height=\"1\" border=\"0\"/></td>\n<td>\n<table width=\"150\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"3\" border=\"0\"></td>\n</tr>");
	
	// Search the level 3 array for this level of navigation
	for (i=0; i < level3.length; i++)
	{
		// Check if this level 3 navigation element belongs under the level 2
		if( level3[i][1].indexOf(dir) == 0)
		{
		  // Extract the relative part of this navigation link
		  var navuri = level3[i][1].substr(0,level3[i][1].lastIndexOf("/"));

		  // Break down the rest of the link for this navigation
		  var therest = level3[i][1].substr((dir.length)+1,level3[i][1].length);
		  var togo = therest.split("/");
		  
		  if (level3[i][1] == uridocroot)
		  {
			document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"10\" height=\"1\" border=\"0\"></td>\n<td>\n");
		  	document.write("<div class=\"lnavDivHang\">\n<a href=\""+level3[i][1]+"\" class=\"lnavLinkRed\">" + level3[i][0] + "</a>\n</div>\n</td>\n</tr>\n");
		  	
			if( togo.length > 1 )
			{
		  	  // Show the next level down
			  buildlevel4(navuri);
            		}
		  } else {

			document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"10\" height=\"1\" border=\"0\"></td>\n<td>\n");
			document.write("<div class=\"lnavDivHang\">\n<a href=\""+level3[i][1]+"\" class=\"lnavLink\">"+ level3[i][0] + "</a>\n</div>\n</td>\n</tr>\n");

			// Look to see if we need to build the 4th level navigation for this element
			if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
			{
				buildlevel4(navuri);
			}

		  }
		}
	}
	document.write("<tr>\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"3\" border=\"0\"></td>\n</tr>\n</table>\n</td>\n</tr>\n");
	
}

// buildlevel2
// dir - the current directory hierarchy to search and build
function buildlevel2(dir) {

	var i;

	document.write("<tr>\n<td colspan=\"2\">\n<table width=\"185\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<td colspan=\"2\">\n<img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"1\" border=\"0\">\n</td>\n</tr>\n");
	// Search the level 2 array for this level of navigation
	for (i=0; i < level2.length; i++)
	{
		// Extract the relative part of this navigation link
		var navuri = level2[i][1].substr(0,level2[i][1].lastIndexOf("/"));

		// Break down the rest of the link for this navigation
		var therest = level2[i][1].substr((dir.length)+1,level2[i][1].length);
		var togo = therest.split("/");

		// Check if this level 2 navigation element belongs under the current top level
		if(level2[i][1].indexOf(dir) == 0)
		{

		  // Does this entry match the current URI? If so, then show different HTML
		  if (level2[i][1] == uridocroot)
		  {
		  	document.write("<tr>\n<td><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"25\" height=\"1\" border=\"0\"></td>\n<td>\n");
		  	document.write("<div class=\"lnavDivHang\">\n<a href=\""+level2[i][1]+"\" class=\"lnavLinkRed\">" + level2[i][0] + "</a>\n</div>\n</td>\n</tr>");

			if( togo.length > 1 )
			{
			  // Show the next level down
			  buildlevel3(navuri);
			}

		  } else {
		  	document.write("<tr>\n<td width=\"25\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"25\" height=\"1\" border=\"0\"></td>\n<td width=\"160\">\n");
			document.write("<div class=\"lnavDivHang\">\n<a href=\""+level2[i][1]+"\" class=\"lnavLink\">"+ level2[i][0] + "</a>\n</div>\n</td>\n</tr>");

			// Look to see if we need to build the 2nd level navigation for this element
			if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
			{
			  // Show the next level down
			  buildlevel3(navuri);
			}

		  }
		}
	}
	document.write("<tr>\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"1\" height=\"1\" border=\"0\">\n</td>\n</tr>\n</table>\n</td>\n</tr>\n");
}

// buildnavigation - Main Navigation Build Function
// l - the current page URL
function buildnavigation(l) {

	// Get the current URL and break it down
	var ldirs = l.split("/");
	var fullrootprefix = "/" + rootprefix + "/";
	var pre = rootprefix.split("/");
	var siteprefix = "http://"+ldirs[2]+"/"+rootprefix+"/";
	uri = l.substr(siteprefix.length,l.length);
	uridocroot = "/" + rootprefix + "/" + uri;
	urielements = uri.split("/");

	document.write("<table width=\"185\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");

	// Loop through all of the top level navigation elements	
	for (i=0; i < level1.length; i++)
	{
		    
	  // Break down the rest of the link for this navigation
	  var therest = level1[i][1].substr(fullrootprefix.length,level1[i][1].length);
	  var togo = therest.split("/");

  	  // Extract the relative part of this navigation link
  	  var navuri = level1[i][1].substr(0,level1[i][1].lastIndexOf("/"));
      
      	  // Check if this page matches the current Level 1 navigation entry
      	  if (level1[i][1] == uridocroot)
	  {
		document.write("<tr class=\"bgmenucolor05\">\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"185\" height=\"1\" border=\"0\"></td>\n</tr>\n");
		document.write("<tr class=\"bgmenucolor06\">\n<td><img src=\"/images/lnav_arrow_grey.gif\" alt=\" \" width=\"20\" height=\"17\" border=\"0\" align=\"middle\"/>\n</td>\n<td>");
		document.write("<div class=\"lnavDivHang\">\n<a href=\""+level1[i][1]+"\" class=\"lnavLink\">" + level1[i][0] + "</a>\n</div>\n</td>\n</tr>\n");

		if( togo.length > 1 )
		{
		  // Show the next level down
		  buildlevel2(navuri);
		}

	  } else {

		// Look to see if we need to build the 2nd level navigation for this element
		if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
		{
		  document.write("<tr class=\"bgmenucolor05\">\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"185\" height=\"1\" border=\"0\"></td>\n</tr>\n");
		  document.write("<tr class=\"bgmenucolor06\">\n<td><img src=\"/images/lnav_arrow_grey.gif\" alt=\" \" width=\"20\" height=\"17\" border=\"0\" align=\"middle\"/>\n</td>\n<td>");
		  document.write("<div class=\"lnavDivHang\">\n<a href=\""+level1[i][1]+"\" class=\"lnavLink\">" + level1[i][0] + "</a>\n</div>\n</td>\n</tr>\n");

		  // Show the next level down
		  buildlevel2(navuri);

		} else {
		  document.write("<tr class=\"bgmenucolor05\">\n<td colspan=\"2\"><img src=\"/images/spacer.gif\" alt=\" \" longdesc=\"/images/spacer.txt\" width=\"185\" height=\"1\" border=\"0\"></td>\n</tr>\n");
		  document.write("<tr>\n<td valign=\"top\"><img src=\"/images/lnav_arrow_red.gif\" alt=\" \" width=\"20\" height=\"17\" border=\"0\" align=\"middle\">\n</td>\n<td>");
		  document.write("<div class=\"lnavDivHang\">\n<a href=\""+level1[i][1]+"\" class=\"lnavLink\">"+level1[i][0] + "</a>\n</div>\n</td>\n</tr>");
		}
		
	  }	  	
    	}
	document.write("</table>\n");
}

// buildbread4
// dir - the current directory hierarchy to search and build
function buildbread4(dir) {

	var i;
	
	// Search the level 4 array for this level of navigation
	for (i=0; i < level4.length; i++)
	{
		// Check if this level 4 navigation element belongs under the level 3
		if( level4[i][1].indexOf(dir) == 0)
		{
		  if (level4[i][1] == uridocroot)
		  {
		  	document.write(" &gt; <a href=\""+level3[i][1]+"\" class=\"breadCrumb\">" + level3[i][0] + "</a>");
		  } 
		}
	}

}

// buildbread3
// dir - the current directory hierarchy to search and build
function buildbread3(dir) {

	var i;
	
	// Search the level 3 array for this level of navigation
	for (i=0; i < level3.length; i++)
	{
		// Check if this level 3 navigation element belongs under the level 2
		if( level3[i][1].indexOf(dir) == 0)
		{
		  // Extract the relative part of this navigation link
		  var navuri = level3[i][1].substr(0,level3[i][1].lastIndexOf("/"));

		  // Break down the rest of the link for this navigation
		  var therest = level3[i][1].substr((dir.length)+1,level3[i][1].length);
		  var togo = therest.split("/");
		  
		  if (level3[i][1] == uridocroot)
		  {
		  	document.write(" &gt; <a href=\""+level3[i][1]+"\" class=\"breadCrumb\">" + level3[i][0] + "</a>");
		
		  } else {

			// Look to see if we need to build the 4th level navigation for this element
			if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
			{
				document.write(" &gt; <a href=\""+level3[i][1]+"\" class=\"breadCrumbLink\">"+ level3[i][0] + "</a>");
				
				// Show the next level down
				buildbread4(navuri);
			}

		  }
		}
	}
	
}

// buildbread2
// dir - the current directory hierarchy to search and build
function buildbread2(dir) {

	var i;

	// Search the level 2 array for this level of navigation
	for (i=0; i < level2.length; i++)
	{
		// Extract the relative part of this navigation link
		var navuri = level2[i][1].substr(0,level2[i][1].lastIndexOf("/"));

		// Break down the rest of the link for this navigation
		var therest = level2[i][1].substr((dir.length)+1,level2[i][1].length);
		var togo = therest.split("/");

		// Check if this level 2 navigation element belongs under the current top level
		if(level2[i][1].indexOf(dir) == 0)
		{

		  // Does this entry match the current URI? If so, then show different HTML
		  if (level2[i][1] == uridocroot)
		  {
		  	document.write(" &gt; <a href=\""+level2[i][1]+"\" class=\"breadCrumb\">" + level2[i][0] + "</a>");

		  } else {

			// Look to see if we need to build the 2nd level navigation for this element
			if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
			{
			  document.write(" &gt; <a href=\""+level2[i][1]+"\" class=\"breadCrumbLink\">"+ level2[i][0] + "</a>");
			  
			  // Show the next level down
			  buildbread3(navuri);
			}

		  }
		}
	}

}

// buildbreadcrumb - Main Breadcrumb Build Function
// l - the current page URL
function buildbreadcrumb(l) {

	// Get the current URL and break it down
	var ldirs = l.split("/");
	var fullrootprefix = "/" + rootprefix + "/";
	var pre = rootprefix.split("/");
	var siteprefix = "http://"+ldirs[2]+"/"+rootprefix+"/";
	uri = l.substr(siteprefix.length,l.length);
	uridocroot = "/" + rootprefix + "/" + uri;
	urielements = uri.split("/");

	// See if a breadcrumb cookie exists 
	var breadcrumblink = getQueryVariable('breadcrumb');

	// if the cookie wasn't found, then use the navigation array to build the breadcrumb
	if (!breadcrumblink) { 

		// Show any HTML before the breadcrumb
		document.write(beforebreadcrumb);

		// Loop through all of the top level navigation elements	
		for (i=0; i < level1.length; i++)
		{

		  // Break down the rest of the link for this navigation
		  var therest = level1[i][1].substr(fullrootprefix.length,level1[i][1].length);
		  var togo = therest.split("/");

		  // Extract the relative part of this navigation link
		  var navuri = level1[i][1].substr(0,level1[i][1].lastIndexOf("/"));

		  // Check if this page matches the current Level 1 navigation entry
		  if (level1[i][1] == uridocroot)
		  {
			document.write(" &gt; <a href=\""+level1[i][1]+"\" class=\"breadCrumb\">" + level1[i][0] + "</a>");

		  } else {

			// Look to see if we need to build the 2nd level navigation for this element
			if( (uridocroot.indexOf(navuri) == 0) && (togo.length > 1) )
			{
			  document.write(" &gt; <a href=\""+level1[i][1]+"\" class=\"breadCrumbLink\">" + level1[i][0] + "</a>");

			  // Show the next level down
			  buildbread2(navuri);

			} 

		  }	  	
		}
	} else {

		// Show the breadcrumb link pass to this page
		document.write(unescape(breadcrumblink));
	}
}


// URL - this is a string containing the URL of the document to open 
// name - this is a string containing the name of the new window. 
// w - This sets the width of the new window in pixels. 
// h - This sets the height of the new window in pixels. 
// features - this is an optional string 
// (see: http://www.devguru.com/technologies/ecmascript/quickref/win_open.html)

function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
} 

<!--
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments

function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");

document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist

function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);

if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}


function isCookieInDomain(_cookieDomainName,_domain) {
   var d = getCookie(_cookieDomainName);

   return ( -1 != _domain.indexOf(d)) ? 1 : 0;
}


function resetCookie(_refname, _domainname) {
   // See if referrer cookie already exists 
   var referrer = getCookie(_refname);

   // if the cookie wasn't found, then set the cookie
   if (referrer) { 
     if( !isCookieInDomain(_domainname, document.domain)) {
       setCookie(_refname, document.referrer);
       setCookie(_domainname, document.domain);
     } 

   } else {
     setCookie(_refname, document.referrer);
     setCookie(_domainname, document.domain);
   }
}

//resetCookie();

function svcContactForm(_refname, _svltUrl, _form) {
   _form.pageref.value = getCookie(_refname);
   _form.domain.value = document.domain;
   //eval(_form+".submit()");
   _form.submit();
}


// name - name of the referrer cookie string

function setReferrer(name) {
// See if referrer cookie already exists 
var referrer = getCookie(name);

// if the cookie wasn't found, then set the cookie
if (!referrer) { 
referrer = document.referrer;
setCookie(name, referrer);
}
}

// variable - name of the query string variable to return

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");

  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    } else {
      return "";
    } //end if
  } //end for
}//end function
