﻿// JavaScript Document
// Variable Delcaration

var images2preload = new Array("blank.gif", "sep.gif", "arrow.gif");
var preloadedImages = new Array;
var html = '';
var htmlMenu = '';
var menustarted = false;
var currentMenu = null;
var totalmenus = new Array;
var multilevel = false;
var tempvar = '';

// Load CSS
html += "<link rel=\"stylesheet\" type=\"text/css\" href=\"/includes/xpmenu.css\">\n";
flushHTML();

function addMenu(menuName, menuDesc, islevelone, ismultilevel) {
	if (currentMenu) {
		alert("Error: Please End the current Menu before adding another!");
		return false;
	}
	if (menuName.indexOf(" ") != -1) {
		alert("Error: Please specify a menuName without spaces!");
		return false;
	}
	for (z in totalmenus) {
		if (totalmenus[z] == menuName) {
			alert("Error: Please do not repeat the menuName!");
			return false;	
			break;
		}
	}
	
	totalmenus[totalmenus.length] = currentMenu = menuName;
	multilevel = ismultilevel;
	if (islevelone && (menuDesc != null)) {
		if (!menustarted) beginHTMLmenu();
		temp = replaceChars(menuDesc, "[" ,"<u>");
		temp = replaceChars(temp, "]", "</u>");		
		htmlMenu += "<td id=\"menuButton"+menuName+"\" class=\"menuButton\" onMouseOver=\"showMenu(this)\" onMouseOut=\"swapState(this, 0)\" onClick=\"showMenu(this)\">\n";
       	htmlMenu += temp + "</td>\n"

	}
	html += "<table id=\"subMenu_"+menuName+"\" class=\"subMenu\" cellspacing=\"0\" onMouseOver=\"timer(this, 1)\" onMouseOut=\"timer(this, 0)\"><tr><td>";
	html += "<table class=\"innerTable\" cellspacing=\"0\">\n";
}

