
var protocolPrefix = "http://";
var theLoc = window.location + "";
if (theLoc.indexOf("https://") > -1) {
	protocolPrefix = "https://";
}

// ================================================
// template specific variables
// ================================================
// set the location of the template
templatePath = protocolPrefix+"www.movingaroundmanitoba.ca/Templates/en/fullpage/";

// ================================================



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



// ================================================
// gov_setupPage() 
// - called from the web pages' OnLoad() event
// - generates the header,footer, language toggle, 
//   side menu, breadcrumbs and header links
// ================================================
function gov_setupPage() {
	gov_determineLanguage();
	gov_checkPrint();
	gov_showHeader();
	gov_showFooter();
	if (REPLACE_IFR == 1){ 
		gov_replaceIFR();
	}
	if (REPLACE_LANG == 1) {
		gov_showLangToggle();
	}
	if (REPLACE_SIDEMENU == 1) {
		gov_showMenus();
	} else {
		gov_setMenus();
	}
	if (REPLACE_BREADCRUMB == 1) {
		gov_showBreadCrumbs();
	}
	
	if (REPLACE_LINKS == 1) {
		gov_showHeaderLinks();
	}
}


// ================================================
// gov_showHeader() 
// - the top table header output 
// - if print version is selected, then only shows
//   the printer header image
// ================================================
function gov_showHeader() {
	var html = "";
	obj = document.getElementById("govHeaderDIV");
	if (obj) {
	
		if (tempURL.indexOf("?print") > -1) {
			html += '<div align="center" style="margin-left:-20px;"><img src="'+templatePath+'images/printer_header.jpg" border="0"></div>';
		} else {
			html += "    <table width=\"760\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\n";
			html += "        <tr>\n";
			html += "            <td colspan=\"2\" valign=\"top\" class=\"headerlinks\"><a name=\"top\"></a><div align=\"right\"><div id='langDIV'></div><div id='headerLinksDIV'></div><BR>\n";
			html += "            <br>\n";
			html += "            </div></td>\n";
			html += "        </tr>\n";
			html += "        <tr>\n";
			html += "          <td valign=\"top\" width=\"570\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
			html += "            <tr>\n";
			html += "              <td nowrap class=\"SearchBG\"><a name=\"navigation\" rel=\"Header Navigation\" accesskey=\"1\"></a><a href=\"#navigation\" accesskey=\"1\"></a><a href=\"http://www.gov.mb.ca/government/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image11','','"+templatePath+"images/nav/government_x.gif',1)\"><img src=\""+templatePath+"images/nav/government.gif\" alt=\"Government Link\" name=\"Image11\" height=\"43\" border=\"0\" id=\"Image11\"></a><a href=\"http://www.gov.mb.ca/business/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image21','','"+templatePath+"images/nav/business_x.gif',1)\"><img src=\""+templatePath+"images/nav/business.gif\" alt=\"Business Link\" name=\"Image21\" width=\"75\" height=\"43\" border=\"0\" id=\"Image21\"></a><a href=\"http://www.gov.mb.ca/residents/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image31','','"+templatePath+"images/nav/residents_x.gif',1)\"><img src=\""+templatePath+"images/nav/residents.gif\" alt=\"Residents Link\" name=\"Image31\" width=\"77\" height=\"43\" border=\"0\" id=\"Image31\"></a><a href=\"http://www.gov.mb.ca/tourism/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image41','','"+templatePath+"images/nav/tourism_x.gif',1)\"><img src=\""+templatePath+"images/nav/tourism.gif\" alt=\"Tourism Link\" name=\"Image41\" width=\"72\" height=\"43\" border=\"0\" id=\"Image41\"></a><a href=\"http://www.gov.mb.ca/services/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image51','','"+templatePath+"images/nav/services_x.gif',1)\"><img src=\""+templatePath+"images/nav/services.gif\" alt=\"Services Link\" name=\"Image51\" width=\"80\" height=\"43\" border=\"0\" id=\"Image51\"></a></td>\n";
			html += "              <td width=\"99%\" valign=\"middle\" style=\"padding-left:10px;padding-top:10px; background-image:  url("+templatePath+"images/search_bg.gif); background-repeat:repeat-x;\">\n";
			html += "                <form style=\"padding:0px;\" name=\"gs\" method=\"GET\" action=\"http://discovery.gov.mb.ca/search\">\n";
			html += "\n";
			html += "                  <input name=\"q\" type=\"text\" class=\"searchbox\" value=\"Search...\" size=\"15\" OnFocus=\"if (this.value == 'Search...') this.value = '';\">\n";
			html += "                  <input type=\"image\" src=\""+templatePath+"images/header_button_go.jpg\" alt=\"Search\" name=\"image3\">\n";
			html += "                  <input type=\"hidden\" name=\"entqr\" value=\"0\">\n";
			html += "                  <input type=\"hidden\" name=\"output\" value=\"xml_no_dtd\">\n";
			html += "                  <input type=\"hidden\" name=\"sort\" value=\"date:D:L:d1\">\n";
			html += "                  <input type=\"hidden\" name=\"ud\" value=\"1\">\n";
			html += "                  <input type=\"hidden\" name=\"client\" value=\"manitoba\">\n";
			html += "                  <input type=\"hidden\" name=\"oe\" value=\"UTF-8\">\n";
			html += "                  <input type=\"hidden\" name=\"ie\" value=\"UTF-8\">\n";
			html += "                  <input type=\"hidden\" name=\"proxystylesheet\" value=\"manitoba\">\n";
			html += "                  <input type=\"hidden\" name=\"site\" value=\"default_collection\">\n";
			html += "                </form></td>\n";
			html += "            </tr>\n";
			html += "          </table></td>\n";
			html += "          <td rowspan=\"2\" valign=\"bottom\"><a href=\"http://www.gov.mb.ca/index.html\"><img src=\""+templatePath+"images/mb_logo.jpg\" alt=\"Government of Manitoba Logo\" width=\"190\" height=\"134\" border=\"0\"></a></td>\n";
			html += "        </tr>\n";
			html += "        <tr>\n";
			html += "          <td width=\"570\"><img src=\""+templatePath+"images/background_se.jpg\" alt=\"Spirited Energy\" width=\"570\" height=\"91\"></td>\n";
			html += "\n";
			html += "        </tr>\n";
			html += "        <tr bgcolor=\"#FFFFFF\">\n";
			html += "          <td colspan=\"2\" style=\"height:1px;\"></td>\n";
			html += "        </tr>\n";
			html += "      </table>\n";
		}

		obj.innerHTML = html;
	}
}

