// Sniff for the two major browsers
	var ie  = (document.all)? true:false
	var ns6 = ((document.getElementById)&&(!ie))? true:false

// Sniff for Mac, used for IE Mac browsers
	var mac = (navigator.userAgent.toUpperCase().indexOf("MAC") > -1)? true:false

// Sniff for AOL, used in certain cases where AOL won't pop open a window the size we want it
	var aol = (navigator.userAgent.toUpperCase().indexOf("AOL") > -1)? true:false

// Used to test if a value is 'undefined'.  What 'undefined' represents is different for each
// browser, but any variable that has not been defined a value IS 'undefined' in all browsers.
// So, we'll test against this variable to see if another is 'undefined'.
	var undef;
	
	var bgXcoord = 0;
	
	var HideText = "";

// var is declared in universal nav offsite code, used to define full path.
// we don't want to hose the value, so we'll check if it has one.
	if (T1navPath == undef) {
		var T1navPath = "";
	}

	var PreloadComplete = false;
	var HomePreloadComplete = false;
	
	var MouseOverColor = "#C4C4C4";
	var MouseOffColor = "#DADAD5";

// Global Variables, used to set which model page we're on
	var gVCmodel =  "index";
	var gModelName = "";
	var gLegacyAbbrev = "";
	var gBrochurePDAAbbrev = "";
	var gPageName = "";

// These links are considered absolute links at this point.
// Adjust topNavMacWidth[] when the contents of this nav change.
	var topNavMenu = new Array();

	topNavMenu["About0"] = new Array("Company History", "/company/history/index.htm");
	topNavMenu["About1"] = new Array("Executive Team", "/company/executives/index.htm");
//	topNavMenu["About2"] = new Array("Client List", "/company/clients.htm");
	topNavMenu["About2"] = new Array("Careers", "/company/careers/index.htm");

	topNavMenu["Products0"] = new Array("InfoShip", "/products/infoship/index.htm");
	topNavMenu["Products1"] = new Array("Integration Manager", "/products/im/index.htm");
	topNavMenu["Products2"] = new Array("DMS", "/products/dms/index.htm");
	topNavMenu["Products3"] = new Array("InfoTrack", "/products/infotrack/index.htm");
	topNavMenu["Products4"] = new Array("InfoShare", "/products/infoshare/index.htm");

	topNavMenu["Services0"] = new Array("Integration", "/services/integration/index.htm");
	topNavMenu["Services1"] = new Array("Support", "/services/support/index.htm");
	topNavMenu["Services2"] = new Array("Training", "/services/training/index.htm");

	topNavMenu["Studies0"] = new Array("Customer Profiles", "/studies/profiles/index.htm");
	topNavMenu["Studies1"] = new Array("Local Server", "/studies/localserver/index.htm");
	topNavMenu["Studies2"] = new Array("Central Server", "/studies/centralserver/index.htm");
	topNavMenu["Studies3"] = new Array("In-Motion", "/studies/inmotion/index.htm");
	topNavMenu["Studies4"] = new Array("Black Box", "/studies/blackbox/index.htm");


	var topNavContents = new Array();
	topNavContents["About"] = "";
	topNavContents["Products"] = "";
	topNavContents["Services"] = "";
	topNavContents["Studies"] = "";

	var topNavMacWidth = new Array();
	topNavMacWidth["About"] = "130";
	topNavMacWidth["Products"] = "175";
	topNavMacWidth["Services"] = "125";
	topNavMacWidth["Studies"] = "175";


// Layer Build functions.  The IF verifies that, if a layer doesn't exist
// the function will return null instead of a JavaScript error.
	function refLayer(layerName) {
		var LAYref;
		if (ie) {
			if (document.all[layerName]) {
				document.all[layerName].layerWidth = function() { return this.scrollWidth; };
				LAYref = document.all[layerName];
				HideText = "hidden";
			} else {
				LAYref = null;
			}
		} else {
		    // default to NS6+
			if (document.getElementById(layerName)) {
				HTMLElement.prototype.layerWidth = function() { return this.offsetWidth; };
				LAYref = document.getElementById(layerName);
					HideText = "hidden";
			} else {
				LAYref = null;
			}
		}
			return LAYref;
	}


