	// JavaScript Document
	var ChurchID_Other = 999999999;

	//------------//
	//  General  //
	//------------//
	function emailpage(sPageName) 	{
		sPageName = sPageName.replace(/&/, "(and)");
		//var URL = 'http://www.lhmmen.com/emailtofriend.asp?page=http://www.lhmmen.com/' + sPageName; 
		var URL = 'emailtofriend.asp?page=http://www.lhmmen.com/' + sPageName; 
		var windowSettings = 'height=530,width=560,top=100,left=250,resizable=yes,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no';
		window.open(URL,'', windowSettings);
	}

	function printpage(sPageName)	{
		var windowSettings = 'height=550,width=700,top=50,left=200,resizable=yes,resizable=yes,scrollbars=yes,menubar=yes,toolbar=no,location=no';
		window.open(sPageName,'', windowSettings);
	}

	function GetToday() {
		var date = new Date();
		var day  = date.getDate();
		var month = date.getMonth() + 1;
		var yy = date.getYear();
		
		var sMonth 
		var sDay
	
		if (month<10) { sMonth = '0'+ month; }
		else { sMonth = '' + month }
		
		if (day<10) { sDay = '0' + day;	}
		else { sDay = '' + day;	}	
		
		return yy + sMonth + sDay;		
	}

	function PopPrivacy() {
		URL = 'http://www.lhm.org/email/privacy.htm';
		window.open(URL,'','height=320,width=365,top=175,left=275');
	}
	
	function emailCheck(strEmail) {
		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */

		var emailStr = strEmail.toLowerCase();			
		var checkTLD=1;

		/* The following is the list of known TLDs that an e-mail address must end with. */
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

		/* 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);

		if (matchArray==null) {
			/* Too many/few @'s or something; basically, this address doesn't
			even fit the general mould of a valid e-mail address. */
			//alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
				
		var user=matchArray[1];
		var domain=matchArray[2];

		// Start by checking that only basic ASCII characters are in the strings (0-127).
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				//alert("Ths username contains invalid characters.");
				return false;
			}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				//alert("Ths domain name contains invalid characters.");
				return false;
			}
		}

		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
			//alert("The username doesn't seem to be valid.");
			return false;
		}

		/* 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) {
					//alert("Destination IP address is invalid!");
					return false;
				 }
			}
			return true;
		}

		// Domain is symbolic name.  Check if it's valid.				 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				//alert("The domain name does not seem to be valid.");
				return false;
			}
		}

		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			//alert("The address must end in a well-known domain or two letter " + "country.");
			return false;
		}

		// Make sure there's a host name preceding the domain.
		if (len<2) {
			//alert("This address is missing a hostname!");
			return false;
		}

		// If we've gotten this far, everything's valid!
		return true;
	} 

	//----------------------------//
	//  Blog register			  //
	//----------------------------//
	function BlogGoState(sState) {
		document.frmReg.selectstate.value = 'yes';
		document.frmReg.stateselected.value = sState;
    	document.frmReg.submit(); 
	}

	function BlogSetChurchName(iChurchID)	{
		var seldiv = document.getElementById('divchurchname');
	
		if (iChurchID == ChurchID_Other) {
			seldiv.style.display = "inline";			
		}
		else {
			seldiv.style.display = "none";			
		}
	}

	function BlogRegisterCheck(){ 
		var reBlank = /^\s*$/;
  
		var strValue = document.frmReg.firstname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your First Name.');  
			document.frmReg.firstname.focus(); 
			return false; } 

		var strValue = document.frmReg.lastname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your Last Name.');  
			document.frmReg.lastname.focus(); 
			return false; } 

		var strValue = document.frmReg.address1.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your Address Line 1.');  
			document.frmReg.address1.focus(); 
			return false; } 

		var strValue = document.frmReg.city.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your City.');  
			document.frmReg.city.focus(); 
			return false; } 

		//if (document.frmReg.state.selectedIndex == 0 ) {
		if (document.frmReg.state.options[document.frmReg.state.selectedIndex].value == '' ) {		
			alert('Please select your State.');  
			document.frmReg.state.focus(); 
			return false; } 

		var strValue = document.frmReg.zip.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your Zip Code.');  
			document.frmReg.zip.focus(); 
			return false; } 

		var strValue = document.frmReg.email.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your E-mail Address.');  
			document.frmReg.email.focus(); 
			return false; } 

		if (reBlank.test(document.frmReg.email2.value)){ 
			alert('Please enter Confirm E-mail Address.');  
			document.frmReg.email2.focus(); 
			return false; } 

		if (strValue != document.frmReg.email2.value ){ 
			alert('Confirm E-mail Address does not match E-mail address.');  
			document.frmReg.email2.focus(); 
			return false; }

		if (!emailCheck(strValue)){
			alert('Please enter a valid E-mail Address.');  
			document.frmReg.email.focus();
			return false;
		}

		if (document.frmReg.congregationstate.selectedIndex == 0 ) {
			alert('Please select your Congregation State.');  
			document.frmReg.congregationstate.focus(); 
			return false; } 

		if (document.frmReg.congregation.selectedIndex == 0 ) {
			alert('Please select your Congregation.');  
			document.frmReg.congregation.focus(); 
			return false; } 

		//other church body
		if (document.frmReg.congregation.selectedIndex == 1 ) {    
			var strValue = document.frmReg.churchname.value; 
			if (reBlank.test(strValue)){ 
				alert('Please enter Congregation Name.');  
				document.frmReg.churchname.focus(); 
				return false; } 
		}
	}	


	//----------------------------//
	//  login/register/profile   //
	//----------------------------//
	function PilotLoginCheck() {
		var reBlank = /^\s*$/;	

		var strValue = document.frmLogin.loginpassword.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your password.');  
			document.frmLogin.loginpassword.focus(); 
			return false; } 

		if (document.frmLogin.congregation.selectedIndex == 0 ) {
			alert('Please select your congregation.');  
			document.frmLogin.congregation.focus(); 
			return false; }
	}
	
	function LoginCheck() {
		var reBlank = /^\s*$/;	
		
		var strValue = document.frmLogin.loginemail.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your e-mail address.');  
			document.frmLogin.loginemail.focus(); 
			return false; } 

		var strValue = document.frmLogin.loginpassword.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your password.');  
			document.frmLogin.loginpassword.focus(); 
			return false; } 
	}
	
	function RegisterCheck(){ 
		var reBlank = /^\s*$/;

		var strValue = document.frmReg.email.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your e-mail address.');  
			document.frmReg.email.focus(); 
			return false; } 

		if (!emailCheck(strValue)){
			alert('Please enter a valid e-mail address.');  
			document.frmReg.email.focus();
			return false;
		}

		var strValue = document.frmReg.password.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your password.');  
			document.frmReg.password.focus(); 
			return false; } 

		var strValue = document.frmReg.password2.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your confirm password.');  
			document.frmReg.password2.focus(); 
			return false; } 
  
  		if (strValue != document.frmReg.password.value ){ 
			alert('confirm password does not match password.');  
			document.frmReg.password2.focus(); 
			return false; }
  
		if (document.frmReg.howhear.selectedIndex == 0 ) {
			alert('Please select how did you hear about the Men s NetWork?');  
			document.frmReg.howhear.focus(); 
			return false; } 

		if (document.frmReg.churchaffiliation.selectedIndex == 0 ) {
			alert('Please select your church affiliation.');  
			document.frmReg.churchaffiliation.focus(); 
			return false; } 
			
		if (document.frmReg.churchaffiliation[document.frmReg.churchaffiliation.selectedIndex].value == "LCMS") {
			if (document.frmReg.congregationstate.selectedIndex == 0 ) {
				alert('Please select your congregation state.');  
				document.frmReg.congregationstate.focus(); 
				return false; } 

			if (document.frmReg.congregation.selectedIndex == 0 ) {
				alert('Please select your congregation.');  
				document.frmReg.congregation.focus(); 
				return false; } 

			//other church body
			if (document.frmReg.congregation.selectedIndex == 1 ) {    
				var strValue = document.frmReg.churchname.value; 
				if (reBlank.test(strValue)){ 
					alert('Please enter your church name.');  
					document.frmReg.churchname.focus(); 
					return false; } 
			}	
		}

		if (document.frmReg.churchaffiliation[document.frmReg.churchaffiliation.selectedIndex].value == "LCC") {
			if (document.frmReg.lccstate.selectedIndex == 0 ) {
				alert('Please select your congregation province.');  
				document.frmReg.lccstate.focus(); 
				return false; } 

			if (document.frmReg.lcccongregation.selectedIndex == 0 ) {
				alert('Please select your congregation.');  
				document.frmReg.lcccongregation.focus(); 
				return false; } 

			//other church body
			if (document.frmReg.lcccongregation.selectedIndex == 1 ) {    
				var strValue = document.frmReg.lccchurchname.value; 
				if (reBlank.test(strValue)){ 
					alert('Please enter your church name.');  
					document.frmReg.lccchurchname.focus(); 
					return false; } 
			}	
		}

		var strValue = document.frmReg.firstname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your first name.');  
			document.frmReg.firstname.focus(); 
			return false; } 

		var strValue = document.frmReg.lastname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your last name.');  
			document.frmReg.lastname.focus(); 
			return false; } 
	}	

	function UpdateProfileCheck(){ 
		var reBlank = /^\s*$/;

		var strValue = document.frmReg.email.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your e-mail address.');  
			document.frmReg.email.focus(); 
			return false; } 

		if (!emailCheck(strValue)){
			alert('Please enter a valid e-mail address.');  
			document.frmReg.email.focus();
			return false;
		}
  
  		if (document.frmReg.churchaffiliation.selectedIndex == 0 ) {
			alert('Please select your church affiliation.');  
			document.frmReg.churchaffiliation.focus(); 
			return false; } 
			
		if (document.frmReg.churchaffiliation[document.frmReg.churchaffiliation.selectedIndex].value == "LCMS") {
			if (document.frmReg.congregationstate.selectedIndex == 0 ) {
				alert('Please select your congregation state.');  
				document.frmReg.congregationstate.focus(); 
				return false; } 

			if (document.frmReg.congregation.selectedIndex == 0 ) {
				alert('Please select your congregation.');  
				document.frmReg.congregation.focus(); 
				return false; } 

			//other church body
			if (document.frmReg.congregation.selectedIndex == 1 ) {    
				var strValue = document.frmReg.churchname.value; 
				if (reBlank.test(strValue)){ 
					alert('Please enter your church name.');  
					document.frmReg.churchname.focus(); 
					return false; } 
			}	
		}

		var strValue = document.frmReg.firstname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your first name.');  
			document.frmReg.firstname.focus(); 
			return false; } 

		var strValue = document.frmReg.lastname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your last name.');  
			document.frmReg.lastname.focus(); 
			return false; } 
	}	

	function ChangePasswordCheck(){ 
		var reBlank = /^\s*$/;

		var strValue = document.frmReg.oldpassword.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your old password.');  
			document.frmReg.oldpassword.focus(); 
			return false; } 

		var strValue = document.frmReg.password.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter your new password.');  
			document.frmReg.password.focus(); 
			return false; } 

		var strValue = document.frmReg.password2.value; 
		if (reBlank.test(strValue)){ 
			alert('Please re-enter your new password.');  
			document.frmReg.password2.focus(); 
			return false; } 
  
  		if (strValue != document.frmReg.password.value ){ 
			alert('New password does not match.');  
			document.frmReg.password2.focus(); 
			return false; }
	}

	function ShowPasswordHint() {
		var windowSettings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,"+
							"resizable=no,width=480,height=330,top=200,left=250";
		var strEmail = document.frmLogin.loginemail.value;	
		window.open('passwordhint.asp?u=' + strEmail,'',windowSettings);
	}

	function HintCheck(){ 
		var reBlank = /^\s*$/;
		var strValue;
  
		strValue = document.frmHint.fEmail.value;
		if (reBlank.test(strValue)){
			alert("Please enter your e-mail address.");
			document.frmHint.fEmail.focus();
			return false;
		}		
	}

	function GoState(sState) {
		var seldiv = document.getElementById('divchurchname');
		seldiv.style.display = "none";
		
		document.frmReg.selectstate.value = 'yes';
		document.frmReg.stateselected.value = sState;
		document.frmReg.canadastateselected.value = document.frmReg.lccstate[document.frmReg.lccstate.selectedIndex].value;
    	document.frmReg.submit(); 
	}

	function GoCanadaState(sState) {
		var seldiv = document.getElementById('divchurchname');
		seldiv.style.display = "none";
		
		document.frmReg.selectcanadastate.value = 'yes';
		document.frmReg.canadastateselected.value = sState;
		document.frmReg.stateselected.value = document.frmReg.congregationstate[document.frmReg.congregationstate.selectedIndex].value;
    	document.frmReg.submit(); 
	}
	
	function SetChurchBlock(sAffiliation)	{
		var seldivlcms = document.getElementById('divlcms');
		var seldivlcc = document.getElementById('divlcc');
		var seldivelca = document.getElementById('divelca');		
		var seldivchurchname = document.getElementById('divchurchname');
		var seldivlccchurchname = document.getElementById('divlccchurchname');
	
		//LCMA
		if (sAffiliation == "LCMS") {
			seldivlcms.style.display = "inline";
			seldivlcc.style.display = "none";
			seldivelca.style.display = "none";
			seldivlccchurchname.style.display = "none";
			
			//alert(document.frmReg.congregation.selectedIndex);
			//alert(document.frmReg.congregation[document.frmReg.congregation.selectedIndex].value);
			
			if (document.frmReg.congregation[document.frmReg.congregation.selectedIndex].value == ChurchID_Other) {
				seldivchurchname.style.display = "inline"; }
			else {
				seldivchurchname.style.display = "none"; }
		}

		else {
			//LCC
			if (sAffiliation == "LCC") {
				seldivlcms.style.display = "none";
				seldivlcc.style.display = "inline";
				seldivelca.style.display = "none";
				seldivchurchname.style.display = "none";
				
				if (document.frmReg.lcccongregation[document.frmReg.lcccongregation.selectedIndex].value == ChurchID_Other) {
					seldivlccchurchname.style.display = "inline"; }
				else {
					seldivlccchurchname.style.display = "none"; }
			}
			
			else {
				//ELCA
				if (sAffiliation == "ELCA") {
					seldivlcms.style.display = "none";
					seldivlcc.style.display = "none";				
					seldivelca.style.display = "inline";				
					seldivchurchname.style.display = "none";
					seldivlccchurchname.style.display = "none";
				}
				else {
					seldivlcms.style.display = "none";
					seldivlcc.style.display = "none";
					seldivelca.style.display = "none";
					seldivchurchname.style.display = "none";
					seldivlccchurchname.style.display = "none";
				}
			}
		}
	}

	function SetChurchName(iChurchID)	{
		var seldiv = document.getElementById('divchurchname');
	
		if (iChurchID == ChurchID_Other) {
			seldiv.style.display = "inline";			
		}
		else {
			seldiv.style.display = "none";			
		}
	}

	function SetLCCChurchName(iChurchID)	{
		var seldiv = document.getElementById('divlccchurchname');
	
		if (iChurchID == ChurchID_Other) {
			seldiv.style.display = "inline";			
		}
		else {
			seldiv.style.display = "none";			
		}
	}

	//---------------//
	//   Newsletter  //
	//---------------//
	function NewsletterSignUpCheck(){ 
		var reBlank = /^\s*$/;
  
		var strValue = document.form1.email.value;
		if (reBlank.test(strValue)){
			alert("Please enter your e-mail address.");
			document.form1.email.focus();
			return false;
		}

		if (!emailCheck(strValue)){
			alert('Please enter a valid e-mail address.'); 		 	
			document.form1.email.focus();
			return false;
		}

		var strValue = document.form1.firstname.value;
		if (reBlank.test(strValue)){
			alert("Please enter your first name.");
			document.form1.firstname.focus();
			return false;
		}	

		var strValue = document.form1.lastname.value;
		if (reBlank.test(strValue)){
			alert("Please enter your last name.");
			document.form1.lastname.focus();
			return false;
		}
	}

	function NewsletterLoginCheck(){ 
		var reBlank = /^\s*$/;
  
		var strValue = document.form1.email.value;
		if (reBlank.test(strValue)){
			alert("Please enter your e-mail address.");
			document.form1.email.focus();
			return false;
		}
		else {
			if (!emailCheck(strValue)){
 			  alert ("E-mail address seems incorrect.")
			  document.form1.email.focus();
			  return false;
			}
		}
	}

	function NewsletterUpdateCheck(){ 
		var reBlank = /^\s*$/;
  
		var strValue = document.form1.emailnew.value;
		if (!reBlank.test(strValue)){
			if (!emailCheck(strValue)){
	 		  alert ("New e-mail address seems incorrect.")
			  document.form1.emailnew.focus();
			  return false;
			}
		}
	}

	function NewsletterUnsubscribeCheck(){ 
		var reBlank = /^\s*$/;
  
		var strValue = document.form1.email.value;
		if (reBlank.test(strValue)){
			alert("Please enter your e-mail address.");
			document.form1.email.focus();
			return false;
		}
		else {
			if (!emailCheck(strValue)){
	 		  alert ("E-mail address seems incorrect.")
			  document.form1.email.focus();
			  return false;
			}
			else { 
				return confirm("Are you sure you want to unsubscribe from Men's Network newsletter?");
			}
		}
	}
	
	function ConfirmUnsubscribe() {
		var msg = "Are you sure you want to unsubscribe from Men's Network newsletter?";
		return confirm(msg);
	}
	
//---------------//
//  Men's Group  //
//---------------//
function SubmitRegisterGroupCheck(){ 
	var reBlank = /^\s*$/;
  
	var strValue = document.form1.groupname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Group Name.");
		document.form1.groupname.focus();
		return false;
	}

	var strValue = document.form1.adminfirstname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Admin First Name.");
		document.form1.adminfirstname.focus();
		return false;
	}

	var strValue = document.form1.adminlastname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Admin Last Name.");
		document.form1.adminlastname.focus();
		return false;
	}

	var strValue = document.form1.username.value;
	if (reBlank.test(strValue)){
		alert("Please enter Userame.");
		document.form1.username.focus();
		return false;
	}

	var strValue = document.form1.password.value;
	if (reBlank.test(strValue)){
		alert("Please enter Password.");
		document.form1.password.focus();
		return false;
	}

	var strValue = document.form1.city.value;
	if (reBlank.test(strValue)){
		alert("Please enter City.");
		document.form1.city.focus();
		return false;
	}

	//if (document.form1.state.selectedIndex ==0) {
	if (document.form1.state.options[document.form1.state.selectedIndex].value == '' ) {		
		alert("Please select State/Province.");
		document.form1.state.focus();
		return false;	
	}

	var strValue = document.form1.email.value;
	if (reBlank.test(strValue)){
		alert("Please enter E-mail Address.");
		document.form1.email.focus();
		return false;
	}

	if (!emailCheck(strValue)){
	  alert ("E-mail address seems incorrect.")
	  document.form1.email.focus();
	  return false;
	}

	//if (document.form1.congregationstate.selectedIndex == 0 ) {
	if (document.form1.congregationstate.options[document.form1.congregationstate.selectedIndex].value == '' ) {		
		alert('Please select Church State/Province.');  
		document.form1.congregationstate.focus(); 
		return false; } 

	if (document.form1.congregation.selectedIndex == 0 ) {
		alert('Please select Church.');  
		document.form1.congregation.focus(); 
		return false; } 

	//other church body
	if (document.form1.congregation.selectedIndex == 1 ) {    
		var strValue = document.form1.churchname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter Church Name.');  
			document.form1.churchname.focus(); 
			return false; } 
	}
}

function SubmitUpdateGroupCheck(){ 
	var reBlank = /^\s*$/;
	
	var strValue = document.form1.groupname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Group Name.");
		document.form1.groupname.focus();
		return false;
	}	

	var strValue = document.form1.adminfirstname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Admin First Name.");
		document.form1.adminfirstname.focus();
		return false;
	}

	var strValue = document.form1.adminlastname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Admin Last Name.");
		document.form1.adminlastname.focus();
		return false;
	}

	var strValue = document.form1.username.value;
	if (reBlank.test(strValue)){
		alert("Please enter Userame.");
		document.form1.username.focus();
		return false;
	}

	var strValue = document.form1.password.value;
	if (reBlank.test(strValue)){
		alert("Please enter Password.");
		document.form1.password.focus();
		return false;
	}

	var strValue = document.form1.city.value;
	if (reBlank.test(strValue)){
		alert("Please enter City.");
		document.form1.city.focus();
		return false;
	}

	//if (document.form1.state.selectedIndex ==0) {
	if (document.form1.state.options[document.form1.state.selectedIndex].value == '' ) {		
		alert("Please select State/Province.");
		document.form1.state.focus();
		return false;	
	}

	var strValue = document.form1.email.value;
	if (reBlank.test(strValue)){
		alert("Please enter E-mail Address.");
		document.form1.email.focus();
		return false;
	}

	if (!emailCheck(strValue)){
	  alert ("E-mail address seems incorrect.")
	  document.form1.email.focus();
	  return false;
	}

	if (document.form1.congregationstate.selectedIndex == 0 ) {
		alert('Please select Church State/Province.');  
		document.form1.congregationstate.focus(); 
		return false; } 

	//if (document.form1.congregation.selectedIndex == 0 ) {
	if (document.form1.congregationstate.options[document.form1.congregationstate.selectedIndex].value == '' ) {		
		alert('Please select Church.');  
		document.form1.congregation.focus(); 
		return false; } 

	//other church body
	if (document.form1.congregation.selectedIndex == 1 ) {    
		var strValue = document.form1.churchname.value; 
		if (reBlank.test(strValue)){ 
			alert('Please enter Church Name.');  
			document.form1.churchname.focus(); 
			return false; } 
	}
}

function SubmitGroupLoginCheck(){ 
	var reBlank = /^\s*$/;
  
	var strValue = document.form1.username.value;
	if (reBlank.test(strValue)){
		alert("Please enter your Username.");
		document.form1.username.focus();
		return false;
	}

	var strValue = document.form1.password.value;
	if (reBlank.test(strValue)){
		alert("Please enter Password.");
		document.form1.password.focus();
		return false;
	}
}

function GoGroupState(sState) {
	var seldiv = document.getElementById('divchurchname');
	seldiv.style.display = "none";
		
	document.form1.selectstate.value = 'yes';
	document.form1.stateselected.value = sState;
   	document.form1.submit(); 
}
	
function SetGroupChurchName(iChurchID)	{
	var seldiv = document.getElementById('divchurchname');
	
	if (iChurchID == ChurchID_Other) {
		seldiv.style.display = "inline";			
	}
	else {
		seldiv.style.display = "none";			
	}
}

function gogroup(sState) { 
	location.href = 'findgroup_bystate.asp?state=' + sState;
}

function gogroupprt(sState) { 
	location.href = 'findgroupprt.asp?state=' + sState;
}

function golocalevent(sState) { 
	if (sState == '') { 
		location.href = 'events.asp?state=' + sState; }
	else {
		location.href = 'events_bystate.asp?state=' + sState; }
}

//-------------------//
//  Events/Braggin   //
//------------------ //
function SubmitImpactEventCheck(){ 
	var reBlank = /^\s*$/;

	if (document.form1.eventtype.selectedIndex ==0) {
		alert("Please select Type of Event.");
		document.form1.eventtype.focus();
		return false;	
	}
  
	var strValue = document.form1.eventname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Name of Event.");
		document.form1.eventname.focus();
		return false;
	}

//	var strValue = document.form1.churchname.value;
//	if (reBlank.test(strValue)){
//		alert("Please enter Name of Church.");
//		document.form1.churchname.focus();
//		return false;
//	}

//	var strValue = document.form1.city.value;
//	if (reBlank.test(strValue)){
//		alert("Please enter City.");
//		document.form1.city.focus();
//		return false;
//	}

	// US Impact
	//if (document.form1.eventtype.selectedIndex ==1) {  
//		if (document.form1.state.selectedIndex ==0) {
//			alert("Please select State.");
//			document.form1.state.focus();
//			return false;	
//		}
	//}

	//if (document.form1.country.selectedIndex ==0) {
	//	alert("Please select Country.");
	//	document.form1.country.focus();
	//	return false;	
	//}

//	var strValue = document.form1.contactperson.value;
//	if (reBlank.test(strValue)){
//		alert("Please enter Contact Person.");
//		document.form1.contactperson.focus();
//		return false;
//	}

//	var strValue = document.form1.phone.value;
//	if (reBlank.test(strValue)){
//		alert("Please enter Phone.");
//		document.form1.phone.focus();
//		return false;
//	}

//	var strValue = document.form1.email.value;
//	if (reBlank.test(strValue)){
//		alert("Please enter E-mail Address.");
//		document.form1.email.focus();
//		return false;
//	}

	var iYear = document.form1.startyear.selectedIndex; 
	var iMonth = document.form1.startmonth.selectedIndex; 
	var iDay = document.form1.startday.selectedIndex; 	
	if ( ((iYear==0) && (iMonth==0) && (iDay==0)) || ((iYear>0) && (iMonth>0) && (iDay>0)) ) {
		//selected year & month & day or none of them  
	}
	else {
		alert("Start Date is not a valid date.");
		document.form1.startmonth.focus();
		return false;
	}

	var iYear = document.form1.endyear.selectedIndex; 
	var iMonth = document.form1.endmonth.selectedIndex; 
	var iDay = document.form1.endday.selectedIndex; 	
	if ( ((iYear==0) && (iMonth==0) && (iDay==0)) || ((iYear>0) && (iMonth>0) && (iDay>0)) ) {
		//selected year & month & day or none of them  
	}
	else {
		alert("End Date is not a valid date.");
		document.form1.endmonth.focus();
		return false;
	}

	var strValue = document.form1.email.value;
	if (!reBlank.test(strValue)){
		if (!emailCheck(strValue)){
		  alert ("E-mail address seems incorrect.")
		  document.form1.email.focus();
		  return false;
		}
	}

	var strValue = document.form1.churchurl.value;
	if (reBlank.test(strValue)){
		alert("Please enter Church URL.");
		document.form1.churchurl.focus();
		return false;
	}

	var strValue = document.form1.details.value;
	if (reBlank.test(strValue)){
		alert("Please enter Event Details.");
		document.form1.details.focus();
		return false;
	}

	var strValue = document.form1.hdcaptcha.value;
	if (reBlank.test(strValue)){
		alert("Please enter Security Code.");
		document.form1.hdcaptcha.focus();
		return false;
	}
}

function SubmitLocalCalendarCheck(){ 
	var reBlank = /^\s*$/;
  
	var strValue = document.form1.eventname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Name of Event.");
		document.form1.eventname.focus();
		return false;
	}

	var strValue = document.form1.churchname.value;
	if (reBlank.test(strValue)){
		alert("Please enter Name of Church.");
		document.form1.churchname.focus();
		return false;
	}

	var strValue = document.form1.city.value;
	if (reBlank.test(strValue)){
		alert("Please enter City.");
		document.form1.city.focus();
		return false;
	}

	//if (document.form1.state.selectedIndex ==0) {
	if (document.form1.state.options[document.form1.state.selectedIndex].value == '' ) {		
		alert("Please select State/Province.");
		document.form1.state.focus();
		return false;	
	}

//	var iYear = document.form1.startyear.selectedIndex; 
//	var iMonth = document.form1.startmonth.selectedIndex; 
//	var iDay = document.form1.startday.selectedIndex; 	
//	if ( (iYear==0) || (iMonth==0) || (iDay==0) ) {
//		alert("Please select a valid Start Date.");
//		document.form1.startmonth.focus();
//		return false;
//	}

//	var iYear = document.form1.endyear.selectedIndex; 
//	var iMonth = document.form1.endmonth.selectedIndex; 
//	var iDay = document.form1.endday.selectedIndex; 	
//	if ( (iYear==0) || (iMonth==0) || (iDay==0) ) {
//		alert("Please select a valid End Date.");
//		document.form1.startmonth.focus();
//		return false;
//	}

	var iYear = document.form1.startyear.selectedIndex; 
	var iMonth = document.form1.startmonth.selectedIndex; 
	var iDay = document.form1.startday.selectedIndex; 	
	if ( ((iYear==0) && (iMonth==0) && (iDay==0)) || ((iYear>0) && (iMonth>0) && (iDay>0)) ) {
		//selected year & month & day or none of them  
	}
	else {
		alert("Start Date is not a valid date.");
		document.form1.startmonth.focus();
		return false;
	}

	var iYear = document.form1.endyear.selectedIndex; 
	var iMonth = document.form1.endmonth.selectedIndex; 
	var iDay = document.form1.endday.selectedIndex; 	
	if ( ((iYear==0) && (iMonth==0) && (iDay==0)) || ((iYear>0) && (iMonth>0) && (iDay>0)) ) {
		//selected year & month & day or none of them  
	}
	else {
		alert("End Date is not a valid date.");
		document.form1.endmonth.focus();
		return false;
	}
	
	var strValue = document.form1.contactperson.value;
	if (reBlank.test(strValue)){
		alert("Please enter Contact Person.");
		document.form1.contactperson.focus();
		return false;
	}

	var strValue = document.form1.phone.value;
	if (reBlank.test(strValue)){
		alert("Please enter Phone.");
		document.form1.phone.focus();
		return false;
	}

	var strValue = document.form1.email.value;
	if (reBlank.test(strValue)){
		alert("Please enter E-mail Address.");
		document.form1.email.focus();
		return false;
	}

	if (!emailCheck(strValue)){
	  alert ("E-mail address seems incorrect.")
	  document.form1.email.focus();
	  return false;
	}

	var strValue = document.form1.churchurl.value;
	if (reBlank.test(strValue)){
		alert("Please enter Church URL.");
		document.form1.churchurl.focus();
		return false;
	}

	var strValue = document.form1.details.value;
	if (reBlank.test(strValue)){
		alert("Please enter Event Details.");
		document.form1.details.focus();
		return false;
	}

	var strValue = document.form1.hdcaptcha.value;
	if (reBlank.test(strValue)){
		alert("Please enter Security Code.");
		document.form1.hdcaptcha.focus();
		return false;
	}
}

  function OpenBragginLargePic(iID)
  {
		var URL = 'bragginpic.asp?articleimageid=' + iID;
		var windowSettings = 'height=600,width=700,top=50,left=50,resizable=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no';
		window.open(URL,'', windowSettings);
  }

  function OpenBragginLargePicPreview(iID)
  {
		var URL = 'brpicpreview.asp?articleimageid=' + iID;
		var windowSettings = 'height=600,width=700,top=50,left=50,resizable=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no';
		window.open(URL,'', windowSettings);
  }


//--------------------//
// Email to Friend   //
//--------------------//
function SendToFriendCheck(){
	if (document.form1.toname.value == "") {
		alert("Please enter your friend's name.");
		document.form1.toname.focus();
		return false;
	}

	if (document.form1.tomail.value == "") {
		alert("Please enter your friend's e-mail address.");
		document.form1.tomail.focus();
		return false;
	}
	
	if (!emailCheck(document.form1.tomail.value)){
	  alert("Please enter a valid e-mail address.");
		document.form1.tomail.focus();
	  return false;
	}

	if (document.form1.fromname.value == "") {
		alert("Please enter your name.");
		document.form1.fromname.focus();
		return false;
	}

	if (document.form1.frommail.value == "") {
		alert("Please enter your e-mail address.");
		document.form1.frommail.focus();
		return false;
	}

	if (!emailCheck(document.form1.frommail.value)){
	  alert("Please enter a valid e-mail address.");
		document.form1.frommail.focus();
	  return false;
	}

	if (document.form1.subject.value == "") {
		alert("Please enter the message subject.");
		document.form1.subject.focus();
		return false;
	}

	if (document.form1.message.value == "") {
		alert("Please enter the message.");
		document.form1.message.focus();
		return false;
	}	
}

//----------------//
// Order Online  //
//----------------//
function OpenProductZoomIn(ProductCode) {
	var windowSettings = 'height=500,width=500,top=50,left=380,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no';
	window.open('productzoomin.asp?pcode=' + ProductCode,'', windowSettings);
}

function showshipping() { 
	var seldiv = document.getElementById('divshipping');
	
	// shipping same
	if (document.frmOrder.chkshipping.checked == true) {
		seldiv.style.display = "none";
		//document.frmOrder.shippingfirstname.value = '';
		//document.frmOrder.shippinglastname.value = '';
		//document.frmOrder.shippingaddress1.value = '';
		//document.frmOrder.shippingaddress2.value = '';
		//document.frmOrder.shippingcity.value = '';
		//document.frmOrder.shippingzip.value = '';
	}
	else {
		seldiv.style.display = "inline";
	}
}

	