// ================================================
// gov_showFooter()
// - displays the bottom table of text links
// ================================================
function gov_showFooter() {
	var html = "\n";
	obj = document.getElementById("govFooterDIV");
	if (obj) {
		html += "      <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"760\" align=\"center\">\n";
		html += "        <tr>\n";
		html += "          <td colspan=\"4\" style=\"padding-top:15px;\">\n";
		html += "            <!-- bottom buttons -->\n";
		html += "            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
		html += "              <tr>\n";
		html += "\n";
		html += "                <td style=\"padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;\" align=\"left\"><a href=\"http://www.gov.mb.ca/government/\" class=\"bottombutton\">Government</a></td>\n";
		html += "                <td align=\"left\" rowspan=\"2\" valign=\"top\"><img src=\""+templatePath+"images/footer_button_sep.gif\" ALT=\"\" width=\"1\" height=\"30\"></td>\n";
		html += "                <td style=\"padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;\" ><a href=\"http://www.gov.mb.ca/business/\" class=\"bottombutton\">Business</a></td>\n";
		html += "                <td align=\"left\" rowspan=\"2\" valign=\"top\"><img src=\""+templatePath+"images/footer_button_sep.gif\" ALT=\"\" width=\"1\" height=\"30\"></td>\n";
		html += "                <td style=\"padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;\" ><a href=\"http://www.gov.mb.ca/residents/\" class=\"bottombutton\">Residents</a></td>\n";
		html += "                <td align=\"left\" rowspan=\"2\" valign=\"top\"><img src=\""+templatePath+"images/footer_button_sep.gif\" ALT=\"\" width=\"1\" height=\"30\"></td>\n";
		html += "                <td style=\"padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;\" ><a href=\"http://www.gov.mb.ca/tourism/\" class=\"bottombutton\">Tourism</a></td>\n";
		html += "\n";
		html += "                <td align=\"left\" rowspan=\"2\" valign=\"top\"><img src=\""+templatePath+"images/footer_button_sep.gif\" ALT=\"\" width=\"1\" height=\"30\"></td>\n";
		html += "                <td style=\"padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:10px;\" ><a href=\"http://www.gov.mb.ca/services/\" class=\"bottombutton\">Services</a></td>\n";
		html += "                <td align=\"left\" rowspan=\"2\" valign=\"top\"><img src=\""+templatePath+"images/footer_button_sep.gif\" ALT=\"\" width=\"1\" height=\"30\"></td>\n";
		html += "                <td width=\"100%\" valign=\"middle\" style=\"padding-left:10px;\">\n";
		html += "                  <form style=\"padding:0px;\" name=\"gs\" method=\"GET\" action=\"http://discovery.gov.mb.ca/search\">\n";
		html += "                    <input name=\"q\" type=\"text\" class=\"searchbox\" value=\"Search...\" size=\"15\" OnFocus=\"if (this.value == 'Search...') this.value = '';\">\n";
		html += "                    <input type=\"image\" src=\""+templatePath+"images/header_button_go.jpg\" alt=\"Search\" name=\"image32\">\n";
		html += "                    <input type=\"hidden\" name=\"entqr\" value=\"0\">\n";
		html += "\n";
		html += "                    <input type=\"hidden\" name=\"output\" value=\"xml_no_dtd\">\n";
		html += "                    <input type=\"hidden\" name=\"sort\" value=\"date:D:L:d1\">\n";
		html += "                    <input type=\"hidden\" name=\"ud\" value=\"1\">\n";
		html += "                    <input type=\"hidden\" name=\"client\" value=\"manitoba\">\n";
		html += "                    <input type=\"hidden\" name=\"oe\" value=\"UTF-8\">\n";
		html += "                    <input type=\"hidden\" name=\"ie\" value=\"UTF-8\">\n";
		html += "                    <input type=\"hidden\" name=\"proxystylesheet\" value=\"manitoba\">\n";
		html += "                    <input type=\"hidden\" name=\"site\" value=\"default_collection\">\n";
		html += "                  </form>\n";
		html += "\n";
		html += "                </td>\n";
		html += "              </tr>\n";
		html += "              <tr>\n";
		html += "                <td style=\"background-color:#006643; height:5px;\"></td>\n";
		html += "                <td style=\"background-color:#5BC6E8; height:5px;\"></td>\n";
		html += "                <td style=\"background-color:#CCDC00; height:5px;\"></td>\n";
		html += "                <td style=\"background-color:#739600; height:5px;\"></td>\n";
		html += "                <td style=\"background-color:#E98300; height:5px;\"></td>\n";
		html += "                <td width=\"100%\" valign=\"middle\" style=\"padding-left:10px; background-color:#766A65; height:5px;\" nowrap></td>\n";
		html += "\n";
		html += "              </tr>\n";
		html += "            </table>\n";
		html += "          </td>\n";
		html += "        </tr>\n";
		html += "        <tr>\n";
		html += "          <td colspan=\"4\" align=\"left\" class=\"footerlinks\" style=\"padding-top:10px; padding-bottom:5px;\">\n";
		html += "            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
		html += "              <tr>\n";
		html += "                <td style=\"padding-left:30px;\"><a href=\"http://www.spiritedenergy.ca/index.php\"><img src=\""+templatePath+"images/footer_energy.gif\" alt=\"Manitoba: Spirited Energy Link\" border=\"0\" align=\"middle\" width=\"103\" height=\"43\"></a></td>\n";
		html += "\n";
		html += "                <td style=\"padding-left:20px; padding-right:20px;\" width=\"100%\" align=\"center\"><a name=\"footer\" rel=\"Footer Navigation\" accesskey=\"4\"></a><a href=\"#footer\" accesskey=\"4\"></a><a href=\"http://news.gov.mb.ca/news/\" class=\"footerlinks\">News</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a href=\"http://www.gov.mb.ca/government/departments.html\" class=\"footerlinks\">Departments</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"http://www.gov.mb.ca/legal/disclaimer.html\" class=\"footerlinks\">Disclaimer</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"http://www.gov.mb.ca/legal/copyright.html\" class=\"footerlinks\">Copyright</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"http://www.gov.mb.ca/legal/privacy.html\" class=\"footerlinks\">Privacy</a> &nbsp;| &nbsp;<a href=\"http://www.gov.mb.ca/contact/\" class=\"footerlinks\">Contact Us 1-866-626-4862</a></td>\n";
		html += "                <td  style=\"padding-right:30px;\" valign=\"top\"><a href=\"http://www.gov.mb.ca/index.html\"><img src=\""+templatePath+"images/footer_govmb_logo.gif\" alt=\"Government of Manitoba Logo Link\" border=\"0\" align=\"middle\" width=\"118\" height=\"33\"></a></td>\n";
		html += "\n";
		html += "              </tr>\n";
		html += "            </table>\n";
		html += "          </td>\n";
		html += "        </tr>\n";
		html += "      </table>\n";
		obj.innerHTML = html;
	}
}