function addMenuItem(menuItemName, menuItemDesc, gfx, selectedgfx, itemAction, isexpandable) {
	if ((isexpandable) && (!multilevel)) {
		alert("Error: Please change the current Menu to multi-level before making a menu-item expandable!");
		return false;
	}
	if ((!isexpandable) && (!itemAction) && !(menuItemName.toLowerCase() == "sep")) {
		alert("Error: Either make multi-level expandable or contain an action!");
		return false;
	}
	if ((isexpandable) && (itemAction)) {
		alert("Error: Either make multi-level expandable or contain an action!");
		return false;
	}
	if (gfx == null) gfx = "blank.gif";
	else {
		entered = false;
		for (y in images2preload) {
			if (images2preload[y] == imagePath+gfx) {
				entered = true;
				break;
			}
		}
		if (!entered) {
			images2preload[images2preload.length] = imagePath+gfx;
			if (selectedgfx) {
				images2preload[images2preload.length] = imagePath+selectedgfx;
			}
		}
	}
	if (menuItemDesc != null) {
		temp = replaceChars(menuItemDesc, "[" ,"<u>");
		temp = replaceChars(temp, "]", "</u>");		
	}
	if (menuItemName.toLowerCase() == "sep") {
		html += "<tr style=\"padding: 0px;\"><td class=\"leftSide\"><img src=\""+imagePath+"blank.gif\" height=\"0\"></td>";
		html += "<td id=\"subMenuItem_"+currentMenu+"_"+menuItemName+"\" class=\"subMenuSep\" colspan=2>";
		html += "<img src=\""+imagePath+"sep.gif\" width=\"96%\" height=\"1\"></td></tr>\n";	
	} else if ((isexpandable) && (multilevel)) {
		html += "<tr onMouseOver=\"swapSubMenuItem(this, 1";
		if (selectedgfx != null) html += ", '"+selectedgfx+"'";
		html += ");openMenuItem('open_menu', this)\" onMouseOut=\"swapSubMenuItem(this, 0";
		if (selectedgfx != null) html += ", '"+gfx+"'";		
		html += ");closeMenuItem(this)\">\n";
    	html += "<td class=\"subMenuGfx\"><img src=\""+imagePath+gfx+"\" width=\"20\" height=\"20\"></td>\n";
    	html += "<td id=\"subMenuItem_"+currentMenu+"_"+menuItemName+"\" class=\"subMenuText\">"+temp+"</td>\n";
		html += "<td class=\"rightSide\"><img src=\""+imagePath+"arrow.gif\"></td></tr>\n";
	} else if (!(isexpandable) && (multilevel)) {
		html += "<tr onMouseOver=\"swapSubMenuItem(this, 1";
		if (selectedgfx != null) html += ", '"+selectedgfx+"'";		
		html += ")\" onMouseOut=\"swapSubMenuItem(this, 0";
		if (selectedgfx != null) html += ", '"+gfx+"'";				
		html += ")\" onClick=\"openMenuItem();"+itemAction+"\">\n";
    	html += "<td class=\"subMenuGfx\"><img src=\""+imagePath+gfx+"\" width=\"20\" height=\"20\"></td>\n";
    	html += "<td id=\"subMenuItem_"+currentMenu+"_"+menuItemName+"\" class=\"subMenuText\">"+temp+"</td>\n";
		html += "<td class=\"rightSide\"><img src=\""+imagePath+"blank.gif\" width=\"20\" height=\"20\"></td></tr>\n";
	} else if (!(multilevel)) {
		html += "<tr onMouseOver=\"swapSubMenuItem(this, 1";
		if (selectedgfx != null) html += ", '"+selectedgfx+"'";		
		html += ")\" onMouseOut=\"swapSubMenuItem(this, 0";
		if (selectedgfx != null) html += ", '"+gfx+"'";				
		html += ")\" onClick=\"openMenuItem();"+itemAction+"\">\n";
    	html += "<td class=\"subMenuGfx\"><img src=\""+imagePath+gfx+"\" width=\"20\" height=\"20\"></td>\n";
    	html += "<td id=\"subMenuItem_"+currentMenu+"_"+menuItemName+"\" class=\"subMenuText\">"+temp+"</td>\n";
  		html += "</tr>\n";	
	}
	else alert("Error: An Unknown Error has occurred. Please Alert the Author and send all important details via email.");
}

function endMenu() {
	if (!currentMenu) {
		alert("Error: Please Begin a Menu before ending one!");
		return false;	
	}
	html += "</table></td></tr></table>\n";
	currentMenu = null;
}

function beginHTMLmenu() {
	htmlMenu += "<table id=\"menuBar\" class=\"bar\" cellspacing=\"0\" style=\"position: absolute;\">\n";
	htmlMenu += "  <tr>\n";
	htmlMenu += "     <td><table>\n";
	htmlMenu += "         <tr>\n";
	menustarted = true;
}

function endHTMLmenu() {
	if (currentMenu) {
		alert("Error: Please end all menus!");
		return false;	
	}
	htmlMenu += "</tr></table></td></tr></table>\n";
	htmlMenu += "<table cellspacing=\"0\" class=\"barBg\" id=\"menuBarBg\" style=\"position: relative;\" name=\"menuBarBg\">\n";
	htmlMenu += "<tr><td><table><tr><td class=\"barBgItem\">|</td></tr></table></td></tr></table>\n";
	//Preload Imgs
	for (z in images2preload) {
		preloadedImages[z] = new Image;
		preloadedImages[z].src = imagePath + images2preload[z];
	}

	document.write("<script language=\"JavaScript\" type=\"text/javascript\" src=\"/includes/xpmenu.js\"></script>\n");
}

function flushHTML() {
	document.write(html);
	tempvar += html;
	html = '';
}

function GenerateCode() {
	document.write(htmlMenu);
	flushHTML();
}

function replaceChars(entry, out, add) {
temp = "" + entry; // temporary holder

function OpenPage(e)
{
	window.open(e);
}

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
return temp;
}

