//var $jq = jQuery.noConflict();
jQuery.noConflict();
jQuery(document).ready(function($){// Put all your code in your document ready area
//onLoad event handlers
	$(document).click(function(event){
		MapLinks.handler();
	});
	//$("#input_username").focus();
	$("input.focus:first").focus().select();//set class on the inputs. any index forms come before the login form.
	//$('.returntotop').animate({scrollTop: $('window')[0].scrollHeight});//not really
});

//if (abindex.closed) window.name = abindex;



var TEXT_NODE = 3;

/********************************************************************
 * Global variables
 ********************************************************************/
var g_objBody;
var g_objRuler;
var g_fontSize = 0;
var g_blnGo = true;
//not in use above
var g_httpPrefix = location.href.split("://")[0] + "://";
/*
	A. This regex starts from the end of the address and moves back.
	B. From the right side, the domain name must end in a 2- to 4-letter/number top-level domain name, such as com, info, uk, etc.
	C. Next, there must be one or more subdomains.
	D.   Subdomains are followed by periods.
	E.   Each subdomain can be one number or letter.
	F.   It can also be more than one letter or number.
	G.     Subdomains containing more than one letter or number can also use hyphens in the positions not directly adjacent to the periods.

	H. An 'at' symbol separates the domain from the address.

	I. An e-mail address is comprised of one or more of the following characters:
	J.   These characters must be preceded by a backslash.
	K.   These characters may optionally be preceded by a backslash.
*/

