// JavaScript Document
function stripspaces(input)
{
    //input.value = input.value.replace(/\s/gi,"");
	input.value = input.value.replace(/^\s+|\s+$/g, '') ;
    return true;
}
function validateForm()

         

{

	var school_name = trim(document.getElementById('school_name').value);	

	var coach_name = trim(document.getElementById('coach_name').value);

	var school_address = trim(document.getElementById('school_address').value);

	var school_phone = trim(document.getElementById('school_phone').value);

	var email = trim(document.getElementById('email').value);
	
	//var school_country = trim(document.getElementById('school_country').value);

	var school_colors = trim(document.getElementById('school_colors').value);

	var sports_of_interest = trim(document.getElementById('sports_of_interest').value);

	var grade_level = trim(document.getElementById('grade_level').value);
	var schoolCity = trim(document.getElementById('school_city').value);
	var schoolState = trim(document.getElementById('school_state').value);
	var schoolZip = trim(document.getElementById('school_zipcode').value);
	
	var edit = trim(document.getElementById('edit_group').value);
	if(edit == 'no'){
		var username = trim(document.getElementById('username_group').value);
	
		var password = trim(document.getElementById('password_group').value);
	
		var repeat_password = trim(document.getElementById('repeat_password').value);
		var security_code = trim(document.getElementById('security_code').value);

	}


	//var disclaimer = document.getElementById('disclaimer').value;

	

	var numberRegx=/^[\d]*$/;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	var alphaRegex = /^[a-zA-Z '-]*$/;
	var unameRegex = /^[a-zA-Z0-9_-]*$/;
	var charRegex = /^[a-zA-Z-\. ]*$/;



	//alert(disclaimer);



	if(school_name=='') {



		 inlineMsg('school_name','Please enter School/Group Name',2);

    return false;



	}
	if(school_name.length<2) {



		 inlineMsg('school_name','School/Group Name Should Be Minimum 2 Characters',2);

    return false;



	}
	
	/*if(!school_name.match(charRegex))
	{
		inlineMsg('school_name','Please Enter Only Alphabets, . , -',2);
		return false;	
	}*/


	if(coach_name=='') {	



		inlineMsg('coach_name','Please Enter Coach/Contact Person',2);

		return false;



	}
	if(coach_name.length<2) {	



		inlineMsg('coach_name','Coach/Contact Person Should Be Minimum 2 Characters',2);

		return false;



	}
	if(coach_name.length>40) {	



		inlineMsg('coach_name','Coach/Contact Person Can Be Maximum 40 Characters',2);

		return false;



	}
	
/*if(!coach_name.match(charRegex))
	{
		inlineMsg('coach_name','Please Enter Only Alphabets, . , -',2);
		return false;	
	}*/
	
	if(school_phone=='') {	

		inlineMsg('school_phone','Please Enter Phone Number',2);
		return false;



	}


	

	if(school_address=='') {		



		inlineMsg('school_address','Please Enter Address',2);

		return false;



	}
	if(school_address.length<2) {		



		inlineMsg('school_address','Address Should Be Minimum 2 Characters',2);

		return false;



	}


	if(schoolCity == '')
	{
		inlineMsg('school_city','Please Enter City',2);
		return false;	
	}
	
	
	/*if(!schoolCity.match(alphaRegex))
	{
		inlineMsg('school_city','Please Enter Only Alphabets',2);
		return false;	
	}*/
	
	
	if(schoolState == '')
	{
		inlineMsg('school_state','Please Enter State',2);
		return false;	
	}
	
	
	/*if(!schoolState.match(alphaRegex))
	{
		inlineMsg('school_state','Please Enter Only Alphabets',2);
		return false;	
	}*/
	
	
	if(schoolZip == '')
	{
		inlineMsg('school_zipcode','Please Enter Zipcode',2);
		return false;	
	}

	/*if(school_country=='') {	

		inlineMsg('school_country','Please Select Country',2);
		return false;



	}*/


	

	if(email=='') {

		inlineMsg('email','Please Enter Email Id',2);	



		return false;



	}



	



	if(!(email.match(emailRegex)) && email!="") {



		inlineMsg('email','Please Enter Valid Email Id',2);



		return false;



	}



  if(school_colors=='') {	

		inlineMsg('school_colors','Please Enter School Colors',2);

		return false;



	}

	

	 if(sports_of_interest=='') {	

		inlineMsg('sports_of_interest','Please Select Sports Of Interest',2);

		return false;



	}

	

	 if(grade_level=='') {	

		inlineMsg('grade_level','Please Select Grade Level',2);

		return false;



	}

	if(edit == 'no'){

	 if(username=='') {	

		inlineMsg('username_group','Please Enter Username',2);

		return false;



	}
	if(username.length<8) {



		 inlineMsg('username_group','Please Enter Username Minimun 8 characters',2);

    return false;



	}
	/*if(!username.match(unameRegex))
	{
		 inlineMsg('username_group','You Can Use Only a-z,A-z,0-9,_,-',2);

    		return false;
	}*/

	if(password=='') {	

		inlineMsg('password_group','Please Enter Password',2);

		return false;



	}

	

	if(repeat_password=='') {	

		inlineMsg('repeat_password','Please Enter Password repeat',2);

		return false;



	}

	

	if(repeat_password!=password) {	

		inlineMsg('repeat_password','Please Re-Enter The Password Correctly',2);

		return false;
	}
	
	
   if(security_code == ''){
		inlineMsg('security_code','Please Enter Security Code',2);
		return false;
	}

	
	}

return true;

}


function validateSchoolName(schoolName)
{
	var schoolName = trim(schoolName);
	var charRegex = /^[a-zA-Z-\. ]*$/;
	
	if(schoolName == ''){
		inlineMsg('school_name','Please Enter School/Group Name',2);
		return false;
	}
	if(schoolName.length<2){
		inlineMsg('school_name','School/Group Name Should Be Minimum 2 Characters',2);
		return false;
	}
	/*if(!schoolName.match(charRegex))
	{
		inlineMsg('school_name','Please Enter Only Alphabets, . , -',2);
		return false;	
	}*/
}
function validateCoachName(coachName)
{
	var coachName = trim(coachName);
	var charRegex = /^[a-zA-Z ]*$/;
	
	if(coachName == ''){
		inlineMsg('coach_name','Please Enter Coach/Contact Person',2);
		return false;
	}
	if(coachName.length<2){
		inlineMsg('coach_name','Coach/Contact Person Should Be Minimum 2 Characters',2);
		return false;
	}
	/*if(!coachName.match(charRegex))
	{
		inlineMsg('coachName','Please Enter Only Alphabets',2);
		return false;	
	}*/
	
}
function validateSchoolPhone(school_phone)
{
	var school_phone = trim(school_phone);
	if(school_phone == '')
	{
		inlineMsg('school_phone','Please Enter Phone Number',2);
		return false;
	}
}
function validateSchoolAddr(schoolAddr)
{
	var schoolAddr = trim(schoolAddr);
	if(schoolAddr == '')
	{
		inlineMsg('school_address','Please Enter Address',2);
		return false;
	}
}
function validateSchoolCity(schoolCity)
{
	var schoolCity = trim(schoolCity);
	var alphaRegex = /^[a-zA-Z '-]*$/;
	if(schoolCity == '')
	{
		inlineMsg('school_city','Please Enter City',2);
		return false;	
	}
	/*if(!schoolCity.match(alphaRegex))
	{
		inlineMsg('school_city','Please Enter Only Alphabets',2);
		return false;	
	}*/
}
function validateSchoolState(schoolState)
{
	var schoolState = trim(schoolState);
	var alphaRegex = /^[a-zA-Z '-]*$/;
	if(schoolState == '')
	{
		inlineMsg('school_state','Please Enter State',2);
		return false;	
	}
	/*if(!schoolState.match(alphaRegex))
	{
		inlineMsg('school_state','Please Enter Only Alphabets',2);
		return false;	
	}*/
}
function validateSchoolZip(schoolZip)
{
	var schoolZip = trim(schoolZip);
	if(schoolZip == '')
	{
		inlineMsg('school_zipcode','Please Enter Zipcode',2);
		return false;	
	}

}
function validateSchoolCountry(schoolCountry)
{
	var schoolCountry = trim(schoolCountry);
	if(schoolCountry == '')
	{
		inlineMsg('school_country','Please Select Country',2);
		return false;	
	}
}
function validateSchoolEmail(schoolEmail)
{
	var schoolEmail = trim(schoolEmail);
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	if(schoolEmail == '')
	{
		inlineMsg('email','Please Enter Email',2);
		return false;	
	}
	
	if(!schoolEmail.match(emailRegex))
	{
		inlineMsg('email','Please Enter Valid Email',2);
		return false;	
	}
}
function validateSchoolColor(schoolColor)
{
	var schoolColor = trim(schoolColor);
	if(schoolColor == '')
	{
		inlineMsg('school_colors','Please Enter School Color',2);
		return false;	
	}
}
function validateSchoolSport(schoolSport)
{
	var schoolSport = trim(schoolSport);
	
	if(schoolSport == '')
	{
		inlineMsg('sports_of_interest','Please Select Sport',2);
		return false;	
	}
}	
function validateSchoolGrade(schoolGrade)
{
	var schoolGrade = trim(schoolGrade);
	if(schoolGrade == '')
	{
		inlineMsg('grade_level','Please Select Grade',2);
		return false;	
	}
}
function validateSchoolUsername(schoolUName)
{
	var schoolUName = trim(schoolUName);
	var unameRegex = /^[a-zA-Z0-9_-]*$/;
	if(schoolUName == '')
	{
		inlineMsg('username_group','Please Enter Username',2);
		return false;	
	}
	if(schoolUName.length<8) {
		inlineMsg('username_group','Please Enter Username Minimun 8 characters',2);
		return false;
	}
	/*if(!schoolUName.match(unameRegex))
	{
		inlineMsg('username_group','You can use only a-z,A-z,0-9,_,-',2);
		return false;
	}*/
}
function validateSchoolPass(schoolPass)
{
	var schoolPass = trim(schoolPass);
	if(schoolPass == '')
	{
		inlineMsg('password_group','Please Enter Password',2);
		return false;	
	}
	if(schoolPass.length<8)
	{
		inlineMsg('password_group','Password Should Be Minimum 8 Characters',2);
		return false;	
	}
}
function validateSchoolRepPass(schoolRepPass)
{
	var schoolRepPass = trim(schoolRepPass);
	if(schoolRepPass == '')
	{
		inlineMsg('repeat_password','Please Re-Enter Password',2);
		return false;	
	}
}


function checkSecuritycode()
{
	var security_code = trim(document.getElementById('security_code').value);
	if(security_code == ''){
		inlineMsg('security_code','Please Enter Security Code',2);
		return false;
	}
}
