/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.
   
   http://www.sitepoint.com/article/scroll-smoothly-javascript
   
   v1.0 2003-11-11
*/
function ss_fixAllLinks() {
 // Get a list of all links in the page
 var allLinks = document.getElementsByTagName('a');
 // Walk through the list
 for (var i=0;i<allLinks.length;i++) {
   var lnk = allLinks[i];
   if ((lnk.href && lnk.href.indexOf('#') != -1) &&  
       ( (lnk.pathname == location.pathname) ||
   ('/'+lnk.pathname == location.pathname) ) &&  
       (lnk.search == location.search)) {
     // If the link is internal to the page (begins in #)
     // then attach the smoothScroll function as an onclick
     // event handler
     ss_addEvent(lnk,'click',smoothScroll);
   }
 }
}

function smoothScroll(e) {
 // This is an event handler; get the clicked on element,
 // in a cross-browser fashion
 if (window.event) {
   target = window.event.srcElement;
 } else if (e) {
   target = e.target;
 } else return;
 
 // Make sure that the target is an element, not a text node
 // within an element
 if (target.nodeType == 3) {
   target = target.parentNode;
 }
 
 // Paranoia; check this is an A tag
 if (target.nodeName.toLowerCase() != 'a') return;
 
 // Find the <a name> tag corresponding to this href
 // First strip off the hash (first character)
 anchor = target.hash.substr(1);
 // Now loop all A tags until we find one with that name
 var allLinks = document.getElementsByTagName('a');
 var destinationLink = null;
 for (var i=0;i<allLinks.length;i++) {
   var lnk = allLinks[i];
   if (lnk.name && (lnk.name == anchor)) {
     destinationLink = lnk;
     break;
   }
 }
 
 // If we didn't find a destination, give up and let the browser do
 // its thing
 if (!destinationLink) return true;
 
 // Find the destination's position
 var destx = destinationLink.offsetLeft;  
 var desty = destinationLink.offsetTop;
 var thisNode = destinationLink;
 while (thisNode.offsetParent &&  
       (thisNode.offsetParent != document.body)) {
   thisNode = thisNode.offsetParent;
   destx += thisNode.offsetLeft;
   desty += thisNode.offsetTop;
 }
 
 // Stop any current scrolling
 clearInterval(ss_INTERVAL);
 
 cypos = ss_getCurrentYPos();
 
 ss_stepsize = parseInt((desty-cypos)/ss_STEPS);
 ss_INTERVAL = setInterval('ss_scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
 
 // And stop the actual click happening
 if (window.event) {
   window.event.cancelBubble = true;
   window.event.returnValue = false;
 }
 if (e && e.preventDefault && e.stopPropagation) {
   e.preventDefault();
   e.stopPropagation();
 }
}

function ss_scrollWindow(scramount,dest,anchor) {
 wascypos = ss_getCurrentYPos();
 isAbove = (wascypos < dest);
 window.scrollTo(0,wascypos + scramount);
 iscypos = ss_getCurrentYPos();
 isAboveNow = (iscypos < dest);
 if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
   // if we've just scrolled past the destination, or
   // we haven't moved from the last scroll (i.e., we're at the
   // bottom of the page) then scroll exactly to the link
   window.scrollTo(0,dest);
   // cancel the repeating timer
   clearInterval(ss_INTERVAL);
   // and jump to the link directly so the URL's right
   location.hash = anchor;
 }
}

function ss_getCurrentYPos() {
 if (document.body && document.body.scrollTop)
   return document.body.scrollTop;
 if (document.documentElement && document.documentElement.scrollTop)
   return document.documentElement.scrollTop;
 if (window.pageYOffset)
   return window.pageYOffset;
 return 0;
}

function ss_addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
}  

var ss_INTERVAL;
var ss_STEPS = 25;