//                 <-------------------------------------------- I -------------------------------------------->H<------------------ C ---------------------><---- B ---->A
//                  <-------------- J --------------> <--------------------------- K ------------------------>     <- E --> <------------ F -----------> DD
//                                                                                                                                       <-- G ---> 
var g_emailFormat = /(\\[\x00-\x20<|>()\[\]\\,;:@"\x80]|(\\?[\w\x21\x23-\x27\x2A-\x2F\x3D\x3F\x5E\x60\x7B-\x7F]))+@(([a-z0-9]|([a-z0-9][-a-z0-9]*[a-z0-9]))\.)+[a-z0-9]{2,4}$/i;


/********************************************************************
 * Pop up behavior manipulation utilities
 ********************************************************************/
function popupRel(link, data) {
//alert("pop");
	var url;
	var popup;
	if (typeof link == "string") {
		url = link;
	} else {
		url = link.getAttribute("href");
		if (data.length > 0) {
			link.target = data[0];
		}
	}
/********************************************************************
 * If a popup window name is already being used, this will change the second window
 * name invoked to be named EMPTY_STRING.  This allows a popup window to
 * open another popup window and not replace its existing location.
 ********************************************************************/
	data[0] = (window.name === data[0]) ? "" : data[0];

	switch (data.length) {
		case 0:
			popup = window.open(url);
			break;
		case 1:
			popup = window.open(url, data[0]);
			break;
		default:
			popup = window.open(url, data[0], data[1]);
			break;
	}
	popup.focus();
	return false;
}

var MapLinks = {
	runMapLinks: true,
	popup: function(rel, targetObj, e) {
		e = e || window.event;
		var self = MapLinks;
		var functionData = self.relFunctionsMap[rel];
		if ( isPresent(functionData) ) {
			var functionRef = functionData[0];
			var functionValues = functionData[1];
			if (!functionRef(targetObj, functionValues) ) {
				if (e) {
					e.preventDefault();
					return false;
				}
			}
		}
	},
	handler: function(e) {
		var self = MapLinks;
//alert('finally!');
		if (!self.runMapLinks) {
			self.runMapLinks = true;
			return;
		}
		if (!e) {
			e = window.event;
		}
		var targetObj = getTargetObj(e, "a") || getTargetObj(e, "area");
		if (!targetObj) {
			return;
		}
		return self.relHandler(targetObj, e);
	},
	relHandler: function(objLink, e) {
		var self = MapLinks;
		var rel = objLink.getAttribute("rel");
		var functionData = self.relFunctionsMap[rel];
		if (isPresent(functionData) && !isModifiedClick(e) ) {
			var functionRef = functionData[0];
			var functionValues = functionData[1];
			if (!functionRef(objLink, functionValues) ) {
				e.preventDefault();
				return false;
			}
		}
	},
/**************************************************************
 * relFunctionsMap maps rel attributes to functions.
 * syntax is:  relName:[function, functionArgsAsArray]
 **************************************************************/
	relFunctionsMap: {
		  external:[popupRel, ["abcomexternal"]],
		     popup:[popupRel, ["abcompopup","width=800, height=600, menubar=yes, scrollbars=yes, resizable=yes, location=no, toolbar=yes"]],
		   abpopup:[popupRel, ["abindex","width=827,height=668,scrollbars=yes,resizable=yes, menubar=yes, location=no, toolbar=yes"]],
		      mini:[popupRel, ["mini","width=400, height=250, status=no, resizable=yes, scrollbars=yes, toolbar=no, menubar=no, location=no"]],
//		 contactus:[popupRel, ["contactus","width=650,height=650,menubar=no,scrollbars=yes, resizable=yes, location=no, toolbar=no"]],
		  comments:[popupRel, ["abcomments","width=500,height=450,menubar=no,scrollbars=auto,resizable=yes,location=no,toolbar=no,status=no"]],
//	   returnToTop:[scrollThis, ["foo","content","up"]],
//	   returnToTop:[scrollThis, ["content","up"]],
	   returnToTop:[scrollUp, []],
	     promptBtn:[promptInsert, [this.href]],
	     emoteBtn:[emoteInsert, [this.href]],
//	    scrollDown:[scrollThis, ["content","down"]],
	  sendToOpener:[sendToOpener,[this.href]],
	         close:[function(){return window.close()},[this.href]],
	         reset:[],
	         email:[],
		// unfortunately the popup parameters can't be placed here for this special object.  the popup parameters are found on the
		// getImgProperties function below.  Ideally we can put this in the function map.
	      imgPopup:[getImgProperties, [this]]
	}
};


/********************************************************************
 * Plugin Utilities
 ********************************************************************/
var g_isMozPlugin = (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length);
var g_isIePlugin = (!g_isMozPlugin && window.ActiveXObject);

function pdfPluginInstalled() {
	var isPdfPluginInstalled = false;
	if (g_isMozPlugin) {
		duff(navigator.plugins, function(objPlugin) {
			// "Adobe PDF" is the description for Acrobat 8 (ver 3 doesn't have "Adobe" in the desc)
			if (objPlugin.description.indexOf("Adobe Acrobat") != -1 || objPlugin.description.indexOf("Adobe PDF") != -1) {
				isPdfPluginInstalled = true;
			}
		});
	}
	else if (g_isIePlugin) {
		var versions = [
			"AcroPDF.PDF.1",
			"PDF.PdfCtrl.6",
			"PDF.PdfCtrl.5",
			"PDF.PdfCtrl.1"
		];
		for (i = 0; i < versions.length; i++) {
			try {
				objAcro = eval("new ActiveXObject(versions[i]);");
				if (objAcro) {
					isPdfPluginInstalled = true;
					break;
				}
			}
			catch(e) { }
		}
	}
	return (isPdfPluginInstalled) ? true : false;
}

var SwfDetection = function() {
	var self = {
		ver: null,
		getSwfVer: function() {
			var strVersion;
			var objFlash;
			var arrVer;
		
			if (g_isMozPlugin) {
				var swfVer = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				objFlash = navigator.plugins["Shockwave Flash" + swfVer];
				if (!objFlash) { return null; }
				arrVer = objFlash.description.match(/(\d+)\.(\d+)\s+\w(\d+)$/);
				return [(arrVer[1]|0), (arrVer[2]|0), (arrVer[3]|0)];
			}
			else if (g_isIePlugin) {
				eval('try { objFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); objFlash.AllowScriptAccess = "always"; strVersion = objFlash.GetVariable("$version"); } catch(e) {}');
		
				if (!strVersion) {
					eval('try { objFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); strVersion = " 6,0,21"; } catch(e) {}');			
				}
		
				if (!strVersion) {
					eval('try { objFlash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); strVersion = objFlash.GetVariable("$version"); } catch(e) {}');
				}
			}
		
			if (!strVersion) { return null; }
			arrVer = strVersion.split(" ")[1].split(",");
			return [(arrVer[0]|0), (arrVer[1]|0), (arrVer[2]|0)];
		},
	
		getVersionString: function() {
			if (!self.ver) { self.ver = self.getSwfVer(); }
			return self.ver ? self.ver.join(".") : "n/a";
		},
	
		reqVersionMet: function(reqMajorVer, reqMinorVer, reqRevision) {
			if (!self.ver) { self.ver = self.getSwfVer(); }
			if (!self.ver) { return false; }
			var versionArray = self.ver;
			var versionMajor = versionArray[0];
			var versionMinor = versionArray[1];
			var versionRevision = versionArray[2];
			if (versionMajor > reqMajorVer) { return true; }
			if (versionMajor == reqMajorVer) {
				if (versionMinor > reqMinorVer) { return true; }
				if (versionMinor == reqMinorVer && versionRevision >= reqRevision) { return true; }
			}
			return false;
		}
	};
	return self;
}();

var MakePlugin = function() {
	var self = {
		objEmbedContainer: {},
		objEmbededMedia: {},
		create: function(id, type, url, width, height, params, isFixedWidth) {
			var insertObj = document.getElementById(id);
			var strDivWidth;
			if (!insertObj) { return; }
			
			var strObject = '<object';
			switch(type) {
				case "flash" :
					strObject += g_isIePlugin ? ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
						' codebase="' + g_httpPrefix + 'fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"' :
						' type="application/x-shockwave-flash" data="' + url + '"';
					strObject += ' width="' + width + '" height="' + height + '" style="position: absolute; z-index: 0;">';
					strObject += '<param name="movie" value="' + url + '" />';
					/* The AFI choice for wmode is "transparent". This causes 2 bugs in Firefox (2-3) and Adobe Player 9 (.124) with SWFs v9. If we change setting to "window", it is at risk of any dynamic layers or possibly form elements getting lost behind the Flash movies.  We'll have to test each piece, but so far it's been fine.  I'm considering copying this function to start-small-ease.js to make a local version with "window" without affecting the rest of the site.  The bugs in question are:  border around SWF when selecting/using it, and components lose mousedown when traveling off edge of movie.  Additional note - transparent setting also causes IE bug (scrolling mouse/paint weirdness a la Roadmap) */
					strObject += '<param name="wmode" value="window" />';
					break;
				case "quicktime" :
					strObject += g_isIePlugin ? ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' +
						' codebase="' + g_httpPrefix + 'www.apple.com/qtactivex/qtplugin.cab"' :
						' type="video/quicktime" data="' + url + '"';
					strObject += ' width="' + width + '" height="' + height + '">';
					strObject += g_isIePlugin ? '<param name="src" value="' + url + '" />' : "";
					break;
				case "windowsMedia" :
					strObject += g_isIePlugin ? ' classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' :
						' type="video/x-ms-wmv" data="' + url + '"';
					strObject += ' width="' + width + '" height="' + height + '">';
					strObject += '<param name="' + (g_isIePlugin ? "url" : "src") + '" value="' + url + '"/>';
					break;
			}
			
			strObject += self.addParams(id, params);
			strObject += "</object>";
			strDivWidth = !isFixedWidth ? "" : "width: "+ width + "px;";
			
			/* this is used because IE makes all quicktimes movies added 
			   via the dom to have their position changed to relative 
			   to the view port instead of relative to their 
			   containing element */
			if (type == "quicktime" && g_isIePlugin) {
				insertObj.style.height = height + "px";
				insertObj.style.width = strDivWidth;
				insertObj.style.position = "relative";
				insertObj.innerHTML = strObject;
				return;
			}

			strObject = '<div id="' + insertObj.id + '-flash" class="flash-content" style="position: relative; height:' + height + 'px;' + strDivWidth + '">' + strObject + "</div>";
			objObject = strObject.toDom();

			addClass(insertObj,"non-flash-content");
			insertObj.parentNode.insertBefore(objObject,insertObj);
			self.getMediaObject(id);
		},
		addParams: function(id, params) {
			function sObjectToJSON() {
				var s_account = window.s_account;
				var s = window.s;
				if (!s_account || !s) { return ""; }
				var strJSON = '{"account": "' + s_account + '"', type, strTmp;
				var afProps = s.__addedProps;
				for (var i in afProps) {    
					type = String(typeof(afProps[i]) ).toLowerCase();
					switch(type) {
						case "function": 
							break;
						case "object": 
							//one or more of the objects is causing a recursion error, 
							//so right now, we just skip them
							continue;
							break;
						default: 
							strTmp = afProps[i]+"";
							if (strTmp.match(/%\d/g) ) { strTmp = unescape(strTmp); }
							strJSON += ', "' + i + '": "' + escape(strTmp) + '"';
							break;
					}
				}
				
				strJSON += "}";
				return escape(strJSON);
			}
			
			if (!params) {
				params = { "FlashVars": "containerId="+id };
			} else if (!params.FlashVars) { 
				params.FlashVars = "containerId="+id; 
			} else if (params.FlashVars.indexOf("containerId") === -1) {
				params.FlashVars += "&amp;containerId="+id;
			}
			
			params.FlashVars += "&amp;sObject=" + sObjectToJSON();
			
			var strParams = "";
			for (var key in params) {
				strParams += '<param name="' + key + '" value="' + params[key] + '" />';
			}
			
			return strParams;
		},
		getMediaObject: function(id) {
			if (!self.objEmbededMedia[id]) {
				self.objEmbedContainer[id] = document.getElementById(id + "-flash");
				self.objEmbededMedia[id] = self.objEmbedContainer[id].getElementsByTagName("object")[0];
			}
		},
		changeHeight: function(containerId,height) {
			self.objEmbedContainer[containerId].style.height = height + "px";
			self.objEmbededMedia[containerId].setAttribute("height", height);
		},
		changeWidth: function(containerId,width) {
			if (self.objEmbedContainer[containerId].style.width !== "") {
				self.objEmbedContainer[containerId].style.width = width + "px";
			}
			self.objEmbededMedia[containerId].setAttribute("width", width);
		},
		changeObjectId: function(containerId,instanceId) {
			self.objEmbededMedia[containerId].setAttribute("id", instanceId);
		}
	};
	return self;
}();

function reqFlashVerPluginInstalled() {
	return SwfDetection.reqVersionMet(9,0,124);
}





function getImgProperties(obj) {
	var hrefStr = obj.href;
	var dimensions = hrefStr.split("?")[1];

	//if (isPresent(dimensions)) {
		var width = dimensions.split("&")[0];
		var height= dimensions.split("&")[1];
		var popupProperties = width+","+height+",menubar=no,scrollbars=no,resizable=yes,location=no,toolbar=no";
		return popupRel(obj.href,["",popupProperties]);
	/*} else {
		return popupRel(obj.href,[""]);
	}*/
}


function showNav() {
	this.getElementsByTagName('ul').item(0).style.visibility='visible';
}


function hideNav() {
	this.getElementsByTagName('ul').item(0).style.visibility='hidden';
}




function validateSearch(fieldObj, submitObj) {
	var sLength = fieldObj.value.replace(/\W/g, "").length;
	var Limit   = 255;
	var errmsg  = "";

	if (sLength == 0 || sLength > Limit){
		if (sLength == 0) {
			errmsg = "Please enter text to search before clicking \"" + submitObj.value + "\".";
			fieldObj.value = "";
		}
		if (sLength > Limit){
			errmsg = "There is a " + Limit + " character limit in the search query.";
			var s = fieldObj.value.substr(0,Limit);
			fieldObj.value = s;
	//		fieldObj.focus();		//???? GPB
		}
		alert(errmsg);
		fieldObj.focus();
		return false;
	}
	return true;
}


function popup(href, name, specs) {
	// if the specs are not passed, assign the default parameters
	if (typeof specs != "string") specs = "";  // empty implies 'yes' to all
	var windowObj = window.open(href, name.replace(/-/g, ""), specs);
	windowObj.focus();

	if(window.event){
		event.returnValue = false;
	}
	return false;
}


function sendToOpener(href) {
	if (window.opener.closed) return true;
	window.opener.location = href;
	window.opener.focus();
	//self.close();

	if(window.event){
		event.returnValue = false;
	}
	return false;
}


function backButton() {
	var historyObj = window.history;
	if (historyObj.length > 1) document.write('<form id="formBackButton"><fieldset><input type="button" onclick="history.back()" value="Back" class="button" /></fieldset></form>');
}



/********************************************************************
 * Dom manipulation utilities
 ********************************************************************/
function appendChild(parentObj, addObj) {
	if (addObj.id != "tmp-div") {
		parentObj.appendChild(addObj);
	}
	else {
		duff(addObj.childNodes, function(node) {
			parentObj.appendChild(node.cloneNode(true));
		});
	}
}

function replaceChild(parentObj, newObj, replaceObj) {
	if (newObj.id != "tmp-div") {
		parentObj.replaceChild(newObj, replaceObj);
	}
	else {
		insertBefore(parentObj, newObj, replaceObj);
		parentObj.removeChild(replaceObj);
	}
}

function insertBefore(parentObj, newObj, beforeObj) {
	if (newObj.id != "tmp-div") {
		parentObj.insertBefore(newObj, beforeObj);
	}
	else {
		duff(newObj.childNodes, function(node) {
			parentObj.insertBefore(node.cloneNode(true), beforeObj);
		});
	}
}


/********************************************************************
 * Event handler utilities
 ********************************************************************/
// the following event handling code created by Dean Edwards and Tino Zijdel
// with modifications to ensure handler execution order

// http://dean.edwards.name/weblog/2005/10/add-event/

function fixEvent(event) {
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
}

fixEvent.preventDefault = function() {
	this.returnValue = false;
};

fixEvent.stopPropagation = function() {
	this.cancelBubble = true;
};

function handleEvent(event) {
	var returnValue = true;
	event = isPresent(event) ? event : isPresent(document.getElementById) ? fixEvent(window.event) : window.event;
	var handlers = this.events[event.type];
	var order = handlers.order;
	for (var i = 0; i < order.length; i++) {
		this.$$handleEvent = handlers[ order[i] ];
		if (this.$$handleEvent(event) === false) {
			returnValue = false;
		}
	}
	return returnValue;
}

function addEvent(element, type, handler) {
	if (!handler.$$guid) { handler.$$guid = addEvent.guid++; }
	if ( !isPresent(element.events) ) { element.events = {}; }
	var handlers = element.events[type];
	if (!handlers) {
		handlers = element.events[type] = {};
		handlers.order = [];
		if (element["on" + type] && (element != document || type != "readystatechange") ) {
			handlers[0] = element["on" + type];
			handlers.order[0] = 0;
		}
	}
	handlers[handler.$$guid] = handler;
	handlers.order[handlers.order.length] = handler.$$guid;
	if (element != document || type != "readystatechange") {
		element["on" + type] = handleEvent;
	}
}
addEvent.guid = 1;

function removeEvent(element, type, handler) {
	if (element.events && element.events[type]) {
		var handlers = element.events[type];
		var id = handler.$$guid;
		if (delete handlers[handler.$$guid]) {
			for (var i = 0; i < handlers.order.length; i++) {
				if (handlers.order[i] == handler.$$guid) {
					var newOrder = handlers.order.slice(0, i);
					if (i + 1 != handlers.order.length) {
						newOrder = newOrder.concat( handlers.order.slice(i + 1) );
					}
					handlers.order = newOrder;
				}
			}
		}
	}
}

function endOfPageDivExists() {
	var endDiv = document.getElementById("end-of-page-check");
	return (typeof endDiv != "undefined");
}

window.intervalId = 0;

function handleReadyStateChange() {
	if (window.intervalId !== 0) {
		if ( endOfPageDivExists() ) {
			clearInterval(window.intervalId);
			window.intervalId = 0;
		}
		else {
			return;
		}
	}
	var event = {};
	var dummyHandlers = {};
	event.readyState = "complete";
	event.srcElement = document;
	event.target = document;
	event.currentTarget = document;
	event.type = "readystatechange";
	if ( !isPresent(document.events) ) {
		document.Events = {};
		var dummyEvents = {};
		dummyEvents.readystatechange = dummyHandlers;
		document.events = dummyEvents;
	}
	if ( !isPresent(document.events.readystatechange) ) {
		dummyHandlers.order = [];
		document.events.readystatechange = dummyHandlers;
	}
	document.$$handleEvent = handleEvent;
	document.$$handleEvent(event);
}

function isModifiedClick(e) {
	var intButton = e.which ? e.which - 1 : e.button;
	return ( intButton !== 0 || e.ctrlKey || e.shiftKey);
}

function getTargetObj(e, targetTag, withAttr) {
	if (!e) { e = window.event; }
	var isBody = (targetTag == "body");
	var targetObj =  isBody ? document.body : e.target ? e.target : e.srcElement ? e.srcElement : null;
	if (!targetObj) { return null; }
	if (!isBody && targetObj.nodeType == 3) { targetObj = targetObj.parentNode; } //defeat khtml bug
	if (getTagName(targetObj.tagName) != targetTag || !hasAttribute(targetObj,withAttr)) {
		targetObj = getAncestor(targetObj, targetTag, withAttr); 
	}
	return targetObj;
}


/********************************************************************
 * General utilities to speed iterations and general event handling functions.
 ********************************************************************/
function isPresent(param) {
	return typeof param !== "undefined" && param !== null;
}

// "duff" functions to unroll loops for faster performance
// default version loops forward
function duff(objectArray, method) {
	var arrayLength = objectArray.length;
	var loopLength = arrayLength % 8;
	var index = 0;
	while (loopLength--) {
		method(objectArray[index++]);
	}
//	loopLength = parseInt(arrayLength / 8);
	loopLength = parseInt(arrayLength / 8, 10);
	while (loopLength--) {
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
		method(objectArray[index++]);
	}
}

// reverse variation loops backward
function duffReverse(objectArray, method) {
	var arrayLength = objectArray.length;
	var loopLength = arrayLength % 8;
	var index = arrayLength - 1;
	while (loopLength--) {
		method(objectArray[index--]);
	}
//	loopLength = parseInt(arrayLength / 8);
	loopLength = parseInt(arrayLength / 8, 10);
	while (loopLength--) {
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
		method(objectArray[index--]);
	}
}

function isNumeric(e, legalChar) {
	if (!e) { e = window.event; }
	if (isControlCharacter(e)) {
		return true;
	}
	var keyCode = isAValue(e) ? (isAValue(e.which) ? e.which : e.keyCode) : window.event.keyCode;
	var pattern;
	if (legalChar) {
		pattern = new RegExp("[\\d\\r\\b\\t\\x00\\x2e\\x25\\x26\\x27\\x28\\x60\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69" + legalChar + "]");
	}
	else {
		pattern = /[\d\r\b\t\x00\-\x00\x2e\x25\x26\x27\x28\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69]/;
	}
	return pattern.test(String.fromCharCode(keyCode));
}

function isAValue(param) {
	return isPresent(param);
}

function isControlCharacter(e) {
	if (isAValue(e) && isAValue(e.modifiers)) {
		return e.modifiers ^ 2 == 2;
	}
	else {
		return isAValue(e) ? e.ctrlKey : window.event.ctrlKey;
	}
}

function isValueInArray(value, array) {
	var i = array.length;
	while (i--) {
		if (value == array[i]) {
			return true;
		}
	}
	return false;
}

function isValidEmail(strEmail) {
	return strEmail.length >= 6 && g_emailFormat.test(trim(strEmail) );
}

function createClosure(obj,func) {
	return function(e) {
		e = e || window.event;
		obj.f = func;
		obj.f(e);
	};
}


/********************************************************************
 * String utilities
 ********************************************************************/
// trim whitespace from left and right of string
function trim(str) {
	return str === null ? null : str.replace(/^\s*|\s*$/g,"");
}

// trim whitespace from left of string
function ltrim(str) {
	return str === null ? null : str.replace(/^\s*/g,"");
}

// trim whitespace from right of string
function rtrim(str) {
	return str === null ? null : str.replace(/\s*$/g,"");
}

function addComma(nStr){
	nStr += "";
	var dpos = nStr.indexOf(".");
	var nStrEnd = "";
	var rgx = /(\d+)(\d{3})/;
	if (dpos != -1) {
		nStrEnd = "." + nStr.substring(dpos + 1, nStr.length);
		nStr = nStr.substring(0, dpos);
	}
	while (rgx.test(nStr)) {
		nStr = nStr.replace(rgx, "$1" + "," + "$2");
	}
	return nStr + nStrEnd;
}

function applyCommas() {
	this.value = this.value.replace(/,/g, "");
	this.value = addComma(this.value);
}

//pass url w/query and query param you want the value from
function getQueryParamValue(strLocation, strParam) {
	strLocation = strLocation.split("#")[0];
	var arrQuery = strLocation.split("?");
	if (arrQuery.length < 2) {
		return false;
	}
	var arrQuery = arrQuery[1].split("&");
	var i = arrQuery.length;
	while (i--) {
		var arrParam = arrQuery[i].split("=");
		if (arrParam[0] == strParam) {
			return trim(arrParam[1]);
		}
	}
	return false;
}

function setQueryParamValue(strLocation, objParams, escapeAmps) {
	var arrTmp = strLocation.split("#");
	var strHash = arrTmp.length > 1 ? "#" + arrTmp[1] : "";
	var strNewParamValue, strCurrValue, strCurrParamValue, arrQuery, strUrl;
	strLocation = arrTmp[0];
	
	for (var strParam in objParams) {
		strValue = escape(objParams[strParam]);
		strNewParamValue  = strParam + "=" + strValue;
		strCurrValue = getQueryParamValue(strLocation, strParam);
		arrQuery = strLocation.split("?");
		
		if (arrQuery.length > 1 && trim(arrQuery[1]).length !== 0) {
			arrQuery[1] = trim(arrQuery[1]);
			if (strCurrValue.length > 0 || strLocation.indexOf(strParam + "=") != -1) {
				strUrl = arrQuery[0] + "?" + arrQuery[1].replace(strParam + "=" + strCurrValue, strNewParamValue) + strHash;
			} else {
				strUrl = arrQuery[0] + "?" + arrQuery[1] + "&" + strNewParamValue + strHash;
			}
		} else {
			strUrl = arrQuery[0] + "?" + strNewParamValue + strHash;
		}
		strLocation = strUrl;
	}
	return  escapeAmps ? strUrl.replace("&", "&amp;") : strUrl;
}


/********************************************************************
 * DOM Utilities
 ********************************************************************/

var XSLT = function() {
	var self = {
		needsFix: null,
		hasProcessor: function() {
			var regex = /(function|object)/;
			return (regex.test(typeof XSLTProcessor) && regex.test(typeof (new XSLTProcessor()).importStylesheet) );
		},
		convToFragment: function(str) {
			if (!XSLT.hasProcessor() ) { return null; }
			var strXML = "<?xml version=\"1.0\"?><root>" + str + "</root>";
			var strXSL = '<?xml version="1.0" encoding="utf-8"?>' +
				'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">' +
				'<xsl:output method="html" encoding="utf-8"/>' +
				'<xsl:template match="root">' +
				'<xsl:copy-of select="node()"/>' +
				'</xsl:template>' +
				'</xsl:stylesheet>';
			var xslProc = new XSLTProcessor();
			var xmlDoc = (new DOMParser() ).parseFromString(strXML, "text/xml");
			var xslDoc = (new DOMParser() ).parseFromString(strXSL, "text/xml");
			xslProc.importStylesheet(xslDoc);
			return xslProc.transformToFragment(xmlDoc, document);
		},
		getFix: function() {
			if (!XSLT.hasProcessor() ) { return false; }
			if (self.needsFix === null) {
				var htmlObj = self.convToFragment("<strong>testing</strong>");
				self.needsFix = (htmlObj.firstChild.nodeType === TEXT_NODE);
			}
			return self.needsFix;
		}
	};
	return self;
}();

// Firefox XSLT work around https://bugzilla.mozilla.org/show_bug.cgi?id=355068
if (XSLT.getFix() ) {
	XSLTProcessor._styleSheetFix = null;
	XSLTProcessor.prototype._importStylesheet = XSLTProcessor.prototype.importStylesheet;
	XSLTProcessor.prototype.importStylesheet = function(oStylesheet) {
		// preload empty stylesheet document "factory"
		if (!this.constructor._styleSheetFix) {
			var oXMLHttpRequest = new XMLHttpRequest();
			oXMLHttpRequest.open('GET', '/style/XSLTProcessorFix.xsl', false);
			oXMLHttpRequest.send(null);
			while (oXMLHttpRequest.readyState !== 4) {}
			var xmlDoc = oXMLHttpRequest.responseXML;
			if (!xmlDoc) {
				this.constructor._styleSheetFix = oStylesheet;
				return this._importStylesheet(oStylesheet);
			}
			this.constructor._styleSheetFix = xmlDoc;
		}
		// replace documentElement in "factory" document with new stylesheet
		this.constructor._styleSheetFix.replaceChild(oStylesheet.documentElement.cloneNode(true), this.constructor._styleSheetFix.documentElement);
		// import stylesheet to processor
		return this._importStylesheet(this.constructor._styleSheetFix);
	};
}

String.prototype.toDom = function() {
	var tmpObj, htmlObj = XSLT.convToFragment(this);
	if (!htmlObj) {
		htmlObj = document.createDocumentFragment();
		tmpObj = document.createElement("div");
		tmpObj.innerHTML = this;
		objChildren = tmpObj.childNodes;
		duffReverse(objChildren, function(child) {
			var firstChild = htmlObj.firstChild;
			if (firstChild) { 
				htmlObj.insertBefore(child, firstChild); 
			} else {
				htmlObj.appendChild(child);
			}
			firstChild = null;
			child = null;
		});
	}

	tmpObj = null;
	return htmlObj;
};

String.prototype.stripHtml = function() {
	return this.replace(/<\/?[^>]+\/?>/gi," ").replace(/\s+/gi," ").replace(/([\w\)]\/)\s((&#8203;)?\s)?/gi,"$1$3");
};

function getTagName(str) {
	if (!isAValue(str) ) { return ""; }
	var tmpArr = str.split(":");
	return trim((tmpArr.length > 1 ? tmpArr[1] : str).toLowerCase() );
}

function hasAttribute(objT,withAttr) {
	if (!isPresent(withAttr) ) { return true; }
	var attrConverter = {"class":"className", "className":"className", "for":"htmlFor", "htmlFor":"htmlFor"};
	var blnTmp = true;
	
	for (var attr in withAttr) {
		var realValue = attrConverter[attr] ? objT[attrConverter[attr] ] : objT.getAttribute(attr);
		if (!isPresent(realValue) || realValue === "") {
			return false;
		}
		
		var testValues = withAttr[attr];
		if (!isPresent(testValues) || !testValues.length) {
			continue;
		}
		
		realValue = trim(realValue.replace(",", " ") ).split(" ");
		duff(testValues, function(testValue) {
			if (!blnTmp) { return; }
			blnTmp = isValueInArray(testValue, realValue);
		});
	}
	
	return  blnTmp;
}

// function used to get a specified Ancester. requires an obj and tagName of the targetTag you wish to stop at.
// example getAncestor(document.getElementById('foo'),"div")
function getAncestor(objT, targetTag, withAttr) {
	var isBody = (targetTag == "body");
	if (isBody) { 
		objT = document.body; 
	}
	else { 
		objT = objT.parentNode;
		while (objT && getTagName(objT.tagName) != targetTag) {
			if (isValueInArray(getTagName(objT.tagName), ["body", "html"]) ) {
				return null;
			}
			objT = objT.parentNode;
		}
	}
	
	if (objT && !hasAttribute(objT, withAttr)) {
		if (isValueInArray(getTagName(objT.tagName), ["body", "html"]) ) {
			return null;
		}
		objT = getAncestor(objT, targetTag, withAttr);
	} 
	
	return objT;
}

// function used to get specified parent. requires obj and tagname of parent you wish to stop at
// example getParent(document.getElementById("foo"),"div")
// should be replaced with getAncestor()
function getParent(objT, stopAt) {
	return getAncestor(objT, stopAt);
}

function getPreviousElement(obj) {
	var previousNode = obj.previousSibling;
	while (previousNode && previousNode.nodeType !== ELEMENT_NODE) {
		previousNode = previousNode.previousSibling;
	}
	
	obj = null;
	return previousNode;
}

function getComputedStyleFix(obj,strProperty) {
	var strComputedStyle;
	if (window.getComputedStyle) {
		return window.getComputedStyle(obj, null).getPropertyValue(strProperty);
	} else {
		switch(strProperty) {
			case "top" : return obj.offsetTop;
			case "right" : return obj.parentNode.offsetWidth - (obj.offsetWidth + obj.offsetLeft);
			case "bottom" : return obj.parentNode.offsetHeight - (obj.offsetHeight + obj.offsetTop);
			case "left" : return obj.offsetLeft;
			default :
				return obj.currentStyle[strProperty];
		}
	}
}

function convToInt(strCurrentStyle) {
	if (!isPresent(strCurrentStyle) ) { return 0; }
	strCurrentStyle += "";
	if (strCurrentStyle.indexOf("em") != -1) {
		return strCurrentStyle.replace(/em/,"") * g_fontSize;
	} else {
		return strCurrentStyle.replace(/px/,"") * 1;
	}
}

function wrapObjects(parent, strElement, objAttributes) {
	var objElement = document.createElement(strElement);
	var i, attr;
	var attrConverter = {"class":"className", "className":"className", "for":"htmlFor", "htmlFor":"htmlFor"};
	for (i in objAttributes) {
		attr = attrConverter[i];
		if (isValueInArray(attr, ["className","htmlFor"]) ) {
			objElement[attr] = objAttributes[i];
		} else {
			objElement.setAttribute(attr, objAttributes[i]);
		}
	}

	duffReverse(parent.childNodes, function(child) {
		if (objElement.childNodes.length === 0) {
			objElement.appendChild(child);
		} else {
			objElement.insertBefore(child,objElement.firstChild);
		}
		child = null;
	});

	parent.appendChild(objElement);
	return objElement;
}


/********************************************************************
 * Class utilities
 ********************************************************************/
function hasClass(obj, className) {
	var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
	return regexp.test(obj.className);
}

function addClass(obj, className) { // Replaces setClass()????
	if (!hasClass(obj, className)) {
		if (obj.className) {
			obj.className += " " + className;
		}
		else {
			obj.className = className;
		}
	}
}

function removeClass(obj, className) {
	var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
	obj.className = obj.className.replace(regexp, "$2");
}

function toggleClass(obj, className) {
	if (hasClass(obj, className)) {
		removeClass(obj, className);
	}
	else {
		addClass(obj, className);
	}
}

function setClass(objId,newClass) { // a generic CSS class switcher. helps IE<7 mimic div:hover,td:hover, etc. (used on AAM)
	var obj = document.getElementById(objId);
	obj.className = newClass;
}


/********************************************************************
 * Cookie utilities -- Get, set, delete, and parse cookies
 ********************************************************************/

 // Create client-side Cookie object
function Cookie(cookieName) {
	this.name = escape(cookieName);
}
function getCookie(name) {
	return (new Cookie(name) ).get();
}

//this gets replaced how?
function setCookie(name, value, days) {
	var e = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		e = ";expires="+date.toGMTString();
	}
	var host = self.location.hostname;
	host = host.substring(host.indexOf("."), host.length);
	document.cookie = name + "=" + escape(value) + e + ";domain=" + host + ";path=/;";
}

// returns the value of the cookie represented by this object, or null if the cookie is not valid
Cookie.prototype = {
	get: function() {
		if (!isPresent(document.cookie) ) {
			return null;
		}
		var valueRegExp = new RegExp(this.name + "=([^;]*)");
		var value = valueRegExp.exec(document.cookie);
		if (value && value[1]) {
			value = unescape(value[1]);
			return value == "__invalid__" ? null : value;
		}
		return null;
	},
	// sets the cookie represented by this object. If seconds not provided, makes a session cookie.
	set: function(value, seconds) {
		var cookieText = this.name + "=" + escape(value) + (isPresent(window.DOMAIN) && DOMAIN.length ? "; domain=" + DOMAIN : "") + "; path=/";
		if (isPresent(seconds) ) {
			var expiry = new Date();
			expiry.setTime(expiry.getTime() + (seconds * 1000) );
			expiry = expiry.toUTCString().split(" ");
			expiry[1] = ("00" + expiry[1]).substring(expiry[1].length);
			expiry = "; expires=" + expiry.join(" ").replace(/([a-zA-Z]{3}, \d{2}) ([a-zA-Z]{3}) /, "$1-$2-").replace(/UTC/, "GMT");
			cookieText += expiry;
		}
		document.cookie = cookieText;
	},
	// sets a session cookie for the cookie represented by this object
	setInSession: function(value) {
		this.set(value);
	},
 // removes the cookie represented by this object, returning the last value present for the cookie
	remove: function() {
	var value = this.get();
	this.set("__invalid__", -(365 * 24 * 60 * 60) );
	return value;
	},
	parseValue: function(delimiter, object) {
		var cookieValue = this.get();
		if (cookieValue === null) { return false; }
	
		var values = cookieValue.split(delimiter);
		var name, value, index;
		for (var i = 0; i < values.length; i++) {
			index = values[i].indexOf("=");
			if (index != -1) {
				name = trim(values[i].substring(0, index));
				if (name.length > 0) {
					if (index < values[i].length-1) {
						value = trim(values[i].substr(index+1));
						if (value == "null") { value = ""; }
					}
					else {
						value = "";
					}
					value = value.replace(/"/g, '\\"');
					object[name] = value;
				}
			}
		}
		return true;
	}
};













































/******************************************************************************
  old here
*******************************************************************************/

function initGlobal(){
//		alert('test!');
	//	if (document.all) ieNavFix(); // IE only drop-down nav hover fix
//		externalLinks();
//	relEvents.init();
//	fieldFocus();
//	if(document.getElementsByTagName('body')[0].id=='comments') document.forms.contactform.name.focus();
//	loadStyles();
}
//addEvent(document, "readystatechange", initGlobal);


var timer;
var px = 0;
function scrollUp() {
//alert('scrolling');
	px += 10;
	clearTimeout(timer);
	contentDiv = document.getElementById('content');
//alert(contentDiv);
	if (contentDiv.scrollTop > 0) {
		contentDiv.scrollTop -= px;
		timer = setTimeout('scrollUp()', 50);
	} else {
		clearTimeout(timer);
		px = 0;
	}
	return false; // kill the actual href (#top)
}

function promptInsert(targetBtn) {
//alert(targetBtn.substring(0, targetBtn.indexOf('/')));
//alert(targetBtn.id);
//	var sayBtn = document.getElementById('sayBtn').id;
	var comField = document.getElementById('textprompt');
	switch (targetBtn.id) {
		case 'sayBtn':
			comField.value = 'say ' + comField.value;
			break;
		case 'emoteBtn':
			comField.value = 'emote ' + comField.value;
			break;
		case 'shoutBtn':
			comField.value = 'shout ' + comField.value;
			break;
		case 'correctBtn':
			comField.value = '*' + comField.value;
			break;
		case 'bkspcBtn':
			comField.value = comField.value.substring(0,comField.value.length-1);
			break;
		case 'delBtn':
			comField.value = '';
			break;
		case 'enterBtn':
			document.getElementById('inputprompt').submit();
			break;
	}
	return false; // kill the actual href
}

function emoteInsert(targetBtn) {
	var comField = document.getElementById('textprompt');
	switch (targetBtn.id) {
		case 'angelEmote':
			comField.value += 'o:)';
			break;
		case 'angryEmote':
			comField.value += '>:(';
			break;
		case 'clockEmote':
			comField.value += '(O)';
			break;
		case 'cryEmote':
			comField.value += ';(';
			break;
		case 'devilEmote':
			comField.value += '(6)';
			break;
		case 'embarassedEmote':
			comField.value += ':o';
			break;
		case 'grinEmote':
			comField.value += ':D';
			break;
		case 'hmmmEmote':
			comField.value += ':mm';
			break;
		case 'laughEmote':
			comField.value += ':-D';
			break;
		case 'omgEmote':
			comField.value += ':omg';
			break;
		case 'pantsEmote':
			comField.value += ':Y';
			break;
		case 'sadEmote':
			comField.value += ':(';
			break;
		case 'smileEmote':
			comField.value += ':)';
			break;
		case 'teethEmote':
			comField.value += ':E';
			break;
		case 'tongueEmote':
			comField.value += ':p';
			break;
		case 'winkEmote':
			comField.value += ';)';
			break;
	}
	return false; // kill the actual href
}


var timer;
var px = 0;
var scrollObj2 = new String();
var direction = "";
var scrollTemp = "";
function scrollThis(scrollObject,direction) {
//alert('scrollObject: '+scrollObject);
//alert('direction: '+direction);
	clearTimeout(timer);
	scrollObj2 = (scrollObject != "" && scrollObject != "undefined" && scrollObject != "null") ? scrollObject : "content"; // this is the default ID in case none has been passed in.
//alert('scrollObj2: '+scrollObj2);
//alert('scrollObj2: '+scrollObj2[0]);
	objectDiv = (document.getElementById(scrollObject) != "" && document.getElementById(scrollObject) != "undefined" && document.getElementById(scrollObject) != "null") ? document.getElementById(scrollObject) : document.getElementById(scrollObj2[0]);
//alert(document.getElementById('command'));
//alert('objectDiv: '+objectDiv);
	if (!direction) direction = (scrollObj2[1]) ? scrollObj2[1] : "up"; // default "up" if none passed in
//alert('direction: '+direction);
	if (direction == "down") {
//alert ('down');
		px += 10;
		if (objectDiv.scrollTop < (objectDiv.scrollHeight * .6) && objectDiv.scrollTop != scrollTemp) { //what the heck??
			scrollTemp = objectDiv.scrollTop;
//alert('scrollTop: '+objectDiv.scrollTop+' | scrollHeight: '+objectDiv.scrollHeight);
			objectDiv.scrollTop += px * 10; //? what the heck??
			scrollObject = scrollObj2;
//alert('so: '+scrollObject);
			timer = setTimeout('scrollThis(null,scrollObj2)', 50);
		} else {
			clearTimeout(timer);
			px = 0;
		}
	} else { // up!
//alert('up!');
		px += 10;
		if (objectDiv.scrollTop > 0) {
//alert('scrollTop: '+objectDiv.scrollTop+' | scrollHeight: '+objectDiv.scrollHeight);
			objectDiv.scrollTop -= px;
			scrollObject = scrollObj2;
//alert('so: '+scrollObject);
			timer = setTimeout('scrollThis(null,scrollObj2)', 50);
		} else {
			clearTimeout(timer);
			px = 0;
		}
	}
	return false; // kill the actual href (#top or other)
}

function fieldFocus() {//must work for idx and ab
//	alert('doc.forms.len = ' + document.forms.length);
	if (document.forms.length > 1) {
		document.forms[0].elements[1].focus(); // if multiple forms on page, focus on the real first (now with source ordering!)
	} else {
		if (document.forms[0].elements.length > 1) {
			document.forms[0].elements[1].focus(); // else default focus to Search input
		} else {
			document.forms[0].elements[0].focus(); // just in case backup (areabeyond)
		}
		//else document.forms.searchForm.query1.focus();
	}
}

function selectFocus( field ) {
	getElementById( field ).focus();
	if( getElementById( field ).value.length > 0 ) {
		getElementById( field ).select();
	}
}

//	Mozilla does not properly readjust absolutely positioned elements with
//	relative units unless the style of those elements are tweaked somehow.
//	We simply flick the display style from block to none and back to wake up Moz.
function resetNav() {
	var obj = document.getElementById("nav-main");
	obj.style.display = "none";
	obj.style.display = "block";
	obj = document.getElementById("search-input");
	obj.style.display = "none";
	obj.style.display = "block";
}

//	This is called when the user clicks "Change contrast" to alternate between
//	"Color" and "Contrast".
function changeContrast() {
	cssVal = cssVal == "Color" ? "Contrast" : "Color";
	setStyle(cssVal);
}

//	This sets the page's alternate stylesheet choice and font size choice based
//	upon defaults or the user's cookies. It is called as the first item in the
//	document body, so that document.body is defined and the font/style switching
//	does not cause any presentation jumping.
function loadStyles() {
	fontSize = getCookie("size");
	if (isValid(fontSize)) {
		fontSize = parseInt(fontSize, 10);
	} else {
		fontSize = 100;
	}
	setSize();
	cssVal = getCookie("cssc");
	if (!isValid(cssVal)) {
		cssVal = "Color";
	}
	setStyle(cssVal);
}

//	Sets the body font size, based upon the value in fontSize
function setSize() {
	document.body.style.fontSize = fontSize + "%";
	setCookie("size", fontSize, 365);
	//alert(fontSize);
}

//	This is called to increase the font size in increments of 10, up to 201.
function fontUp() {
	fontSize += 20;
	if (fontSize > 201) fontSize = 201;
	else {
		setSize();
		//	The following ensures that Moz properly resets its absolutely positioned elements.
		resetNav();
	}
}

//	This is called to decrease the font size in increments of 10, down to 51.
function fontDown() {
	fontSize -= 10;
	if (fontSize < 51) fontSize = 51;
	else {
		setSize();
		//	The following ensures that Moz properly resets its absolutely
		//	positioned elements.
		resetNav();
	}
}

//	This resets the font size to default (100% not 81% any more).
function fontReset() {
	fontSize = 100;
	setSize();
	resetNav();
}

//	This writes the style switches for contrast and font size. This is written
//	via JavaScript because these features are only available in JS-enabled
//	browsers.
function addStyleSwitches() {
	var text = "</li><li><a href=\"javascript:void(changeContrast())\" title=\"Change color scheme between colored and black/white\">Change contrast</a></li>";
	var ua = navigator.userAgent.toLowerCase();
	text += "<li>Change size: <span class=\"nowrap\"><a class=\"box\" href=\"javascript:fontDown()\" title=\"Decrease font size\">&#8211;</a>|<a class=\"box\" href=\"javascript:fontReset()\" title=\"Reset font size to default\">=</a>|<a class=\"box\" href=\"javascript:fontUp()\" title=\"Increase font size\">+</a></span>";
	document.write(text);
}

function viewer() { //to launch Webcam window
	ViewerWin=window.open("../main/webcam/viewer.html","","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=auto,copyhistory=0,width=324,height=286")
	// large width=644,height=520
	ViewerWin.creator=self
}

function searchFieldHasValue(theField)
{
	var theValue = theField.value.replace(/\W/g, "");
	if (theValue.length == 0)
	{
		alert("Please enter text to search before clicking \"Search\".");
		theField.select();
		theField.focus();
		return false;
	}
	else
		return true;
}

var relArticles = new Object();

function redirectToParent(href)
{
	if (top.opener && !top.opener.top.closed)
	{
		top.opener.top.location.href = href;
		top.opener.top.focus();
	}
	else
		top.location.href = href;
}

function goTo(url, winName, features)
{
	var tempVar = null;
	var feats = features ? features : null;
	url = url.replace(/%(25)?__/g, "%");
	if (feats == null)
		tempVar = window.open(url, winName ? winName : "_top");
	else
		tempVar = window.open(url, winName ? winName : "_top", feats);
	tempVar.focus();
}

//externalLinks to replace deprecated target attribute with rel attribute 5/2/03 GPB
//replacing this with event delegation 6/6/2007 GPB
//relEvents? GPB 1/24/2008
function externalLinks() {
	//alert("running");
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && 
			anchor.getAttribute("rel") == "external") 
	//		alert("External link: " + anchor);
			anchor.target = "_blank";
	}
}
//moved to top - window.onload = externalLinks;


// photo view
	var showing = false;
	function toggleInfo() {
			if (showing == false) {
				if (document.all || document.getElementById) document.getElementById('imageinfo').style.visibility="visible";	// IE & Gecko
				else document.layers['imageinfo'].visibility="show"; // Netscape 4
				showing = true;
			}
			else {
				if (document.all || document.getElementById) document.getElementById('imageinfo').style.visibility="hidden";	// IE & Gecko
				else document.layers['imageinfo'].visibility="hide";	// Netscape 4
				showing = false;
		}
	}



//	Sets the visibility for the UL associated with the tab identified by id.
//	Causes the drop-down to appear/disappear as appropriate.
function tabSet(event, tab, state) {
	if (isValid(event) && isValid(event.currentTarget)) {
		tab = event.currentTarget;
	}
	if (isValid(tab)) {
		tab.getElementsByTagName("ul").item(0).style.visibility = state;
	}
}



function isDefined(param) {
	return typeof param != "undefined";
}

function isValid(param) {
	return isDefined(param) && param != null;
}

function isPopulated(param) {
	return isValid(param) && isValid(param.length) && param.length > 0;
}



//	The following value stores if the browser defines addEventListener
var hasEventRegistrar;
if (isDefined(document.implementation) && isDefined(document.implementation.hasFeature)) {
	hasEventRegistrar = document.implementation.hasFeature("Events", "2.0");
}
else
	hasEventRegistrar = false;

//	A single function for adding events in IE and DOM models
function addEventListenerCompat(eventTarget, eventName, eventListener, useCapture) {
	if (hasEventRegistrar)
		eventTarget.addEventListener(eventName, eventListener, useCapture);
	else
		eventTarget["on" + eventName.toLowerCase()] = eventListener.handleEvent;
}

function setProperty(styleObj, property, value, importance) {
	if (hasSetProperty)
		styleObj.setProperty(property, value, importance);
	else
		styleObj[property.replace(/-(.)/gi, function(str, p1) { return p1.toUpperCase(); })] = value;
}


//	Values for saved styles/font sizes
var cssc = new Array("Color", "Contrast");
var cssVal;
var fontSize;

//	Enables the stylesheet whose title matches cssVal, while disabling others
//	that have titles.
function setStyle(name) {
	var links = document.getElementsByTagName("link");
	for (var i = 0; i < links.length; i++) {
		var linkObj = links[i];
		var rel = linkObj.getAttribute("rel");
		var title = linkObj.getAttribute("title");
		if (isDefined(rel) && rel.indexOf("style") >= 0 && title) {
			linkObj.disabled = true;
			if (title == name) linkObj.disabled = false;
		}
	}
	//	Saves the current stylesheet in a cookie.
	setCookie("cssc", name, 365);
}
































/********************************************************************
 * Init Globals
 ********************************************************************/
function initGlobalObjs() {
	g_objBody = document.getElementsByTagName("body")[0];
	g_objRuler = document.getElementById("ruler");
	g_fontSize = g_objRuler.offsetHeight;

	var objGlobal = document.getElementById("global");
	if (!objGlobal) { return; }
	var objSearchForm = objGlobal.getElementsByTagName("form")[0];
	addEvent(objSearchForm,"submit",function(e) {
		e = e || window.event;
		var strValue = trim(this.elements.query.value);
		var blnNotEmpty = isAValue(strValue) && strValue !== "";
		if (!blnNotEmpty) {
			e.preventDefault();
		}
		return blnNotEmpty;
		
	});
}



function forceScrollBottom(divName) {
	var mydiv = document.getElementById(divName);
	if (mydiv) {
		//var debug = "ScrollTop: " + mydiv.scrollTop;
		for (i = 50; i < mydiv.scrollHeight; i += 50) {
			var tmp = mydiv.scrollTop; // pre-store scrollTop
			mydiv.scrollTop += i; // update scrollTop
			if (tmp == mydiv.scrollTop) {
				break;
			}
			//debug += i + "ScrollTop: " + mydiv.scrollTop + "\n";
		}
		//alert(debug);
	}
}

function statusOn(param) {
	window.status = param;
	alert('here');
	return true;
}
function statusOff() {
	window.status = '';
}

function htmlspecialchars (string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Nathan
    // +   bugfixed by: Arno
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
    // *     returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'
 
    var histogram = {}, symbol = '', tmp_str = '', i = 0;
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}


function reqFlashVerPluginInstalled() {
	return SwfDetection.reqVersionMet(9,0,124);
}







// Event setup
addEvent(document, "click", MapLinks.handler);

