	function requestedDate()
	{
	if (document.tournamentRequest.month.selectedIndex==0){return "no specific date"}else{
										x=document.tournamentRequest.month.options[document.tournamentRequest.month.selectedIndex].text+" "+document.tournamentRequest.date.options[document.tournamentRequest.date.selectedIndex].text+", "+document.tournamentRequest.year.options[document.tournamentRequest.year.selectedIndex].text
										tourndate=new Date(x)
										rdate=dayName[tourndate.getDay()+1]+", "+x;return rdate
																							}
	}

//////////VALIDATE FORM/////////////////////	
var validating=false;

function validate(thisform){
string=""
validating=true;
if(thisform.group_name){
if (thisform.elements["group_name"].value==""){string=string + "\n Name of Group"}
if (thisform.elements["contact_name"].value==""){string=string + "\n Contact's Name"}
}else{
if(!confirm_password(thisform)){return false}
if(thisform.old_password){
if (thisform.elements["old_password"].value==""){string=string + "\n OLD OR CURRENT PASSWORD"}
}else if(!thisform.old_password && thisform.password){
if (thisform.elements["password"].value==""){string=string + "\n A Proper Password"}
}
if (thisform.elements["first_name"].value=="" || thisform.elements["first_name"].value=="first"){string=string + "\n Your First Name"}
if (thisform.elements["last_name"].value=="" || thisform.elements["last_name"].value=="last"){string=string + "\n Your Last Name"}
}
if (!validateEmail(thisform.email)){string = string + "\n Valid E-mail Address"}
if (!validatePhone(thisform.phone)){string = string + "\n  Valid Phone Number"}
validating=false

if (string!=""){
message="You must provide the following:" + string
alert(message)
return false
}
if(thisform.name=="tournamentRequest"){
if (!confirm(thisform.elements['contact_name'].value+": \n\n Thank you for requesting a tournament on "+requestedDate()+". \n\n All requests must be confirmed through further correspondence.  \n A member of our staff will contact you within 48 hours.  \n\n\n Are you ready to submit the information entered?")){return false}else{if(thisform.group_type_specified.value=="specify"){thisform.group_type_specified.value=""};thisform.elements["submit_by"].value=thisform.elements["email"].value;return true;window.close()}		
}
}

function confirm_password(thisform){
if(thisform.password.value!=thisform.confirm_password.value){
alert("Retyping of password did not match.  \nPlease re-enter both password fields.");return false
}else{return true}
}

/////////VALIDATE EMAIL//////////////////////
function validateEmail(email){
validemail=true
for (i=0; i<email.value.length; i+=1){
	//check for invalid characters
	if (email.value.charAt(i)=="/"){validemail=false;break}
	if (email.value.charAt(i)==","){validemail=false;break}
	if (email.value.charAt(i)==";"){validemail=false;break}
	if (email.value.charAt(i)==":"){validemail=false;break}
}
if (validemail){
	atPos = email.value.indexOf("@")//check starting with second character for one @ 
	if (atPos <= 0){validemail=false} //if no @ , email not valid
	if (email.value.indexOf("@",atPos+1)>-1){validemail=false}//check for invalid second @
					}
if (validemail){//check for period in suitable positions
	perPos = email.value.indexOf("..");if(perPos>=0){validemail=false}//if consecutive periods, email is bogus
	perPos = email.value.indexOf(".",atPos);if(perPos < 0){validemail=false}//if no period after @, email is bogus
	perPos = email.value.indexOf(".",email.value.length-2);if (perPos>=0){validemail=false}// if period in one of last two postions, e-mail is bogus
					}
if (!validating && !validemail){
			alert("This is not a valid E-mail address. \nMake sure you type in your complete address\n(eg: you@someplace.com)");
			email.focus();
			email.select()
				}
return validemail
}

////////////VALIDATE PHONE NUMBER/////insist on 10 digits/////////////
function validatePhone(phone)
{
validphone=true 
brcount=0 //count the left(+) and right(-) brackets
numcount=phone.value.length // count total number of characters
for (i=0; i<phone.value.length; i+=1)
		{
		if (isNaN(phone.value.charAt(i))) //skip digits
			{
			numcount=numcount-1 //subtract non-digit characters from count
			if (phone.value.charAt(i)!="-" && phone.value.charAt(i)!=".")//dashes or decimals are OK otherwise check further
				{
				if (phone.value.charAt(i)=="("){brcount=brcount+1}//brackets are OK if left-right count comes out to zero
				if (phone.value.charAt(i)==")"){brcount=brcount-1}
				if (phone.value.charAt(i)!="(" && phone.value.charAt(i)!=")"){validphone=false}//any other character is unacceptable
				}						
			}
		}
if (numcount<10){validphone=false}//numcount should now equal number of digits. Phone numbers must have at least ten digits
if (brcount!=0){validphone=false}//if brackets match up brcount will be zero
if (!validating && !validphone){alert("This is not a valid phone number. \n Do not include letters. \n Only numbers, dashes, and paired parenthesis are allowed in this field. \n Include area code and seven digits.");phone.focus();phone.select()}
return validphone
}	

////////////FOR FIELDS REQUIRING A NUMBER//////////////
function checkForNumber2(input)
{
if (isNaN(input.value)){alert("You must enter a number.");input.focus();input.select();}
}

function checkForNumber(input)
{
if (isNaN(input.value)&&input.value!=""){alert("You must enter a number or leave blank.");input.focus();input.select();}
}

function select_year(thisselector){
if(parseInt(thisselector.options[thisselector.selectedIndex].value)<=now.getMonth()){
thisselector.form.year.options[1].selected=true
}else{
thisselector.form.year.options[0].selected=true
}
}