/**********************************************************************/
// Cascading Menus for Standard GE Corporate Top Navbar
// By Matthew Rasnake and Scott Henderson, GE Consumer & Industrial
// Revision and Adaption by Khamla Saenglongma, GE Inspection Technologies
// January 2006
/**********************************************************************/


//Create the only array we'll need.
geMenuArray = new Array();

/* The first menu */
geMenuArray[0] = [
			"مونيتورينگ خوردگي چيست||what's_CorrosionM.htm",
			"تجهيزات مونیتورینگ خوردگی||Corrosion_equipment.htm",
             ];
geMenuArray[0]['id']    = "navbarCell_1"; // id of Parent object for this menu
geMenuArray[0]['width'] = "175";          // width of this menu
geMenuArray[0]['left']  = "";             // left offset (positive or negative)

/* The second menu */
geMenuArray[1] = [
			"عيب‌ياب آلتروسونيك||flaw_detector.htm",
			"ضخامت‌ سنج آلتروسونيك||thickness_gauge.htm",
			"سختي سنج پرتابل||Hardness_tester.htm",
			"ادي كارنت||EddyCurrent.htm",
			"تست ذرات مغناطيسي||MT.htm",			
			"ضخامت سنج رنگ||CoatingThicknessGauge.htm",			
			"پيت‌گيجهاي پيشرفته||PitGauge.htm",
			"گيجهاي جوشكاري||Gauge.htm",
			"وكيوم باكس||Vacuum_Box.htm",	
			"بوراسكوپ و ويدئواسكوپ||videoscope.htm",
             ];
geMenuArray[1]['id']    = "navbarCell_2";
geMenuArray[1]['width'] = "125";
geMenuArray[1]['left']  = "";

/* The third menu */
geMenuArray[2] = [
             ];
geMenuArray[2]['id']    = "navbarCell_3";
geMenuArray[2]['width'] = "125";
geMenuArray[2]['left']  = "";

/* The fourth menu */
geMenuArray[3] = [
             ];
geMenuArray[3]['id']    = "navbarCell_4";
geMenuArray[3]['width'] = "125";
geMenuArray[3]['left']  = "";

/* The fourth menu */
geMenuArray[4] = [
             ];
geMenuArray[4]['id']    = "navbarCell_5";
geMenuArray[4]['width'] = "125";
geMenuArray[4]['left']  = "";




/***********************************************/
/* 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:7px; visibility:hidden; text-transform:none; border-top:1px solid #CCCCCC;}';
ourStyles += 'a.ddcell       {background-color:#F7F7F7; border:1px solid #CCCCCC; border-top:0px; padding: 6px 7px 6px 8px; text-transform:none; display:block;}';
ourStyles += 'a.ddcell:hover {background-color: #FFFFFF;}';
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
}
