
/*
Original Script Credits

menutree.js  http://www.kryogenix.org/code/browser/aqlists/  Stuart Langridge, November 2002  sil@kryogenix.org
Inspired by Aaron's labels.js (http://youngpup.net/demos/labels/) and Dave Lindquist's menuDropDown.js (http://www.gazingus.org/dhtml/?id=109)

*/

function spamtest() {
    alert('test');
}


var resized = false;
function resize_sidebar() { 
   // document.onresize = null;
   
    
   
    var winHeight = getWindowHeight();

    var container = document.getElementById("container");
    var containerHeight = height(container);
    
    var top = document.getElementById("top");
    var topHeight = height(top);
    
    var content = document.getElementById("content");
    var contentHeight = height(content);
    
    var pathbar = document.getElementById("pathbar");
    var pathbarHeight = height(pathbar);
   
    var footer = document.getElementById("footer"); 
    var footerHeight = height(footer);
    
    var navigation = document.getElementById("navigation"); 
    var navigationHeight = height(navigation);
    
    var maincontent = document.getElementById("maincontent");
    var maincontentHeight = height(maincontent);

    var sidebar = document.getElementById("sidebar"); 
    var sidebarHeight = height(sidebar);
    

    /** two cases:
    
    - viewport is larger than content: sidebar needs to be set to viewport height - (top + pathbar)
    - viewport is smaller than content: 
       - find the greatest of (maincontent + pathbar, navigation, sidebar + pathbar)
         add the difference to the two smaller divs
    
    **/
         

    

    var newHeight;
    
    if (winHeight > containerHeight) {
       newHeight = winHeight - topHeight - pathbarHeight -15;
       sidebar.style.height=newHeight + 'px';
      //  alert('window greater than content. sidebar newheight = ' + newHeight + 'winHeight,containerHeight: ' + winHeight + ', ' + containerHeight);
        }
        
    else if ( containerHeight > winHeight ) {
      /**  viewport is smaller than content: 
       - find the greatest of (maincontent + pathbar, navigation, sidebar + pathbar)
         add the difference to the two smaller divs
    
    **/  
   // alert(navigator.appName);
    if (navigator.appName == "Microsoft Internet Explorer" && resized == true) {return}
    
     var sidebarBottom = sidebarHeight + pathbarHeight;
     var mainContentBottom = maincontentHeight + footerHeight + pathbarHeight;
     var navigationBottom = navigationHeight;
    // alert("sidebarBottom,mainContentBottom,navigationBottom:" + sidebarBottom + ',' + mainContentBottom +',' + navigationBottom);
     var max = Math.max(sidebarBottom,mainContentBottom,navigationBottom);
     
     if (sidebarBottom < max) {sidebar.style.height= ((max - sidebarBottom) + sidebarHeight + 10) + 'px'; }
     if (mainContentBottom < max) {footer.style.height= ((max - mainContentBottom) + footerHeight - pathbarHeight) + 'px'; }       
        
        
    
        }

   // document.onresize = resize_sidebar();
   resized = true;
    }

function height(d) {
    var divHeight;
  //  alert(d.offsetHeight + ' ' + d.style.pixelHeight + ' '+ document.body.scrollHeight);
    if(d.offsetHeight){ divHeight=d.offsetHeight; } 
    else if(d.style.pixelHeight){ divHeight=d.style.pixelHeight; } 
    return divHeight;
}  






function getWindowHeight() {
    var windowHeight=0;
 //   alert(window.innerHeight);
    if (typeof(window.innerHeight)=='number') {windowHeight=window.innerHeight;}
    else {
        if (document.documentElement && document.documentElement.clientHeight) {windowHeight=document.documentElement.clientHeight;}
        else {if (document.body&&document.body.clientHeight) {windowHeight=document.body.clientHeight;}}
        }
    return windowHeight;
}


/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}  
    
var nodeid = 0;  
var subMenuStorage = new Array();

function makeTreesC() {
    // We don't actually need createElement, but we do need good DOM support, so this is a good check.
    if (!document.createElement) return;
		// process all divs of class = "menutree".  On COE site this should just be one div since there is only one menu per page.
    divs = document.getElementsByTagName("div");
		if (divs.length > 0 ) {  
	    for (divi=0;divi<divs.length;divi++) {
	        div = divs[divi];
	        //alert(div.id);
	        if (div.id == "menutree") {
	            
	            processULELC(div); // this is the menu tree div
	        }
			}
    }
 //   alert('end makeTreesC');
}

