// JavaScript Document

function ChannelValidator(){

	if(document.getElementById('ch_name').value == ''){

		alert('Enter the Channel Name');

		return false;

	}

	if(document.getElementById('ch_site').value == ''){

		alert('Please Enter your Channel Website');

		return false;

	}

	if(document.getElementById('ch_type').value == ''){

		alert('Please Select your Channel Type');

		return false;

	}

	return true

}

function Validator(theForm){
	
	if(theForm.cpassword.value == "" && theForm.password.value != ""){
		alert("Please enter the password again for confirmation");
		theForm.cpassword.focus();
		return (false);
	}
	if(theForm.username.value == ""){
		alert("Please enter the username");
		theForm.username.focus();
		return (false);
	}
	if(theForm.cpassword.value != theForm.password.value){
		alert("Password did not match");
		theForm.cpassword.focus();
		return (false);
	}
	
	  if (theForm.fname.value == "")

	  {

		alert("Please enter a value for the First Name field.");

		theForm.fname.focus();

		return (false);

	  }

	  if (theForm.lname.value == "")

	  {

		alert("Please enter a value for the Last Name field.");

		theForm.lname.focus();

		return (false);

	  }

	  if (theForm.gender[0].checked == false && theForm.gender[1].checked == false)

	  {

		alert("Please select your Gender.");

		return (false);

	  }

	  if (theForm.username.value == "")

	  {

		alert("Please enter a value for the Login Name field.");

		theForm.username.focus();

		return (false);

	  }

	  if (theForm.password.value == "")

	  {

		alert("Please enter a value for the Password field");

		theForm.password.focus();

		return (false);

	  }

	 /* if (theForm.password.value.length < 6)

	  {

		alert("Please enter at least 6 characters in the Password field");

		theForm.password.focus();

		return (false);

	  }*/

	  if (theForm.cpassword.value != theForm.password.value)

	  {

		alert("The Password and Confirm Password value are not same.");

		theForm.cpassword.focus();

		return (false);

	  }

	  if (theForm.address.value == "")

	  {

		alert("Please Enter your Address");

		theForm.address.focus();

		return (false);

	  }

	  if (theForm.state.selectedIndex == "")

	  {

		alert("Please Select your State");

		theForm.state.focus();

		return (false);

	  }

	  if (theForm.city.selectedIndex == "")

	  {

		alert("Please Select your City");

		theForm.city.focus();

		return (false);

	  }

	  if (theForm.zip.value == "")

	  {

		alert("Please Enter your ZipCode");

		theForm.zip.focus();

		return (false);

	  }

	  if (theForm.zip.value.length < 5)

	  {

		alert("Please Enter valid ZipCode");

		theForm.zip.focus();

		return (false);

	  }

	  if (theForm.email.value == "")

	  {

		alert("Please Enter your Email ID");

		theForm.email.focus();

		return (false);

	  }

	  if(echeck(theForm.email.value)==false)

	  {

		  theForm.email.value="";

		  theForm.email.focus();

		   return (false);

	  }

	  /*if (theForm.phone.value == "")

	  {

		alert("Please Enter your Phone Number");

		theForm.phone.focus();

		return (false);

	  }*/

	  if (theForm.phone.value.length < 10)

	  {

		alert("Please Enter valid Phone Number");

		theForm.phone.focus();

		return (false);

	  }

	  /*if (theForm.school.value == "")

	  {

		alert("Please Enter your school name");

		theForm.school.focus();

		return (false);

	  }
	  
	  if (theForm.school_country.value == "")

	  {

		alert("Please Enter country of school");

		theForm.school_country.focus();

		return (false);

	  }
	  
	  if (theForm.school_state.value == "")

	  {

		alert("Please Enter state of your school");

		theForm.school_state.focus();

		return (false);

	  }*/
	  
	  if (theForm.school_state.selectedIndex == "" && theForm.college_state.selectedIndex == "")

	  {

		alert("Please fillin either HighSchool or College info");

		theForm.school_state.focus();

		return (false);

	  }

	  if (theForm.school_state.selectedIndex != "" && theForm.school_city.selectedIndex == "")

	  {

		alert("Please Select your HighSchool City");

		theForm.school_city.focus();

		return (false);

	  }

	  if (theForm.school_state.selectedIndex != "" && theForm.school_city.selectedIndex != "" && theForm.school_school.selectedIndex == "" && theForm.others.value == "")

	  {

		alert("Please Select your HighSchool Name  (or)" + '\n' + "Enter your HighSchool Name in 'Other Schools' field ");

		theForm.school_school.focus();

		return (false);

	  }

	  if (theForm.college_state.selectedIndex != "" && theForm.college_city.selectedIndex == "")

	  {

		alert("Please Select your College City");

		theForm.college_city.focus();

		return (false);

	  }

		if (theForm.college_state.selectedIndex != "" && theForm.college_city.selectedIndex != "" && theForm.college_college.selectedIndex == "" && theForm.other.value == "")

	  {

		alert("Please Select your College/University  (or)" + '\n' + "Enter your College/University Name in 'Other Colleges' field ");

		theForm.college_college.focus();

		return (false);

	  }

	  if (theForm.category.selectedIndex == "")

	  {

		alert("Please Select the 'Choose your Identity' field");

		theForm.category.focus();

		return (false);

	  }

	  if (theForm.game.selectedIndex == "")

	  {

	   alert("Please Select your Game ");

	   theForm.game.focus();

	   return (false);

	  }



	  if (theForm.category.selectedIndex == "1" && theForm.game.selectedIndex == "")

	  {

	   alert("Please Select the Game you Coach");

	   theForm.game.focus();

	   return (false);

	  }

	  if (theForm.category.selectedIndex == "1" && theForm.location.selectedIndex == "")

	  {

	   alert("Please Select the Location of your Coaching");

	   theForm.location.focus();

	   return (false);

	  }

	  if (theForm.category.selectedIndex == "2" && theForm.weight.value == "")

	  {

	   alert("Please enter your Weight");

	   theForm.weight.focus();

	   return (false);

	  }

	  if (theForm.category.selectedIndex == "2" && theForm.height.value == "")

	  {

		alert("Please enter your Height");

		theForm.height.focus();

		return (false);

	  }

	  if (theForm.category.selectedIndex == "2" && theForm.firstsport.value == "")

	  {

		alert("Please enter your Firstsport positon");

		theForm.firstsport.focus();

		return (false);

	  }

	 return (true);

	}



	function numbersonly(e)

	{

	var unicode=e.charCode? e.charCode : e.keyCode

	 if (unicode!=8)

	 {                                     //if the key isn't the backspace key (which we should allow)

	  if (unicode<48||unicode>57)          //if not a number

	  return false                         //disable key press

	 }

	}



   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 E-mail ID")

		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

			alert("Invalid E-mail ID")

			return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

			alert("Invalid E-mail ID")

			return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

			alert("Invalid E-mail ID")

			return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

			alert("Invalid E-mail ID")

			return false

		 }



		 if (str.indexOf(" ")!=-1){

			alert("Invalid E-mail ID")

			return false

		 }



		 return true

   }