// JavaScript Document
function openWindow(URL, WIDTH, HEIGHT) {
	 var w = ((screen.width-WIDTH)/2);
	 var h = ((screen.height-HEIGHT)/2);
	 popupWin = window.open(URL, 'remote', 'scrollbars=no,resizable=no,width='+WIDTH+',height='+HEIGHT+',top='+h+',left='+w+'')
}
function openWindow2(URL, WIDTH, HEIGHT) {
	 var w = ((screen.width-WIDTH)/2);
	 var h = ((screen.height-HEIGHT)/2);
	 popupWin = window.open(URL, 'remote', 'scrollbars=yes,resizable=no,width='+WIDTH+',height='+HEIGHT+',top='+h+',left='+w+'')
}
			function CheckContactFriend(form){
					
					if(form.MyName.value==""){
						alert("Please tell us your name!");
						form.MyName.focus();
						return false;
					}
					if(form.MyEmail.value==""){
						alert("Please type your phone number!");
						form.MyEmail.focus();
						return false;
					}
					if(form.FriendsMessage.value==""){
						alert("Please add a message for your friend!");
						form.FriendsMessage.focus();
						return false;
					}

			}
			function CheckContactBug(form){
					
					if(form.MyName.value==""){
						alert("Please tell us your name!");
						form.MyName.focus();
						return false;
					}
					if(form.MyEmail.value==""){
						alert("Please type your phone number!");
						form.MyEmail.focus();
						return false;
					}
					if(form.MyType.value==""){
						alert("Please choose your reason for contact!");
						form.MyType.focus();
						return false;
					}
					if(form.MyMessage.value==""){
						alert("Please add your message before submitting!");
						form.MyMessage.focus();
						return false;
					}

			}
			function ValidateCoachInfo(form){
					if(form.first_name.value==""){
						alert("Please tell us your current First Name!");
						form.first_name.focus();
						return false;
					}
					if(form.middle_name.value==""){
						alert("Please tell us your current Middle Name!");
						form.middle_name.focus();
						return false;
					}
					if(form.last_name.value==""){
						alert("Please tell us your current Last Name!");
						form.last_name.focus();
						return false;
					}
					if(form.street_address.value==""){
						alert("Please tell us your current Street Address!");
						form.street_address.focus();
						return false;
					}
					if(form.phone.value==""){
						alert("Please tell us your current Phone Number!");
						form.phone.focus();
						return false;
					}
					if(form.city.value==""){
						alert("Please tell us your current City!");
						form.city.focus();
						return false;
					}
					if(form.state.value==""){
						alert("Please tell us your current State!");
						form.state.focus();
						return false;
					}
					if(form.zipcode.value==""){
						alert("Please tell us your current Zipcode!");
						form.zipcode.focus();
						return false;
					}
					if(form.country.value==""){
						alert("Please tell us your current Country!");
						form.country.focus();
						return false;
					}
					if(form.school.value==""){
						alert("Please tell us your current University!");
						form.school.focus();
						return false;
					}
					if(form.coachposition.value==""){
						alert("Please tell us your current Position!");
						form.coachposition.focus();
						return false;
					}
					if(form.coachteam.value==""){
						alert("Please tell us your current Team!");
						form.coachteam.focus();
						return false;
					}
			}
			function ValidateEmailChange(form){
					if(form.cur_email.value==""){
						alert("Please tell us your current email address!");
						form.cur_email.focus();
						return false;
					}
					if(form.new_email.value==""){
						alert("Please tell us your new email address!");
						form.new_email.focus();
						return false;
					}
					if(form.new_email_conf.value==""){
						alert("Please type your new email address a second time!");
						form.new_email_conf.focus();
						return false;
					}
					if(form.new_email.value!=form.new_email_conf.value){
						alert("Your new email and new email confirmation boxes do NOT match!");
						form.new_email.focus();
						return false;
					}
					var emailID=form.cur_email;
					
					if ((emailID.value==null)||(emailID.value=="")){
						alert("Please Enter your email address!");
						emailID.focus();
						return false;
					}
					if (echeck(emailID.value)==false){
						emailID.value="";
						emailID.focus();
						return false;
					}
					
					var emailID=form.new_email;
					
					if ((emailID.value==null)||(emailID.value=="")){
						alert("Please Enter your email address!");
						emailID.focus();
						return false;
					}
					if (echeck(emailID.value)==false){
						emailID.value="";
						emailID.focus();
						return false;
					}
					
					var emailID=form.new_email_conf;
					
					if ((emailID.value==null)||(emailID.value=="")){
						alert("Please Enter your email address!");
						emailID.focus();
						return false;
					}
					if (echeck(emailID.value)==false){
						emailID.value="";
						emailID.focus();
						return false;
					}
					if(form.acct_password.value==""){
						alert("Please tell us your current password to prove it's you!");
						form.acct_password.focus();
						return false;
					}
			}
			function CheckPWForm(form){
					if(form.cur_email.value==""){
						alert("Please tell us your current email address!");
						form.cur_email.focus();
						return false;
					}
					if(form.acct_password.value==""){
						alert("Please tell us your current password to prove it's you!");
						form.acct_password.focus();
						return false;
					}
					if(form.new_acct_password.value==""){
						alert("Your new password cannot be blank!");
						form.new_acct_password.focus();
						return false;
					}
					if(form.new_acct_password_conf.value==""){
						alert("Please type your new new password again!");
						form.new_acct_password_conf.focus();
						return false;
					}
					var e = form.elements;
					if(e['new_acct_password'].value != e['new_acct_password_conf'].value) {
						alert('Your passwords do not match. Please type more carefully.');
						return false;
					}

			}
			function CheckContactUs(form){
					
					if(form.name.value==""){
						alert("Please tell us your name!");
						form.name.focus();
						return false;
					}
					if(form.phone.value==""){
						alert("Please type your phone number!");
						form.phone.focus();
						return false;
					}
					if(form.email.value==""){
						alert("Please tell us your current email address!");
						form.email.focus();
						return false;
					}
					if(form.comments.value==""){
						alert("Please add your comments before submitting!");
						form.comments.focus();
						return false;
					}

			}
			function ValidateRegister(form){
					if(form.type.value==""){
						alert("Please tell us what you are registering as!");
						form.type.focus();
						return false;
					}
					if(form.first_name.value==""){
						alert("Please tell us your first name!");
						form.first_name.focus();
						return false;
					}
					if(form.last_name.value==""){
						alert("Please tell us your last name!");
						form.last_name.focus();
						return false;
					}
					var emailID=form.email;
				
					if ((emailID.value==null)||(emailID.value=="")){
						alert("Please Enter your email address!");
						emailID.focus();
						return false;
					}
					if (echeck(emailID.value)==false){
						emailID.value="";
						emailID.focus();
						return false;
					}
					if(form.state.value==""){
						alert("Please tell us your state!");
						form.state.focus();
						return false;
					}
					if(form.country.value==""){
						alert("Please tell us your country!");
						form.country.focus();
						return false;
					}
					if(form.sex.value==""){
						alert("Please tell us your gender!");
						form.sex.focus();
						return false;
					}
					if(form.sport.value==""){
						if(form.type.value!="F"){
							alert("Please chose your main sport!");
							form.sport.focus();
							return false;
						}
					}
				}