// =================================================================
// gov_replaceIFR()
// - replaces elements with Inman Flash Replacement SWFs
// - if you have more elements to replace, then create a javascript 
//   function in your web page header call it before 
//   gov_setupPage() in the OnLoad() Event
// =================================================================
function gov_replaceIFR() {

/* Replacement calls. Please see documentation for more information. */
if(typeof sIFR == "function"){
	sIFR.replaceElement(named({sSelector:"h6", sFlashSrc:templatePath+"highlight_ifr.swf", sFlashVars:"", sWidth:"207", sHeight:"60"}));
	sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:templatePath+"title_ifr.swf", sFlashVars:"", sWidth:"600", sHeight:"38"}));
	sIFR.replaceElement(named({sSelector:"div.abovesidemenu h3", sFlashSrc:templatePath+"h3_ifr.swf", sFlashVars:"", sWidth:"189", sHeight:"60"}));
};

}



// =================================================================
// gov_stripSubPath(path, find)
// - removes all portions of the "path" prior to the "find" parameter
// e.g. path="http://www.gov.mb.ca/seeinggreen/index.html",
//      find="/seeinggreen/"
//      returns  "/seeinggreen/index.html"
// =================================================================
function gov_stripSubPath(path, find) {
	var ret;
	var mypath = path;
	ret = false;
	if (path.indexOf("\\")) {
		mypath = mypath.replace(/\\/g, "/");
	}
	if (mypath.indexOf(find) > -1) {
		ret = mypath.substr(mypath.indexOf(find) + find.length);
	}

	return ret;
}






