

	<!--POP UP WINDOW FUNCTION------------------------------------>

	function dirtypop(title, info)

	{

		var title = title;

		var info = info;

		//alert (page_name);

		var generator=window.open('','name','height=300,width=400,status=1');

			generator.document.write('<html><head><title>'+title+'</title>');

			generator.document.write('</head><body>');

			generator.document.write('<h1 style="font-family:Arial Narrow, Arial; color:#892034; font-size: 16px">'+title+'</h1>');

			generator.document.write('<p style="text-align: justify; font-size: 12px; font-family: Arial Narrow, Arial">'+info+'</p>');

			//generator.document.write('<p style="text-align: justify; font-size: 12px; font-family: Arial Narrow, Arial"><a href="javascript:alert(self.location.href)">View the URL of this window</a>.</p>');

			generator.document.write('<p style="text-align: right; font-size: 12px; font-family: Arial Narrow, Arial" ><a href="javascript:self.close()">Close</a></p>');

			generator.document.write('</body></html>');	

			generator.document.close();

	}

	

	<!--VALIDATE FIELDS FOR FORMS------------------------------------>

	function validate_required(field,alerttxt)

	{

		with (field)

		{

			if (value==null||value=="")

			  {alert(alerttxt);return false}

			else {return true}

		}

	}

	

	<!--VALIDATE EMAIL ADDRESS FIELDS-------------------------------->

	function validate_email(field,alerttxt)

	{

		with (field)

		{

			apos=value.indexOf("@")

			dotpos=value.lastIndexOf(".")

			if (apos<1||dotpos-apos<2) 

			{alert(alerttxt);return false}

			else {return true}

		}

	}

	<!--VALIDATE PHONE NUMBER FIELDS--------------------------------->



	

	// Declaring required variables

	var digits = "0123456789";

	// non-digit characters which are allowed in phone numbers

	var phoneNumberDelimiters = "()- ";

	// characters which are allowed in international phone numbers

	// (a leading + is OK)

	var validWorldPhoneChars = phoneNumberDelimiters + "+";

	// Minimum no of digits in an international phone no.

	var minDigitsInIPhoneNumber = 10;

	

	function isInteger(s)

	{   

		var i;

		for (i = 0; i < s.length; i++)

		{   

			// Check that current character is number.

			var c = s.charAt(i);

			if (((c < "0") || (c > "9"))) return false;

		}

		// All characters are numbers.

		return true;

	}

	

	function stripCharsInBag(s, bag)

	{   var i;

		var returnString = "";

		// Search through string's characters one by one.

		// If character is not in bag, append to returnString.

		for (i = 0; i < s.length; i++)

		{   

			// Check that current character isn't whitespace.

			var c = s.charAt(i);

			if (bag.indexOf(c) == -1) returnString += c;

		}

		return returnString;

	}

	

	function checkInternationalPhone(strPhone)

	{

		s=stripCharsInBag(strPhone,validWorldPhoneChars);

		return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

	}

	

	



	

	

	<!--VALIDATE SPECFIC FORMS----------------------------------------->

	function validate_createGroup(thisform)

	{

		with (thisform)

		{

			if (validate_required(gName,"Please state a unique group Name.")==false)

				{gName.focus();return false}

		}

	}

	<!--------------------------------------->

	function validate_login(thisform)

	{

		with (thisform)

		{

		if (validate_required(gName,"Please select your group's Name.")==false)

		  	{gName.focus();return false}

		}

	}

	<!--------------------------------------->

	function selectText(currentObject)

	{

		currentObject.select();

	}

	

	<!------------------------------------->

	function validate_iRegistration(thisform)

	{

		with (thisform)

		{

		if (validate_required(fName,"Please state your first name.")==false)

		  	{fName.focus();return false}

		else if(validate_required(mName,"Please state your middle name.")==false)

		  	{mName.focus();return false}

		else if(validate_required(lName,"Please state your last name.")==false)

		  	{lName.focus();return false}

		else if(validate_required(addressLine1,"Please state your primary address.")==false)

		  	{addressLine1.focus();return false}

		else if(validate_required(city,"Please state the city in which you live.")==false)

		  	{city.focus();return false}

		else if(validate_required(state,"Please select the state in which you live.")==false)

		  	{state.focus();return false}

		else if(validate_required(zip,"Please state the zipcode in which you live.")==false)

		  	{zip.focus();return false}

		else if(validate_required(primaryPhone,"Please state your primary phone number.")==false)

		  	{primaryPhone.focus();return false}

		else if (checkInternationalPhone(primaryPhone.value)==false)

			{alert("Please Enter a Valid Primary Phone Number")

			primaryPhone.value=""

			primaryPhone.focus();return false}

		else if(validate_required(primaryPhoneType,"Please select a primary phone type.")==false)

		  	{primaryPhoneType.focus();return false}

		else if (secondaryPhone.value !== "")

			{

				if (checkInternationalPhone(secondaryPhone.value)==false)

					{alert("Please Enter a Valid Secondary Phone Number")

					secondaryPhone.value=""

					secondaryPhone.focus();return false}

				else if(validate_required(secondaryPhoneType,"Please select your secondary phone type.")==false)

		  		{secondaryPhoneType.focus();return false}

			}

		else if(validate_required(primaryEmail,"Please state your primary email address.")==false)

		  	{primaryEmail.focus();return false}

		else if (validate_email(primaryEmail,"Not a valid primary e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

			{

				primaryEmail.value=""

			  	primaryEmail.focus();return false

			}

		else if (secondaryEmail.value !== "")

			{

				if (validate_email(secondaryEmail,"Not a valid secondary e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

					  {secondaryEmail.value=""

					  secondaryEmail.focus();return false}

			}

		else if(validate_required(medCo,"Please state your Medical Insurance Company. If you do not have medical insurance please state 'No Insurance'.")==false)

		  	{medCo.focus();return false}

		else if(validate_required(medPoNo,"Please state your Medical Insurance Policy Number. If you do not have medical insurance please state 'No Insurance'.")==false)

		  	{medPoNo.focus();return false}

		else if(validate_required(school,"Please state the school you are currently attending.")==false)

		  	{school.focus();return false}

		<!--PARENT INFORMATION-->

		else if(validate_required(parentfName,"Please state your Parent or Gaurdian's First Name.")==false)

		  	{parentfName.focus();return false}

		else if(validate_required(parentlName,"Please state your Parent or Gaurdian's Last Name.")==false)

		  	{parentlName.focus();return false}

		else if(validate_required(parentPhoneNum,"Please state your Parent or Gaurdian's Phone Number.")==false)

		  	{parentPhoneNum.focus();return false}

		else if (checkInternationalPhone(parentPhoneNum.value)==false)

			{

				alert("Please Enter a Valid Parent Phone Number")

				parentPhoneNum.value=""

				parentPhoneNum.focus();return false

			}

		else if(validate_required(parentPhoneType,"Please select your parent or gaurdian's phone number type.")==false)

		  	{parentPhoneType.focus();return false}

		else if(validate_required(parentEmail,"Please state your parent's email address.")==false)

		  	{parentEmail.focus();return false}

		else if (validate_email(parentEmail,"Not a valid parent e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

			{parentEmail.value=""

			parentEmail.focus();return false}

		<!--validate optional info-->

		else if (coachEmail.value !== "")

			{

				if (validate_email(coachEmail,"Not a valid coach e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

					  {coachEmail.value=""

					  coachEmail.focus();return false}

				else if(validate_required(coachfName,"You forgot your coach's First Name!")==false)

					{coachfName.focus();return false}

				else if(validate_required(coachLName,"You forgot your coach's Last Name!")==false)

					{coachLName.focus();return false}

			}

		

		else if(validate_required(camps,"Please state what camp you would like to attend.")==false)

		  	{camps.focus();return false}

		else if(validate_required(shirt,"Please select your shirt size.")==false)

		  	{shirt.focus();return false}

		}

	}

	

	function enableCommuting(thisform)

	{

		with (thisform)

		{

			commuter.value = "Undecided";

			commuter.disabled = true;

			laundry.disabled = true; <!--laundry option not available-->

			rm1FirstName.disabled = true;

			rm1LastName.disabled = true;

			rm2FirstName.disabled = true;

			rm2LastName.disabled = true;

			laundry.value = "No Laundry Service"; <!--laundry option not available-->

			rm1FirstName.value = "";

			rm1LastName.value = "";

			rm2FirstName.value = "";

			rm2LastName.value = "";

			var extract1 = camps.value.substring(0,2);

			if ((extract1 == "AL") )
			{
				commuter.disabled = true;

			}
			else
			{
				commuter.disabled = false;
				
				var str = camps.value.substring(0);
				var pos = str.match("Eight");
				var pos2 = str.match("Six");
				if ((pos == "Eight")||(pos2 == "Six"))
				{
					commuter.value = "No";
					laundry.disabled = false;
					rm1FirstName.disabled = false;
					rm1LastName.disabled = false;
					rm2FirstName.disabled = false;
					rm2LastName.disabled = false;
				} 	
				else{
					commuter.disabled = false;
				}	
			}

			

		}

	}

	 

	function enableLaundry(thisform)

	{

		with (thisform)

		{

			laundry.disabled = true; <!--laundry option not available-->

			rm1FirstName.disabled = true;

			rm1LastName.disabled = true;

			rm2FirstName.disabled = true;

			rm2LastName.disabled = true;

			laundry.value = "No Laundry Service"; <!--laundry option not available-->

			rm1FirstName.value = "";

			rm1LastName.value = "";

			rm2FirstName.value = "";

			rm2LastName.value = "";

			

			if (commuter.value == "No" )

			{

				rm1FirstName.disabled = false;

				rm1LastName.disabled = false;

				rm2FirstName.disabled = false;

				rm2LastName.disabled = false;

				laundry.disabled = false; <!--laundry option is available-->

			}

			

		}

	}

	

	function enableRegistration(thisform)

	{

		

		with (thisform)

		{

			register.disabled = true; <!--register option not available-->

			

			if (agree.checked == true)

			{

				register.disabled = false;

			}

			

		}

	}

	

	function validate_joinGroup(thisform)

	{

		with (thisform)

		{

		if (validate_required(fName,"Please state your first name.")==false)

		  	{fName.focus();return false}

		else if(validate_required(mName,"Please state your middle name.")==false)

		  	{mName.focus();return false}

		else if(validate_required(lName,"Please state your last name.")==false)

		  	{lName.focus();return false}

		else if(validate_required(addressLine1,"Please state your primary address.")==false)

		  	{addressLine1.focus();return false}

		else if(validate_required(city,"Please state the city in which you live.")==false)

		  	{city.focus();return false}

		else if(validate_required(state,"Please select the state in which you live.")==false)

		  	{state.focus();return false}

		else if(validate_required(zip,"Please state the zipcode in which you live.")==false)

		  	{zip.focus();return false}

		else if(validate_required(primaryPhone,"Please state your primary phone number.")==false)

		  	{primaryPhone.focus();return false}

		else if (checkInternationalPhone(primaryPhone.value)==false)

			{alert("Please Enter a Valid Primary Phone Number")

			primaryPhone.value=""

			primaryPhone.focus();return false}

		else if(validate_required(primaryPhoneType,"Please select a primary phone type.")==false)

		  	{primaryPhoneType.focus();return false}

		else if (secondaryPhone.value !== "")

			{

				if (checkInternationalPhone(secondaryPhone.value)==false)

					{alert("Please Enter a Valid Secondary Phone Number")

					secondaryPhone.value=""

					secondaryPhone.focus();return false}

				else if(validate_required(secondaryPhoneType,"Please select your secondary phone type.")==false)

		  		{secondaryPhoneType.focus();return false}

			}

		else if(validate_required(primaryEmail,"Please state your primary email address.")==false)

		  	{primaryEmail.focus();return false}

		else if (validate_email(primaryEmail,"Not a valid primary e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

			{

				primaryEmail.value=""

			  	primaryEmail.focus();return false

			}

		else if (secondaryEmail.value !== "")

			{

				if (validate_email(secondaryEmail,"Not a valid secondary e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

					  {secondaryEmail.value=""

					  secondaryEmail.focus();return false}

			}

		else if (isWrestler.value == "Wrestler")

			{

				if(validate_required(medCo,"Please state your Medical Insurance Company. If you do not have medical insurance please state 'No Insurance'.")==false)

					{medCo.focus();return false}

				else if(validate_required(medPoNo,"Please state your Medical Insurance Policy Number. If you do not have medical insurance please state 'No Insurance'.")==false)

					{medPoNo.focus();return false}

				else if(validate_required(school,"Please state the school you are currently attending.")==false)

					{school.focus();return false}

				<!--PARENT INFORMATION-->

				else if(validate_required(parentfName,"Please state your Parent or Gaurdian's First Name.")==false)

					{parentfName.focus();return false}

				else if(validate_required(parentlName,"Please state your Parent or Gaurdian's Last Name.")==false)

					{parentlName.focus();return false}

				else if(validate_required(parentPhoneNum,"Please state your Parent or Gaurdian's Phone Number.")==false)

					{parentPhoneNum.focus();return false}

				else if (checkInternationalPhone(parentPhoneNum.value)==false)

					{

						alert("Please Enter a Valid Parent Phone Number")

						parentPhoneNum.value=""

						parentPhoneNum.focus();return false

					}

				else if(validate_required(parentPhoneType,"Please select your parent or gaurdian's phone number type.")==false)

					{parentPhoneType.focus();return false}

				else if(validate_required(parentEmail,"Please state your parent's email address.")==false)

					{parentEmail.focus();return false}

				else if (validate_email(parentEmail,"Not a valid parent e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

					{parentEmail.value=""

					parentEmail.focus();return false}

				<!--validate optional info-->

				else if (coachEmail.value !== "")

					{

						if (validate_email(coachEmail,"Not a valid coach e-mail address. Example of valid e-mail: 'example@host.com'.")==false)

							  {coachEmail.value=""

							  coachEmail.focus();return false}

						else if(validate_required(coachfName,"You forgot your coach's First Name!")==false)

							{coachfName.focus();return false}

						else if(validate_required(coachLName,"You forgot your coach's Last Name!")==false)

							{coachLName.focus();return false}

					}

			}

		}

	}

	

	function validate_iType(thisform)

	{

		with (thisform)

		{

		if(iType.value == "Undecided")

		  	{

				alert ("Please select a status.");

				iType.focus();return false

			}

		}

	}


function validate_payType(thisform)

	{

		with (thisform)

		{

		if((amount.value == "") || (amount.value == "0"))

		  	{

				alert ("Please type the dollar value of the amount you owe. Ex:(595)");

				amount.focus();return false

			}

		}

	}

	

	function delPerson(individualID,gName,fName,lName) 

	{

		if (confirm("Are you sure you want to delete " + fName + " " + lName +" from " + gName + "?"))

			{document.location = "manage.php?del=" + individualID + "&gName=" + gName;}

		

		

	}	

	

	

	function enableFields(changedObject)

	{

		var num = document.newGroup.elements.length;

		for (var i=1; i<num; i++)

		{

			if (changedObject.name == "camps")

			{if (document.newGroup.elements[i].name != "camps")
				{if (document.newGroup.elements[i].name != "submit")
	
					{if (document.newGroup.elements[i].name != "back")
	
						{if (document.newGroup.elements[i].name != "reset")
	
							{
	
								document.newGroup.elements[i].disabled = true;
							}
	
						}
	
					}
				}
						

				var fieldType = document.newGroup.elements[i].name.substring(1,5);

				if (fieldType == "comm")

				{

					document.newGroup.elements[i].value = "Undecided";

					var campType = document.newGroup.camps.value.substring(0,5);

					if ((campType != "State") && (campType != "Youth"))

					{document.newGroup.elements[i].disabled = false;
					}

				}

				else if (fieldType == "laun")

				{document.newGroup.elements[i].value = "";}

				else if (fieldType == "rmFi")

				{document.newGroup.elements[i].value = "";}

				else if (fieldType == "rmLa")

				{document.newGroup.elements[i].value = "";}

			}

			else 

			{

				var b = i+1;

				var changedField = changedObject.name.substr(10,2);

				var element = document.newGroup.elements[b].name.substr(9,2);

				var changedField = changedField + (changedObject.name.substr(0,1));

				var element = element + (document.newGroup.elements[b].name.substr(0,1));

									  

				 if (element == changedField)

				 {

					 if (changedObject.name != document.newGroup.elements[b].name)

					 {

						var d = b+1;

						var e = d+1;

						if (changedObject.value == "No" || changedObject.value == "Undecided")

						{

							document.newGroup.elements[b].disabled = false;

							document.newGroup.elements[d].disabled = false;

							document.newGroup.elements[e].disabled = false;

							break;

						}

						else if (changedObject.value == "Yes")

						{

							document.newGroup.elements[b].disabled = true;

							document.newGroup.elements[b].value = "No Laundry Service";

							document.newGroup.elements[d].disabled = true;

							document.newGroup.elements[d].value = "";

							document.newGroup.elements[e].disabled = true;

							document.newGroup.elements[e].value = "";

							break;

						}

					 }

				 }

			}

		}

	}

	

	



function checkFields()

{

	if(validate_required(document.newGroup.camps,"Please select the camp your group would like to attend.")== false)

	{

		document.newGroup.camps.focus();

		return false;}

	else

	{//check remaining fields...

		var num = document.newGroup.elements.length;

		var validFlag = true;

		for(var i=1; i<num; i++)

		{

			var element = document.newGroup.elements[i].name.substr(0,1);

			if (element == "c")

				{var element = "coach";}

			else if (element == "w")

				{element = "wrestler";}

			

			var fieldType = document.newGroup.elements[i].name.substring(1,5);

				if (fieldType == "comm")

				{fieldType = "housing option";}

				else if (fieldType == "laun")

				{fieldType = "laundry option";}

				else if (fieldType == "rmFi")

				{fieldType = "roommate";}
				
				else if (fieldType == "rmLa")

				{fieldType = "roommate";}



			if((document.newGroup.elements[i].value == "Undecided") || (document.newGroup.elements[i].value == ""))

			{

				if((document.newGroup.elements[i].disabled == false) && (fieldType != "roommate"))

				{

					alert("A "+ element + "'s "+ fieldType +" is blank. Please select an option.");

				 	document.newGroup.elements[i].focus();

					return false;

				 	break;

				}

			}

		}

	}

}





