var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
var ck_username = /^[A-Za-z0-9_]{1,20}$/;
var ck_password =  /^[A-Za-z0-9!@#$%^&*()_]{6,20}$/;


function validate(form1){

var salute = form1.visitorsalute.value;
var name = form1.visitor.value;
var mailad = form1.visitormail.value;
var subj = form1.attn.value;
var mess = form1.notes.value;
var numm = form1.contact.value;
var sname = form1.studentname.value;
var sage = form1.studentage.value;
var sexp = form1.drummingexp.value;
var shand = form1.hand.value;
var scourse = form1.course.value;
var scoursetype = form1.coursetype.value;
var scourseduration = form1.courseduration.value;



if (sname=='') {

      var errors = [];

          if (salute==' ') 
		{
                 errors[errors.length] = "Select your salute";
		 document.form1.visitorsalute.id = "picked";
                }
	  else
		{
		 document.form1.visitorsalute.id = "visitorsalute";
		}
 
 
         if (!ck_name.test(name)) {
                 		   errors[errors.length] = "State your name";
				   document.form1.visitor.id = "picked";
                                   }
	  else
		{
		 document.form1.visitor.id = "visitor";
                }

          if (!ck_email.test(mailad)) {
                 		      errors[errors.length] = "Enter a valid email address";
				      document.form1.visitormail.id = "picked";
                                      }
	  else
		{
		 document.form1.visitormail.id = "visitormail";
		}

	  if (numm=='') {
                 errors[errors.length] = "Please leave us your number";
		 document.form1.contact.id = "picked";
                        }
	  else
		{
		 document.form1.contact.id = "contact";
		}

	  if (subj=='No Subject') 
		{
                 errors[errors.length] = "Select enquiry subject";
		 document.form1.attn.id = "picked";
                }
	  else
		{
		 document.form1.attn.id = "attn";
                }


          if (mess=='') {
                 errors[errors.length] = "Please leave us a message";
		 document.form1.notes.id = "picked";
                        }
	  else
		{
		document.form1.notes.id = "notes";
		}
	

       if (errors.length > 0) {
            reportErrors(errors);
            return false;
                              }
 

}
else
{

      var errors = [];

          if (salute==' ') 
		{
                 errors[errors.length] = "Select your salute";
		 document.form1.visitorsalute.id = "picked";
                }
	  else
		{
		 document.form1.visitorsalute.id = "visitorsalute";
		}
 
 
          if (!ck_name.test(name)) {
                 		   errors[errors.length] = "State your name";
				   document.form1.visitor.id = "picked";
                                   }
	  else
		{
		 document.form1.visitor.id = "visitor";
                }
                                   

          if (!ck_email.test(mailad)) {
                 		      errors[errors.length] = "Enter a valid email address";
				      document.form1.visitormail.id = "picked";
                                      }
	  else
		{
		 document.form1.visitormail.id = "visitormail";
		}

	 if (numm=='') {
                 errors[errors.length] = "Please leave us your number";
		 document.form1.contact.id = "picked";
                        }
	  else
		{
		 document.form1.contact.id = "contact";
		}


	  
	 if (subj=='No Subject') 
		{
                 errors[errors.length] = "Select enquiry subject";
		 document.form1.attn.id = "picked";
                }
	  else
		{
		 document.form1.attn.id = "attn";
                }

          if (mess=='') {
                 errors[errors.length] = "Please leave us a message";
		 document.form1.notes.id = "picked";
                        }
	  else
		{
		 document.form1.notes.id = "notes";
		}
 
  

	  if (sage=='') {
                 errors[errors.length] = "State the age of the student";
		 document.form1.studentage.id = "picked";
                        }
	  else
		{
		 document.form1.studentage.id = "studentage";
		}

	  if (sexp=='-') {
                 errors[errors.length] = "State the experience of the student";
		 document.form1.drummingexp.id = "picked";
			}
	  else
		 {
		  document.form1.drummingexp.id = "drummingexp";
		 }


          if (shand==' ') {
                 errors[errors.length] = "Select preferrence of location";
		 document.form1.hand.id = "picked";
                        }
	  else
		{
		 document.form1.hand.id = "hand";
		}

          if (scourse=='-') {
                 errors[errors.length] = "Select a course";
		 document.form1.course.id = "picked";
                        }
	  else
		{
		 document.form1.course.id = "course";
		}	

          if (scoursetype=='  ') {
                 errors[errors.length] = "Indicate whether you prefer a group or individual lesson.";
		 document.form1.coursetype.id = "picked";
                        }
	  else
		{
		document.form1.coursetype.id = "coursetype";
                        }


          if (scourseduration=='  ') {
                 errors[errors.length] = "Select a drum programme duration";
		 document.form1.courseduration.id = "picked";
                        }
	  else
		{
		document.form1.courseduration.id = "courseduration";
		}
	
          


       if (errors.length > 0) {
            reportErrors(errors);
            return false;
                              }
 
}
return true;
}
	







function reportErrors(errors){
 var msg = "Please enter the following:\n";
 for (var i = 0; i<errors.length; i++) {
  var numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}