/* ******************** a top level menu div has the following form   *********************

<div id="menutree">
		<div class="nostatenode">
			<table><tr><td class="switch"></td>
				<td class="menuheading">
					<span>About the College of Education</span>
			
				<ul class="menu2ndlevel">
					<li class="menu2ndlevelitem"><a href="/oet" shape="rect">Unit Home Sample</a>
						<ul class="menu3rdlevel">
							<li class="menu3rdlevel">test3 </li>
							<li class="menu3rdlevel">test3 too </li>
						</ul>
					</li>
					<li class="menu2ndlevelitem"><a href="/oet/standard.html" shape="rect">StandardSample </a></li>
					<li class="menu2ndlevelitem"><a href="/oet/sidebar.html" shape="rect">Standard with Sidebar Sample </a></li>
					<li class="menu2ndlevelitem">Dean's Welcome<a href="/about/welcome.html/" shape="rect"></a></li>
				</ul>
			</td></tr></table>
		</div>
		<div class="nostatenode">
			<table><tr><td class="switch"></td>
			<td class="menuheading">
				<span>
					<a href="/research/index.html" shape="rect">Research Activities</a>
				</span>
				<ul class="menu2ndlevel">
					<li class="menu2ndlevelitem">Highlighted Projects  &amp; Partners</li>
					<li class="menu2ndlevelitem">Bureau of Educational Research</li>
					<li class="menu2ndlevelitem">Research &amp; Grants List</li>
					<li class="menu2ndlevelitem">Faculty Research Profile</li>
					<li class="menu2ndlevelitem">Research Journals</li>
					<li class="menu2ndlevelitem">Publications and  Presentations</li>
				</ul>
			</td></tr></table>
		</div>
...
</div>
*/


function processULELC(menuTreeRootDiv) {
    if (!menuTreeRootDiv.childNodes) return;
		if (menuTreeRootDiv.childNodes.length == 0) return; // if no top level divs in menu tree, exit

    // Iterate through all top level divs in menu tree
    for (var topLevelDivCounter=0;topLevelDivCounter<menuTreeRootDiv.childNodes.length;topLevelDivCounter++) {
        var topLevelDiv = menuTreeRootDiv.childNodes[topLevelDivCounter];
        if (topLevelDiv.nodeName == "DIV" && topLevelDiv.className != 'nochildrennode') {ProcessTopLevelDivisionTable(topLevelDiv) }
    	}
	}