// =================================================================
// gov_arrangeMenus()
// - determines which entries in arrMenu[] will be expanded and shown
//   based on the current page path
// =================================================================
  		function gov_arrangeMenus()
  		{
  		
  			var k=0;
  			var maxLevel = 0;
  			for( var i=0; i<arrMenu.length; i++)
  			{
				if (arrMenu[i]["level"] > maxLevel) {
					maxLevel = arrMenu[i]["level"];
				}
  				if( pagePath + "" == arrMenu[i]["url_"+langID] + "")
  				{
  					if (arrMenu[i]["alt_link_"+langID] + "" == "1") {
						arrMenu[i]["active"] = false;
						arrMenu[i]["show"] = false;
						arrMenu[i]["expand"] = false;
  					} else {
						arrMenu[i]["active"] = true;
						arrMenu[i]["show"] = true;
						arrMenu[i]["expand"] = true;

						// move up and set the parent to expand...
						var curdepth = arrMenu[i]["level"];
						for (ii = i; ii > 0; ii--) {
							if (curdepth > arrMenu[ii]["level"]) {
								arrMenu[ii]["expand"] = true;
								arrMenu[ii]["active"] = true;
								curdepth = arrMenu[ii]["level"];
							}
						}
						k  = i;
						kk = i;
  					}
  				}
  				else
  				{
  					arrMenu[i]["active"] = false;
  					arrMenu[i]["show"] = false;
  					arrMenu[i]["expand"] = false;
  				}

  			}

			
			// loop through the array "maxLevel" times to properly expand the entries
			// basically we only expand the immediate children of that entry... it will naturally expand...


			// always show top level menus
			for( var i=0; i<arrMenu.length; i++)
			{
				if (arrMenu[i]["level"] == 0) {
					arrMenu[i]["show"] = true;
				}
			}
			var expanding = false;
			for (var currentLevel = 0; currentLevel <= maxLevel; currentLevel++) {
				expanding = false;
				for( var i=0; i<arrMenu.length; i++)
				{
					if (arrMenu[i]["expand"] == true) {
						// show immediate children..
						for( var ii=i+1; ii<arrMenu.length; ii++)
						{
							if (arrMenu[ii]["level"] == currentLevel + 1) {
								arrMenu[ii]["show"] = true;
							}  else {
								if (arrMenu[ii]["level"] == currentLevel) {
									break;
								}
							}
						}
					}
				}
			}


  			return;
  		}





