widthReg  = /^w([0-9]+)$/;
heightReg = /^h([0-9]+)$/;
foundClass = "";

featuredPartners = [
	[ "AMECO.jpg", "AMECO", "http://www.amecoinc.org" ],
	[ "ATF.jpg", "ATF", "http://www.atf.gov" ],
	[ "CEC.jpg", "CEC", "http://www.cec.sped.org" ], 
	[ "CommunityWatch.jpg", "CommunityWatch", "http://www.communitywatch.us" ],
	[ "Cops.jpg", "COPS", "http://www.cops.usdoj.gov" ],
	[ "DEA.jpg", "DEA", "http://www.usdoj.gov/dea" ],
	[ "DOJ.jpg", "DOJ", "http://www.usdoj.gov" ],
	[ "FLEOA.jpg", "FLEOA", "http://www.fleoa.gov" ],
	[ "FOP.jpg", "FOP", "http://www.grandlodgefop.org" ],
	[ "Masonichip.jpg", "MasoniCHIP", "http://www.masonichip.org" ],
	[ "MD-PIRC.jpg", "MDPIRC", "http://www.mdpirc.org" ],
	[ "Noble.jpg", "NOBLE", "http://www.noblenatl.org" ],
	[ "OldNavy.jpg", "Old Navy", "http://www.oldnavy.com" ],
	[ "POMWA.jpg", "POMWA", "http://www.pomwa.org" ],
	[ "PTA.jpg", "PTA", "http://www.pta.org" ],
	[ "SalemRedSox.jpg", "Salem Red Sox", "http://www.salemredsox.com" ],
	[ "Soroptimist.jpg", "Soroptimist", "http://www.nwcat.org" ],
	[ "TEAM-HOPE.jpg", "Team Hope", "http://www.teamhope.org" ],
	[ "USCCB.jpg", "USCCB", "http://www.usccb.org" ],
	[ "USSS.jpg", "USSS", "http://www.secretservice.org" ]

];

gOLPass = 0

function globalOnLoad() {
    // Assign link events
    anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
/*        if (FM.checkForClass(anchors[i],"ToggleMenu")) {
            FM.toggleClass(anchors[i],"ToggleMenu");
            anchors[i].onmouseover = function() { togglePopMenu(trim(this.className)); return false; }
        }
*/
        if (FM.checkForClass(anchors[i],"VideoPop"))  foundClass = "VideoPop";
        if (FM.checkForClass(anchors[i],"ImagePop"))  foundClass = "ImagePop";
        if (FM.checkForClass(anchors[i],"Popup"))     foundClass = "Popup";

        if (FM.checkForClass(anchors[i],"PDF")) {
            anchors[i].onclick = function() { PDFPopup(this.href); return false; }
        }
        if (FM.checkForClass(anchors[i],"Offsite") || isOffsiteLink(anchors[i].href)) {
            anchors[i].onclick = function() { offsitePopup(this.href); return false; }
        }
        if (FM.checkForClass(anchors[i],"Footnote")) {
            if (!anchors[i].href.indexOf("OpenFootnotes(")) {
                anchors[i].onclick = function() { CSSOpenFootnotes(this.href); return false; }
            }
        }
        if (FM.checkForClass(anchors[i],"Definition")) {
            anchors[i].onclick = function() { CSSDefinitionPopup(this.href); return false; }
        }
        if (FM.checkForClass(anchors[i],"EnlargePhoto")) {
            anchors[i].onclick = function() { EnlargePhoto(this.href.substr(this.href.lastIndexOf("/")+1)); return false; }
        }
        if (FM.checkForClass(anchors[i],"GetDirections")) {
            anchors[i].onclick = function() { getDirections(this.href); return false; }
        }
        if (FM.checkForClass(anchors[i],"CloseButton")) {
            anchors[i].onclick = function() { self.close(); return false; }
        }
        if (FM.checkForClass(anchors[i],"PrintButton")) {
            anchors[i].onclick = function() { self.print(); return false; }
        }
//        if (FM.checkForClass(anchors[i],"DDMenuItem")) {
//            anchors[i].onmouseover = function() { resetMenuTimer(); return false; }
//            anchors[i].onmouseout = function() { resetMenuTimer(); return false; }
//        }
        if (foundClass != "") {
            // width & height should be specified by class names that begin with a 'w' or an 'h'
            // popup class names should be, e.g.: class="Popup w400 h320"
            if (foundClass=="ImagePop") {
                anchors[i].onclick = function () { NewImagePopup(this); return false; };
            } else if (foundClass=="VideoPop") {
                anchors[i].onclick = function () { VideoPopup(this); return false; };
            } else {
                anchors[i].onclick = function() { CSSpopupWindow(this); return false; };
            }
        }
        foundClass = "";
    }

    // start featuredPartner rotation
    swapFeaturedPartner();

	gOLPass = 1;
}

