 var navImgArray;
 var navImgArrayIndex;		// this var holds the top navigation images when on index page
 
 function initArray(path) {
    navImgArray = new Array(
				path + '/topnav_home.gif',	
				path + '/topnav_home_on.gif',
			    path + '/topnav_customer.gif',
			    path + '/topnav_customer_on.gif',
			    path + '/topnav_products.gif',
			    path + '/topnav_products_on.gif',
			    path + '/topnav_society.gif',
			    path + '/topnav_society_on.gif',
			    path + '/topnav_company.gif',
			    path + '/topnav_company_on.gif',
			    path + '/topnav_business.gif',
			    path + '/topnav_business_on.gif',
			    path + '/topnav_pressroom.gif',
			    path + '/topnav_pressroom_on.gif');
 }
 
 /*
  * initialize the array holding the navi images of when TOP page
  *
  */
 function initArrayIndex(path) {
    navImgArrayIndex = new Array(
				path + '/index_topnav_home.gif',	
				path + '/index_topnav_home_on.gif',
			    path + '/index_topnav_customer.gif',
			    path + '/index_topnav_customer_on.gif',
			    path + '/index_topnav_products.gif',
			    path + '/index_topnav_products_on.gif',
			    path + '/index_topnav_society.gif',
			    path + '/index_topnav_society_on.gif',
			    path + '/index_topnav_company.gif',
			    path + '/index_topnav_company_on.gif',
			    path + '/index_topnav_business.gif',
			    path + '/index_topnav_business_on.gif',
			    path + '/index_topnav_pressroom.gif',
			    path + '/index_topnav_pressroom_on.gif');
 }
		
 function mouseMe(imgName, arrNum) {
	
 	if(navImgArray != null) {
		imgName.src = navImgArray[arrNum];
	}
 }
 
  function mouseMeIndex(imgName, arrNum) {
	
 	if(navImgArrayIndex != null) {
		imgName.src = navImgArrayIndex[arrNum];
	}
 }
 
 
/* this function checks if the current page is selected and if so select the highlighted version of the graphic 
 * input:	indexOrNot - Top page (index) or not
 *			currentsection - specifies if part is selected or not. if not selected is set to "unfocused", otherwise its "name"
 *			section  - the name of the setion 
 *			purl - object link ...?
 *			path - path to the image file
 *			imgPath - included in path so set to ""
 *			arrayNum - the index in the navImgArray array(used to change between on and off graphics)
 *			the tile of the navi which is used in the ALT
 */
  
function navitemhighlight(currentsection, section, purl, path, imgPath, arrayNum, alt_title)
 {
 	var arrayNumMinus1=arrayNum--;
	if(navImgArray == null)	{
		initArray(imgPath);
	}
	if(navImgArrayIndex == null)	{
		initArrayIndex(imgPath);
	}
	
	if (section=="home") {
		var sectionpath = "";
	} else {
		sectionpath = "/" + section;
	}

	/*
	 * The following IF statement is to check if the current page (by URL) is the top page (index page) or not
	 * It is not an ideal way of doing so and in CMS mode, because the URL changes so much, the IF statement
	 * is so big. 
	 * TODO: change later to searching for substring.
	 */
	
	if (
		/* check the top page of live */
		document.URL == "http://www.amway.co.jp/" ||
		document.URL == "http://www.amway.co.jp/index.cfm" || 
		document.URL == "http://amway.co.jp/index.cfm" || 
		document.URL == "http://amway.co.jp/" || 
		document.URL == "amway.co.jp/index.cfm" || 
		document.URL == "amway.co.jp/" || 
		
		/* amway-cms-live*/
		document.URL == "http://amway-cms-live.ashleyassociates.co.jp/index.cfm" ||
		
		
		/* check if top page in CMS mode */
		document.URL.indexOf("index.cfm?fuseaction=index.index",0) > -1 ||
		
		/* check internal and external */		
		document.URL == "http://amwaycojp-internal.ashleyassociates.co.jp/" ||
		document.URL == "http://amwaycojp-internal.ashleyassociates.co.jp/index.cfm" || 
		document.URL == "http://amwaycojp-external.ashleyassociates.co.jp/" ||
		document.URL == "http://amwaycojp-external.ashleyassociates.co.jp/index.cfm" ||
		document.URL == "http://amway-external-old.ashleyassociates.co.jp/" ||
		document.URL == "http://amway-external-old.ashleyassociates.co.jp/index.cfm"  ) {		// check if TOP page
	
		if (currentsection==section) {
			document.write("<a href=\""+purl+"\"><img src=\"" +imgPath+ "/index_topnav_" +section+ "_on.gif\" border=\"0\" alt=\"" + alt_title + "\" title=\"" + alt_title + "\"></a>");
		} else {
			document.write("<a href=\""+purl+"\"><img src=\"" +imgPath+ "/index_topnav_" + section + ".gif \"  name=\"" + section + "\" onMouseOver=\"mouseMeIndex(this, " + arrayNumMinus1 + ")\" onMouseOut=\"mouseMeIndex(this, " + arrayNum + ")\" onClick=\"\" border=\"0\" alt=\"" + alt_title + "\" title=\"" + alt_title + "\"></a>");
		}
	} else {
		if (currentsection==section) {
			document.write("<a href=\""+purl+"\"><img src=\"" +imgPath+ "/topnav_" +section+ "_on.gif\" border=\"0\" alt=\"" + alt_title + "\" title=\"" + alt_title + "\"></a>");
		} else {
			document.write("<a href=\""+purl+"\"><img src=\"" +imgPath+ "/topnav_" + section + ".gif \"  name=\"" + section + "\" onMouseOver=\"mouseMe(this, " + arrayNumMinus1 + ")\" onMouseOut=\"mouseMe(this, " + arrayNum + ")\" onClick=\"\" border=\"0\" alt=\"" + alt_title + "\" title=\"" + alt_title + "\"></a>");
		}
	}
 }

 
 function leftnavhighlight(currentsection, section, sectiontitle)
 {
	
 	if (currentsection==section)
 	{
		document.write("<td class=\"leftNav_on\">"+ sectiontitle +"</td>");
 	}
 	else
 	{
		document.write("<td class=\"leftNav\" onmouseover=\"this.className='leftNav_hover'\" onmouseout=\"this.className='leftNav'\"><a href=\"" + section +".html\" className=\"leftNav\">" + sectiontitle + "</a>");
 	}
 
 }

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];}
}

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;
}