// Functions to determine browser window width/height
	function getInsideWindowWidth() {
		if (ie) {
			return document.body.scrollWidth
		} else {
			return document.width
		}
	}

	function getInsideWindowHeight() {
		if (ie) {
			return document.body.scrollHeight
		} else {
			return document.Height 
		}
	}


// Calculate Offsets from current item.
	function eventXoffset(nsEvt) {
		if (ie) {
			return document.body.scrollLeft - document.body.clientLeft + event.clientX - event.offsetX;
		} else {
			
			return nsEvt.pageX - nsEvt.layerX;
		}
	}
	function getPageOffsetLeft(el)
	{
		var x;

  		// Return the x coordinate of an element relative to the page.

  		x = el.offsetLeft;
  		if (el.offsetParent != null) 
  		{
    			x += getPageOffsetLeft(el.offsetParent);
		}
  		return x;
		
	}
	
	function eventYoffset(nsEvt) {
		
		if (ie) {
			return document.body.scrollTop - document.body.clientTop + event.clientY - event.offsetY;
		} else {
			return nsEvt.pageY - nsEvt.layerY;
		}
	}

	function layerWidth(LAYer) {
		if (ie) {
			return LAYer.scrollWidth;
		} else {
			return LAYer.offsetWidth;
		}
	}

// Create the objects
	function menuInit() {
		LAYtopNavMenu = refLayer("topNavDIV");
		LAYarrowHL = refLayer("arrowHL");
		PreloadComplete = true;
	}

//****************************************
//** Top Nav DHTML Menu Functions START **
//****************************************

	var NotInMenuNow = true;

	function topNavBuild(menuName) {
		var i, menuHTML, linkURL;
// Build Menu Contents.  Should only be done once.
		i = 0;
		menuHTML = "";

		while (topNavMenu[menuName + i]) {
		//	menuHTML += '<DIV CLASS="menuSpacer" STYLE="width:52px; height:1px;"></DIV>\n';

// If this is a JavaScript command, just use it instead of trying a document.location.href.
			if (topNavMenu[menuName + i][1].toLowerCase().indexOf("javascript:") == 0) {
				linkURL = topNavMenu[menuName + i][1].substr(11);
			} else if (topNavMenu[menuName + i][1].toLowerCase().indexOf("http") == 0) {
				linkURL = "top.location.href='"+topNavMenu[menuName+i][1]+"'";
			} else {
				linkURL = "top.location.href='"+T1navPath+topNavMenu[menuName+i][1]+"'";
			}
			menuHTML += '<DIV CLASS="menuItem" onClick="'+linkURL+'" style="cursor: pointer ;" onMouseOver="changeBGcolor(this, MouseOverColor)" onMouseOut="changeBGcolor(this, MouseOffColor)"'

			if (ie && mac) {
				menuHTML += ' STYLE="width:'+topNavMacWidth[menuName]+'px;"'
			}
			menuHTML += '><NOBR>'+topNavMenu[menuName + i][0]+'&nbsp;</NOBR></DIV>\n';
			i++;
		}
		
		return menuHTML;
	}