// =================================================================
// gov_setMenus()
// - dynamically hides/shows the appropriate side menu links
// =================================================================
function gov_setMenus() {
var obj = document.getElementById("sidemenu");

var foundExactLink = -1; // if we've matched the current page to the side menu link


if (obj) {
	// retrieve the contents of the side menu
	var links = obj.getElementsByTagName("a");

	// hide them all first...

	for(x=0; x<links.length; x++) {
		links[x].parentNode.style.display = "none";
	}


	// show first level links in this node (UL)...
	// just in case we can't match the current page to any side menu links
	for (xx=0; xx< obj.childNodes.length;xx++) {
		if (obj.childNodes[xx].nodeName == "UL") {
			var foundUL = obj.childNodes[xx];
			for (xxx=0; xxx< foundUL.childNodes.length;xxx++) {
				if (foundUL.childNodes[xxx].nodeName == "LI") {
					foundUL.childNodes[xxx].style.display="block";
					if (foundUL.childNodes[xxx].className == "") {
						foundUL.childNodes[xxx].className ="LeftHandMenus_l0_off";
					}
				}
			}
		}
	}

	// see if we can match this page to a sidemenu link
	for(x=0; x<links.length; x++) {
		if (document.location.href == links[x]) {
			if (links[x].className=="altlink") {
			} else {
				foundExactLink = x;
			}
		}
	}


	for(x=0; x<links.length; x++) {

		href = links[x];

		var match = 0;
		if (foundExactLink > -1) {
			if (x == foundExactLink) {
				match = 1;
			}
		} else {
			if (document.location.href.indexOf(href) == 0) {
				match = 1;
				foundExactLink = x;
			}
		}


			if (match == 1) {
				if(links[x].className=="altlink") {
					links[x].style.className = "";
					links[x].parentNode.style.display = "none";
				} else {

					// show the parents...
					cntParents = 0;
					// figure out how deep we are...
					foundDIV = links[x].parentNode;
					while(foundDIV.id != "sidemenu") {
						foundDIV = foundDIV.parentNode;
						if(foundDIV.nodeName == "UL") {
							cntParents++;
						}
					}

					// set classes and visibility of links
					var depth = cntParents - 1;

					// show first level child links in this node (UL)...
					foundDIV = links[x].parentNode;
					for (xx=0; xx< foundDIV.childNodes.length;xx++) {
						if (foundDIV.childNodes[xx].nodeName == "UL") {
							var foundUL = foundDIV.childNodes[xx];
							for (xxx=0; xxx< foundUL.childNodes.length;xxx++) {
								if (foundUL.childNodes[xxx].nodeName == "LI") {
									foundUL.childNodes[xxx].style.display="block";
									if (foundUL.childNodes[xxx].className == "") {
										foundUL.childNodes[xxx].className ="LeftHandMenus_l"+cntParents+"_off";
									}
								}
							}
						}
					}

					// proceed backwards up the tree, setting the visibility of the parent menus and siblings
					foundDIV = links[x].parentNode;
					if (foundDIV.className == "hidden") {
						foundDIV.style.display = "none";
					} else {
						foundDIV.className ="LeftHandMenus_l"+depth+"_on";
					}
					while(foundDIV.id != "sidemenu") {
						foundDIV = foundDIV.parentNode;
						if(foundDIV.nodeName == "UL") {
							// show the siblings at this level...
							for (xx=0; xx< foundDIV.childNodes.length;xx++) {
								if (foundDIV.childNodes[xx].nodeName == "LI") {
									foundDIV.childNodes[xx].style.display="block";
									if (foundDIV.childNodes[xx].className == "") {
										foundDIV.childNodes[xx].className ="LeftHandMenus_l"+depth+"_off";
									}
									if (foundDIV.childNodes[xx].className == "hidden") {
										foundDIV.childNodes[xx].style.display = "none";
									}
								}
							}
							depth=depth - 1;

							foundDIV.parentNode.className ="LeftHandMenus_l"+depth+"_on";
						}
					}
				}
		}

	}

}



}






// =================================================================
// gov_showMenus()
// - generates the dynamic side menu using list items (<li>)
//   using the contents of arrMenu[]
// =================================================================
function gov_showMenus()
{
	// don't replace anything if there isn't a menu array
	if (arrMenu) {
		if (arrMenu.length > 0) {
		} else {
			return;
		}
	} else {
		return;
	}
	var html = "";
	// determine which menus should be shown/activated
	gov_arrangeMenus();


	html += ("<ul>");

	for( var i=0; i<arrMenu.length; i++)
	{
	
		if (arrMenu[i]["hidden_"+langID] + "" == "1") {
			
		} else {
 

		if(arrMenu[i]["level"]==0)
		{

// ##################### Change Background Image ################################
// #
// # Look for i == and set ID to appropriate nav.
// # ID is generated through each navigation item added
// # Search for: background-image:url("+rootPath+"  the image path is located here
// ################################################################################
			if(arrMenu[i]["active"] || arrMenu[i]["expand"])
			{
				if(i==0)
				{
					// show arrow pointing down
					html += ("<li class='LeftHandMenus_l0_on'>");
				}
				else
				{
					// show arrow pointing down
					html += ("<li class='LeftHandMenus_l0_off'>");
				}

			}
			else
			{
				if(i==0)
				{
					// show arrow pointing right
					html += ("<li class='LeftHandMenus_l0_off'>");
				}
				else
				{
					// show arrow pointing right
					html += ("<li class='LeftHandMenus_l0_off'>");
				}


			}

			arrMenu[i]["show"] = true;

		}
		if(arrMenu[i]["level"]==1)
		{
			if(arrMenu[i]["show"])
			{
				if(arrMenu[i]["active"])
				{
					html += ('<li class="LeftHandMenus_l1_on">');
				}
				else
				{
					html += ('<li class="LeftHandMenus_l1_off"" onMouseover="this.className=\'LeftHandMenus_l1_on\';" onMouseout="this.className=\'LeftHandMenus_l1_off\';">');
				}

			}
		}
		if(arrMenu[i]["level"]==2)
		{
			if(arrMenu[i]["show"])
			{
				if(arrMenu[i]["active"])
				{
					html += ('<li class="LeftHandMenus_l2_on">');
				}
				else
				{
					html += ('<li class="LeftHandMenus_l2_off"" onMouseover="this.className=\'LeftHandMenus_l2_on\';" onMouseout="this.className=\'LeftHandMenus_l2_off\';">');
				}

			}
		}


		if(arrMenu[i]["show"])
		{
			html += ("<a href=\"");
			var testHTTP = arrMenu[i]["url_"+langID];
			if (testHTTP.indexOf("http:") > -1 || testHTTP.indexOf("https:") > -1 || testHTTP.indexOf("ftp://") > -1 || testHTTP.indexOf("mailto:") > -1 || testHTTP.indexOf("javascript:") > -1 ) {
			} else {
				html += rootPath;
			}
			html += (arrMenu[i]["url_"+langID]);
			html += ("\" title=\"");
			html += (arrMenu[i]["text_"+langID]);
			html += ("\"");
			
			if (arrMenu[i]["attributes_"+langID]) {
				html += (" ");
				html += (arrMenu[i]["attributes_"+langID]);
			}
			
			html += (">");
			html += (arrMenu[i]["text_"+langID]);
			html += ("</a>");

			html += ("</li>");
		}
		}
	}
	html += ("</ul>");
	var obj = document.getElementById("sidemenu");
	if (obj) {
		obj.innerHTML = html;
	}
	return false;
}
  		