function ProcessTopLevelDivisionTable(topLevelDiv) {


/* 
	1.  based on cookie (1 signifies open node, 0 signifies closed node, null signifes cookie doesn't exist for node) 
			and initial class name of top level menu div  (can be nostatenode or defaultopennode), 
			sets class value for top level menu div to
    	one of the following: defaultopennode, opennode, or closednode

		meaning of states:
			- nostatenode     ' node has not been touched and is in its initial state, which defaults to closed.
			- opennode        ' node has been opened
			- defaultopennode ' node is in initial state, which is defaulted open 
			- closednode      ' node has been closed.  May have been nostatenode,opennode or defaultopennode before being closed

		how is initial state decided in this function?

		initial html					cookie value                  class value
	  class value																					after initial js run
		----------- 					----------------------				-----------
		nostatenode 		&& 		cookie=1 -> 									opennode
		nostatenode 		&& 		(no cookie or cookie=0) -> 		closednode

		defaultopennode && 		(cookie=1) -> 								opennode
		defaultopennode && 		(cookie=0) -> 								closednode
		defaultopennode && 		(no cookie) -> 								defaultopennode
 */

	var debugmneu;
	debugmenu = false;

	var initialState = topLevelDiv.className;

	nodeid = nodeid + 1;  // global scope variable used to id top level nodes in cookies
	var ThisNodeCookieValue = getThisNodeMenuCookie(nodeid,menuid); // is 1,0, or null
	if (debugmenu) {alert('processed getThisNodeMenuCookie(' + nodeid + ',' + menuid + ')'); };

	if (topLevelDiv.getElementsByTagName("table").length > 0 ) {
		var topLevelMenuTable = topLevelDiv.getElementsByTagName("table")[0];
		if (debugmenu) {alert('topLevelMenuTable nodename and class=' + topLevelMenuTable.nodeName + ',' + topLevelMenuTable.className ); };
		} 
	else return;

	if (topLevelMenuTable.getElementsByTagName("tr").length > 0 ) {
		var headingTR = topLevelMenuTable.getElementsByTagName("tr")[0];
		if (debugmenu) {alert('headingTR nodename and class=' + headingTR.nodeName + ',' + headingTR.className ); };
		}
	else return;

	var objSubMenuUL = null;
	if (topLevelMenuTable.getElementsByTagName("tr").length > 1 ) {
		var subMenuTR = topLevelMenuTable.getElementsByTagName("tr")[1];
		if (subMenuTR.getElementsByTagName("td").length > 1 ) {
			var subMenuTD = subMenuTR.getElementsByTagName("td")[1];
			if (subMenuTD.getElementsByTagName("ul").length > 0 ) {
				//	alert('found sub meu ul');
					objSubMenuUL = subMenuTD.getElementsByTagName("ul")[0];
					subMenuStorage[nodeid] = objSubMenuUL;
				}
			}	
		}
//	alert('sub mebu UL:' + objSubMenuUL.nodeName);
	if (headingTR.getElementsByTagName("td").length > 0 ) {
		var switchTD = headingTR.getElementsByTagName("td")[0];
		switchTD.id = nodeid;
		if (debugmenu) {alert('switchTD nodename and class=' + switchTD.nodeName + ',' + switchTD.className ); };
		}
	else return;


	if (headingTR.getElementsByTagName("td").length > 1 ) {
		var headingTD = headingTR.getElementsByTagName("td")[1];
		if (debugmenu) {alert('headingTD nodename and class=' + headingTD.nodeName + ',' + headingTD.className ); };
		}
	else return;


	if (headingTD.getElementsByTagName("span").length > 0 ) {
		var headingSpan = headingTD.getElementsByTagName("span")[0];
		if (debugmenu) {alert('headingSpan nodename and class=' + headingSpan.nodeName + ',' + headingSpan.className ); };
		}
	else return;


	var blnLink = false; // is there a link in the top level menu heading span?
	if (headingSpan.getElementsByTagName("a").length > 0) {
	//	alert('found link');
		var headingLink = headingSpan.getElementsByTagName("a")[0];
		if (headingLink.nodeName == 'A') { 
			blnLink = true ;
		//	alert(headingLink.nodeName + headingLink.className + 'blnLink=' + blnLink );
			}
		}
	

	if (debugmenu) { alert(initialState + 'id=' + nodeid + 'initialState=' + initialState + 'ThisNodeCookieValue=' + ThisNodeCookieValue );}
//	alert(menuid + '_' + nodeid + '=' + ThisNodeCookieValue)
  if (initialState == 'nostatenode' && ThisNodeCookieValue == '1') {
		topLevelDiv.className = 'opennode'; 
		setSwitchImage(switchTD, 'open',objSubMenuUL,topLevelDiv); 
		}
  else if (initialState == 'nostatenode' && (ThisNodeCookieValue == '0' || ThisNodeCookieValue == null)) {
		topLevelDiv.className = 'closednode';
		setSwitchImage(switchTD, 'closed',objSubMenuUL,topLevelDiv);
		}
  else if (initialState == 'defaultopennode' &&  ThisNodeCookieValue == '0' ) {
		topLevelDiv.className = 'closednode';
		setSwitchImage(switchTD, 'closed',objSubMenuUL,topLevelDiv);
		}
  else if (initialState == 'defaultopennode' &&  (ThisNodeCookieValue == '1' || ThisNodeCookieValue == null ) ) {
		topLevelDiv.className = 'opennode';
		setSwitchImage(switchTD, 'open',objSubMenuUL,topLevelDiv);
		}

/*

  2.  Add event handler to switch TD.  This event handler is for opening and closing menu node.

*/

  switchTD.onclick = function () {
		//alert('executing event handler for switchTD.' + this.nodeName);
		var topLevelMenuDivisionStateNode = this.parentNode.parentNode.parentNode.parentNode; // this is the div outside the table
		var state = topLevelMenuDivisionStateNode.className;
		// alert('state=' + state + topLevelMenuDivisionStateNode.nodeName);
		var subMenuULX = getSubMenuULFromtopLevelMenuDivisionStateNode(topLevelMenuDivisionStateNode);
		if (state == 'opennode' || state == 'defaultopennode'  ) { 
			topLevelMenuDivisionStateNode.className = "closednode";
			setNodeMenuCookie(0,this.id,menuid); // 0 = closed node cookie
			setSwitchImage(this, 'closed',subMenuULX,topLevelMenuDivisionStateNode);
			}
		else { 
      topLevelMenuDivisionStateNode.className = "opennode";
			setNodeMenuCookie(1,this.id,menuid); // 1 = closed node cookie
			setSwitchImage(this, 'open',subMenuULX,topLevelMenuDivisionStateNode);
			}
		}


/*
	3.  Add event handler for A link within heading. 
	    need to add event handler to heading links on closed nodes (to set cookie)
*/

	if (topLevelDiv.className == 'closednode' && blnLink) { 

		headingLink.onclick = function () {
			var parentTR = this.parentNode.parentNode.parentNode;
			if (parentTR.getElementsByTagName("td").length > 0 ) {
				var switchTD = parentTR.getElementsByTagName("td")[0];
				setNodeMenuCookie(1,switchTD.id,menuid); // 1 = open node cookie
				window.location = this.getAttributeNode("href").value; 
				}
			};


		}
	}