ss_addEvent(window,"load",ss_fixAllLinks);


	//Changes:  Sandeep V. Tamhankar (stamhankar@hotmail.com)
	/* 1.1.2: Fixed a bug where trailing . in e-mail address was passing
	            (the bug is actually in the weak regexp engine of the browser; I
	            simplified the regexps to make it work).
	   1.1.1: Removed restriction that countries must be preceded by a domain,
	            so abc@host.uk is now legal.  However, there's still the 
	            restriction that an address must end in a two or three letter
	            word.
	     1.1: Rewrote most of the function to conform more closely to RFC 822.
	     1.0: Original  */

	//This script and many more are available free online at The JavaScript Source!! http://javascript.internet.com
	//Begin
	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)
		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]

		// 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
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert("The domain name doesn't seem to be valid.")
		    return false
		}

		/* 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>3) {
		   // the address must end in a two letter or three letter word.
		   alert("The address must end in a three-letter domain, or two letter country.")
		   return false
		}

		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   alert(errStr)
		   return false
		}

		// If we've gotten this far, everything's valid!
		return true;
	}
	//  End

	function isPhoneNumber(strPhoneNumber){
		// Check for correct phone number
		rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);

		if (!rePhoneNumber.test(strPhoneNumber)) {
			alert("Please enter your phone number as (555) 555-1234.\n\n(This number will only be used as a last resort ).");
			return false;
		}

		return true;
	}


	function confirmCancel(){
		var bolSelection = confirm('Navigating away from this page will cause all your data will be lost.\n\nAre you sure you want to cancel?');

		if(bolSelection == true){
			window.location='index.php';
		}
	}

	function validateAdoptionApplication(){
		var bolReturnCode = false;
		var strFirstName = frmAdoptionApplication.txtApplicant1FirstName.value;
		var strLastName = frmAdoptionApplication.txtApplicant1LastName.value;
		if(frmAdoptionApplication.txtApplicant1FirstName.value == "" || frmAdoptionApplication.txtApplicant1LastName.value == "" || frmAdoptionApplication.txtHomePhone.value == "" || frmAdoptionApplication.txtStreetAddress.value == "" || frmAdoptionApplication.txtCity.value == "" || frmAdoptionApplication.txtState.value == "" || frmAdoptionApplication.txtZipCode.value == "" || frmAdoptionApplication.txtEmailAddress.value == "" || frmAdoptionApplication.txtNumberAdults.value == "" || frmAdoptionApplication.txtAdultAgeRange.value == "" || frmAdoptionApplication.txtNumberChildren.value == "" || frmAdoptionApplication.txtChildrenVisit.value == "" || frmAdoptionApplication.txtFencedYard.value == "" || frmAdoptionApplication.txtOtherPets.value == "" || frmAdoptionApplication.txtHomeDuringDay.value == "" || frmAdoptionApplication.txtHoursAlone.value == "" || frmAdoptionApplication.txtLocationDuringDay.value == "" || frmAdoptionApplication.txtLocationAtNight.value == "" || frmAdoptionApplication.txtSex.value == "" || frmAdoptionApplication.txtAge.value == "" || frmAdoptionApplication.txtConsiderOver5.value == "" || (frmAdoptionApplication.txtToy.value == "" && frmAdoptionApplication.txtSmall.value == "" && frmAdoptionApplication.txtMedium.value == ""  && frmAdoptionApplication.txtLarge.value == "" && frmAdoptionApplication.txtGiant.value == "") || frmAdoptionApplication.txtConsiderCrating.value == "" || frmAdoptionApplication.txtActivityLevel.value == "" || frmAdoptionApplication.txtPurebred.value == "" || frmAdoptionApplication.txtConsiderFostering.value == "" || (frmAdoptionApplication.txtGoodWithChildren.value == "" && frmAdoptionApplication.txtGoodWithDogs.value == "" && frmAdoptionApplication.txtGoodWithCats.value == "" && frmAdoptionApplication.txtTravels.value == "" && frmAdoptionApplication.txtFriendly.value == "" && frmAdoptionApplication.txtLowEnergyLevel.value == "" && frmAdoptionApplication.txtHighEnergyLevel.value == "" && frmAdoptionApplication.txtPlaysFetch.value == "" && frmAdoptionApplication.txtNoObedienceTraining.value == "" && frmAdoptionApplication.txtOffLeash.value == "" && frmAdoptionApplication.txtDoesntChew.value == "" && frmAdoptionApplication.txtDoesntJump.value == "" && frmAdoptionApplication.txtWillRun.value == "" && frmAdoptionApplication.txtObedienceCompetition.value == "") || frmAdoptionApplication.txtApplicantEmployer.value == "" || frmAdoptionApplication.txtApplicantPosition.value == "" || frmAdoptionApplication.txtLiveIn.value == "" || frmAdoptionApplication.txtOwnRent.value == "" || frmAdoptionApplication.txtSetting.value == "" || frmAdoptionApplication.txtChemicallyTreatedLawn.value == "" || frmAdoptionApplication.txtTypeOfExercise.value == "" || frmAdoptionApplication.txtPreviousPets.value == "" || frmAdoptionApplication.txtObedienceTraining.value == "" || frmAdoptionApplication.txtPlanToTrain.value == "" || frmAdoptionApplication.txtReference1Name.value == "" || frmAdoptionApplication.txtReference1Phone.value == "" || frmAdoptionApplication.txtReference2Name.value == "" || frmAdoptionApplication.txtReference2Phone.value == "" || frmAdoptionApplication.txtVetName.value == "" || frmAdoptionApplication.txtVetPhone == "" || frmAdoptionApplication.txtHeardHow.value == "" || frmAdoptionApplication.txtSecurityImage.value == ""){
			alert("All fields in bold are required.\n\nPlease try again.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(strFirstName.indexOf('@') >= 0 || strLastName.indexOf('@') >= 0){
			alert("Please enter a valid first and last name.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(!emailCheck(frmAdoptionApplication.txtEmailAddress.value)){
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else {
			if(frmAdoptionApplication.txtHaveChildren.value == "Yes" && frmAdoptionApplication.txtNumberChildren.value == ""){
				alert("Please specify how many children are in your house.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmAdoptionApplication.txtHaveChildren.value == "Yes" && frmAdoptionApplication.txtChildrenAges.value == ""){
				alert("Please specify the ages of the children in your house.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmAdoptionApplication.txtFencedYard.value == "Yes" && frmAdoptionApplication.txtFenceType.value == ""){
				alert("Please specify the type/height of your fence.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmAdoptionApplication.txtOtherPets.value == "Yes" && (frmAdoptionApplication.txtOtherPetsType1.value == "" || frmAdoptionApplication.txtOtherPetsName1.value == "" || frmAdoptionApplication.txtOtherPetsAge1.value == "" || frmAdoptionApplication.txtOtherPetsSex1.value == "" || frmAdoptionApplication.txtOtherPetsAltered1.value == "" || frmAdoptionApplication.txtOtherPetsCharacteristics1.value == "")){
				alert("Please specify all the details of at least one of your other pets.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmAdoptionApplication.txtPurebred.value == "Yes" && (frmAdoptionApplication.txtPurebredBreeds.value == "" || frmAdoptionApplication.txtShareApplication.value == "")){
				alert("Please indicate the type of purebred breeds that you are interested in as well as if you would like us to share your application with purebred rescue groups.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmAdoptionApplication.txtPreviousPets.value == "Yes" && (frmAdoptionApplication.txtPreviousPetsType1.value == "" || frmAdoptionApplication.txtPreviousPetsName1.value == "" || frmAdoptionApplication.txtPreviousPetsAge1.value == "" || frmAdoptionApplication.txtPreviousPetsSex1.value == "" || frmAdoptionApplication.txtPreviousPetsAltered1.value == "" || frmAdoptionApplication.txtPreviousPetsCharacteristics1.value == "")){
				alert("Please specify all the details of at least one of your previous pets.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else {
				bolReturnCode = true;
			}
		}
		return bolReturnCode;
	}

	function validateFosterApplication(){
		var bolReturnCode = false;
		var strFirstName = frmFosterApplication.txtApplicant1FirstName.value;
		var strLastName = frmFosterApplication.txtApplicant1LastName.value;
		if(frmFosterApplication.txtApplicant1FirstName.value == "" || frmFosterApplication.txtApplicant1LastName.value == "" || frmFosterApplication.txtHomePhone.value == "" || frmFosterApplication.txtStreetAddress.value == "" || frmFosterApplication.txtCity.value == "" || frmFosterApplication.txtState.value == "" || frmFosterApplication.txtZipCode.value == "" || frmFosterApplication.txtEmailAddress.value == "" || frmFosterApplication.txtNumberAdults.value == "" || frmFosterApplication.txtAdultAgeRange.value == "" || frmFosterApplication.txtNumberChildren.value == "" || frmFosterApplication.txtChildrenVisit.value == "" || frmFosterApplication.txtFencedYard.value == "" || frmFosterApplication.txtOtherPets.value == "" || frmFosterApplication.txtHomeDuringDay.value == "" || frmFosterApplication.txtHoursAlone.value == "" || frmFosterApplication.txtLocationDuringDay.value == "" || frmFosterApplication.txtLocationAtNight.value == "" || frmFosterApplication.txtSex.value == "" || frmFosterApplication.txtAge.value == "" || frmFosterApplication.txtConsiderOver5.value == "" || (frmFosterApplication.txtToy.value == "" && frmFosterApplication.txtSmall.value == "" && frmFosterApplication.txtMedium.value == ""  && frmFosterApplication.txtLarge.value == "" && frmFosterApplication.txtGiant.value == "") || frmFosterApplication.txtConsiderCrating.value == "" || frmFosterApplication.txtActivityLevel.value == "" || frmFosterApplication.txtPurebred.value == "" || frmFosterApplication.txtConsiderFostering.value == "" || (frmFosterApplication.txtGoodWithChildren.value == "" && frmFosterApplication.txtGoodWithDogs.value == "" && frmFosterApplication.txtGoodWithCats.value == "" && frmFosterApplication.txtTravels.value == "" && frmFosterApplication.txtFriendly.value == "" && frmFosterApplication.txtLowEnergyLevel.value == "" && frmFosterApplication.txtHighEnergyLevel.value == "" && frmFosterApplication.txtPlaysFetch.value == "" && frmFosterApplication.txtNoObedienceTraining.value == "" && frmFosterApplication.txtOffLeash.value == "" && frmFosterApplication.txtDoesntChew.value == "" && frmFosterApplication.txtDoesntJump.value == "" && frmFosterApplication.txtWillRun.value == "" && frmFosterApplication.txtObedienceCompetition.value == "") || frmFosterApplication.txtApplicantEmployer.value == "" || frmFosterApplication.txtApplicantPosition.value == "" || frmFosterApplication.txtLiveIn.value == "" || frmFosterApplication.txtOwnRent.value == "" || frmFosterApplication.txtSetting.value == "" || frmFosterApplication.txtChemicallyTreatedLawn.value == "" || frmFosterApplication.txtTypeOfExercise.value == "" || frmFosterApplication.txtPreviousPets.value == "" || frmFosterApplication.txtObedienceTraining.value == "" || frmFosterApplication.txtPlanToTrain.value == "" || frmFosterApplication.txtReference1Name.value == "" || frmFosterApplication.txtReference1Phone.value == "" || frmFosterApplication.txtReference2Name.value == "" || frmFosterApplication.txtReference2Phone.value == "" || frmFosterApplication.txtVetName.value == "" || frmFosterApplication.txtVetPhone == "" || frmFosterApplication.txtHeardHow.value == "" || frmFosterApplication.txtSecurityImage.value == ""){
			alert("All fields in bold are required.\n\nPlease try again.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(strFirstName.indexOf('@') >= 0 || strLastName.indexOf('@') >= 0){
			alert("Please enter a valid first and last name.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(!emailCheck(frmFosterApplication.txtEmailAddress.value)){
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else {
			if(frmFosterApplication.txtNumberChildren.value == "Yes" && frmFosterApplication.txtChildrenAges.value == ""){
				alert("Please specify the ages of the children in your house.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmFosterApplication.txtFencedYard.value == "Yes" && frmFosterApplication.txtFenceType.value == ""){
				alert("Please specify the type/height of your fence.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmFosterApplication.txtOtherPets.value == "Yes" && (frmFosterApplication.txtOtherPetsType1.value == "" || frmFosterApplication.txtOtherPetsName1.value == "" || frmFosterApplication.txtOtherPetsAge1.value == "" || frmFosterApplication.txtOtherPetsSex1.value == "" || frmFosterApplication.txtOtherPetsAltered1.value == "" || frmFosterApplication.txtOtherPetsCharacteristics1.value == "")){
				alert("Please specify all the details of at least one of your other pets.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmFosterApplication.txtPurebred.value == "Yes" && (frmFosterApplication.txtPurebredBreeds.value == "" || frmFosterApplication.txtShareApplication.value == "")){
				alert("Please indicate the type of purebred breeds that you are interested in as well as if you would like us to share your application with purebred rescue groups.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else if(frmFosterApplication.txtPreviousPets.value == "Yes" && (frmFosterApplication.txtPreviousPetsType1.value == "" || frmFosterApplication.txtPreviousPetsName1.value == "" || frmFosterApplication.txtPreviousPetsAge1.value == "" || frmFosterApplication.txtPreviousPetsSex1.value == "" || frmFosterApplication.txtPreviousPetsAltered1.value == "" || frmFosterApplication.txtPreviousPetsCharacteristics1.value == "")){
				alert("Please specify all the details of at least one of your previous pets.");
				rowButtons.style.display = "inline";
				rowPleaseWait.style.display = "none";
				bolReturnCode = false;
			} else {
				bolReturnCode = true;
			}
		}
		return bolReturnCode;
	}
	
	function validateSurrenderApplication(){
		var bolReturnCode = false;
		var strFirstName = frmSurrenderApplication.txtOwnerFirstName.value;
		var strLastName = frmSurrenderApplication.txtOwnerLastName.value;
		if(frmSurrenderApplication.txtDogName.value == "" || frmSurrenderApplication.txtBreed == "" || frmSurrenderApplication.txtAge == "" || frmSurrenderApplication.txtSex == "" || frmSurrenderApplication.txtOwnerFirstName == "" || frmSurrenderApplication.txtOwnerLastName == "" || frmSurrenderApplication.txtStreetAddress == "" || frmSurrenderApplication.txtCity == "" || frmSurrenderApplication.txtState == "" || frmSurrenderApplication.txtZipCode == "" || frmSurrenderApplication.txtHomePhone == "" || frmSurrenderApplication.txtEmailAddress == "" || frmSurrenderApplication.txtSpayedNeutered == "" || frmSurrenderApplication.txtLicensed == "" || frmSurrenderApplication.txtAKCPapers == "" || frmSurrenderApplication.txtOwnedFor == "" || frmSurrenderApplication.txtGotFrom == "" || frmSurrenderApplication.txtReason == "" || frmSurrenderApplication.txtHousebroken == "" || frmSurrenderApplication.txtNeglectedAbused == "" || (frmSurrenderApplication.txtFriendlyWithAdults == "" && frmSurrenderApplication.txtFriendlyWithMen == "" && frmSurrenderApplication.txtFriendlyWithWomen == "" && frmSurrenderApplication.txtFriendlyWithChildren == "" && frmSurrenderApplication.txtFriendlyWithStrangers == "" && frmSurrenderApplication.txtFriendlyWithOtherDogs == "" && frmSurrenderApplication.txtFriendlyWithCats == "") || frmSurrenderApplication.txtAlarmBark == "" || frmSurrenderApplication.txtProtective == "" || frmSurrenderApplication.txtAggressive == "" || frmSurrenderApplication.txtObedienceTraining == "" || frmSurrenderApplication.txtPrimarilyKept == "" || frmSurrenderApplication.txtExercise == "" || frmSurrenderApplication.txtFoodTypeBrand == "" || frmSurrenderApplication.txtFoodCannotEat == "" || frmSurrenderApplication.txtSit == "" || frmSurrenderApplication.txtDown == "" || frmSurrenderApplication.txtStay == "" || frmSurrenderApplication.txtHeel == "" || frmSurrenderApplication.txtCome == "" || frmSurrenderApplication.txtVetCare == "" || frmSurrenderApplication.txtRabies == "" || frmSurrenderApplication.txtDHLPP == "" || frmSurrenderApplication.txtHeartworm == "" || frmSurrenderApplication.txtBordetella == "" || frmSurrenderApplication.txtLyme == "" || frmSurrenderApplication.txtWorming == "" || frmSurrenderApplication.txtHeartwormPreventative == "" || frmSurrenderApplication.txtFleaControl == "" || frmSurrenderApplication.txtOtherProblems == "" || frmSurrenderApplication.txtWillingToStay == "" || frmSurrenderApplication.txtTransferPossession == "" || frmSurrenderApplication.txtSecurityImage.value == ""){
			alert("All fields in bold are required.\n\nPlease try again.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(strFirstName.indexOf('@') >= 0 || strLastName.indexOf('@') >= 0){
			alert("Please enter a valid first and last name.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else if(!emailCheck(frmSurrenderApplication.txtEmailAddress.value)){
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			bolReturnCode = false;
		} else {
			bolReturnCode = true;
		}
		return bolReturnCode
	}

	function validateVolunteerApplication(){
		var strFirstName = frmVolunteerApplication.txtFirstName.value;
		var strLastName = frmVolunteerApplication.txtLastName.value;
		if(frmVolunteerApplication.txtFirstName.value == "" || frmVolunteerApplication.txtLastName.value == "" || frmVolunteerApplication.txtHomePhone.value == "" || frmVolunteerApplication.txtStreetAddress.value == "" || frmVolunteerApplication.txtCity.value == "" || frmVolunteerApplication.txtState.value == "" || frmVolunteerApplication.txtZipCode.value == "" || frmVolunteerApplication.txtEmailAddress.value == "" || frmVolunteerApplication.txtRescueBefore.value == "" || frmVolunteerApplication.txtHaveDogs.value == "" || frmVolunteerApplication.txtOtherPets.value == "" || frmVolunteerApplication.txtCurrentStatus.value == "" || frmVolunteerApplication.txtChildren.value == "" || (frmVolunteerApplication.chkAvailableTime1 == "" && frmVolunteerApplication.chkAvailableTime2.value == "" || frmVolunteerApplication.chkAvailableTime3.value == "") || frmVolunteerApplication.txtDrive.value == "" || frmVolunteerApplication.txtFosterHome.value == "" || (frmVolunteerApplication.chkHelpWith1.value == "" && frmVolunteerApplication.chkHelpWith2.value == "" || frmVolunteerApplication.chkHelpWith3.value == "" || frmVolunteerApplication.chkHelpWith4.value == "" || frmVolunteerApplication.chkHelpWith5.value == "" || frmVolunteerApplication.chkHelpWith6.value == "") || frmVolunteerApplication.txtSkills.value == "" || frmVolunteerApplication.txtHeardHow.value == "" || frmVolunteerApplication.txtSecurityImage.value == ""){
			alert("All fields in bold are required.\n\nPlease try again.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			return false;
		} else if(strFirstName.indexOf('@') >= 0 || strLastName.indexOf('@') >= 0){
			alert("Please enter a valid first and last name.");
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			return false;
		} else if(!emailCheck(frmVolunteerApplication.txtEmailAddress.value)){
			rowButtons.style.display = "inline";
			rowPleaseWait.style.display = "none";
			return false;
		} else {
			return true;
		}
	}

	function verifyIncoming(){
		var bolSelection = confirm('All votes on this page are final and cannot be changed once submitted.\n\nAre you sure you want to submit these votes?');

		if(bolSelection == true){
			return true;
		} else {
			return false;
		}
	}

	function updateOrder(){
		var lngShirtTotal = 0;
		var lngShippingTotal = 0;
		var lngOrderTotal = 0;
		var lngPriceSmall = 12;
		var lngPriceMedium = 12;
		var lngPriceLarge = 12;
		var lngPriceXLarge = 12;
		var lngPriceXXLarge = 13;
		var lngPriceXXXLarge = 14;
		var lngShippingCost = 3;

		lngShirtTotal = (parseInt(frmOrderShirts.cboSmall.value) * lngPriceSmall) + (parseInt(frmOrderShirts.cboMedium.value) * lngPriceMedium) + (parseInt(frmOrderShirts.cboLarge.value) * lngPriceLarge) + (parseInt(frmOrderShirts.cboXLarge.value) * lngPriceXLarge) + (parseInt(frmOrderShirts.cboXXLarge.value) * lngPriceXXLarge) + (parseInt(frmOrderShirts.cboXXXLarge.value) * lngPriceXXXLarge);

		if(frmOrderShirts.cboDeliveryPickup.value == "Delivery"){
			lngShippingTotal = (parseInt(frmOrderShirts.cboSmall.value) * lngShippingCost) + (parseInt(frmOrderShirts.cboMedium.value) * lngShippingCost) + (parseInt(frmOrderShirts.cboLarge.value) * lngShippingCost) + (parseInt(frmOrderShirts.cboXLarge.value) * lngShippingCost) + (parseInt(frmOrderShirts.cboXXLarge.value) * lngShippingCost) + (parseInt(frmOrderShirts.cboXXXLarge.value) * lngShippingCost);
		}
		lngOrderTotal = lngShirtTotal + lngShippingTotal;

		lngShirtTotal = "$" + lngShirtTotal + ".00";
		lngShippingTotal = "$" + lngShippingTotal + ".00";
		lngOrderTotal = "$" + lngOrderTotal + ".00";

		document.getElementById('txtShirtTotal').innerHTML=lngShirtTotal;
		document.getElementById('txtShippingTotal').innerHTML=lngShippingTotal;
		document.getElementById('txtOrderTotal').innerHTML=lngOrderTotal;
	}

	function validateOrderForm(){
		if(frmOrderShirts.txtFirstName.value == "" || frmOrderShirts.txtLastName.value == ""){
			alert("Please enter your first and last name.");
			return false;
		} else if(frmOrderShirts.cboDeliveryPickup.value == ""){
			alert("Please specify delivery or pickup.");
			return false;
		} else if(frmOrderShirts.cboDeliveryPickup.value == "Delivery" && (frmOrderShirts.txtStreetAddress1.value == "" || frmOrderShirts.txtCity.value == "" || frmOrderShirts.txtState.value == "" || frmOrderShirts.txtZipCode.value == "")){
			alert("Please enter your shipping information.");
			return false;
		} else if(frmOrderShirts.cboSmall.value == 0 && frmOrderShirts.cboMedium.value == 0 && frmOrderShirts.cboLarge.value == 0 && frmOrderShirts.cboXLarge.value == 0 && frmOrderShirts.cboXXLarge.value == 0 && frmOrderShirts.cboXXXLarge.value == 0){
			alert("Please select at least one shirt.");
			return false;
		} else {
			return true;
		}
	}

	function validateRSVPForm(){
		rowPleaseWait.style.display='inline';
		rowButtons.style.display='none';

		var lngPicnicTotal = 0;

		if(frmRSVP.txtFirstName.value == "" || frmRSVP.txtLastName.value == "" || frmRSVP.txtStreetAddress1.value == "" || frmRSVP.txtCity.value == "" || frmRSVP.txtState.value == "" || frmRSVP.txtZipCode.value == "" || frmRSVP.txtPhoneNumber.value == "" || frmRSVP.txtEmailAddress.value == "" || frmRSVP.txtChicken.value == "" || frmRSVP.txtPulledPork.value == ""){
			alert("All fields are required.  Please try again.\n\n(If you do not want to order one of the dinner choices, please enter 0 (zero) in the corresponding box.)");

			rowPleaseWait.style.display='none';
			rowButtons.style.display='inline';

			return false;
		} else if(!emailCheck(frmRSVP.txtEmailAddress.value)){
			rowPleaseWait.style.display='none';
			rowButtons.style.display='inline';

			return false;
		} else if(!IsNumeric(frmRSVP.txtChicken.value) || !IsNumeric(frmRSVP.txtChicken.value)){
			alert("Please enter numbers for your dinner choices.");

			rowPleaseWait.style.display='none';
			rowButtons.style.display='inline';

			return false;
		} else {
			rowPleaseWait.style.display='inline';
			rowButtons.style.display='none';

			lngPicnicTotal = (parseInt(frmRSVP.txtChicken.value) + parseInt(frmRSVP.txtPulledPork.value)) * 8;
			
			if(lngPicnicTotal == 0){
				alert("Thank you for your RSVP.\n\nWe'll see you at the picnic!!");
			} else {
				alert("Please send a check made payable to Peppertree Rescue for $" + lngPicnicTotal + ".00 to:\n\nPeppertree Rescue\nPO Box 2396\nAlbany, NY 12220-0396\n\nWe will also be sending a confirmation email to " + frmRSVP.txtEmailAddress.value + ".\n\nSee you there!!");
			}

			return true;
		}
	}

	function IsNumeric(sText){
		var ValidChars = "0123456789";
		var IsNumber=true;
		var Char;

		for (i = 0; i < sText.length && IsNumber == true; i++){ 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1){
				IsNumber = false;
			}
		}
		return IsNumber;
	}


	function checkForm(strFormName) {
		if(!checkRequired(document.forms[strFormName])) {
			if(document.all) {
//				document.all.spanError.innerText = 'Please fill in all required fields.';
			} else {
//				document.getElementById('spanError').innerHTML = 'Please fill in all required fields.';
			}
			alert("Please fill in all required fields.");
		} else {
//			document.forms[strFormName].submit();  
			alert("OK");
		}
	} 

	function checkRequired(frmData) {
		var bFail;
		bFail = false; // Default to pass

		for(iElement = 0; iElement < frmData.elements.length; iElement++) {
			if(frmData.elements[iElement].className == 'requiredInputField' || frmData.elements[iElement].className == 'missingInfoField') {
				if(frmData.elements[iElement].value == '') {
					bFail = true;
					frmData.elements[iElement].className = 'missingInfoField';
				} else {
					frmData.elements[iElement].className = 'requiredInputField';
				}
			}
		}
		return !bFail;
	}

	function isAlphaNumeric(strField){
	//ln
		//alert("I'm in isAlphaNumeric.");
	
		var strFieldValue = strField.value;
		var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ";
		var IsAlphaNumeric=true;
		var Char;

		for (i = 0; i < strFieldValue.length && IsAlphaNumeric == true; i++){ 
			Char = strFieldValue.charAt(i); 
			if (ValidChars.indexOf(Char) == -1){
				IsAlphaNumeric = false;
				alert("This field can only contain letters.  Please try again.");
				strField.focus();
				strField.select();
			}
		}

		//ln put toProperCase here
		if (IsAlphaNumeric == true){
			strField.value = toProperCase(strFieldValue);
		}

		return IsAlphaNumeric;
	}
	
	function fieldToProperCase(strField){
		var strFieldValue = strField.value;
		strField.value = toProperCase(strFieldValue);	
	}
	// proper case function (JScript 5.5+)
	function toProperCase(s)
	{
	  return s.toLowerCase().replace(/^(.)|\s(.)|.\s\s(.)/g, 
       function($1) { return $1.toUpperCase(); });

	}