// Top Nav Dropdown functions
// Check PreloadComplete on these just in case
	function showTopNavDD() {
		if (PreloadComplete) {
			NotInMenuNow = false;
			LAYtopNavMenu.style.visibility = "inherit";
		}
	}

	function hideTopNavDD(FirstTry) {
		if (PreloadComplete) {
			if (FirstTry) {
				NotInMenuNow = true;
				setTimeout("hideTopNavDD(false)", 500);
			} else if (NotInMenuNow) {
				LAYtopNavMenu.style.visibility = "hidden";
			}
		}
	}

	function revealTopNavDD(menuName, xCoord, evt) {
		var MenuEdge, MDxCoord, MDyCoord;

		if (PreloadComplete) {
		    //** Hide menu and move it off the page.  This resolves menu flicker. **
			NotInMenuNow = true;
			hideTopNavDD(false);
			LAYtopNavMenu.style.left = -200;
			LAYtopNavMenu.style.top = -200;

// If we haven't viewed this menu before, write out its contents and store in array.
			if (topNavContents[menuName] == "") {
				topNavContents[menuName] = topNavBuild(menuName);
			}

			LAYtopNavMenu.innerHTML = topNavContents[menuName];

// Calculate right edge of menu.  If it's past the edge of the centered table, align it so it is.
// This layer is in a table cell, which triggers an IE5 Mac positioning bug.
// To fix it, set these vars to 0.
			
			LeftPageStart = (getInsideWindowWidth()-778)/2;
			//TopPageStart =  (getInsideWindowWidth()-778)/2;
			if (ie && mac) {
				MDxCoord = 0;
				MDyCoord = 0;
			} else if (!ie) {
				MDxCoord = LeftPageStart +150;// eventXoffset(evt); // // + 150; //
				MDyCoord = 100; //eventYoffset(evt) ;//
			} else if (ie) {
				MDxCoord = eventXoffset(evt); //LeftPageStart + 100; 
				MDyCoord = eventYoffset(evt); //eventYoffset(evt) ;//100; //
			}
			
			MenuEdge = MDxCoord + xCoord + layerWidth(LAYtopNavMenu) - LeftPageStart;

			if (MenuEdge > 778) {
// The right edge of the menu is beyond the designed-for
// 778 pixel page width.  Adjust MDxCoord appropriately.
				
				MDxCoord -= (MenuEdge-776);
			}

		    //** Set left & top coordinates. **
			LAYtopNavMenu.style.left = MDxCoord + xCoord;
			LAYtopNavMenu.style.top = MDyCoord + 32 - 15;

			setTimeout("showTopNavDD()", 750);
		}
	}

	function changeBGcolor(LAYer, hexColor) {
		if (PreloadComplete) {
			LAYer.style.backgroundColor = hexColor;
		}
	}

//**************************************
//** Top Nav DHTML Menu Functions END **
//**************************************

//**************************************
//** Nav DHTML Arrows Functions START **
//**************************************

	var ArrowHLURL = "";
	var ArrowHLmodel = "";

	function moveArrowHL(AHxOffset, AHyOffset, evt) {
		var AHxCoord, AHyCoord;

		if (PreloadComplete) {
			AHxCoord = eventXoffset(evt);
			AHyCoord = eventYoffset(evt);

			if (ie) {
				AHyCoord = AHyCoord - 1;
			}

			LAYarrowHL.style.left = AHxCoord + AHxOffset;
			LAYarrowHL.style.top = AHyCoord + AHyOffset;

			showArrowHL();
		}
	}

	function showArrowHL() {
		if (PreloadComplete) {
			LAYarrowHL.style.visibility = "inherit";
		}
	}

	function hideArrowHL() {
		if (PreloadComplete) {
			LAYarrowHL.style.visibility = "hidden";
		}
	}

	function clickArrowHL() {
		if (ArrowHLURL != "") {
			top.location.href = ArrowHLURL;
		}
	}


//************************************
//** Nav DHTML Arrows Functions END **
//************************************

//*****************************************
//** Nav Rollover Arrows Functions START **
//*****************************************

	plArrowHL = new Image();
	plArrowHL.src = "/assets/arrow_highlight.gif";
	plArrowGR = new Image();
	plArrowGR.src = "/assets/arrow_gray.gif";
	plArrowBK = new Image();
	plArrowBK.src = "/assets/arrow_current.gif";

	plArrowUpHL = new Image();
	plArrowUpHL.src = "/assets/arrow_up_highlight.gif";
	plArrowUpGR = new Image();
	plArrowUpGR.src = "/assets/arrow_up_gray.gif";

	CurArrowGroup = new Array();

	function arrowHL(imgName) {
		if (document.images[imgName]) {
			document.images[imgName].src = plArrowHL.src;
		}
	}

	function arrowHLBK(imgName, lastImg) {
		if (document.images[imgName]) {
			if (imgName != CurArrowGroup[lastImg]) {
				document.images[imgName].src = plArrowHL.src;
			}
		}
	}

	function arrowGR(imgName) {
		if (document.images[imgName]) {
			document.images[imgName].src = plArrowGR.src;
		}
	}

	function arrowGRBK(imgName, lastImg) {
		if (document.images[imgName]) {
			if (imgName == CurArrowGroup[lastImg]) {
				document.images[imgName].src = plArrowBK.src;
			} else {
				document.images[imgName].src = plArrowGR.src;
			}
		}
	}

	function arrowBK(imgName, lastImg) {
		if (CurArrowGroup[lastImg] != "-1") {
			if (document.images[CurArrowGroup[lastImg]]) {
				document.images[CurArrowGroup[lastImg]].src = plArrowGR.src;
			}
		}

		if (document.images[imgName]) {
			document.images[imgName].src = plArrowBK.src;
			CurArrowGroup[lastImg] = imgName;
		}
	}

	function arrowUpHL(imgName) {
		if (document.images[imgName]) {
			document.images[imgName].src = plArrowUpHL.src;
		}
	}

	function arrowUpGR(imgName) {
		if (document.images[imgName]) {
			document.images[imgName].src = plArrowUpGR.src;
		}
	}

