// JavaScript Document
function checkEmail(str)
	{
		if((str.indexOf("@")==-1) || (str.indexOf(".")==-1))
		{
			fstr="Please Enter @ or .";
			return false;
		}
		else
		{
		if((str.indexOf("@") == 0) || (str.indexOf(".") == 0))
		{
			fstr="@ or . Cannot Be first";
			return false;
		}
		if((str.indexOf("@") == (str.length-1)) || (str.indexOf(".") == (str.length-1)))
		{
			fstr="@ or . Cannot Be Last";
			return false;
		}

		if(str.indexOf("@") > str.indexOf("."))
		{
			fstr="@ Should be After .";
			return false;
		}
		if((str.indexOf("@")+1) == str.indexOf("."))
		{
			fstr="@. IS Invalid Email";
			return false;
		}
		}
		var cp=0;					
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == ".") || (c == "@") || (c == "_"))
			if(c=="@") cp++;
			if(b==true)
			   continue;
			else
			{
				fstr="Cannot include "+c;
				return false;
			}
		}
		if(cp==2)
		{
			fstr="@ cannnot be repetaed";
			return false;

		}
		return true;
	}
function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}
function RTrim(str)
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
     var i = s.length - 1;       // Get length of string
      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }
   return s;
}
function trim(str)
{
   return RTrim(LTrim(str));
}
function checkNum(str)
{
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || (c==" "))
			if(b==true)
			   continue;
			else
			   return false;
		}
		return true;
}
function check_fields()
{
	if(trim(form.txtclassday.value)=="")
		{
			alert("Please Enter Class Day")
			form.txtclassday.focus()
			return false
		}
	if(trim(form.txtclasstime.value)=="")
		{
			alert("Please Enter Class Time")
			form.txtclasstime.focus()
			return false
		}
	if(trim(form.txtlevel.value)=="")
		{
			alert("Please Enter Level")
			form.txtlevel.focus()
			return false
		}
	if(checkNum(form.txtlevel.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtlevel.focus()
			return false
		}		
	if(form.txtcoach.value=="")
		{
			alert("Please Enter Coach Name")
			form.txtcoach.focus()
			return false
		}
	if(form.txtfname.value=="")
		{
			alert("Please Enter  Student First Name")
			form.txtfname.focus()
			return false
		}
	if(form.txtecname.value=="")
		{
			alert("Please Enter Students Emergency Contact Number")
			form.txtecname.focus()
			return false
		}
	if(form.txtphone.value=="")
		{
			alert("Please Enter Student Phone Number")
			form.txtphone.focus()
			return false
		}
	if(checkNum(form.txtphone.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtphone.focus()
			return false
		}
	if(form.cday.value=="0")
		{
			alert("Please Select a Day")
			form.cday.focus()
			return false
		}
	if(form.month.value=="Month")
		{
			alert("Please Select a Month")
			form.month.focus()
			return false
		}
	if(form.year.value=="year")
		{
			alert("Please Select a Year")
			form.year.focus()
			return false
		}
		
	if(form.age.value=="")
		{
			alert("Please Enter Your Age")
			form.age.focus()
			return false
		}
	if(checkNum(form.age.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.age.focus()
			return false
		}
	if(trim(form.email.value)=="")
	{
		alert("Please Enter Your Email Address")
		form.email.focus()
		return false
	}
	else
	{
			st=form.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					form.email.focus();
					return false;
			}
	}
	if(form.textpnm.value=="")
		{
			alert("Please Enter  Your Physical Limitations and Medications")
			form.textpnm.focus()
			return false
		}
	if(form.txtpfname.value=="")
		{
			alert("Please Enter Parent name")
			form.txtpfname.focus()
			return false
		}
	if(form.txtpadd.value=="")
		{
			alert("Please Enter Parent Address")
			form.txtpadd.focus()
			return false
		}
	if(form.txtpcity.value=="")
		{
			alert("Please Enter parent City Name")
			form.txtpcity.focus()
			return false
		}
	if(form.txtpstate.value=="")
		{
			alert("Please Enter Parent State Name")
			form.txtpstate.focus()
			return false
		}
	if(form.txtpzip.value=="")
		{
			alert("Please Enter Parent Zipcode")
			form.txtpzip.focus()
			return false
		}
	if(checkNum(form.txtpzip.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtpzip.focus()
			return false
		}
	if(form.txtphphone.value=="")
		{
			alert("Please Enter Parent Home Phone Number")
			form.txtphphone.focus()
			return false                    
		}
	if(checkNum(form.txtphphone.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtphphone.focus()
			return false
		}
	if(form.txtpwphone.value=="")
		{
			alert("Please Enter Parent Work Phone Number")
			form.txtpwphone.focus()
			return false
		}
	if(checkNum(form.txtpwphone.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtpwphone.focus()
			return false
		}
	if(form.txtpcell.value=="")
		{
			alert("Please Enter Parent Cell Number")
			form.txtpcell.focus()
			return false
		}
	if(checkNum(form.txtpcell.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtpcell.focus()
			return false
		}
	if(trim(form.txtpemail.value)=="")
	   {
		alert("Please Enter Your Parent Email Address")
		form.txtpemail.focus()
		return false
	   }
	else
	   {
			st=form.txtpemail.value;
			if(checkEmail(st)==false)
			{
				alert("Invalid Email Id \n"+st);
				form.txtpemail.focus();
				return false;
			}
	    }		
	if(form.txtpemp.value=="")
		{
			alert("Please Enter Parent Employer")
			form.txtpemp.focus()
			return false
		}
	if(form.txtpocc.value=="")
		{
			alert("Please Enter Parent Occupation")
			form.txtpocc.focus()
			return false
		}
	if(form.txtsfname.value=="")
		{
			alert("Please Enter Spouse/Guardian Name")
			form.txtsfname.focus()
			return false
		}
	if(form.txtsadd.value=="")
		{
			alert("Please Enter Spouse/Guardian Address")
			form.txtsadd.focus()
			return false
		}
	if(form.txtscity.value=="")
		{
			alert("Please Enter Spouse/Guardian City")
			form.txtscity.focus()
			return false
		}
	if(form.txtsstate.value=="")
		{
			alert("Please Enter Spouse/Guardian State")
			form.txtsstate.focus()
			return false
		}
	if(form.txtszip.value=="")
		{
			alert("Please Enter Spouse/Guardian Zipcode")
			form.txtszip.focus()
			return false
		}
	if(checkNum(form.txtszip.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtszip.focus()
			return false
		}
	if(form.txtshphone.value=="")
		{
			alert("Please Enter Spouse/Guardian Home Phone Number")
			form.txtshphone.focus()
			return false
		}
	if(checkNum(form.txtshphone.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtshphone.focus()
			return false
		}
	if(form.txtswphone.value=="")
		{
			alert("Please Enter Spouse/Guardian Work Phone Number")
			form.txtswphone.focus()
			return false
		}
	if(checkNum(form.txtswphone.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtswphone.focus()
			return false
		}
	if(form.txtscell.value=="")
		{
			alert("Please Enter Spouse/Guardian Cell Number")
			form.txtscell.focus()
			return false
		}
	if(checkNum(form.txtscell.value)==false)
		{
			alert("Please Enter a Numeric Value")
			form.txtscell.focus()
			return false
		}
	if(trim(form.txtsemail.value)=="")
	   {
		alert("Please Enter Your Spouse/Guardian Email Address")
		form.txtsemail.focus()
		return false
	   }
	else
	   {
			st=form.txtsemail.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					form.txtsemail.focus();
					return false;
			}
	    }		
	if(form.txtsemp.value=="")
		{
			alert("Please Enter Spouse/Guardian Employer")
			form.txtsemp.focus()
			return false
		}
	if(form.txtsocc.value=="")
		{
			alert("Please Enter Spouse/Guardian Occupation ")
			form.txtsocc.focus()
			return false
		}
	if(form.friend.value=="")
		{
			alert("Please Enter Your Friend Name ")
			form.friend.focus()
			return false
		}
	if(form.txtc1name.value=="")
		{
			alert("Please Enter Child 1 Name ")
			form.txtc1name.focus()
			return false
		}
	if(form.txtc1parent.value=="")
		{
			alert("Please Enter  Child 1 Parent Name ")
			form.txtc1parent.focus()
			return false
		}
	if(form.txtc2name.value=="")
		{
			alert("Please Enter Child 2 Name")
			form.txtc2name.focus()
			return false
		}
	if(form.txtc2parent.value=="")
		{
			alert("Please Enter  Child 2 Parent Name")
			form.txtc2parent.focus()
			return false
		}
	if(form.termcheck.checked==false)
		{
			alert("Please Accept the Terms and Conditions")
			form.termcheck.focus()
			return false
		}		
}
function check_pay_fields()
{
	if(trim(pay.fname.value)=="")
		{
			alert("Please Enter Your First Name")
			pay.fname.focus()
			return false
		}
	if(trim(pay.lname.value)=="")
		{
			alert("Please Enter Your Last Name")
			pay.lname.focus()
			return false
		}
	if(trim(pay.cctype.value)==0)
		{
			alert("Please Select Your Credit Card Type")
			pay.cctype.focus()
			return false
		}
	if(trim(pay.fullname.value)=="")
		{
			alert("Please Enter Your Full Name as on Credit Card")
			pay.fullname.focus()
			return false
		}
	if(trim(pay.ccno.value)=="")
		{
			alert("Please Enter Your Credit Card Number")
			pay.ccno.focus()
			return false
		}
	if(trim(pay.expdate.value)=="")
		{
			alert("Please Enter Your Credit Card Expiry Date")
			pay.expdate.focus()
			return false
		}
	if(trim(pay.amt.value)=="")
		{
			alert("Please Enter Amount")
			pay.amt.focus()
			return false
		}
		pay.amount.value = pay.amt.value	
}
