/*the base image directory location*/
var base = "/images/";

/*********
pop up a new window
*********/
function openWindow(url,x,y,toolbar,scrollbars,resizable)
{
	new_x=x+20;
	new_y=y+20;
	var options = "toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",width=" + new_x + ",height=" + new_y;
	newWindow=window.open(url,"WinOpen",options);
}

/*********
switch an image with an ID
*********/
function switchImage(thisId,thisImageSlice)
{
	//is the text "_off" inside this btn?
	if (document.getElementById(thisId).src.indexOf('_off.') < 0)
	{
		thisImg=base+thisImageSlice+thisId+'_off.gif';
	}
	else
	{
		thisImg=base+thisImageSlice+thisId+'_on.gif';
	}
	//set the image
	document.getElementById(thisId).src=thisImg;
}
function toggleImage(obj)
{
	// The image is currently in the OFF state
	if (obj.src.indexOf('_off.') < 0)
	{
		obj.src = obj.src.replace('_on', '_off');
	}
	// The image is currently in the ON state
	else
	{
		obj.src = obj.src.replace('_off', '_on');
	}
}

/*********
expand code for both browsers
*********/
function expandIt(whichEl){
	var browser=navigator.userAgent.toLowerCase();
	var pos=browser.indexOf("gecko");
	var myElement = document.getElementById(whichEl);
	//do for Gecko Browsers
	if (pos>=0) {
		if (myElement.style.visibility == 'visible') {
			myElement.style.visibility = 'hidden';
			myElement.style.position = 'absolute';
			}
		else {
			myElement.style.position = 'relative';
			myElement.style.visibility = 'visible';
			}
	//do for IE
	} else {
		myElement.style.display = (myElement.style.display == "none" ) ? "" : "none";
	}
}

/*********
toggle the text inside a form on/off
*********/
function toggleFormText(thisId, thisText)
{
	if (document.getElementById(thisId).value == thisText)
	{
		document.getElementById(thisId).value='';
	}
	else if (document.getElementById(thisId).value == '')
	{
		document.getElementById(thisId).value=thisText;
	}
}


/************
getFormType - Returns a string name of the type of form object. The types are: select, radio, button, submit, hidden, textarea, text
************/
function getFormType(formObject)
{
	type = formObject.type;

	// Make the select type simpler, we don't care which kind of select as long as it's a select
	if ((formObject.type == 'select-one') || (formObject.type == 'select-multiple'))
		type = 'select';

	return type;
}

