﻿// 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", "COMPANY", true);
addMenuItem("ABT", "About Us", null, null, "window.open('company_aboutus.asp','_self')");
addMenuItem("NEW", "Company News", null, null, "window.open('company_news.asp','_self')");
addMenuItem("MSG", "Mission & Values", null, null, "window.open('company_mission.asp','_self')");
endMenu();

addMenu("SER", "SERVICES", true, true);
addMenuItem("OV", "Overview", null, null, "window.open('service_overview.asp','_self')");
addMenuItem("sep");
addMenuItem("LOC", "Localization Solution", null, null, null, true);
//addMenuItem("sep");
addMenuItem("DEV", "Content Solution", null, null, null, true);
//addMenuItem("TST", "Testing", null, null, null, true);
endMenu();

addMenu("SER_LOC", null, null, true);
addMenuItem("SW", "Sofware Localization", null, null, "window.open('service_loc_software.asp','_self')");
addMenuItem("WEB", "Website Localization", null, null, "window.open('service_loc_web.asp','_self')");
addMenuItem("MED", "Multimedia Localization", null, null, "window.open('service_loc_multimedia.asp','_self')");
addMenuItem("DOC", "Document Translation", null, null, "window.open('service_loc_doc.asp','_self')");
addMenuItem("DTP", "Multilingual DTP", null, null,"window.open('service_dtp_multilingual.asp','_self')");
endMenu();

//addMenu("SER_TST");
//addMenuItem("LOC", "Localization Testing", null, null, "window.open('service_tst_localization.asp','_self')");
//addMenuItem("SND", "Software & Hardware", null, null, "window.open('service_tst_softwarehardware.asp','_self')");
//EndMenu();

addMenu("SER_DEV");
addMenuItem("CNT", "e-Learning Content", null, null, "window.open('service_dev_elearning.asp','_self')");
addMenuItem("Tec", "Technical Writing", null, null, "window.open('service_dev_techwriting.asp','_self')");
endMenu();

addMenu("PTN", "PARTNERS", true, true);
addMenuItem("PRO", "Strategic Partnership", null, null,  "window.open('partner_strategic.asp','_self')");
addMenuItem("PRO", "Service Alliance", null, null,  "window.open('partner_service.asp','_self')");
endMenu();

addMenu("CON", "CONTACT US", true, true);
addMenuItem("JOB", "Job Opportunities", null, null, "window.open('career_job_overview.asp','_self')");
addMenuItem("INF", "Contact Info", null, null, "window.open('contact_contactinfo.asp','_self')");
endMenu();

endHTMLmenu();