﻿/**********************************************************************/
// Cascading Menus for Standard GE Corporate Top Navbar
// By Matthew Rasnake, Scott Henderson and Khamla Saenglongma, GE Consumer & Industrial
// January 2006
/**********************************************************************/


//Create the only array we'll need.
geMenuArray = new Array();

/* The first menu */
geMenuArray[0] = [
			"USM Go 首页||index.html",
			"USM Go 系列 ||usm-go-series.html",
			"USM Go 特性||features.html",
			"USM Go 应用||applications.html",
			"性能测试视频||videos.html",
			"虚拟演示||demo.html",
		    //"accessories||/en/products/ut/fd/usm-go/accessories.html",
			//"specifications||/en/products/ut/fd/usm-go/specifications.html",
			"下载 & 支持||USM Go_datasheet-210x285mm-lo.pdf",
             ];
geMenuArray[0]['id']    = "navbarCell_1"; // id of Parent object for this menu
geMenuArray[0]['width'] = "145";          // width of this menu
geMenuArray[0]['left']  = "";             // left offset (positive or negative)

/***********************************************/
/* You should not have to edit below this line */
/***********************************************/


//Write additional styles required for menus.
ourStyles = '<style type="text/css">';
ourStyles += 'div.ddmenu {position:absolute; margin-top:0px; visibility:hidden; text-transform:none;}';
ourStyles += 'a.ddcell       {background-color:#FF8500; border-right:0px solid #ffffff; border-left:0px solid #ffffff; border-bottom:0px solid #ffffff; border-top:1px solid #ffffff; padding: 5px 0px 5px 5px; text-transform:none; display:block;}';
ourStyles += 'a.ddcell:hover {background-color: #3b73b9;}';
ourStyles += '</style>';
document.write(ourStyles);


//fnBuildMenu(mNum) returns the html for a single menu.
function fnBuildMenu(mNum) {
	mArr = geMenuArray[mNum];
	mWidth = "width:"+mArr.width+"px;";                      // a CSS style width statement string
	mLeft = (mArr.left)?"margin-left:"+mArr.left+"px;":"";   // a CSS style left-margin statement string
	menuString =  '<br><div id="menudiv'+mNum+'" class="ddmenu" style="'+mWidth+mLeft+'">'; // start menuString with opening DIV
	for (mItem in mArr) {                           // loop through this sub-array
		if (parseInt(mItem)||(parseInt(mItem)==0)) {  // if array item name is a number (i.e. it's not "id" or "width")
			linky = mArr[mItem].split('||');            // split the contents of this array item to get Link Text and Link URL
			menuString += '<a href="'+linky[1]+'" class="ddcell" id="m'+mNum+'-'+mItem+'" style="'+mWidth+'">'+linky[0]+'</a>'; // add this menu item to HTML DIV string
		}
	}
	menuString += '</div>';                         // close HTML DIV string
	return menuString;                              // return the constructed Menu HTML 
}

//fnDefineMenus() uses fnBuildMenu to create the HTML, insert it into the page, and attach event listeners to the Parent Objects  
function fnDefineMenus() {
	if(!document.getElementById(geMenuArray[geMenuArray.length-1].id)) { //a test for final Parent object that's supposed to spawn a menu
		fred = setTimeout("fnDefineMenus()",500);  //if it doesn't exist yet, wait a bit longer
	} else {
		for (men in geMenuArray) {                      // loop through main menu Array
	  		tempObj = document.getElementById(geMenuArray[men].id); //get obj ref. to this menu's Parent Object
	  		tempObj.innerHTML  += fnBuildMenu(men);     //build menu HTML string and add it to Parent Object's HTML
	  		tempObj.onmouseover = fnOpenMen;          //define Parent Object's mouseover event to call fnOpenMen
	  		tempObj.onmouseout  = fnCloseMen;         //define Parent Object's mouseout event to call fnCloseMen
    	}
	}
}

function fnOpenMen() {
  menObj = this.getElementsByTagName('div')[0];  // Our menu is the first div within the Parent Object (this)
  menObj.style.visibility = "visible";           
}
function fnCloseMen() {
  menObj = this.getElementsByTagName('div')[0];  // Our menu is the first div within the Parent Object (this)
  menObj.style.visibility = "hidden";
}

//Let's get things started!!
//We're NOT using document.onload -- It could conflict with an onload already in the BODY tag.
if (document.getElementsByTagName) { // if we're DOM capable
	fnDefineMenus();  //start _trying_ to define menus
}
