	Event.observe(window, 'load', initAccordion, false);
	Event.observe(window, 'load', initLoading, false);
	Event.observe(window, 'load', initLoginForm, false);
	Event.observe(window, 'load', initSkipLink, false);
	
	var gSafe = true;
	function checkBrowser(){
		var browser = navigator.appName;
		var version = parseFloat(navigator.appVersion);
		if (browser == "Microsoft Internet Explorer"){
			gSafe = false;
		}
	}
	
	checkBrowser();
	
/************************************************************************************
backup for the skip link -- since I can't make it work in any browser w/out JavaScript
(though I left the standard HTML in the skip link for screen readers, since I can't test there)
************************************************************************************/
	function initSkipLink(e){
		if ($('skipLink') != null){
			Event.observe('skipLink', 'click', skipToMain, false);
		}
	}
	
	function skipToMain(e){
		//alert('TESTING');
		$('startmain').focus();
	}

/************************************************************************************/
	function initLoading(){
		if ($('sideNav') != null){
			Event.observe($('sideNav'),'click',showSideNavLoading,false);	
		}
		hideLoading();
	}

/************************************************************************************/
	function initLoginForm(){
		if ($('loginForm') != null){
			$('loginForm').focusFirstElement();
		}
	}
	
/************************************************************************************/
	function showLoginForm(){
	
		var phpcode = "";
		phpcode = "$mgr = new Manager();";
		phpcode += "echo $mgr->showLoginForm();";
	
		var obj = new Object();
		obj["phpcode"] = phpcode;
		
		var aj = new Ajax.Request(
			'processor.php', {
				method:'post', 
				parameters: obj,
				onComplete: function(r,o){ 
					$('mainContent').replace(r.responseText);
					$('loginForm').focusFirstElement();
				}
			}
		);
		
	}
	
/************************************************************************************/
	function hideLoginForm(){
		$('loginBoxContents').innerHTML = "please wait";
		$('loginBox').fade( { duration:0.3, from:1, to:0 } );
		window.location.reload();
	}
	
/************************************************************************************/
	function login(f){
	
		var username = processParam($F('username'),"string","");
		var usercode = processParam($F('usercode'),"string","");
	
		var phpcode = "";
		phpcode = "$mgr = new Manager();";
		phpcode += "echo $mgr->login(" + username + "," + usercode + ");";
	
		var obj = new Object();
		obj["phpcode"] = phpcode;
		
		var aj = new Ajax.Request(
			'processor.php', {
				method:'post', 
				parameters: obj,
				onComplete: function(r,o){
				
					if (getUrlParam('diagnostic') == '1') sayHowdy(r.responseText);

					if (r.responseText == "1"){
						$('loginBoxContents').innerHTML = "logging in ... ";
						window.location.reload();
					}else{
						if ($('loginBoxContents').down('.errorMsg') == null){
							$('loginBoxContents').insert({Top:'<p class="errorMsg">Username and/or password incorrect. Try again.</p>'});
						}
						$('loginForm').reset();
						$('username').activate();
						
					}
						
				}
			}
		);
	}
	
/************************************************************************************/
	function logout(){
		showLoading();
	
		var phpcode = "";
		phpcode = "$mgr = new Manager();";
		phpcode += "echo $mgr->logout();";
	
		var obj = new Object();
		obj["phpcode"] = phpcode;
		var aj = new Ajax.Request(
			'processor.php', {
				method:'post', 
				parameters: obj,
				onComplete: function(r,o){ 
					window.location.reload();
				}
			}
		);
	
	}
	
/************************************************************************************/
	function showSideNavLoading(e){
		var element = e.element();
		if ($(element).tagName == "A"){
	
			var showBox = false;
			
			var href = $(element).readAttribute('href');
			var ext = href.substring(href.lastIndexOf('.') + 1,href.length);
			if (ext == "php") showBox = true;
			if ($(element).readAttribute("target") == "_blank") showBox = false;
			
			if(showBox){
				showLoading();
			}
			
			if ($(element).readAttribute("href") == "#"){
				alert("This feature is coming!");	
			}
			
		}
			
	}
	
/************************************************************************************/
	function showLoading(){
		$('loadingBox').appear({  duration:0.2, from: 0, to: 1 });
	}
	
/************************************************************************************/
	function hideLoading(){
		$('loadingBox').fade({  duration:0.5, from: 1, to: 0 });
	}
	