// ================================================
// gov_generateSiteMap() 
// - creates a site map using the contents of the arrMenu
// - on the sitemap web page, you should 
// ================================================

		function gov_generateSiteMap()
		{
			document.write("<br>");
			for( var i=0; i<arrMenu.length; i++)
			{
				if(arrMenu[i]["level"]==2)
				{
					document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
				}
				if(arrMenu[i]["level"]==1)
				{
					document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
				}
				
				if(arrMenu[i]["level"]==0)
				{
					document.write("<br>");
				}

				document.write("<a href='");
				var testHTTP = arrMenu[i]["url_"+langID];
				if (testHTTP.indexOf("http:") > -1 || testHTTP.indexOf("https:") > -1 || testHTTP.indexOf("ftp://") > -1 || testHTTP.indexOf("mailto:") > -1 || testHTTP.indexOf("javascript:") > -1) {
				} else {
					html += rootPath;
				}
				document.write(arrMenu[i]["url_"+langID]);
				document.write("' title='");
				document.write(arrMenu[i]["text_"+langID]);
				document.write("'>");
				document.write(arrMenu[i]["text_"+langID]);
				document.write("</a>");

				if(i<arrMenu.length-1)
				{
					document.write("<br>");
				}
			}
			return false;
		}





// ================================================
// gov_showLangToggle() 
// - generates the link that will switch to the 
//   alternate langauges
// ================================================
function gov_showLangToggle() {
	// don't replace anything if there isn't a language array
	if (LANGUAGE_IDS) {
		if (LANGUAGE_IDS.length > 0) {
		} else {
			return;
		}
	} else {
		return;
	}

	var html = "";
	var sepChar = "";
	if (arrHeaderLink) {
		if (arrHeaderLink.length > 0) {
			sepChar = " | ";
		}
	}
	for( var i=0; i<arrMenu.length; i++)
	{
		if (arrMenu[i]["alt_link_"+langID] + "" == "1") {
		} else {
			if( pagePath + "" == arrMenu[i]["url_"+langID] + "") {
				var obj = document.getElementById("langDIV");
				if (obj) {
					for (x = 0; x < LANGUAGE_IDS.length; x++) {
						var this_lang = LANGUAGE_IDS[x];
						if (LANGUAGE_IDS[x] == langID) {
						} else {
							if (""+arrMenu[i]["url_"+this_lang] != "") {
								html += "<a href=\""+arrMenu[i]["url_"+this_lang]+"\" class=\"headerlinks\">"+LANGUAGE_LABELS[x]+"</a>"+sepChar;
							}
						}
					}
					obj.innerHTML = html;

				}
			}
		}
	}	
}



// ================================================
// gov_showPrinterFriendly() 
// - reloads page with printer friendly version
// - usually called from an anchor in the web page
// - just redirects to the current page with 
//   ?print appended to it
// ================================================
function gov_showPrinterFriendly()
{
	var newLocation = windowURL;
	if (newLocation.indexOf("?") > -1) {
		newLocation = newLocation.substr(0,  newLocation.indexOf("?"));
	} else {
		if (newLocation.indexOf("#") > -1) {
			newLocation = newLocation.substr(0,  newLocation.indexOf("#"));
		}
	}
	if (urlParameters != "") {
		// automatically includes named anchor...
		newLocation = newLocation + "?print&" + urlParameters;
	} else {
		if (namedAnchor != "") {
			newLocation = newLocation + "?print#" + namedAnchor;
		} else {
			newLocation = newLocation + "?print";
		}
	}
	// launch printer version in new window...
	newwin = window.open(newLocation);
	
	if (newwin) {
	} else {
		alert("Please enable popups for the printer friendly page to show.");
	}
	return false;
}