timeOut = 100;
menuBarBgColor = "#e9ce99";//"#e9ce99";
subMenuBdrColor = "#8A867A";
subMenuGfxBgColor = "#EFEDDE";
keepMenuBarOnTop = false;
bgColorArray = new Array("#e9ce99", "#C1D2EE", "#EFEDDE");
bdrColorArray = new Array("#e9ce99", "#316AC5", "#8A867A #8A867A #FCFCF9");
subMenuBgColor = new Array("#FFFFFF", "#C1D2EE", "#C1D2EE");

imagePath = "images/";

subMenuItemBdrColor = new Array("#EFEDDE", "#FFFFFF", "#FFFFFF");

TDpart1 = "#316AC5 "+subMenuBgColor[1]+" #316AC5 #316AC5";
TDpart2 = "#316AC5 "+subMenuBgColor[1];
TDpart3 = "#316AC5 #316AC5 #316AC5 "+subMenuBgColor[1]+"";

subMenuItemSelectedBdrColor = new Array(TDpart1, TDpart2, TDpart3);

//addMenu(menuName, menuDesc, islevelone, ismultilevel);
//addMenuItem(menuItemName, menuItemDesc, gfx, selectedgfx, action, isexpandable);
//endMenu();

//endHTMLmenu();
//GenerateCode();
addMenu("COM", "关于新诺", true);
addMenuItem("ABT", "公司简介", null, null, "window.open('company_aboutus_chs.asp','_self')");
addMenuItem("MSG", "公司新闻", null, null, "window.open('company_news_chs.asp','_self')");
addMenuItem("MSG", "企业使命", null, null, "window.open('company_mission_chs.asp','_self')");

endMenu();

addMenu("SER", "新诺服务", true, true);
addMenuItem("OV", "服务概览", null, null, "window.open('service_overview_chs.asp','_self')");
addMenuItem("sep");
addMenuItem("LOC", "本地化解决方案", null, null, null, true);
//addMenuItem("sep");
addMenuItem("DEV", "内容解决方案", null, null, null, true);
//addMenuItem("TST", "测试", null, null, null, true);
endMenu();

addMenu("SER_LOC", null, null, true);
addMenuItem("SW", "软件本地化", null, null,  "window.open('service_loc_software_chs.asp','_self')");
addMenuItem("WEB", "网站全球化", null, null, "window.open('service_loc_web_chs.asp','_self')");
addMenuItem("MED", "多媒体本地化", null, null,  "window.open('service_loc_multimedia_chs.asp','_self')");
addMenuItem("DOC", "文档翻译", null, null,  "window.open('service_loc_doc_chs.asp','_self')");
addMenuItem("DTP", "多语言排版", null, null, "window.open('service_dtp_multilingual_chs.asp','_self')");
endMenu();

//addMenu("SER_TST");
//addMenuItem("LOC", "本地化测试", null, null,  "window.open('service_tst_localization_chs.asp','_self')");
//addMenuItem("FUN", "软硬件测试", null, null,  "window.open('service_tst_softwarehardware_chs.asp','_self')");
//EndMenu();

addMenu("SER_DEV");
addMenuItem("CNT", "e-Learning 内容开发", null, null,  "window.open('service_dev_elearning_chs.asp','_self')");
addMenuItem("Tec", "技术写作", null, null, "window.open('service_dev_techwriting.asp','_self')");
endMenu();

addMenu("PTN", "合作伙伴", true, true);
addMenuItem("PRO", "战略合作伙伴", null, null,  "window.open('partner_strategic_chs.asp','_self')");
addMenuItem("PRO", "服务合作伙伴", null, null,  "window.open('partner_service_chs.asp','_self')");
endMenu();

addMenu("CON", "联系我们", true, true);
addMenuItem("JOB", "工作机会", null, null, "window.open('career_job_overview_chs.asp','_self')");
addMenuItem("INF", "联系信息", null, null,  "window.open('contact_contactinfo_chs.asp','_self')");
endMenu();

endHTMLmenu();