/* **************************************************************************
  getSubMenuULFromtopLevelMenuDivisionStateNode(switchTD)
	
	given swtichTD, find UL that menu belongs in (or is already in)
*************************************************************************** */

function getSubMenuULFromtopLevelMenuDivisionStateNode(topLevelMenuDiv) {

	var objSubMenuUL = null;
	//	alert('topLevelMenuDiv=' + topLevelMenuDiv.nodeName);
	if (topLevelMenuDiv.getElementsByTagName("table").length > 0 ) {
		var topLevelMenuTable = topLevelMenuDiv.getElementsByTagName("table")[0];
	//	alert('topLevelMenuTable=' + topLevelMenuTable.nodeName);
		if (topLevelMenuTable.getElementsByTagName("tr").length > 1 ) {
			var subMenuTR = topLevelMenuTable.getElementsByTagName("tr")[1];
			if (subMenuTR.getElementsByTagName("td").length > 1 ) {
				var subMenuTD = subMenuTR.getElementsByTagName("td")[1];
				if (subMenuTD.getElementsByTagName("ul").length > 0 ) {
					var objSubMenuUL = subMenuTD.getElementsByTagName("ul")[0];
					}
				}
			}
		} 
//	alert('getSubMenuTDFromtopLevelMenuDivisionStateNode' + topLevelMenuDiv.nodeName + ',' + objSubMenuTD.nodeName);
	return objSubMenuUL;
}

/* **************************************************************************
  getSubMenuTDFromtopLevelMenuDivisionStateNode(switchTD)
	
	given swtichTD, find TD that menu belongs in (or is already in)
*************************************************************************** */

function getSubMenuTDFromtopLevelMenuDivisionStateNode(topLevelMenuDiv) {

	var subMenuTD = null;
	//	alert('topLevelMenuDiv=' + topLevelMenuDiv.nodeName);
	if (topLevelMenuDiv.getElementsByTagName("table").length > 0 ) {
		var topLevelMenuTable = topLevelMenuDiv.getElementsByTagName("table")[0];
	//	alert('topLevelMenuTable=' + topLevelMenuTable.nodeName);
		if (topLevelMenuTable.getElementsByTagName("tr").length > 1 ) {
			var subMenuTR = topLevelMenuTable.getElementsByTagName("tr")[1];
			if (subMenuTR.getElementsByTagName("td").length > 1 ) {
				 subMenuTD = subMenuTR.getElementsByTagName("td")[1];
				}
			}
		} 
//	alert('getSubMenuTDFromtopLevelMenuDivisionStateNode' + topLevelMenuDiv.nodeName + ',' + objSubMenuTD.nodeName);
	return subMenuTD;
}

/* **************************************************************************
  setSwitchImage(switchTD, enumOpenClosed) 
	   add or replace appropriate image to switch td based of enumOpenClosed
	   enumOpenClosed is 'open' or 'closed'
*************************************************************************** */
function nodeIconHref() { 
}

