function Browser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4);
	this.ns4=(this.b=="ns" && this.v==4);
	//this.ns6=(this.b=="ns" && this.v==5);
	this.ie=(this.b=="ie" && this.v>=4);
	this.ie4=(this.version.indexOf('MSIE 4')>0);
	this.ie5=(this.version.indexOf('MSIE 5')>0);
	this.ie55=(this.version.indexOf('MSIE 5.5')>0);
	this.ie6up = ((navigator.appVersion.indexOf("MSIE 6")!=-1)||(navigator.appVersion.indexOf("MSIE 7")!=-1));
	this.opera=(this.b=="opera");
	var ua=navigator.userAgent.toLowerCase();
	this.mac = (ua.indexOf("mac")!=-1);
	this.win = (ua.indexOf("windows")!=-1);
}
var is = new Browser();
//-----Begin LyrObj-----------------
function LyrObj(divId) {   
	this.name="";
	this.x = 0;
	this.y = 0;
	this.width=0;
	this.height=0;
}
LyrObj.prototype.px = (is.v>=5)?"px":"";
LyrObj.prototype.hideSyntax = (is.ns4)? "hide":"hidden";
LyrObj.prototype.showSyntax = "visible";
LyrObj.prototype.init = function(divId) {  
	this.name = divId;
	if (is.ns4) this.ob = eval("document." +divId);
	else if (is.ie4) this.ob = document.all(divId);
	else this.ob = document.getElementById(divId);
	// position should always be pushed to the dom for these objects, but width and height can be pulled from the dom safely
	this.width	=	this.getWidth();
	this.height	=	this.getHeight();

}
// these 2 functions will attempt to pull the positions of the object from an embedded location within a page. It will check the offsets with each parent and then check the parents offsets with its parents and so on and so forth.  In a typical page there can be quite a lot of parents. note: td, tr and table are accounted for seperately.
LyrObj.prototype.getInlineLeft = function() {
	if (is.ns4) return this.ob.pageX;
	else if ((is.ie) || (is.opera)) {
		var elem = this.ob;
		var xPos = 0;
		var yPos = 0;
		while (elem.offsetParent != null) {
			xPos += elem.offsetLeft;
			elem = elem.offsetParent;
		}
		return xPos;
	}	
	else return (this.ob.offsetLeft + document.body.offsetLeft);
}
LyrObj.prototype.getInlineTop = function() {
	if (is.ns4) return this.ob.pageY;
	else if ((is.ie) || (is.opera)) {
		var elem = this.ob;
		var yPos=0;
		while (elem.offsetParent != null) {
			yPos += elem.offsetTop;
			elem = elem.offsetParent;
		}
		return yPos;
	}
	else return (this.ob.offsetTop+ document.body.offsetTop);
}
LyrObj.prototype.getWidth = function () {	
	
	if (is.ns4) return this.ob.clip.width;
	else if (is.opera) return this.ob.style.pixelWidth;
	else return this.ob.offsetWidth;
}
LyrObj.prototype.getHeight = function () {
	if (is.ns4) return this.ob.clip.height;
	else if (is.opera) return this.ob.style.pixelHeight;
	else return this.ob.offsetHeight;
}
LyrObj.prototype.hide = function() {
	if (is.ns4) this.ob.visibility = this.hideSyntax;
	else this.ob.style.visibility = this.hideSyntax;
}
LyrObj.prototype.show = function() {	
//	alert('showing');
	if (is.ns4) this.ob.visibility = this.showSyntax;
	else this.ob.style.visibility = this.showSyntax;
}
LyrObj.prototype.moveLayerTo = function(toX, toY) {
	this.x = toX;
	this.y = toY;
}
LyrObj.prototype.moveLayerBy = function(dX, dY) {
	this.x += dX;
	this.y += dY;
}
LyrObj.prototype.clipTo = function(x1,x2,y1,y2) {
	if (is.ns4){
		this.ob.clip.left   = x1;
		this.ob.clip.right  = x2;
		this.ob.clip.top	  = y1;
		this.ob.clip.bottom = y2;
	}
	else {
		this.ob.style.clip = "rect("+y1+"px "+x2+"px "+y2+"px "+x1+"px)";
	}
}
LyrObj.prototype.updateLayer =  function() {
	if (is.ns4) {
		this.ob.left = Math.round(this.x) + this.px;
		this.ob.top = Math.round(this.y)+ this.px ;
	}
	else {
		this.ob.style.left = Math.round(this.x) + this.px;
		this.ob.style.top = Math.round(this.y)  + this.px;
	}
}
//----------End LyrObj---------------------
//----------Begin MenuManager-----------------