function isOffsiteLink(theAnchor) {
	if ((theAnchor.indexOf("://take25.")>0) || (theAnchor.indexOf("://toma25.")>0) || (theAnchor.indexOf("take25.org")>0) || (theAnchor.indexOf("cript:")>0) || (theAnchor.indexOf("ailto:")>0)) {
		return false;
	} else {
		return true;
	}
}
/*sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
		alert(sfEls[i].onmouseover + "\n" + sfEls[i].onmouseout);
	}
}
*/
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		    FM.toggleClass(this,"sfhover");
		}
		sfEls[i].onmouseout=function() {
		    FM.toggleClass(this,"sfhover");
		}
	}
}


function addOnLoad(theFn) {
	if (window.addEventListener) {
		window.addEventListener("load", theFn, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload", theFn)
	} else if (document.getElementById) {
		window.onload = function() { window.onload; theFn; }
	}
}

// swap featured partner logos
currentFPLogo = "";
function swapFeaturedPartner() {
    fpAnchor = document.getElementById("FeaturedPartnerAnchor");
    fpImage = document.getElementById("FeaturedPartnerImage");

    if (currentFPLogo == "") currentFPLogo = 0
    fpAnchor.href = featuredPartners[currentFPLogo][2];
    fpImage.src = "/res/images/PartnerLogos/" + featuredPartners[currentFPLogo][0];
    fpImage.alt = featuredPartners[currentFPLogo][1];

    if (currentFPLogo == (featuredPartners.length-1)) currentFPLogo = 0
    else currentFPLogo = currentFPLogo + 1;

    setTimeout("swapFeaturedPartner();",8000);
}

function NewImagePopup(trigger) {
    /* Reads Width & Height from the triggering object's wXXX and hXXX classes */
    FM.toggleClass(trigger,"ImagePop");
    aClass = trigger.className.split(" ");
    width = 700;
    height = 550;
    for (var j = 0; j < aClass.length; j++) {
        if (aClass[j].search(widthReg) >= 0)  { width = aClass[j].substr(1); }
        if (aClass[j].search(heightReg) >= 0) { height = aClass[j].substr(1); }
    }

    var popUp = window.open('/popups/image-popup.asp?filename=' + trigger.href, 'imagepopup', 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    popUp.focus();
}

// A general-purpose popup window function
function CSSpopupWindow(trigger) {
    FM.toggleClass(trigger,"Popup");
    aClass = trigger.className.split(" ");
    width = 700;
    height = 550;
    for (var j = 0; j < aClass.length; j++) {
        if (aClass[j].search(widthReg) >= 0)  { width = aClass[j].substr(1); }
        if (aClass[j].search(heightReg) >= 0) { height = aClass[j].substr(1); }
    }
    var windowName = 'popup';
    if(arguments.length > 3) {
        windowName = arguments[3];
    }
    var popUp = window.open(trigger.href, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    if (typeof popUp == 'object') { popUp.focus(); }
}

function offsitePopup(href) {
	popupFullWindow(href);
}

function VideoPopup(trigger) {
    /* Reads Width & Height from the triggering object's wXXX and hXXX classes */
    FM.toggleClass(trigger,"VideoPop");
    aClass = trigger.className.split(" ");
    width = 350;
    height = 300;
    for (var j = 0; j < aClass.length; j++) {
        if (aClass[j].search(widthReg) >= 0)  { width = aClass[j].substr(1); }
        if (aClass[j].search(heightReg) >= 0) { height = aClass[j].substr(1); }
    }

    var popUp = window.open('/popups/video-popup.asp?f=' + trigger.href, 'imagepopup', 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    popUp.focus();
}


function PDFPopup(file) {
    var popUp = window.open(file, 'pdfPopup', 'width=500,height=700,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    popUp.focus();
}

function switchLang(langObj) {
    inputs = langObj.getElementsByTagName('input');
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].checked) {
            host = (document.location.href.indexOf(enURL) > -1)?enURL:esURL;
            curURL = document.location.href.split(host)
            host = ((inputs[i].value == "es") && (document.location.href.indexOf(enURL)))?esURL:enURL;
            document.location = "http://" + host + curURL[curURL.length-1];
        }
    }
}

/*
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("HeaderNav");
		if (navRoot != null) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() { this.className+=" over"; }
					node.onmouseout=function() { this.className=this.className.replace(" over", ""); }
				} //end if
			} //for
		} //navroot != null
	 } //if doc.all
} //function
window.onload=startList;*/


function PopUpload(formName,UploadPath, fileName) {
  var n = window.open("upload.asp?field=" + formName + "&path=" + UploadPath ,'uploader','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=320,height=285');
}

function getRef(obj){
  if(typeof obj == "string") {obj= document.getElementById(obj);}
  else if (typeof obj == "object") {obj = obj;}

  return obj;
}

// A general-purpose popup window function
function popupWindow(uri, width, height) {
    var windowName = 'popup';
    if(arguments.length > 3) {
        windowName = arguments[3];
    }
    //alert(width);
    var popUp = window.open(uri, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    if (typeof popUp == 'object') { popUp.focus(); }
    return false;
}

// A general-purpose popup window function
function popupFullWindow(uri) {
    var windowName = 'popup';
    if(arguments.length > 3) {
        windowName = arguments[3];
    }
    //alert(width);
    var popUp = window.open(uri, '_blank');
    if (typeof popUp == 'object') { popUp.focus(); }
    return false;
}


// This function is used to make sure that required form fields have values.
//    Field_Name: name of a form field in the form of document.form_name.form_field_name that will be validated.
//    Error_Message: this is the alert error message that will be displayed to the user.
function Has_Value(Field_Name, Error_Message) {
	var text;

	text = Field_Name.value;

	while(text.search(/\s/) > -1) {
        text = text.replace(/\s/, "");
    }

    if(text == 0) {
        alert(Error_Message);
        Field_Name.focus();
        return false;
    }
    return true;
}

// IS_VALID_EMAIL( emailaddy )
// Returns TRUE if Email is valid and FALSE if NOT VALID
function Is_Valid_Email( emailaddy ){
    var tempchar;       // temp holder
    var atPos;          // string position holder
    var periodPos;      // position of the period in string
    var invalchar = "/:,;"; // not valid email characters
    // if the email string is empty return false
    //if( Is_Empty( emailaddy ) ){ return false; }
    // Loop through each invalid character
    for( count = 0; count < invalchar.length; count++ ){
        // Pull one character out of the string
        tempchar = invalchar.charAt( count );
        // If an invalid character is found return false
        if( emailaddy.indexOf( tempchar, 0 ) > -1 ){
            return false;
        }
    }
    // find and store the position of the at sign
    atPos = emailaddy.indexOf( "@", 1 );
    // If no at sign is in the string return false
    if( atPos == -1 ){ return false; }
    // If at sign is the last character in the string return false
    if( emailaddy.indexOf( "@", atPos + 1 ) > -1 ){ return false; }
    // Find and store the position of the period in the email string
    periodPos = emailaddy.indexOf(".", atPos);
    // If there is no period in the string return false
    if( periodPos == -1 ){ return false; }
    // If the period is less than 3 characters from
    // the end of the string return false
    if( periodPos + 3 > emailaddy.length ){ return false; }
    // all is well this is a valid email address so return true
    return true;
}
// END OF FUNCTION

function Is_Valid_Date(Field_Name, Error_Message) {
	//This function will validate a form date field to make sure that its in the proper
	//format.  It will accept dates in the following format: mm/dd/yyyy || m/dd/yyyy || m/d/yy ||
	// 	m/dd/yy || mm/d/yy || any valid date that is delemitted by the '/' symbol.
	//Field_Name: name of a form field in the form of document.form_name.form_field_name that will be validated.
	//Error_Message: this is the alert error message that will be displayed to the user.
	if (!Is_Date(Field_Name, Error_Message)) {
		alert(Error_Message);
		Field_Name.focus();
		return false;
	}
	//everything passed so...
	return true;
}

function Is_Date(Field_Name) {
	//Returns true if value is a date format or is NULL
	//otherwise returns false

	if (Field_Name.value.length == 0) return true;

	//Returns true if value is a date in the mm/dd/yyyy format
	isplit = Field_Name.value.indexOf('/');
	if (isplit == -1 || isplit == Field_Name.value.length) {
		return false;
	}

	sMonth = Field_Name.value.substring(0, isplit);
	if (sMonth.length == 0) {
		return false;
	}

	isplit = Field_Name.value.indexOf('/', isplit + 1);
	if (isplit == -1 || (isplit + 1 ) == Field_Name.value.length) {
		return false;
	}

	sDay = Field_Name.value.substring((sMonth.length + 1), isplit);
	if (sDay.length == 0) {
		return false;
	}

	sYear = Field_Name.value.substring(isplit + 1);
	if (!_CF_checkinteger(sMonth)) {				//check month
		return false;
	} else if (!_CF_checkrange(sMonth, 1, 12)) {	//check month
		return false;
	} else if (!_CF_checkinteger(sYear))  {			//check year
		return false;
	} else if (!_CF_checkrange(sYear, 0, 9999)) {	//check year
		return false;
	} else if (sYear.length != 4) {
		return false;
	}

	//check day
	if (!_CF_checkinteger(sDay)) {
		return false;
	} else if (!_CF_checkday(sYear, sMonth, sDay)) {
		return false;
	} else {
		return true;
	}
}


function _CF_checkday(checkYear, checkMonth, checkDay) {
	maxDay = 31;
	if (checkMonth == 4 || checkMonth == 6 || checkMonth == 9 || checkMonth == 11) {
		maxDay = 30;
	} else {
		if (checkMonth == 2) {
			if (checkYear % 4 > 0) {
				maxDay =28;
			} else {
				if (checkYear % 100 == 0 && checkYear % 400 > 0) {
					maxDay = 28;
				} else {
					maxDay = 29;
				}
			}
		}
	}
	return _CF_checkrange(checkDay, 1, maxDay); //check day
}

function _CF_checkinteger(Field_Name) {
	//Returns true if value is a number or is NULL
	//otherwise returns false

	if (Field_Name.length == 0) return true;

	//Returns true if value is an integer defined as
	//   having an optional leading + or -.
	//   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

	//The first character can be + -  blank or a digit.
	check_char = Field_Name.indexOf(decimal_format)
	//Was it a decimal?
	if (check_char < 1)	{
		return _CF_checknumber(Field_Name);
	} else {
		return false;
	}
}

function _CF_numberrange(Field_Name, min_value, max_value) {
	// check minimum
	if (min_value != null) {
		if (Field_Name < min_value) {
			return false;
		}
	}
	// check maximum
	if (max_value != null) {
		if (Field_Name > max_value) {
			return false;
		}
	}
	//All tests passed, so...
	return true;
}

function _CF_checknumber(Field_Name) {
	//Returns true if value is a number or is NULL
	//otherwise returns false

	if (Field_Name.length == 0) return true;

	//Returns true if value is a number defined as
	//   having an optional leading + or -.
	//   having at most 1 decimal point.
	//   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

	//The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(Field_Name.charAt(0))
	//Was it a decimal?
	if (check_char == 1) {
		decimal = true;
	} else if (check_char < 1) {
		return false;
	}

	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < Field_Name.length; i++) {
		check_char = number_format.indexOf(Field_Name.charAt(i));
		if (check_char < 0) {
			return false;
		} else if (check_char == 1) {
			// Second decimal.
			if (decimal) {
				return false;
			} else {
				decimal = true;
			}
		} else if (check_char == 0) {
			// ignore leading blanks
			if (decimal || digits) trailing_blank = true;
		} else if (trailing_blank) {
			return false;
		} else {
			digits = true;
		}
	}
	//All tests passed, so...
	return true
}

function _CF_checkrange(Field_Name, min_value, max_value) {
	//if value is in range then return true else return false

	if (Field_Name.length == 0) return true;

	if (!_CF_checknumber(Field_Name)) {
		return false;
	} else {
		return (_CF_numberrange((eval(Field_Name)), min_value, max_value));
	}

	//All tests passed, so...
	return true;
}

	retVal = true;

	/************************************************
	 * Validates dates
	 * Depends: showMsg(),noError(),Is_Date()
	 * Arguments:
	 * 		field: the form field to be validate
	 * 		constraint: a comma separated argument, with either of: onlypast, onlyfuture
	 * 					if constraint is not passed, date will be validated generally
	 *		popUpMsg: if true indicates that a popup should be displayed (instead of displaying the error message in-line on the page);
	 *
	 ************************************************/
	function validDate(field) {
	    constraint = ((arguments[1]>"")&&(arguments[1]!="undefined"))?arguments[1]:"";
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
		if (field.value <= "") {
			retVal = false;
	    } else if (!Is_Date(field)) {
	        retVal = false;
	    } else {
			if (constraint > "") {
				todayDate = new Date();
				todayDate = todayDate.getTime();
				theDate = Date.parse(field.value);
				if (constraint.indexOf("onlypast")>=0) {
					if (todayDate > theDate) {
						retVal = true;
					} else {
						retVal = false;
					}
				} else if (constraint.indexOf("onlyfuture")>=0) {
					if (todayDate < theDate) {
						retVal = true;
					} else {
						retVal = false;
					}
				} else {
					retVal = true;
				}
			}
	    }
		if (!retVal) {
			field.onchange = function () { validDate(field,constraint,popUpMsg) };			//set field to recall this fn onChange
	        showMsg("Please enter a valid future date.",field,popUpMsg);					//show user the Error
        } else {
	        noError(field,popUpMsg);														//unset Error indicators
	        retVal = true;
		}
	    return retVal;
	}


	/************************************************
	 * Validates zip/postal numbers (US & Canada)
	 * Depends: showMsg(),noError()
	 ************************************************/
	function validPostal(field,fDesc) {
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
	    reFull =/^[0-9]{5}-[0-9]{4}$/;														//regular expression matching US Zip+4
	    reZip =/^[0-9]{5}$/;																//regular expression matching US Zip
	    reCan =/^[abceghj-np-tvxyABCEGHJ-NPRSTVXY]\d[abceghj-nprstvwxyzABCEGHJ-NPRSTVWXYZ]( )?\d[abceghj-nprstvwxyzABCEGHJ-NPRSTVWXYZ]\d$/    //regular expression matching Canadian Postal Code
	    if ((field.value.search(reFull) == -1) && (field.value.search(reZip) == -1) && (field.value.search(reCan) == -1)) cleaned = false;
	    else cleaned = true;
	    if(!cleaned) {
	        field.onchange = function () { validPostal(field,popUpMsg) };					//set field to recall this fn onChange
	        showMsg(fDesc + ".",field,popUpMsg);		//show user the Error
	        retVal = retVal && cleaned;
	    } else {
	        noError(field,popUpMsg);														//unset Error indicators
	        retVal = true;
	    }
	    return retVal;
	}

	/************************************************
	 * Validates zip/postal numbers (US & Canada)
	 * Depends: showMsg(),noError()
	 ************************************************/
	function validPhone(field,fDesc) {
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
		phoneNum = field.value.replace(/\D/g,"");
		cleaned = (phoneNum.length == 10)?true:false;
	    if(!cleaned) {
	        field.onchange = function () { validPhone(field,popUpMsg) };					//set field to recall this fn onChange
	        showMsg(fDesc + ".",field,popUpMsg);			//show user the Error
	        retVal = retVal && cleaned;
	    } else {
	        noError(field,popUpMsg);														//unset Error indicators
	        retVal = true;
	    }
	    return retVal;
	}

	/************************************************
	 * Validates email addresses
	 * Depends: showMsg(),noError()
	 ************************************************/
	function validEmail(field,fDesc) {
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
	    //re =/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/;
	    re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    if(field.value.search(re) == -1) {													//if not valid
	        field.onchange = function () { validEmail(field,popUpMsg) };					//set field to recall this fn onChange
	        showMsg(unescape(fDesc) + ".",field,popUpMsg);					//show user the Error
	        retVal = false;
	    } else {
	        retVal = true;
	        noError(field,popUpMsg);														//unset Error indicators
	    }
	    return retVal;
	}

	/************************************************
	 * Validates general text fields (tests for any value)
	 * Depends: showMsg(),noError()
	 ************************************************/
	function hasValue(field,fDesc) {
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
	    if (field.value>"") {
	        noError(field,popUpMsg);														//unset Error indicators
	    } else {
	        field.onchange = function () { hasValue(field,fDesc,popUpMsg) };				//set field to recall this fn onChange
	        showMsg(fDesc+".",field,popUpMsg);							//show user the Error
	        retVal = false;
	    }
	    return retVal;
	}

	/************************************************
	 * Validates general text fields (tests for any value)
	 * Depends: showMsg(),noError()
	 ************************************************/
	function hasSelectedValue(field,fDesc) {
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
	    if (field.options[field.selectedIndex].value > "") {
	        noError(field,popUpMsg);														//unset Error indicators
	    } else {
	        field.onchange = function () { hasSelectedValue(field,fDesc,popUpMsg) };		//set field to recall this fn onChange
	        showMsg(fDesc+".",field,popUpMsg);												//show user the Error
	        retVal = false;
	    }
	    return retVal;
	}

	/************************************************
	 * Validates general text fields (tests for any value)
	 * Depends: showMsg(),noError()
	 ************************************************/
	function hasOtherValue(field,fDesc) {
		fieldOther = document.getElementById(field.id + "_other");
	    popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
		if (field.value == "Other" && (fieldOther.value <= "" || fieldOther.value == "(Please Specify)")) {
	        field.onchange = function () { hasOtherValue(field,fDesc,popUpMsg) };		//set field to recall this fn onChange
			showMsg(fDesc+".",field,popUpMsg);
			retVal = false;
		} else {
			noError(field,popUpMsg);
		}
		ShowOther(field);
	    return retVal;
	}


	/***********************************************************
	 * Shows "interactive" error status of form field
	 * Depends: Must have appropriately named Error DIV in HTML, unless using popup alert method.
	 ***********************************************************/
	function showMsg(msg,field) {
	  popUpMsg = ((arguments[2]>"")&&(arguments[2]!="undefined"))?arguments[2]:"";
	  if ((!field.oBGC)&&(field.style.backgroundColor!="pink")) field.oBGC = field.style.backgroundColor;  //save field bG color
	  field.style.backgroundColor = "pink";													//set field Error bG color
	  if (popUpMsg) {
	    alert(msg);																			//alert message text
	  } else {
	    errSpan = eval("document.getElementById('"+field.name+"_error')");
	    errSpan.innerHTML = msg;
	  }
	  field.focus();																		//put focus on offending field
	  return;
	}

	/********************************************************
	 * Removes error highlighting as set by showMsg function
	 * Depends: Must have appropriately named Error DIV in HTML, unless using popup alert method.
	 ********************************************************/
	function noError(field,popUpMsg) {
	  if (field.style.backgroundColor == "pink") field.style.backgroundColor = field.oBGC;	//reset field bG color
	  if (!popUpMsg) {
	    errSpan = eval("document.getElementById('"+field.name+"_error')");					//get error Span
	    errSpan.innerHTML = ""																//empty it
	  }
	}



function getRadioValue( radio ) {
	var i;
	for( i = 0; i < radio.length; i++ ) {
		if( radio[i].checked )
			return radio[i].value;
	}
	return null;
}


function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xHide2(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
  if(e.style && xDef(e.style.visibility)) e.style.display='none';
}

function HideAll(className) {
  var e=document.getElementsByTagName("div");
  var j =0;
  for(var i=0;i<e.length;i++) {
    if (e[i].className == className ) {
      j++;
      xHide2(e[i].id);
    }
  }
}

function ShowHide(e) {
  if(!(e=xGetElementById(e))) return;

  //alert(e.className);
  if (e.className == "FAQSection") { HideAll('FAQSection'); }

  if (e.className == "A") { HideAll('A')  }

  if (e.style && e.style.visibility == 'visible') {
  	e.style.visibility = "hidden";
  	e.style.display = "none";
  } else {
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
  if(e.style && xDef(e.style.display)) e.style.display='inline';
  }

}

function isempty(testvar) {
    empty = (testvar==="")
    empty = empty && typeof(window[testvar])==='undefined'
}

function ShowOther(field) {
	targetField = document.getElementById(field.id+"_other");
	if (field.options[field.selectedIndex].value == "Other") {
		targetField.type = 'text';
	} else {
		targetField.value = '(Please Specify)';
		targetField.type = 'hidden';
	}
}

function getDirections(destHref){
	if (destHref > '') {
		w=window;
		nb='&nbsp;';
		dest = unescape(destHref.split("maps?q=")[1])
		sT = dest.replace(/\s/g,"+");
		G=w.open('http://maps.google.com/maps?q='+escape(sT),'_blank');
	}
}

// Dan's FluidMind functions //
// Make sure the "FM" namespace object exists
if (typeof FM != 'object') {
    FM = new Object();
}

/**
 * Checks a given class attribute for the presence of a given class
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   element         DOM Element object (or element ID) to remove the class from
 * @param   nameOfClass     The name of the CSS class to check for
 */
FM.checkForClass = function(element, nameOfClass) {
    if (typeof element == 'string') { element = document.getElementById(element); }
    if (element.className == '') {
        return false;
    } else {
        return new RegExp('\\b' + nameOfClass + '\\b').test(element.className);
    }
}


/**
 * Adds a class to an element's class attribute
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   element         DOM Element object (or element ID) to add the class to
 * @param   nameOfClass     Class name to add
 * @see     checkForClass
 */
FM.addClass = function(element, nameOfClass) {
    if (typeof element == 'string') { element = document.getElementById(element); }

    if (!FM.checkForClass(element, nameOfClass)) {
        element.className += (element.className ? ' ' : '') + nameOfClass;
        return true;
    } else {
        return false;
    }
}


/**
 * Removes a class from an element's class attribute
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   element         DOM Element object (or element ID) to remove the class from
 * @param   nameOfClass     Class name to remove
 * @see     checkForClass
 */
FM.removeClass = function(element, nameOfClass) {
    if (typeof element == 'string') { element = document.getElementById(element); }

    if (FM.checkForClass(element, nameOfClass)) {
        element.className = element.className.replace(
            (element.className.indexOf(' ' + nameOfClass) >= 0 ? ' ' + nameOfClass : nameOfClass),
            '');
        return true;
    } else {
        return false;
    }
}


/**
 * Replaces a class with another if the class is present
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   element         DOM Element object (or element ID) to remove the class from
 * @param   class1          Class name to replace
 * @param   class2          Class name to replace it with
 * @see     checkForClass
 * @see     addClass
 * @see     removeClass
 */
FM.replaceClass = function(element, class1, class2) {
    if (typeof element == 'string') { element = document.getElementById(element); }

    if (FM.checkForClass(element, class1)) {
        FM.removeClass(element, class1);
        FM.addClass(element, class2);
        return true;
    } else {
        return false;
    }
}


/**
 * Toggles the specified class on and off
 *
 * @author  Dan Delaney     http://fluidmind.org/
 * @param   element         DOM Element object (or element ID) to toggle the class of
 * @param   nameOfClass     Class name to toggle
 * @see     checkForclass
 * @see     addClass
 * @see     removeClass
 */
FM.toggleClass = function(element, nameOfClass) {
    if (typeof element == 'string') { element = document.getElementById(element); }

    if (FM.checkForClass(element, nameOfClass)) {
        FM.removeClass(element, nameOfClass);
    } else {
        FM.addClass(element, nameOfClass);
    }

    return true;
}
// Dan's FluidMind functions //

// OnLoad Stuff
addOnLoad(sfHover);
addOnLoad(globalOnLoad);
if (typeof onLoad != 'undefined') {
	addOnLoad(onLoad);
}