/*********
validates an email address
*********/
function validateEmail(thisEmail)
{
	//initiate returnMessage variable
	var returnMessage="";

	if(thisEmail == '')
	{
		// alert the user
		returnMessage = "Please type in a valid email address.";
	}
	else
	{
		// function to check email address vilidity
		function emailCheck(emailStr)
		{
			/* The following pattern is used to check if the entered e-mail address
			   fits the user@domain format.  It also is used to separate the username
			   from the domain. */
			var emailPat=/^(.+)@(.+)$/
			/* The following string represents the pattern for matching all special
			   characters.  We don't want to allow special characters in the address.
			   These characters include ( ) < > @ , ; : \ " . [ ]    */
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			/* The following string represents the range of characters allowed in a
			   username or domainname.  It really states which chars aren't allowed. */
			var validChars="\[^\\s" + specialChars + "\]"
			/* The following pattern applies if the "user" is a quoted string (in
			   which case, there are no rules about which characters are allowed
			   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
			   is a legal e-mail address. */
			var quotedUser="(\"[^\"]*\")"
			/* The following pattern applies for domains that are IP addresses,
			   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
			   e-mail address. NOTE: The square brackets are required. */
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			/* The following string represents an atom (basically a series of
			   non-special characters.) */
			var atom=validChars + '+'
			/* The following string represents one word in the typical username.
			   For example, in john.doe@somewhere.com, john and doe are words.
			   Basically, a word is either an atom or quoted string. */
			var word="(" + atom + "|" + quotedUser + ")"
			// The following pattern describes the structure of the user
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			/* The following pattern describes the structure of a normal symbolic
			   domain, as opposed to ipDomainPat, shown above. */
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


			/* Finally, let's start trying to figure out if the supplied address is
			   valid. */

			/* Begin with the coarse pattern to simply break up user@domain into
			   different pieces that are easy to analyze. */
			var matchArray=emailStr.match(emailPat);
			//alert(emailStr);
			var checkMatch='-' + matchArray + '-';
			if (checkMatch == "-null-")
			{
			  /* Too many/few @'s or something; basically, this address doesn't
				 even fit the general mould of a valid e-mail address. */
				returnMessage = "The email address seems incorrect (check @ and .'s).";
			}
			else
			{
				var user=matchArray[1];
				var domain=matchArray[2];

				// See if "user" is valid
				if (user.match(userPat)==null)
				{
					// user is not valid
					returnMessage = "The email's username doesn't seem to be valid (before the @).";
				}

				/* if the e-mail address is at an IP address (as opposed to a symbolic
				   host name) make sure the IP address is valid. */
				var IPArray=domain.match(ipDomainPat)
				if (IPArray!=null) {
					// this is an IP address
					  for (var i=1;i<=4;i++) {
						if (IPArray[i]>255) {
							returnMessage = "The email's destination IP address is invalid.";
						}
					}
				}

				// Domain is symbolic name
				var domainArray=domain.match(domainPat)
				if (domainArray==null) {
					returnMessage = "The email's domain name doesn't seem to be valid (after the @).";
				}

				/* domain name seems valid, but now make sure that it ends in a
				   three-letter word (like com, edu, gov) or a two-letter word,
				   representing country (uk, nl), and that there's a hostname preceding
				   the domain or country. */

				/* Now we need to break up the domain to get a count of how many atoms
				   it consists of. */
				var atomPat=new RegExp(atom,"g")
				var domArr=domain.match(atomPat)
				var len=domArr.length
				if (domArr[domArr.length-1].length<2 ||
					domArr[domArr.length-1].length>4) {
				   // the address must end in a two letter or three letter word.
				   returnMessage = "The email must end in a four-letter domain, three-letter domain, or two letter country.";
				}

				// Make sure there's a host name preceding the domain.
				if (len < 2) {
				   returnMessage="This email is missing a hostname!";
				}
			}
		}
		// call the validation function and return its result
		val=emailCheck(thisEmail);
		// if it returns val=no_submit, stop form
	}
	return returnMessage;
}