function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid email address format!");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid email address format!");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid email address format!");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid email address format!");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid email address format!");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid email address format!");
		    return false;
		 }

 		 return true;
}

			  function ValidateProfile(form){
					if(form.first_name.value==""){
						alert("Please tell us your first name!");
						form.first_name.focus();
						return false;
					}
					if(form.last_name.value==""){
						alert("Please tell us your last name!");
						form.last_name.focus();
						return false;
					}
					if(form.street_address.value==""){
						alert("Please tell us your street address!");
						form.street_address.focus();
						return false;
					}
					if(form.city.value==""){
						alert("Please tell us your city!");
						form.city.focus();
						return false;
					}
					if(form.state.value==""){
						alert("Please tell us your state!");
						form.state.focus();
						return false;
					}
					if(form.zipcode.value==""){
						alert("Please tell us your zipcode!");
						form.zipcode.focus();
						return false;
					}
					if(form.country.value==""){
						alert("Please tell us your country!");
						form.country.focus();
						return false;
					}
					if(form.DOB_M.value==""){
						alert("Please tell us your Birthday month!");
						form.DOB_M.focus();
						return false;
					}
					if(form.DOB_D.value==""){
						alert("Please tell us your Birthday day!");
						form.DOB_D.focus();
						return false;
					}
					if(form.DOB_Y.value==""){
						alert("Please tell us your Birthday year!");
						form.DOB_Y.focus();
						return false;
					}
					if(form.password.value==""){
						alert("Please tell us your current password to prove it's you!");
						form.password.focus();
						return false;
					}
				}

// JavaScript Document
function ValidateQuestions(form){
					//Check if a Question 1 was given
					if(form.SecQ1.value==""){
						alert("Please Pick Your First Security Question.");
						form.SecQ1.focus();
						return false;
					}
					//Check if a Question 2 was given
					if(form.SecQ2.value==""){
						alert("Please Pick Your Second Security Question.");
						form.SecQ2.focus();
						return false;
					}
					//Check if a Answer 1 was given
					if(form.SecA1.value==""){
						alert("Please Enter Your First Security Question's Answer.");
						form.SecA1.focus();
						return false;
					}
					//Check if a Answer 2 was given
					if(form.SecA2.value==""){
						alert("Please Enter Your Second Security Question's Answer.");
						form.SecA2.focus();
						return false;
					}		
}