// JavaScript Document
// 2.16.04 Kerry Colligan --
// this uses variable definitions set in script_defs.js

// added by DWW for netscape compat
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// get divs
function _getElement(eName) {
	if (document.all) return(eval("document.all." + eName));
	else return(document.getElementById(eName));
	}
		
// page load init
function booter(){
// loop through menu Items from script_defs and store the one that matches the URL folder, else
// set to the "0" value (presumably home)
var activeMenu;
for(i=0;i<=menuItem.length - 1; i++){
	if(document.URL.indexOf(menuItem[i])!= -1){
		activeMenu = menuItem[i];
		}
	}

// changes background color of the activeMenu 
var aObj = _getElement(activeMenu);
if(aObj!=null){
	aObj.style.backgroundColor = menuHighlightColor; // color set in scripts_def or in the body onload (overwrites)
	}
}

/*************** show the subMenu ******************/
function getSubMenu(activeMenu){
var bObj = _getElement(activeMenu + "SubMenu");
if(bObj!=null){
	bObj.style.visibility="visible";
	}
//var aObj = _getElement(activeMenu);
//aObj.style.backgroundColor = menuRollOverColor;
}
/*************** hide the subMenu ******************/
function hideSubMenu(activeMenu){
var bObj = _getElement(activeMenu + "SubMenu");
if(bObj!=null){
	bObj.style.visibility="hidden";
	}
}

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

function isBlank(s) {
        for(var i=0; i<s.length; i++){
                var c=s.charAt(i);
                if((c != ' ') && (c != '\n') && (c!= '\t')) return false;
                }
        return true;
        }
function verify(f){
        var msg;
        var empty_fields ="";
        var errors="";
        for(var i=0; i<f.length; i++){
                var e=f.elements[i];
                if(((e.type=="text") || (e.type=="textarea") || (e.type=="password")) && !e.optional){
                        if((e.value==null) || (e.value=="") || isBlank(e.value)){
                                empty_fields += "\n     " + e.name;
                                continue;
                                }
                        }
                }

//this is here exclusively for the registration form to validate the Profession field.
// how do you automate the select fieldname here?
//      if(f.Profession.selectedIndex=="0"){
//                      empty_fields += "\n\tProfession";
//                      }

        if(!empty_fields && !errors) return true;
        msg = "---------------------------------------------------------------------------\n\n";
        msg += "The form was not submitted because of the following error(s).\n";
        msg += "Please correct these error(s) and re-submit.\n";
        msg += "--------------------------------------------------------------------------\n\n";
        if(empty_fields){
                var re = new RegExp ('_', 'gi') ;
                var newstr = empty_fields.replace(re, ' ') ;

                msg += "- The following required field(s) are empty:" + newstr + "\n";
                if(errors) msg += "\n";
                }
        msg += errors;
        alert(msg);
        return false;
        }



var i;
// takes the div id # beg. at 1 and the total number of divs
function showDiv(whichDiv, divShutOff) {
        if(whichDiv == divShutOff) { return false; }
        var aObj = _getElement(whichDiv);
        if (aObj!=null) {
                aObj.style.visibility = "visible";
                }
        }
function hideDiv(i) {
        var aObj = _getElement(i);
        if(aObj!=null) {
                aObj.style.visibility = "hidden";
                }
        }