function MenuObject(elt) {
	this.triggerName = elt.getAttribute("id");
	this.openAndCloseMethod = elt.getAttribute("method");
	this.offsetX = this.offsetY = 0;
	if (elt.getAttribute("menuoffsetx")) this.offsetX = parseInt(elt.getAttribute("menuoffsetx")) ;
	if (elt.getAttribute("menuoffsety")) this.offsetY = parseInt(elt.getAttribute("menuoffsety")) ;
	this.hasGraphicalTextTriggers = false;

	// start a new layer object for the menu div.
	this.init(this.triggerName + "_menu");

//	if ((this.hasGraphicalTextTriggers) && (this.selectedImageNumber >-1)) 	roll(-1,this.mNames[this.selectedImageNumber],"on");
	this.attachEventHandlers();
	this.setupMenuPosition();
}
MenuObject.prototype = new LyrObj();
MenuObject.prototype.constructor = LyrObj;
MenuObject.superclass = LyrObj.prototype;


MenuObject.prototype.attachEventHandlers = function() {
	var trigger = document.getElementById(this.triggerName);
	var image = trigger.childNodes[0];
	
	
	
	
	
	if (this.openAndCloseMethod == "mouseover") {
	// for mouseover to open, mouseover to close
		eval("trigger.onmouseover =function() {mcp.openMenu('"+this.triggerName+"');}");
		eval("trigger.onmouseout  = function() {mcp.menuMouseOut();}");

		
	}
	else if (this.openAndCloseMethod == "click") {
	// for behaviour of "click to open,  click elsewhere to close"
		eval("trigger.onclick =function() {mcp.openMenu('"+this.triggerName+"');return false}");	

	}

	
	var menuContainer = this.ob;
	if (menuContainer.childNodes[0].className == "menuInner") menuContainer = menuContainer.childNodes[0];

	var menuItemCollection = menuContainer.getElementsByTagName("DIV");
	for (var i=0; i<menuItemCollection.length; i++) {
		menuItemCollection[i].onmouseover = function() {appendClassName(this,"menuItemOver");};
		menuItemCollection[i].onmouseout = function() {removeClassName(this,"menuItemOver");};
		menuItemCollection[i].onclick = function() {this.childNodes[0].click();};
	}

}
// this function matches the positions of the menus with their triggers.  It does not change the visibility of the layers, which by default will be hidden. 
// if the page uses a centered or otherwise liquid design, this will have to be run on window.onresize. 
MenuObject.prototype.setupMenuPosition = function () {
	
	var imgX=0;
	var imgY=0;
	var imgWidth = 0;
	var imgHeight = 0;
	var elem=document.getElementById(this.triggerName).childNodes[0];
	
	imgWidth = elem.offsetWidth;
	imgHeight = elem.offsetHeight;

	while (elem.offsetParent != null) {
		imgX += elem.offsetLeft;
		imgY += elem.offsetTop;
		elem = elem.offsetParent;
	}

	
	this.x = imgX + this.offsetX;
	this.y = imgY + imgHeight + this.offsetY;

	this.width = this.getWidth();
	
	
	if (this.height > 98) {
		this.ob.style.overflow = "auto";
		this.ob.style.height = 98;
		this.height= this.getHeight();
	}
	else {
		this.height= this.getHeight();
	}
	this.updateLayer();
	
}