function setSwitchImage(switchTD, enumOpenClosed, subMenuUL, topLevelMenuDiv) {
//	 alert( 'setting switch for node: ' + switchTD.id +',' + ',' + enumOpenClosed); 
	var subMenuID =  switchTD.id;
	// change imag
	if (switchTD.getElementsByTagName("img").length > 0 ) {
		var imageElement = switchTD.getElementsByTagName("img")[0];
		var newImageURL = 'http://library.education.illinois.edu/edwebs/images/cssmenu/'+ enumOpenClosed + '.gif';
		var newImgElement;
		if (enumOpenClosed == 'closed') { newImgElement = '<img src="' + newImageURL + '" alt="open sub menu items." />';
		} else if (enumOpenClosed == 'open') {newImgElement = '<img src="' + newImageURL + '" alt="close sub menu items." />'; }
		else { newImgElement = '<img src="' + newImageURL + '" " />';}

		if (! imageElement) {
		//	alert('insert image' + newImgElement);
			switchTD.innerHTML = '<a href="javascript:nodeIconHref();">' + newImgElement + '</a>';
			}
		else {
			switchTD.innerHTML = '<a href="javascript:nodeIconHref();">' + newImgElement + '</a>';
			// imageElement.setAttribute('src',newImageURL);
			}
		}

	if (enumOpenClosed == 'closed'  && subMenuUL) { 
	//	alert('removing node menu id='+ subMenuID + 'node type=' + subMenuUL.nodeName);
		subMenuUL.parentNode.removeChild(subMenuUL);
		} 
	if (enumOpenClosed == 'open') { 
	//	alert('opening node id='+ subMenuID);
		var menuTD = getSubMenuTDFromtopLevelMenuDivisionStateNode(topLevelMenuDiv)
		// if no ul node exists, append the one from the storage array, otherwise don;t do anything.
		if (menuTD) {
			menuTD.appendChild(subMenuStorage[subMenuID]);
			}

		} 


/*

	// if opening node, get ul from global array
function removeFooter() {
		if (document.getElementById("footer")) {
			var footer = document.getElementById("footer");
	    var body = document.getElementById("body");
	    removedFooter = body.removeChild(footer);
			}


function returnFooter() {

		if (removedFooter) {
    	document.getElementById("body").appendChild(removedFooter);
			removedFooter = null;
			}

*/


	}


/* **************************************************************************
  getThisNodeMenuCookie(nodeid,menuid) gets cookie for a given menu node
*************************************************************************** */

function getThisNodeMenuCookie(nodeid,menuid) {
// gets the value of the cookie for a given menu and node 
	var cookieID = menuid + '_' + nodeid ;  // global scope variable to id differnet menus on site. i.e. ed_webdev_edwebsdev_root_menu is id for wwwdev.ed.uiuc.edu/root/menu.html
	var pos = allcookies.indexOf(cookieID + "=");
	var returnCookieValue;
		if (pos != - 1) {
			var start = pos + cookieID.length + 1;
			returnCookieValue = allcookies.substring(start,start+1);
			}
		else {
			returnCookieValue =  null;
		}

//	 alert('getting cookie value: ' + cookieID + '=' + returnCookieValue);

	return returnCookieValue;
}

/* **************************************************************************
  setNodeMenuCookie(blnValue,nodeid,menuid) sets cookie for a given menu node
*************************************************************************** */

function setNodeMenuCookie(blnValue,nodeid,menuid) {
// sets the value of the cookie for a given menu and node to the correct value
	var  cookieID = menuid + '_' + nodeid ;
	var  cookie = cookieID +'=' + blnValue +'; path=/; domain=' + domain + ';';
//  alert('setting cookie: ' + cookie );
	 	document.cookie = cookie;
// + '; path=/oet';
}


/* **************************************************************************

*************************************************************************** */



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function searchFunction() {
	if(document.gSearch.q.value=='' || document.gSearch.q.value=='search uiuc.edu') {
		alert('Please enter a search parameter.');
		return false;
		}
	return true;
}


function printerFriendlyOn() {
	document.cookie = 'printerFriendly=1; path=/; domain=' + domain + ';';
	window.location = location.href;
//	location.reload();  // location = document.location;

	}

function printerFriendlyOff() {
	document.cookie = 'printerFriendly=0; path=/; domain=' + domain + ';';
	window.location = location.href;
//	location.reload();   // location = document.location; 
}


function confirmSubmit()
{
var agree=confirm("Are you sure you wish to submit this form?");
if (agree)
	return true ;
else
	return false ;
}

function spamFree(spamTest,spamResponse)
{
var strResult;
// if (myForm.spamtest.value == myForm.spamresponse.value) {
if (spamTest.value == spamResponse.value) { return true; }
else { return false; };

}



function checkEmailAddress(field,fieldname) {

// Note: The next expression must be all on one line...
//       allow no spaces, linefeeds, or carriage returns!
//var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
var goodEmail = field.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i);

var good;
if (goodEmail){
   good = true
} else {
   alert('Please enter a valid e-mail address for ' + fieldname + '.')
   field.focus()
   field.select()
   good = false
   }
   
return good;
}