// ================================================
// gov_showPrinterFriendly(title) 
// - sets appropriate stylesheet by disabling all
//   stylesheets that have a title attribute, then
//   enables the stylesheet which matches "title"
// - this is only used for when toggling printer
//   friendly version
// ================================================
function gov_setActiveStyleSheet(title) 
{
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
   {
	 if(a.getAttribute("rel").indexOf("style") != -1
		&& a.getAttribute("title")) {
	   a.disabled = true;
	   if(a.getAttribute("title") == title) {
	   	a.disabled = false;
	   }
	 }
   }
}
		
		
		
// ================================================
// gov_checkPrint()
// - used to determine if which stylesheet to use 
//   when the page loads (print.css, screen.css)
// - common.css is always used regardless
// ================================================
function gov_checkPrint()
{
	if (windowURL.indexOf("?print") > -1) {
		gov_setActiveStyleSheet("print");
	} else {
		gov_setActiveStyleSheet("screen");
	}
	return false;
}


// ================================================
// gov_showBreadCrumbs()
// - generates the breadcrumb trail using the array arrCrumb[] 
// ================================================
function gov_showBreadCrumbs()
{
	// don't replace anything if there isn't a breadcrumb array
	if (arrCrumb) {
		if (arrCrumb.length > 0) {
		} else {
			return;
		}
	} else {
		return;
	}
	
	var num_slashes = pagePath.split("/");
	var html = "";
	
	var sepChar = " &gt; ";
	if (num_slashes.length == 1) {
		// at the root!
		for (x = 0; x < arrCrumb.length; x++) {
			if (arrCrumb[x]["folder"] == "") {
				html += "<a href=\""+arrCrumb[x]["url_"+langID]+"\">"+arrCrumb[x]["text_"+langID]+"</a>"+sepChar;
			}
		}
	} else {
		
		// show the top-level breadcrumbs first
		for (x = 0; x < arrCrumb.length; x++) {
			if (arrCrumb[x]["folder"] == "") {
				html += "<a href=\""+arrCrumb[x]["url_"+langID]+"\">"+arrCrumb[x]["text_"+langID]+"</a>"+sepChar;
			}
		}

		// now show the others		
		var searchFolder = "";
		for (x = 0; x < num_slashes.length; x++) {
			if (num_slashes[x].indexOf(".html") == -1) {
				// it's a folder...
				searchFolder += num_slashes[x];
				for (xx = 0; xx < arrCrumb.length; xx++) {
					if (arrCrumb[xx]["folder"] == searchFolder) {
						html += "<a href=\""+arrCrumb[xx]["url_"+langID]+"\">"+arrCrumb[xx]["text_"+langID]+"</a> ";
						if (xx < arrCrumb.length - 1) {
							html += " &gt; ";
						}
					}
				}
				if (searchFolder == "") {
				} else {
					searchFolder += "/";
				}
			} else {
				// this is a web page... don't show on the breadcrumb trail
			}
		}
	}
	
	var obj = document.getElementById("breadcrumbDIV");
	if (obj) {
		obj.innerHTML = html;
	}

}



// ================================================
// gov_showHeaderLinks()
// - generates the header links from the array arrHeaderLink[]
// - e.g. the "Site Map" and "Contact Us" header links 
// ================================================
function gov_showHeaderLinks()
{
	var html = "";
	
	// don't replace anything if there isn't a header link array
	if (arrHeaderLink) {
		if (arrHeaderLink.length > 0) {
		} else {
			return;
		}
	} else {
		return;
	}
	if (arrHeaderLink) {
		// show the top-level breadcrumbs first
		for (x = 0; x < arrHeaderLink.length; x++) {
			html += "<a href=\""+arrHeaderLink[x]["url_"+langID]+"\" class=\"headerlinks\">"+arrHeaderLink[x]["text_"+langID]+"</a>";
			if (x < arrHeaderLink.length - 1) {
				html += " | ";
			}
		}
		var obj = document.getElementById("headerLinksDIV");
		if (obj) {
			obj.innerHTML = html;
		}
	}

}