/************
verify Contact Form
************/
function verifyContactForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formContact';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check comment
	if (submitForm)
	{
		formElement="comments";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a comment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify NextGen Summit Form
************/
function verifyNextGenSummitForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formNextGenSummit';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check completed_form
	/*if (submitForm)
	{
		formElement="completed_form";
		thisDOM = eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please click "Browse" and select your completed form.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//confirm .doc extension on the form
	if (submitForm)
	{
		formElement="completed_form";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value.search('.doc') == -1)
		{
			warningMessage='Please confirm that the form you completed is submitted to us as a Microsoft Word document.';
			formFocus=formElement;
			submitForm=false;
		}
	}*/

	//check name_first
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check name_last
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check address
	if (submitForm)
	{
		formElement="address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check city
	if (submitForm)
	{
		formElement="city";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check state
	if (submitForm)
	{
		formElement="state";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check zip
	if (submitForm)
	{
		formElement="zip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your zip/postal code.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check country
	if (submitForm)
	{
		formElement="country";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your country.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check church
	if (submitForm)
	{
		formElement="church";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your church/organization.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check title
	if (submitForm)
	{
		formElement="title";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your title.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check phone
	if (submitForm)
	{
		formElement="phone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}
	//check comment
	if (submitForm)
	{
		formElement="comments";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a comment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


/************
verify Newsletter
************/
function verifyNewsletterSubscribe(checkboxCount)
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formNewsletterSubscribe';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name_first
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check for newsletter category checked
	if (checkboxCount > 0)
	{
		if (submitForm)
		{
			newsletterSelected=false;
			formElement="newsletter_categories";
			thisDOM=eval('document.' + formName + '.' + formElement);
			// loop thru all the checkboxes in the page
			for (var i=1; i <= checkboxCount; i++)
			{
				if (document.getElementById('checkbox' + i).checked)
				{
					newsletterSelected=true;
				}
			}
			// no newsletter selected, don't submit the form
			if (!newsletterSelected)
			{
				warningMessage="Please select a newsletter to subscribe to.";
				submitForm=false;
			}
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Send to a Friend
************/
function verifySendToAFriend()
{
	//form variables
	submitBtnMessage='Sending... Please Wait';
	formName='formSendToAFriend';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";
	toEmailFound=false;

	//check friends_emails
	if (submitForm)
	{
		formElement="to_email_1";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus=formElement;
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			// set variable so next function knows a to_email has been found
			toEmailFound=true;
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
				toEmailFound=true;
			}
		}
	}

	//check the second email
	if (!toEmailFound)
	{
		formElement="to_email_2";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus="to_email_1";
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			// set variable so next function knows a to_email has been found
			toEmailFound=true;
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
			}
		}
	}

	//check the third email
	if (!toEmailFound)
	{
		formElement="to_email_3";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in an email address.';
			formFocus="to_email_1";
			submitForm=false;
		}
		// verify correctly formed email
		else
		{
			//check the email address
			thisMessage=validateEmail(thisDOM.value);
			//if there is no message sent back, set the alert.
			if (thisMessage.length != 0)
			{
				warningMessage=thisMessage;
				formFocus=formElement;
				submitForm=false;
			}
		}
	}

	//check from name
	if (submitForm)
	{
		formElement="from_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="from_email";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Job Application
************/
function verifyJobsApplication()
{
	//form variables
	submitBtnMessage='Sending... Please Wait';
	formName='formJobsApplication';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check first name
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check last name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check resume
	if (submitForm)
	{
		formElement="resume";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in or copy and paste resume here.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check reference
	if (submitForm)
	{
		formElement="jobs_references_id";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please let us know how you heard about this position.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
verify Annual Report
************/
function verifyAnnualReportForm()
{
	document.getElementById("formAnnualReport").submit();
	document.getElementById("formAnnualReport").onsubmit();
}

/************
navigation popup for sites not in foursquare.org
************/
function navPopupChangeLinks(fromLeft,fromTop)
{
	for (var i=0; i < document.links.length; i++)
	{
		// don't change if link has /javascript: in it
		if (document.links[i].href.indexOf("javascript:") == -1)
		{
			// replace any ampersands in the url with the string "ampersand" so that it's correctly passed and parsed on the popup page (otherwise it wouldn't recognize the url variables)
			document.links[i].onclick = function () { if (checkWebsiteNetwork(this.href) == -1) {navPopupShowWindow(this.href.replace('&','[ampersand]'),this.target,fromLeft,fromTop); return false;} };
		}
	}
	return true;
}

/************
navigation popup for sites not in foursquare.org
************/
function navPopupShowWindow(thisURL,thisTarget,thisLeft,thisTop)
{
	thisWidth = 760;
	thisHeight = 550;
	// open the window
	navURL = "/nav_popup.sd?sendTo=" + thisURL + "&thisTarget=" + thisTarget;
	newWindow = window.open(navURL, "NavPopup", "menubar=yes, location=yes, toolbar=yes, scrollbars=yes, resizable=yes, width=" + thisWidth +", height=" + thisHeight +",left=" + thisLeft +",top=" + thisTop);
}

/************
navigation popup for sites not in foursquare.org
************/
function checkWebsiteNetwork(thisURL)
{
	// set a variable to store whether or not this is part of the foursquare network of sites, -1 = false
	var withinNetwork = -1;
	var i = 0;

	// create an array of all the foursquare URLs
	var urls = new Array;
	urls[0] = "foursquare.org";
	urls[1] = "foursquarechurch.org";
	urls[2] = "worldbase.org";
	urls[3] = "worldbasela.com";
	urls[4] = "theheritagectr";
	urls[5] = "foursquareconvention";
	urls[6] = "foursquareassociation";
	urls[7] = "israel2007.org";
	urls[8] = "foursquareisrael2007.org";
	urls[9] = "foursquaremissionspress.com";
	urls[10] = "foursquarefoundation";
	urls[11] = "foursquarefoundation.net";
	urls[12] = "lifepacific.edu";
	urls[13] = "reachmore.org";
	urls[14] = "foursquarenextgensummit.com";
	urls[15] = "foursquarenextgensummit.net";
	urls[16] = "foursquarenextgensummit.org";
	urls[17] = "foursquarengs.com";
	urls[18] = "foursquarengs.net";
	urls[19] = "foursquarengs.org";
	urls[20] = "nextgensummit.com";
	urls[21] = "nextgensummit.net";
	urls[22] = "nextgensummit.org";
	urls[23] = "crosspointeconferencecenter.org";
	urls[24] = "foursquareglobalconnect.org";
	urls[25] = "foursquaremissions.blogspot.com";
	urls[26] = "foursquareconnection.org";
	urls[27] = "7fourteen.org";

	// loop through all the items and check if
	for (i=0; i < urls.length; i++)
	{
		withinNetwork = thisURL.indexOf(urls[i]);
		if (withinNetwork > -1)
		{
			break;
		}
	}
	return withinNetwork;
}

// loop thru all links in the page, and disable them only if not media library
function disableAllLinks()
{
	for (var i=0; i < document.links.length; i++)
	{
		document.links[i].onclick=function () { return false; };
		document.links[i].title="All links are disabled while previewing a document.";
	}
	return true;
}
// loop thru all forms in the page, and disable them
function disableAllFormElements()
{
	for (var i=0; i < document.forms.length; i++)
	{
		for (var j=0; j < document.forms[i].length; j++)
		{
			document.forms[i].elements[j].disabled = true;
		}
		document.forms[i].onfocus = function () {return false; };
		document.forms[i].onclick = function () { return false; };
		document.forms[i].title="All forms are disabled while previewing a document.";
	}
	return true;
}

/************
institute Form Confirmation
************/
function verifyInstitutesForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formInstitutes';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check first name
	if (submitForm)
	{
		formElement="first_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check last name
	if (submitForm)
	{
		formElement="last_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	// check uploadedDocument
	if (submitForm)
	{
		formElement = "uploadedDocument";
		thisDOM = eval('document.' +formName + '.' + formElement);

		if (thisDOM.value != "")
		{
			// check for the extensions
			if ((thisDOM.value.indexOf('.pdf') > 0) || (thisDOM.value.indexOf('.doc') > 0))
			{
				submitForm = true;
			}
			// no proper extension found
			else
			{
				warningMessage = "Please upload either a .doc or .pdf document file.";
				formFocus = formElement;
				submitForm = false;
			}
		}
		// no file uploaded
		else
		{
			warningMessage = "Please upload either a .doc or .pdf document file.";
			formFocus = formElement;
			submitForm = false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}
	else
	{
		formElement = "submitButton";
		thisDOM=eval('document.' + formName + '.' + formElement);
		thisDOM.value="Uploading Document ... Please Wait...";
		this.DOM.className='formSubmitDisabledSending';
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


/************
FAQ Comment Confirmation
************/
function verifyFAQCommentForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formFAQComment';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check first name
	if (submitForm)
	{
		formElement="name_first";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your first name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check last name
	if (submitForm)
	{
		formElement="name_last";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your last name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check comment
	if (submitForm)
	{
		formElement="comments";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a comment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}
	else
	{
		formElement = "submitButton";
		thisDOM=eval('document.' + formName + '.' + formElement);
		thisDOM.value="Uploading Document ... Please Wait...";
		this.DOM.className='formSubmitDisabledSending';
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


/************
ASSOCIATION - Church Membership Application
************/
function verifyFormChurchMembershipApplication()
{
   // form variables
   submitBtnMessage = 'Saving... Please Wait';
   formName = 'formChurchMembershipApplication';

   submitForm = true;

   // initialize submitForm value
   warningMessage = '';
   formFocus = '';

   // check name_of_church
   if (submitForm)
   {
      formElement = 'name_of_church';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the name of your church.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check denomination
   if (submitForm)
   {
      formElement = 'denomination';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your denomination.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check mailing_address
   if (submitForm)
   {
      formElement = 'mailing_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your mailing address.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check mailing_city
   if (submitForm)
   {
      formElement = 'mailing_city';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your mailing city.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check mailing_state
   if (submitForm)
   {
      formElement = 'mailing_state';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your mailing state.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check mailing_zip
   if (submitForm)
   {
      formElement = 'mailing_zip';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your mailing zip.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check location_address
   if (submitForm)
   {
      formElement = 'location_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your location address.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check location_city
   if (submitForm)
   {
      formElement = 'location_city';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your location city.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check location_state
   if (submitForm)
   {
      formElement = 'location_state';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your location state.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check location_zip
   if (submitForm)
   {
      formElement = 'location_zip';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your location zip.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check name_of_contact
   if (submitForm)
   {
      formElement = 'name_of_contact';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the name of contact.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check position
   if (submitForm)
   {
      formElement = 'position';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the position of the contact.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_office
   if (submitForm)
   {
      formElement = 'phone_office';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the office phone of the contact.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_emergency
   if (submitForm)
   {
      formElement = 'phone_emergency';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your emergency phone of the contact.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_fax
   if (submitForm)
   {
      formElement = 'phone_fax';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your fax number of the contact.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check email_address
   if (submitForm)
   {
      formElement = 'email_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      thisMessage = validateEmail(thisDOM.value);
      if (thisMessage.length != 0)
      {
         warningMessage = thisMessage;
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check senior_pastor
   if (submitForm)
   {
      formElement = 'senior_pastor';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your senior pastor\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_existence
   if (submitForm)
   {
      formElement = 'church_existence';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the years of your church\'s existence.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_location
   if (submitForm)
   {
      formElement = 'church_location';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select your church location.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check attendance
   if (submitForm)
   {
      formElement = 'attendance';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select the average weekend attendance of your church.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check types_of_ministries
   if (submitForm)
   {
      elementChecked = false;
      i = 0;
      formElement = 'types_of_ministries';
      thisDOM = eval('document.' + formName + '.' + formElement);

      // if there is only a single checkbox with this name
      if(thisDOM.length == undefined)
      {
         // if no element was checked, set message
         if (!thisDOM.checked)
         {
            warningMessage = 'Please select the current types of ministries at your church.';
            formFocus = formElement;
            submitForm = false;
         }
      }
      // else there are multiple checkboxes with this name
      else
      {
         // loop through each checkbox in the group and see if any of them are checked
         while (!elementChecked && (i < thisDOM.length))
         {
            if (thisDOM[i].checked)
            {
               elementChecked = true;
            }
            i++;
         }
         // if no element was checked, set message
         if (!elementChecked)
         {
            warningMessage = 'Please select the current types of ministries at your church.';
            formFocus = formElement + '[0]';
            submitForm = false;
         }
      }
   }

   // check number_of_ministers
   if (submitForm)
   {
      formElement = 'number_of_ministers';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select the number of ministers who may participate.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_pastor_name
   if (submitForm)
   {
      formElement = 'endorsing_pastor_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing pastor\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_church_name
   if (submitForm)
   {
      formElement = 'endorsing_church_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing church\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_email_address
   if (submitForm)
   {
      formElement = 'endorsing_email_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      thisMessage = validateEmail(thisDOM.value);
      if (thisMessage.length != 0)
      {
         warningMessage = thisMessage;
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_phone
   if (submitForm)
   {
      formElement = 'endorsing_phone';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing church\'s phone number.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check level_of_interest
   if (submitForm)
   {
      formElement = 'level_of_interest';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select the level of interest.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // disable the form if the form checks out
   if (!submitForm)
   {
      alert(warningMessage);
   }

   // focus the form if necessary
   if (formFocus.length > 0)
   {
      thisDOM = eval('document.' + formName + '.' + formFocus);
      thisDOM.focus();
   }

   // return the boolean value whether or not we should submit this form
   return submitForm;
}


/************
ASSOCIATION - Minister Membership Application
************/
function verifyFormMinisterMembershipApplication()
{
   // form variables
   submitBtnMessage = 'Saving... Please Wait';
   formName = 'formMinisterMembershipApplication';

   submitForm = true;

   // initialize submitForm value
   warningMessage = '';
   formFocus = '';

   // check first_name
   if (submitForm)
   {
      formElement = 'first_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your first name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check last_name
   if (submitForm)
   {
      formElement = 'last_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your last name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check address
   if (submitForm)
   {
      formElement = 'address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your address.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check city
   if (submitForm)
   {
      formElement = 'city';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your city.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check state
   if (submitForm)
   {
      formElement = 'state';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your state.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check zip
   if (submitForm)
   {
      formElement = 'zip';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your zip code.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_home
   if (submitForm)
   {
      formElement = 'phone_home';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your home phone number.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_office
   if (submitForm)
   {
      formElement = 'phone_office';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your office phone number.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check phone_emergency
   if (submitForm)
   {
      formElement = 'phone_emergency';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your emergency phone number.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check email_address
   if (submitForm)
   {
      formElement = 'email_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      thisMessage = validateEmail(thisDOM.value);
      if (thisMessage.length != 0)
      {
         warningMessage = thisMessage;
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check date_of_birth
   if (submitForm)
   {
      formElement = 'date_of_birth';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your date of birth.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check marital_status
   if (submitForm)
   {
      selected = false;
      i = 0;
      formElement = 'marital_status';
      thisDOM = eval('document.' + formName + '.' + formElement);

      // loop through all radio buttons, if any button is selected, set the 'selected' variable to true
      for(i = 0; i < thisDOM.length; i++)
      {
         if (thisDOM[i].checked)
         {
            selected = true;
         }
      }
      // If no radio button is selected
      if (selected == false)
      {
         warningMessage = 'Please select a marital status.';
         formFocus = formElement + '[0]';
         submitForm = false;
      }
   }

   // check spouses_name
   if (submitForm)
   {
      formElement = 'spouses_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your spouse\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check name_of_church
   if (submitForm)
   {
      formElement = 'name_of_church';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in the name of your church.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check denomination
   if (submitForm)
   {
      formElement = 'denomination';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your denomination.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_website
   if (submitForm)
   {
      formElement = 'church_website';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your church\'s website address.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_address
   if (submitForm)
   {
      formElement = 'church_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your church\'s address.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_city
   if (submitForm)
   {
      formElement = 'church_city';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your church\'s city.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_state
   if (submitForm)
   {
      formElement = 'church_state';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your church\'s state.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check church_zip
   if (submitForm)
   {
      formElement = 'church_zip';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your church\'s zip code.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check current_position
   if (submitForm)
   {
      formElement = 'current_position';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select your current ministry position.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check years_in_ministry
   if (submitForm)
   {
      formElement = 'years_in_ministry';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your years in ministry.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check highest_education
   if (submitForm)
   {
      formElement = 'highest_education';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select the highest education level you\'ve completed.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check hear_about
   if (submitForm)
   {
      formElement = 'hear_about';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select how you heard about us.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check interests
   if (submitForm)
   {
      elementChecked = false;
      i = 0;
      formElement = 'interests';
      thisDOM = eval('document.' + formName + '.' + formElement);

      // if there is only a single checkbox with this name
      if(thisDOM.length == undefined)
      {
         // if no element was checked, set message
         if (!thisDOM.checked)
         {
            warningMessage = 'Please inidicate what your interests are.';
            formFocus = formElement;
            submitForm = false;
         }
      }
      // else there are multiple checkboxes with this name
      else
      {
         // loop through each checkbox in the group and see if any of them are checked
         while (!elementChecked && (i < thisDOM.length))
         {
            if (thisDOM[i].checked)
            {
               elementChecked = true;
            }
            i++;
         }
         // if no element was checked, set message
         if (!elementChecked)
         {
            warningMessage = 'Please inidicate what your interests are.';
            formFocus = formElement + '[0]';
            submitForm = false;
         }
      }
   }

   // check endorsing_pastor_name
   if (submitForm)
   {
      formElement = 'endorsing_pastor_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing pastor\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_church_name
   if (submitForm)
   {
      formElement = 'endorsing_church_name';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing church\'s name.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_email_address
   if (submitForm)
   {
      formElement = 'endorsing_email_address';
      thisDOM = eval('document.' + formName + '.' + formElement);

      thisMessage = validateEmail(thisDOM.value);
      if (thisMessage.length != 0)
      {
         warningMessage = thisMessage;
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check endorsing_phone
   if (submitForm)
   {
      formElement = 'endorsing_phone';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please enter in your endorsing pastor\'s phone number.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // check level_of_interest
   if (submitForm)
   {
      formElement = 'level_of_interest';
      thisDOM = eval('document.' + formName + '.' + formElement);

      if (thisDOM.value.search(/\S/) == -1) // Check for at least one non-space character
      {
         warningMessage = 'Please select the level of interest.';
         formFocus = formElement;
         submitForm = false;
      }
   }

   // disable the form if the form checks out
   if (!submitForm)
   {
      alert(warningMessage);
   }

   // focus the form if necessary
   if (formFocus.length > 0)
   {
      thisDOM = eval('document.' + formName + '.' + formFocus);
      thisDOM.focus();
   }

   // return the boolean value whether or not we should submit this form
   return submitForm;
}


/************
verify NPLS Form
************/
function verifyNPLSForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formNPLSStep3';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name_first
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check church
	if (submitForm)
	{
		formElement="church";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your church.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check church_code
	if (submitForm)
	{
		formElement="church_code";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your church code.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check address
	if (submitForm)
	{
		formElement="address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check city
	if (submitForm)
	{
		formElement="city";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check state
	if (submitForm)
	{
		formElement="state";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check zip
	if (submitForm)
	{
		formElement="zip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your zip/postal code.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check phone
	if (submitForm)
	{
		formElement="phone";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your phone number.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}
	//check church_name
	if (submitForm)
	{
		formElement="church_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in a comment.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

/************
change mail 2s
************/
function ytMicfgTo()
{
	var maildivider="iiiicfgatiii" //enter divider you use to divide your email address strings

	for (i=0; i<=(document.links.length-1); i++)
	{
		if (document.links[i].href.indexOf(maildivider)!=-1)
			document.links[i].href=document.links[i].href.split(maildivider)[0]+"@"+document.links[i].href.split(maildivider)[1]
	}
}

/************
Comment Functions
************/
function postComment()
{
	new Effect.ScrollTo ($('showComments'),{queue: 'front'});
	Effect.SlideUp('showComments', { duration: 0.0});
	Effect.SlideDown('showCommentsForm', { duration: 1.0,  delay: 0.5});
	$('comments').update('<a href="javascript:viewComments();" title="Comments"><img alt="Comments" title="Comments" src="/images/tab_comments_off.gif" width="100" height="32" border="0" class="floatl" onMouseOver="javascript:toggleImage(this);" onMouseOut="javascript:toggleImage(this);" /></a>');
	$('postComment').update('<img alt="Post Comments" title="Post Comments" src="/images/tab_post_on.gif" width="100" height="32" border="0" class="floatl" />');
}
function viewComments()
{
	new Effect.ScrollTo ($('showCommentsForm'),{queue: 'front'});
	Effect.SlideUp('showCommentsForm', { duration: 0.0 });
	Effect.SlideDown('showComments', { duration: 0.0});
	$('comments').update('<img alt="Comments" title="Comments" src="/images/tab_comments_on.gif" width="100" height="32" border="0" class="floatl" />');
	$('postComment').update('<a href="javascript:postComment();" title="Post a Comment"><img alt="Post a Comment" title="Post a Comment" src="/images/tab_post_off.gif" width="100" height="32" border="0" class="floatl" onMouseOver="javascript:toggleImage(this);" onMouseOut="javascript:toggleImage(this);" /></a>');
}

/************
verify Contact Form
************/
function verifyCommentForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formComment';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email_address";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}


/************
verify Convention Form
************/
function verifyConventionForm()
{
	//form variables
	submitBtnMessage='Saving... Please Wait';
	formName='formConvention';

	//initialize submitForm value
	submitForm=true;
	warningMessage="";
	formFocus="";

	//check name
	if (submitForm)
	{
		formElement="last_name";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your name.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check address
	if (submitForm)
	{
		formElement="address1";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your address.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check city
	if (submitForm)
	{
		formElement="city";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your city.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check state
	if (submitForm)
	{
		formElement="state";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your state.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check name
	if (submitForm)
	{
		formElement="zip";
		thisDOM=eval('document.' + formName + '.' + formElement);
		if (thisDOM.value == "")
		{
			warningMessage='Please type in your zip code.';
			formFocus=formElement;
			submitForm=false;
		}
	}

	//check the email
	if (submitForm)
	{
		formElement="email";
		thisDOM=eval('document.' + formName + '.' + formElement);
		//check the email address
		thisMessage=validateEmail(thisDOM.value);
		//if there is no message sent back, set the alert.
		if (thisMessage.length != 0)
		{
			warningMessage=thisMessage;
			formFocus=formElement;
			submitForm=false;
		}
	}

	//disable the form if the form checks out
	if (!submitForm)
	{
		alert(warningMessage);
	}

	//focus the form if necessary
	if (formFocus.length > 0)
	{
		thisDOM=eval('document.' + formName + '.' + formFocus);
		thisDOM.focus();
	}

	//return the boolean value whether or not we should submit this form
	return submitForm;
}