// BEGIN MenuManager
function MenuManager() {
	this.isNavReady = false;
	this.isNewlyLoaded = true;
	this.menus = new Array();

	// find the trigger elements. 
	anchorCollection = document.getElementsByTagName("A");
	var someAreClickActivated = false;
	var someAreMouseOverActivated = false;
	for (var i=0; i<anchorCollection.length; i++) {
		if (anchorCollection[i].className == "menuTrigger") {
			if (anchorCollection[i].getAttribute("method")=="click") someAreClickActivated = true;
			else if (anchorCollection[i].getAttribute("method") == "mouseover") someAreMouseOverActivated = true;
			this.menus[this.menus.length] = new MenuObject(anchorCollection[i]);
			this.isNavReady = true;
		}
	}
	if (someAreClickActivated) {
		document.getElementById("outerWrapper").onmousedown= function() {mcp.closeActiveMenu();};
		document.onkeypress = function(mozEvent) {if ((is.ie)?event.keyCode==27:mozEvent.keyCode==27){mcp.closeActiveMenu();}}
	}
	if (someAreMouseOverActivated) {	
		document.onmousemove = mouseMoveHandler;
	}
	
	this.numberOfMenus = this.menus.length;
	
	this.activeMenu = -1;
	this.mouseX = 0;
	this.mouseY = 0;
	this.peskyFormFields = false;
}
// this function will return true if it's over either the trigger or the menu
MenuManager.prototype.mouseIsOverTriggerOrMenu = function() {
	
	if (this.activeMenu!=-1) {
		//  if mouse is actually outside of the 'active' subnav.
	
		if (
				(!this.activeMenu.mouseIsOverTrigger) && 
				(
					(this.mouseX<this.activeMenu.x) || 
					(this.mouseX>this.activeMenu.x + this.activeMenu.width) || 
					(this.mouseY<this.activeMenu.y) || 
					(this.mouseY>this.activeMenu.y + this.activeMenu.height) 
				)
			) return false;
		else return true;
	}
	// and if activeMenu was already -1, or we're still over the parent Element (menuMouseOut has not yet fired) just return false
	else return false;
}



MenuManager.prototype.mouseMoveHandler = function(e) {
	var scrollOffsetX = ((is.ie5)||(is.ie6up))?(document.body.scrollLeft):0;
	var scrollOffsetY = ((is.ie5)||(is.ie6up))?(document.body.scrollTop):0;
	this.mouseX = (is.ns)?e.pageX:event.x + scrollOffsetX;
	this.mouseY = (is.ns)?e.pageY:event.y + scrollOffsetY;

	if (this.activeMenu.openAndCloseMethod=="mouseover") this.potentiallyCloseMenus();
	// not sure if this helps keep netscape4's event queue from getting gummed up, but it doesnt hurt. 
	return true;
}

MenuManager.prototype.closeActiveMenu = function() {
	if (this.activeMenu!=-1 ) {
		this.activeMenu.hide();
		this.activeMenu.updateLayer();
		this.activeMenu = -1;
	}
}
MenuManager.prototype.potentiallyCloseMenus = function() {
	
	if (
			(this.activeMenu != -1 ) && 
			(
				(this.activeMenu.openAndCloseMethod == "mouseover") &&
				(!this.mouseIsOverTriggerOrMenu())
			)
		) {
		
		// if the system thinks the mouse is not over the selected Global Nav parent, and openMenu has never run since the page loaded, switch off the active image. 
		/*
		if ((this.hasGraphicalTextTriggers) && (this.activeMenu != this.selectedImageNumber)&& (!this.isNewlyLoaded)) {
			var trigger = document.getElementById(this.mNames[this.activeMenu]+"_trigger");
			roll(-1,this.mNames[this.activeMenu],"off");
		}
		*/
		this.closeActiveMenu();
		/*
		if (this.peskyFormFields) {
			this.peskyFormFields.moveLayerTo(this.peskyFormFields.originalX, this.peskyFormFields.originalY);
			this.peskyFormFields.updateLayer();
		}
		*/
	}
}