// ================================================
// gov_generateMenuLists()
// - generates the header links from the array arrHeaderLink[]
// - e.g. the "Site Map" and "Contact Us" header links 
// ================================================
function gov_generateMenuLists(){

	// because the dreamweaver library object for the menu will be in /Library/, we make all the links relative to the root.
	var myRootPath = "../";
	var langID;

	var html = "";
	var lastLevel = -1;

	for (langs = 0; langs < LANGUAGE_IDS.length; langs++) {
		langID = LANGUAGE_IDS[langs];
		html = "";
		lastLevel = -1;
		for( var i=0; i<arrMenu.length; i++)
		{
			if (arrMenu[i]["level"] != lastLevel) {
				if (lastLevel == -1) {
					// starting the menu, let's open up list
					html += "<ul>\n";
				} else {
					if (arrMenu[i]["level"] > lastLevel) {
						// moving down in menus... open the list
						html += "<ul>\n";
					}
					if (arrMenu[i]["level"] < lastLevel) {
						// moving up, close the list
						html += "</ul>\n";
					}
				}
				lastLevel = arrMenu[i]["level"];
			}

			if (arrMenu[i]["hidden_"+langID] + "" == "1") {
				html += "<li class=\"hidden\">";
			} else {
				html += "<li>";
			}

			html += ("<a href=\"");
			var testHTTP = arrMenu[i]["url_"+langID];
			if (testHTTP.indexOf("http:") > -1 || testHTTP.indexOf("https:") > -1 || testHTTP.indexOf("ftp://") > -1 || testHTTP.indexOf("mailto:") > -1 || testHTTP.indexOf("javascript:") > -1 ) {
			} else {
				html += myRootPath;
			}
			html += (arrMenu[i]["url_"+langID]);
			html += ("\" title=\"");
			html += (arrMenu[i]["text_"+langID]);
			html += ("\"");


			// if this link is an alternate way of getting to a page, then set the class
			// so that the menu doesn't expand at this location too.
			if (arrMenu[i]["alt_link_"+langID] + "" == "1") {
				html += " class=\"altlink\"";
			}
			if (arrMenu[i]["attributes_"+langID]) {
				html += (" ");
				html += (arrMenu[i]["attributes_"+langID]);
			}

			html += (">");
			html += (arrMenu[i]["text_"+langID]);
			html += ("</a>\n");
		}

		html += ("</ul>\n");
		document.write("<form><h4>"+LANGUAGE_LABELS[langs]+"</h4><textarea cols='60' rows='20'>"+html+"</textarea></form>");
	}

}




// ================================================
// gov_determineLanguage()
// - based upon the current page being viewed, figures out what language we're viewing
// - loops through the arrMenu[] array and finds the currently viewed page
// - if page can't be found, if ".fr." is not in the filename, langID is 'en'
// ================================================
function gov_determineLanguage() {
	var mylang = "";
	var foundLang = 0;
	for (x=0; x < arrMenu.length; x++) {
		for (xx=0; xx<LANGUAGE_IDS.length; xx++) {
				mylang=LANGUAGE_IDS[xx];	
  				if( pagePath + "" == arrMenu[x]["url_"+mylang] + "") {
  					langID = mylang;
  					foundLang = 1;
  				}
		}
	}
	
	if (foundLang == 0) {
		for (xx=0; xx<LANGUAGE_IDS.length; xx++) {
			mylang=LANGUAGE_IDS[xx];	
			if( windowURL.indexOf("."+mylang+".")>0)
			{
				langID = mylang;
			}
		}
	}
}



/* 
=============================================
MAIN LINE PROCESSING BEGINS
=============================================
*/

/* 
DETERMINE WHICH PAGE IS BEING VIEWED
=============================================
*/

var rootPath = "";
var langID = "en";   // by default, pages are english
var windowPath = window.location.pathname + "";
var windowURL = window.location.href + "";
if (windowURL.indexOf(".html") == -1) {
	// browsing a folder without a filename, append index.html
	windowURL = windowURL + "index.html";
}




var urlParameters = "";
if (windowURL.indexOf("?") > 0) {
	// we got a parameter in the url...
	urlParameters = gov_stripSubPath(windowURL, "?");
}

var namedAnchor = "";
if (windowURL.indexOf("#") > 0) {
	// we got a named anchor...
	namedAnchor = gov_stripSubPath(windowURL, "#");
}

// used in the page template...
var tempURL = windowURL;


var pagePath = "";
for (x = 0; x < validPaths.length; x++) {
	pagePath = gov_stripSubPath(windowPath, validPaths[x]);
	if (pagePath == false) {
	} else {
		x = validPaths.length;
	}
}
// if for some reason the browser can't figure out the page we're on, default to index.html
if (pagePath == false) {
	pagePath = "index.html";
}

// if there is no .html extension in the current URL, it means we're browsing the folder
// so append index.html.
if (pagePath.indexOf(".html") == -1) {
	pagePath = pagePath + "index.html";
}

// figure out where the root of the site is, based on number of slashes
var num_slashes = pagePath.split("/");
for (x = 1; x < num_slashes.length; x++) {
	rootPath = rootPath + "../";
}


templatePath = rootPath+"Templates/en/fullpage/";

