// JavaScript Document

/********************************************************
- Some scripts are modified versions of those found in 
  the O'Reilly _JavaScript and DHTML Cookbook_ by Danny Goodman.
- Scripts created by Josef Cook are (c) Assembly Studio, 2004.
- These scripts may be used in whole or in part so long as 
  this notice is left intact.
********************************************************/

/* Breadcrumb Trail & Link Corrector Scripts begin */

// define variables to determine if page resides on testing server or live server
// then find out which folder level the referring file is on and adjust all links in file accordingly
var pagePath = location.pathname;	// Location of current page
var re = /\\/g;
pagePath = pagePath.replace(re, "/");
var levels = pagePath.split("/");	// Splits full path at each folder level
var pageLevel = "";					
var styleLoc = "";
var depth1, depth2, depth3;
	if (location.protocol == "http:") {	// Checks protocol to determine whether live/test server.
		depth1 = 1;						// Depths can change according to file structure: 
		depth2 = 3;						// --How many levels of folders are there?
		depth3 = 4;						// --Do any folder levels contain no accessible files? etc.
	} else {
		depth1 = 3;
		depth2 = 5;
		depth3 = 6;
	}
	
// Get the folder level for the referring file to 
// adjust links to correct level in hierarchy
pageLevel = levels.length - 1;

if (pageLevel == depth1) {
		styleLoc = "";
	} else if (pageLevel == depth2) {
		styleLoc = "../../";
	} else if (pageLevel == depth3) {
		styleLoc = "../../../";
	}
	
/* Breadcrumb Trail & Link Corrector Scripts end */

/* Dynamic Stylesheet Assignment Script begin */

var whichSheet = "";							

// Browser detection and appropriate stylesheet application
if(navigator.userAgent.indexOf("MSIE") != -1) { // Internet Explorer 
	whichSheet = "IE";
} else if (navigator.userAgent.indexOf("Netscape") != -1) { // Netscape 
	whichSheet = "NN";
} else if (navigator.userAgent.indexOf("Firefox") != -1) { // FireFox 
	whichSheet = "FF";
} else { // Other
	whichSheet = "Gen";
}
document.write("<link href='" + styleLoc + "Styles/Layout" + whichSheet + ".css' rel='stylesheet' type='text/css' title='Browser Style' />");

/* Dynamic Stylesheet Assignment Script end */

/* Macromedia Call Javascript Script begin */

// Function to call scripts from within OnEvent Handlers - Generated by Dreamweaver
function MM_callJS(jsStr) { //v2.0
	return eval(jsStr)
}

/* Macromedia Call Javascript Script end */

/* Search Form Default Text Script begin */

// Functions to replace the default text in the Search Input in site header
// any time the textbox is empty when it loses focus.
function replaceSearchIn(searchStr) {
	var defaultText = "Search This Site";
	if (searchStr == "") {
		document.forms.searchForm.q.value='';
	} else if (searchStr != "") {
		document.forms.searchForm.q.value=document.forms.searchForm.textHolder.value;
	}
}
function replaceSearchOut(searchStr) {
	var defaultText = "Search This Site";
	if (searchStr == "") {
		document.forms.searchForm.q.value=defaultText;
	} else {
		document.forms.searchForm.q.value=document.forms.searchForm.textHolder.value;
	}
}

/* Search Form Default Text Script end */

/* Statusbar Link Content Script begin */

// Function to initialize all links on any page that calls this 
// function from its body onLoad event.  Status text is generated 
// dynamically from the link's name for links with 
// an id of "statLink1, statLink2, ...".
function setLinkStatus() {
	
	// Set the default status bar text.  This might be buggy in older browsers.
	window.defaultStatus = "Automated Digital Technologies: Taming Technology for the Business World.";
	var linkContent = "";
	var linkText = "";
	var newLink = "";
	var maxLinks = 150;	// Arbitrary number of links on a single page - change to fit needs.
	
	for (var i = 0; i < maxLinks; i++) {
		// Make sure there are marked links on the page.
		if (document.getElementById("statLink" + i) != null) {
			// Netscape & IE handle dynamic generation differently
			// Determine the browser, get the original link, and generate the new one.
			if (whichSheet == "NN" || whichSheet == "FF") {
				linkContent = document.getElementById("statLink" + i);
				linkContent.setAttribute("onMouseOver","window.status=this.name; return true");
				linkContent.setAttribute("onMouseOut","window.status=\"Automated Digital Technologies: Taming Technology for the Business World.\"; return true");				
			} else if (whichSheet == "IE" || whichSheet == "Gen") {
				linkContent = document.getElementById("statLink" + i).outerHTML;
				linkText = document.getElementById("statLink" + i).innerHTML;
				var linkParts = linkContent.split(">");
				newLink = linkParts[0] + " onmouseover='window.status=this.name; return true'";
				newLink += " onmouseout='window.status=\"Automated Digital Technologies: Taming Technology for the Business World.\"; return true'>";
				newLink += linkText + "</a>";
				document.getElementById("statLink" + i).outerHTML = newLink;
			}			
		}
	}
}

/* Statusbar Link Content Script end */