/*function called from emailpartnerform.asp*/
function emailPartVal() 
{
	emailcheck1=/\@/
	emailcheck2=/\./

	retval = false;
	if (emailform.body.value !=  "")
		if (emailform.senderemail.value.length > 0)
			if (emailcheck1.test(emailform.senderemail.value))
				if (emailcheck2.test(emailform.senderemail.value))
					retval = true;
				else{
				alert("Please enter a valid email address")
				}
			else{
			alert("Please enter a valid email address")
			}
		else{
		alert("Please enter a valid email address")
		}
	else{
	alert("Please enter a message if you are sending an email")
	}

	return retval;
}
/*function called from emailpartnerform.asp*/

/*functions called on every public page*/
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/*function called from editpage.asp*/
function deletion_msg()
{
	var msg = "Are you sure you want to delete this entry?";
	if (confirm(msg))
		return true;
	else
		return false;
}
/*function called from lesson.asp*/
function popUp(URL) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=350,left = 412,top = 284');");
}
/*function called from newsletter.asp*/
function newsVal(){
	
	emailcheck1=/\@/
	emailcheck2=/\./
	numcheck=/[^0-9]$/
	namecheck=/^[a-zA-Z]{1,}/
	retval = false;
	
	if (newsform.firstname.value.length > 0)
		if(namecheck.test(newsform.firstname.value))
			if(numcheck.test(newsform.firstname.value))
				if (newsform.lastname.value.length > 0)
						if(namecheck.test(newsform.lastname.value))
							if(numcheck.test(newsform.lastname.value))
								if (newsform.email.value.length > 0)
									if (emailcheck1.test(newsform.email.value))
										if (emailcheck2.test(newsform.email.value))
											if (newsform.email.value == newsform.verifyemail.value)
												retval = true;
											else{
												alert("Emails do not match. Try Again")
												newsform.email.value = "";
												newsform.verifyemail.value = "";
												newsform.email.select()
											}												
										else{
											alert("Please enter a valid email address")
											newsform.email.select()
											}
									else{
										alert("Please enter a valid email address")
										newsform.email.select()
										}
								else{
									alert("Please enter a valid email address")
									newsform.email.select()
									}
							else{

								alert("Please check your last name")
								newsform.lastname.select()
								}
						else{
							alert("Please check your last name")
							newsform.lastname.select()
						}
				else{
					alert("Please enter your last name")
					newsform.lastname.select()
				}
			else{
				alert("Please check your first name")
				newsform.firstname.select()
			}
		else{
			alert("Please check your first name")
			newsform.firstname.select()
		}
	else{
		alert("Please enter your first name")
		newsform.firstname.select()
	}
	return retval;
}
/*function called from rsvp.asp*/
function rsvpVal(){

	numcheck=/[0-9]$/
	retval = false;

	if (rsvpform.fullname.value.length > 0)
		if (rsvpform.attending[0].checked || rsvpform.attending[1].checked)
			if (numcheck.test(rsvpform.num_attending.value))
				retval = true;
			else{
				alert("Please enter a valid value for number attending")
				rsvpform.num_attending.select()
			}
		else{
			alert("Please note whether you will be attending or not")
		}
	else{
		alert("Please enter your full name")
		rsvpform.fullname.select()
	}	
		
	return retval;	
}
/*function called from partnerform.asp*/
function partnerVal(){

	emailcheck1=/\@/
	emailcheck2=/\./
	numcheck=/[^0-9]$/
	letcheck=/[^a-zA-Z]/
	namecheck=/^[a-zA-Z]{1,}/
	retval = false;	

	if (partnerform.firstname.value.length > 0)
		if(numcheck.test(partnerform.firstname.value))
			if(namecheck.test(partnerform.firstname.value))
					if (partnerform.lastname.value.length > 0)
						if(numcheck.test(partnerform.lastname.value))
							if(namecheck.test(partnerform.lastname.value))
								if (partnerform.gender.value != "none")
									if (partnerform.height.value != "none")
										if (partnerform.weight.value != "none")
											if (partnerform.phone.value.length < 13)
												if (partnerform.email.value.length > 0)
													if(emailcheck1.test(partnerform.email.value))
														if(emailcheck2.test(partnerform.email.value))
																if (partnerform.tryout.value != "none")
																	if(partnerform.aggieclass.value.length == 4)
																			if(letcheck.test(partnerform.aggieclass.value))
																				if (partnerform.email.value == partnerform.verifyemail.value)
																					retval = true;
																				else{
																					partnerform.email.value = "";
																					partnerform.verifyemail.value = "";
																					alert("Emails do not match. Try again.")
																					partnerform.email.select();
																				}
																			else{
																				alert("Please enter a valid Aggie Class")
																				partnerform.aggieclass.select();
																			}
																		else{
																			alert("Please enter a valid Aggie Class")
																			partnerform.aggieclass.select();
																		}
																else{
																	alert("Please enter whether you are trying out")
																	partnerform.tryout.focus();
																}
							
													else{
														alert("Please enter a valid email")
														partnerform.email.select();
													}
												else{
													alert("Please enter a valid email")
													partnerform.email.select();
												}
											else{
												alert("Please enter your email")
												partnerform.email.select();
											}
										else{
											alert("Please enter a valid phone number")
											partnerform.phone.select();
										}
									else{
										alert("Please enter your weight range")
										partnerform.weight.focus();
									}
								else{
									alert("Please enter your height")
									partnerform.height.focus();	
								}
							else{
								alert("Please enter your gender")
								partnerform.gender.focus();
							}
						else{
							alert("Please enter a valid Last Name")
							partnerform.lastname.select();
						}															
					else{
						alert("Please enter a valid Last Name")
						partnerform.lastname.select();
					}
				else{
					alert("Please enter a Last Name")
					partnerform.lastname.select();
				}
			else{
				alert("Please enter a valid First Name")
				partnerform.firstname.select();
			}
		else{
			alert("Please enter a valid First Name")
			partnerform.firstname.select();
		}
	else{
		alert("Please enter your First Name")
		partnerform.firstname.select();
	}
	return retval;
}
/*functions called in partnersearch.asp*/
function other_validate () {

	retval = false

	if (searchnameform.recordsperpage.value != "none")
			retval = true;
	else{
		alert("Please enter the number of records per page")
	}
	
	return retval;
}
function checkBoxVal(){

	retval = false;
	
	if ((searchotherform.heightrange.checked) && ((searchotherform.maxheight.value == "none") || (searchotherform.minheight.value == "none")))
	{	
		retval = false;
		alert("Please enter a specified height range")
		searchotherform.minheight.focus();
		return retval;
	}
	else if ((searchotherform.weightrange.checked) && ((searchotherform.maxweight.value == "none") || (searchotherform.minweight.value == "none")))
	{
		retval = false;
	    alert("Please enter a specified weight range")
	    searchotherform.minweight.focus(); 
	    return retval;
	}
	else if ((searchotherform.tryoutrange.checked) && (searchotherform.tryout.value == "none")) 
	{
		retval = false;
	    alert("Please enter a tryout value")
	    searchotherform.tryout.focus();
	    return retval;
	}
	else if ((searchotherform.heightrange.checked) && (searchotherform.maxheight.value <= searchotherform.minheight.value))
	{
		retval = false;
		alert("Max Height cannot be less than or equal to Min Height")
		searchotherform.minheight.focus();
		return retval;
	}
	else if ((searchotherform.weightrange.checked) && (searchotherform.maxweight.value <= searchotherform.minweight.value))
	{
		retval = false;
		alert("Max Weight cannot be less than or equal to Min Weight")
		searchotherform.minheight.focus();
		return retval;
	}
	else
		retval = true;
		
	if (searchotherform.gender.value != "none")
		if (searchotherform.recordsperpage.value != "none")
		{
			retval = true;
			return retval;
		}
		else
		{
			alert("Please enter the amount of records per page")
			searchotherform.recordsperpage.focus();
			retval = false;
			return retval;
		}
	else
	{
		alert("Please enter a gender to search for")
		searchotherform.gender.focus();
		retval = false;
		return retval;
	}
}
function disable_enableheight(theForm)
{
  searchotherform.minheight.disabled    = !searchotherform.minheight.disabled;
  searchotherform.maxheight.disabled   = !searchotherform.maxheight.disabled;
}
function disable_enableweight(theForm)
{
  searchotherform.minweight.disabled    = !searchotherform.minweight.disabled;
  searchotherform.maxweight.disabled   = !searchotherform.maxweight.disabled;

}
function disable_enabletryout(theForm)
{
  searchotherform.tryout.disabled = !searchotherform.tryout.disabled;
}
function publicReqVal(){
	
	numcheck=/[^0-9]$/
	letcheck=/[^a-zA-Z]/
	namecheck=/^[a-zA-Z]{1,}/
	retval = false;

	if (requestform.firstname.value.length > 0)
		if(numcheck.test(requestform.firstname.value))
			if(namecheck.test(requestform.firstname.value))
				if (requestform.lastname.value.length > 0)
					if(numcheck.test(requestform.lastname.value))
						if(namecheck.test(requestform.lastname.value))
										if(requestform.tele.value.length > 0)
											if(letcheck.test(requestform.tele.value))
												if(requestform.atele.value.length > 0)
													if(letcheck.test(requestform.atele.value))
															if((requestform.hour.value != "none") && (requestform.minute.value != "none") && (requestform.ampm.value!= "none"))
																if(requestform.perform.value.length > 0)
																	if(requestform.locate.value.length > 0)
																		if(requestform.city.value.length > 0)
																			if(requestform.state.value != "none")
																				if (requestform.monthreq.value != "no")
																					if (requestform.dayreq.value != "no")
																						if (requestform.yearreq.value != "none")
																							retval = true;
																						else{
																							alert("Please enter the year for performance")
																							requestform.yearreq.focus();
																						}
																					else{
																						alert("Please enter the day for performance")
																						requestform.dayreq.focus();
																					}
																				else{
																					alert("Please enter the month for performance")
																					requestform.monthreq.focus();
																				}
																			else{
																				alert("Please enter a valid state")
																				requestform.state.focus()
																			}
																		else{
																			alert("Please enter a valid city")
																			requestform.city.select()
																		}
																	else{
																		alert("Please enter a valid location")
																		requestform.locate.select()
																	}	
																else{
																	alert("Please enter what the performance is for")
																	requestform.perform.select()
																}
															else{
																alert("Please enter a valid time")
																requestform.hour.focus()
															}
													else{
														alert("Please enter a valid alternative number")
														requestform.atele.select()
													}
												else{
													alert("Please enter a valid alternative number")
													requestform.atele.select()
												}
											else{
												alert("Please enter a valid telephone number")
												requestform.tele.select()
											}
										else{
											alert("Please enter a valid telephone number")
											requestform.tele.select()
										}
						else{
							alert("Please enter a valid Last Name")
							requestform.lastname.select()
						}
					else{
						alert("Please enter a valid Last Name")
						requestform.lastname.select()
					}
				else{
					alert("Please enter a valid Last Name")
					requestform.lastname.select()
				}
			else{
				alert("Please enter a valid First Name")
				requestform.firstname.select()
			}
		else{
			alert("Please enter a valid First Name")
			requestform.firstname.select()
		}
	else{
		alert("Please enter your First Name")
		requestform.firstname.select()
	}
	return retval;
}
/*function called from searchname.asp, searchother.asp*/
function go()
{
	box = document.forms['searchsort'].sortfunction;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}