//***************************************
//** Nav Rollover Arrows Functions END **
//***************************************

//****************************
//** Flash Sniffing START ****
//****************************

	// Check for Flash, set vars if T/F
		var Flash4 = false;
		var Flash5 = false;
		var Flash6 = false;
		var FlashEnabled = false;

	// Default is False, so we only need to set it as True.
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) {
			// Check for Flash in Netscape
			var nsFlash = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
			if (nsFlash) {
				var FlashVer = parseInt(nsFlash.description.substring(nsFlash.description.indexOf(".")-1));
				if (FlashVer >= 6) {
					Flash6 = true;
				} else if (FlashVer == 5) {
					Flash5 = true;
				} else if (FlashVer == 4) {
					Flash4 = true;
				}
			}
		} else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
			var f4Inst;
			var f5Inst;
			var f6Inst;

			eval('try { f4Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.4"); f5Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5"); f6Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); } catch (e) { }');

			if (f6Inst != null) {
				Flash6 = true;
			} else if (f5Inst != null) {
				Flash5 = true;
			} else if (f4Inst != null) {
				Flash4 = true;
			}

			f4Inst = null;
			f5Inst = null;
			f6Inst = null;
		}

		if (document.location.search == "?flash=disabled") {
			Flash4 = false;
			Flash5 = false;
			Flash6 = false;
			// FlashEnabled default is false
		} else if (Flash5 || Flash6) {
			FlashEnabled = true;
		}

//**************************
//** Flash Sniffing END ****
//**************************

//**************************
//** Misc Functions START **
//**************************

	function newCursor(imgName, curName) {
		if (PreloadComplete) {
			document.images[imgName].style.cursor = curName;
		}
	}

	//****************************************************
	//** Popup function Fixes IE making popup windows   **
	//** 20px higher than specified when menubar is on  **
	//** Parameters can be passed in as necessary 	    **
	//** returns a reference to the	window if needed    **
	//****************************************************


	function popup(popupurl,winName,w,h,params) {
	    // Build parameter list manually.  This lets us override individual defaults as needed.
		var paramList = "";
		if (params == undef) {
			params = "";
		}

		params = params.toLowerCase();
		if (params.indexOf("menubar=no") != -1) {
			paramList = paramList + ",menubar=no";
		} else {
		    // default
			paramList = paramList + ",menubar=yes";
		    // IE adds to the height with a menubar; subtract to keep height the same.
			if (ie && !mac) {
				h = h - 20;
			}
		}

		if ((params.indexOf("scrollbars=no") != -1) || (params.indexOf("scrollbar=no") != -1)) {
			paramList = paramList + ",scrollbars=no";
		} else {
		    // default
			paramList = paramList + ",scrollbars=yes";

		    // IE needs extra space to allow for the phantom scrollbar, or we'll get horizontal scrollbars too.
		    // IE 6.x needs 4px more than IE 5.x, but IE 5.x's width needs vary a lot.  So, we'll set all
		    // IE browsers to use the wider IE 6.x size.

			if (ie) {
				w = w + 17;
			} else {
				w = w + 15;
			}
		}

		if (params.indexOf("resizable=yes") != -1) {
			paramList = paramList + ",resizable=yes";
		} else {
		    // default
			paramList = paramList + ",resizable=no";
		}

		if ((params.indexOf("toolbar=yes") != -1) || (params.indexOf("toolbars=yes") != -1)) {
			paramList = paramList + ",toolbar=yes";
		} else {
		    // default
			paramList = paramList + ",toolbar=no";
		}

//alert(paramList);
		return window.open(popupurl,winName,"top=35,left=130,width=" + w + ",height=" + h + paramList);
	}

//************************
//** Misc Functions END **
//************************