/************************************************************************************/
	function sayHowdy(sender){
		if (sender != "" && !Object.isUndefined(sender)){
			alert("Howdy from " + sender + "!");
		}else{
			alert("Howdy!");	
		}
	}
	
/************************************************************************************/
	function makeTextPretty(str){
		str = str.gsub(/\[/,"<");
		str = str.gsub(/\]/,">");
		return str;
	}
	
/*******************************************************************************************/
	function processParam(paramValue,paramType,origValue){
	
		var retValue;
		if (paramValue == origValue){
			retValue = "NULL";
		}else{
	
			if (paramType == "number"){
				retValue = paramValue;
			}else if (paramType == "string"){
				retValue = '\"' + paramValue + '\"';
			}
		
		}
		return retValue;
	}
	
/*******************************************************************************************/
	function getUrlParam(name){
		var url = window.location.href;
		var obj = url.parseQuery();		
		return obj[name];
	}

/*******************************************************************************************/
	function processAjaxFail(r){
		var msg = "ERROR! There was a problem processing your request. WEB ADMIN: ";
		msg += r.statusText;
		msg += " (" + r.status + ")";
		var param = r.request["parameters"];
		var man = param.man;
		var fn = param.fn;
		msg += "[ " + man + "->" + fn + " ]";
		alert(msg);
	}
	
/*******************************************************************************************/
	function logError(fn,err){

		var obj = new Object();
		obj["page"] = window.location.href;
		obj["fn"] = fn;
		
		if (typeof(err) == "string"){
			obj["msg"] = err;
		}else{
			obj["msg"] = unescape(Object.toQueryString(err));
		}
		
		var aj = new Ajax.Request(
			'errorProcessor.php', {
				method:'post', 
				parameters: obj,
				onCreate: function(){
					
				},
				onFailure: function(r,o){
					//alert('failure');
					//$('howdy').update(r.statusText);
				},
				onSuccess: function(r,o){ 
					//$('howdy').update(r.responseText);
					//alert('success');
				},
				onComplete: function(){ 
					//alert('complete');
				}
			}
		);

	}

/*******************************************************************************************/
	function showDiagnostics(html){
		if ($('diagnostics') != null) $('diagnostics').remove();
		$('mainContent').insert(html);		
	}
	
/************************************************************************************************
PROTOTYPE UTILITY FUNCTIONS
The following functions are used to collect an id from various places, based on my naming scheme
of name_id (e.g., listItem_6, topic_35, etc.)
/************************************************************************************************
idFromName: given a name ("listItem_35"), returns the id (35); if str is a number, it is returned.
************************************************************************************************/
	function idFromName(str){

		// if the string is only the id number, return it
		if ((str - 0) == str) return str;

		// otherwise, extract the number
		var id = str.substring(str.lastIndexOf('_') + 1, str.length);
		return id;

	}
	
/************************************************************************************************
idFromEvent: given an Event object, returns the name_id from the element that triggered the event
or the first parent up the chain that has a qualifying name -- e.g.:
<form name="form_35" id="form_35">
	<div class="formArea">
		<div class="column1">
			<a href="javascript:;">click me</a>
		</div>
	</div>
</form>
If the <a> tag is observed and triggers a function, these utilities will return "35" from the form
NOTE: If e is just the id number (e.g., 35), the number itself is returned.
************************************************************************************************/
	function idFromEvent(e){
	
		if ((e - 0) == e) return e;
		if (Object.isString(e)) return idFromName(e);
		var element = e.element();
		if (Object.isElement(element)) return idFromElement(element);

	}
	
/************************************************************************************************
idFromElement: given an element, returns its name_id (recursive -- calls itself up the chain)
NOTE: If element is not an Element, element is returned (so a number passed in will come back).
************************************************************************************************/
	function idFromElement(element){ // recursive
		if (!(Object.isElement(element))) return element;
		var element_id = $(element).identify();
		if (element_id.startsWith('anonymous')){
			var parent = $(element).ancestors()[0];
			return idFromElement(parent);
		}else{
			return idFromName(element_id);
		}
	}

/************************************************************************************************
startObserving: a wrapper function for the Event.observe command, which first tests to see if the
passed element exists, so null elements don't throw an error -- can pass an element or an element id
************************************************************************************************/
	function startObserving(element, event, fn){
		if (!(Object.isElement(element)) && !(Object.isElement($(element)))) return;
		Event.observe($(element), event, fn, false);
	}

/*******************************************************************************************/
