window.onload = function () {
	//create e-mail links
	var m = document.getElementsByTagName('a');
	for (var n=0;n<m.length;n++) { if 	(m[n].id == 'mailto') m[n].onclick = m[n].href = m[n].href + '@mdrt.org';}

	// create nav layers
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++) { if (x[i].className == 'labelNav')	x[i].onclick = clickNav;}

	closeNav();

	var curURL = location.href;
	if (curURL.indexOf('?') != -1) {curURL = curURL.substr(0, curURL.indexOf('?'));}
	setNav(curURL,'currentPage');
	//update location.href so it does not include any information passed through the URL, drop the ? and after

	//set up top navigation
	//showDivOnload = "topNavSpaceHolder"; showClassOnload = "info" //default
	showDivOnload = "topNavBooks"; showClassOnload = "books" //show the books nav on every page
	///if(location.href.indexOf('/dept.asp')!=-1) {showDivOnload = "topNavBooks"; showClassOnload = "books" }
	//if(location.href.indexOf('/member/')!=-1) {showDivOnload = "topNavMemberSvcs"; showClassOnload = "member"}
	//if(location.href.indexOf('/meetings/')!=-1) {showDivOnload = "topNavMeetingInfo"; showClassOnload = "meetings"}

	//showHideDiv(showDivOnload);
	//setTopNavClass(showClassOnload);
	setHeaderText(showClassOnload);
	//finish top nav set up
}

function clickNav(e) {
	if (!e) var e = window.event;
	if (e.target) var tg = e.target;
	else if (e.srcElement) var tg = e.srcElement;
	while (tg.nodeName != 'DIV') // Safari GRRRRRRRRRR
		tg = tg.parentNode;
	var nextSib = tg.nextSibling;
	while (nextSib.nodeType != 1)
		nextSib = nextSib.nextSibling;
	var nextSibStatus = (nextSib.style.display == 'none') ? 'block' : 'none';
	nextSib.style.display = nextSibStatus;
}

function closeNav() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)	{
		if (x[i].className == 'innerNav') {
			// IE and other browsers interpret the DOM different.  IE actually seems to interpret it more correctly.
			if(document.all) {
				thisPageParentDiv = x[i].previousSibling; //also used for bottom border
				thisPage = x[i].previousSibling.firstChild.firstChild.href;
				}
			else {
				thisPageParentDiv = x[i].previousSibling.previousSibling;
				thisPage = x[i].previousSibling.previousSibling.firstChild.nextSibling.firstChild.href;
				}
			if (location.href != thisPage) {
				x[i].style.display = 'none';
				}
			else {
			  thisPageParentDiv.style.borderBottomWidth = '0px';
				//make the bottom border 0px so it seems more seemless with its dropdown component
			}
			//alert(thisPageParentDiv.style.borderBottomWidth);
		}
	}
}

function setNav(page,newID) {
	//alert(page);
	//alert(newID);
	var test = page.indexOf('#')+1;
	if (test)
		page = page.substring(0,test-1);
	var x = document.getElementsByTagName('a');
	var i;
	for (i=0;i<x.length;i++) {
		if (x[i].href == page) {
			x[i].id = newID;
			break;
		}
	}

	if (i < x.length && newID == 'currentPage')	{
		var parDiv = x[i];
		while (parDiv.parentNode.parentNode.tagName == 'DIV')	{
			parDiv = parDiv.parentNode.parentNode;
			parDiv.style.display = 'block';
			x[i].style.fontStyle = 'italic';
			x[i].style.fontWeight = 'bold';
		}
		x[i].focus();
	}
}

function cleanNav() {
	closeNav();
	setNav(curURL,'currentPage');
}

<!--- show hide layers for Top Navigation --->
function showHideDiv(divID) {
	//alert(divId)
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)	{
		var s = (x[i].id);
		if (s.indexOf('topNav')!=-1) {
			if (x[i].id == divID) x[i].style.display = 'block'; //show the one we want to highlight
			else x[i].style.display = 'none'; //hide the rest
		}
	}
}
function setTopNavClass(loadClass) {
	var a = document.getElementsByTagName('a');
	for (i=0;i<a.length;i++) {
		if (a[i].className == 'hdrLink') {
			//alert('a tag id:' + a[i].id + ' loadClass being passes: ' + loadClass);
			if(a[i].id==loadClass || a[i].id=='currentPage') {a[i].className = 'hdrLinkOver';}
			//currentPage is a bug in the code being set earlier.  Try to fix.
		}
	}
}
function setHeaderText(loadClass) {
	var h1 = document.getElementsByTagName('h1');
	for (i=0;i<h1.length;i++) {
		if (h1[i].className == 'navTitle') {
			//if(loadClass == 'tot') {setTextTo = "Top of the Table";}
			//else if(loadClass == 'member') {setTextTo = "Member Services";}
			//else if(loadClass == 'meetings') {setTextTo = "Meeting Information";}
			//else {setTextTo = "MDRT Information";}
			if(loadClass == 'books' || loadClass == 'info') {setTextTo = "The MDRT Power Center";}
			setTextTo = "The MDRT Power Center";
			h1[i].firstChild.nodeValue = setTextTo;
		}
	}
}
function showHideBodyDiv(divID) {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++)	{
		var s = (x[i].id);
		if (s.indexOf('body_')!=-1) {
			if (x[i].id == divID) x[i].style.display = 'block'; //show the one we want to highlight
			else x[i].style.display = 'none'; //hide the rest
		}
	}
}

function openwin() {
	var x,y;

	if (window.screenX) {
		x = window.screenX + 150;
		y = window.screenY + 128;
	}
	else {
		x = window.screenLeft + 150;
		y = window.screenTop + 128;
	}

	var position;
	position = "screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y

	var newwindow = window.open("volume_discounts.asp", "Discounts", "height=125,width=480,toolbar=0,resizable=1," + position);
	newwindow.focus();
	}
function disclaimer() {
        dis = window.open('home-page-disclaimer.html', 'Disclaimer', 'toolbar=no,location=no,scrollbars=yes,menubar=no,resizable=yes,width=300,height=230')
	}
function compliance() {
        com = window.open('home-page-compliance.html', 'Compliance', 'toolbar=no,location=no,scrollbars=yes,menubar=no,resizable=yes,width=300,height=230')
	}
function copyright() {
        cop = window.open('home-page-copyright.html', 'Copyright', 'toolbar=no,location=no,scrollbars=yes,menubar=no,resizable=yes,width=300,height=200')
	}
function memberid()
	  {
	    win = window.open('idsearch.asp?form_name=frmLogin', 'Member_ID', 'toolbar=no,location=no,scrollbars=yes,menubar=no,resizable=yes,width=400,height=300')
	  }
function memberidmain()
	  {
	    win = window.open('idsearch_main.asp?form_name=frmLogin', 'Member_ID', 'toolbar=no,location=no,scrollbars=yes,menubar=no,resizable=yes,width=400,height=300')
	  }