MenuManager.prototype.openMenu = function(which) {
	if (this.isNavReady) {
		var activeMenuObject = null;
		for (var i=0; i<this.menus.length; i++) {
			if (this.menus[i].triggerName==which) { 
				activeMenuObject = this.menus[i];
			}
		}
		this.activeMenu = activeMenuObject;
		if (this.activeMenu.openAndCloseMethod=="mouseover") this.activeMenu.mouseIsOverTrigger = true;
		
		
//		if ((this.hasGraphicalTextTriggers) && (which != this.selectedImageNumber)) roll(-1,this.mNames[which],"over");
		for (i= 0; i<this.numberOfMenus; i++) {
			if (this.menus[i].triggerName==which) {
				this.menus[i].show();
				this.menus[i].updateLayer();
//				if ((this.hasGraphicalTextTriggers) && (i != this.selectedImageNumber)&& (!this.isNewlyLoaded)) roll(-1,this.mNames[i],"over");
			}	
			else {
				this.menus[i].hide();
				this.menus[i].updateLayer();
/*
				if ((this.hasGraphicalTextTriggers) && (i != this.selectedImageNumber)&& (!this.isNewlyLoaded)) {
					var trigger = document.getElementById(this.menus[i].triggerName);					
					roll(-1,this.mNames[i],"off");
				}
				*/
			}
		}
		if (this.isNewlyLoaded) this.isNewlyLoaded = false;
		if (this.peskyFormFields) {
			this.peskyFormFields.moveLayerTo(-500,0);
			this.peskyFormFields.updateLayer();
		}
	}
}


// all this does is flip off the boolean, so the mouse is no longer over a parent Element. 
MenuManager.prototype.menuMouseOut = function () {
	if (this.isNavReady) {
		this.activeMenu.mouseIsOverTrigger = false;
	}
}
//--------- END MENUMANAGER---------------




// various functions to be defined globally, but that basically just pass execution down into mcp.



function openMenu(which) {
	//if (mcp.isNavReady) {
		mcp.openMenu(which);
	//}
}
function menuMouseOut() {
	if (mcp.isNavReady) {
		mcp.menuMouseOut();
	}
}
function potentiallyCloseMenus() {
	if (mcp.isNavReady) {
		mcp.potentiallyCloseMenus();
	}
}
function mouseMoveHandler(evt) {
	if (mcp.isNavReady) {
		mcp.mouseMoveHandler(evt);
	}
}


function validateForm() {
	fm = document.frmSendMail
	if (fm.txtName.value=="") {
		alert("Please enter your Name");
		fm.txtName.focus();
		return false;
	}
	if (fm.txtTitle.value=="") {
		alert("Please enter your Title");
		fm.txtTitle.focus();
		return false;
	}
	if (fm.txtOrganization.value=="") {
		alert("Please enter your Organization/Affiliation");
		fm.txtOrganization.focus();
		return false;
	}
	if (fm.txtAddress.value=="") {
		alert("Please enter your Address");
		fm.txtAddress.focus();
		return false;
	}
	if (fm.txtCity.value=="") {
		alert("Please enter your City");
		fm.txtCity.focus();
		return false;

	}
	if (fm.txtState.value=="") {
		alert("Please enter your State");
		fm.txtState.focus();
		return false;
	}
	if (fm.txtZip.value=="") {
		alert("Please enter your Zip Code");
		fm.txtZip.focus();
		return false;
	}
	if (fm.txtPhoneNumber.value=="") {
		alert("Please enter your Phone Number");
		fm.txtPhoneNumber.focus();
		return false;
	}
	if ((fm.txtEmail.value.indexOf(".")==-1)||(fm.txtEmail.value.indexOf("@")==-1)) {
		alert("Please enter a valid email address");
		fm.txtEmail.focus();
		return false;
	}
}


function validateMailingForm() {
	fm = document.frmSendMail
	if (fm.txtName.value=="") {
		alert("Please enter your Name");
		fm.txtName.focus();
		return false;
	}
	if (fm.txtAddress.value=="") {
		alert("Please enter your Address");
		fm.txtAddress.focus();
		return false;
	}
	if (fm.txtCity.value=="") {
		alert("Please enter your City");
		fm.txtCity.focus();
		return false;

	}
	if (fm.txtState.value=="") {
		alert("Please enter your State");
		fm.txtState.focus();
		return false;
	}
	if (fm.txtZip.value=="") {
		alert("Please enter your Zip Code");
		fm.txtZip.focus();
		return false;
	}
	if (fm.txtPhoneNumber.value=="") {
		alert("Please enter your Phone Number");
		fm.txtPhoneNumber.focus();
		return false;
	}
	if ((fm.txtEmail.value.indexOf(".")==-1)||(fm.txtEmail.value.indexOf("@")==-1)) {
		alert("Please enter a valid email address");
		fm.txtEmail.focus();
		return false;
	}
}
