// JavaScript Document

function validate(){

	
	
	
document.getElementById('phoneLabel').style.color = "";
document.getElementById('faxLabel').style.color = "";
document.getElementById('emailLabel').style.color = "";
document.getElementById('fnameLabel').style.color = "";
document.getElementById('zipLabel').style.color = "";
document.getElementById('attendanceLabel').style.color = "";

var valid = 0;

//fname
var fname = document.getElementById('txtName').value;
if (fname.length == 0){
	valid = 1;
	document.getElementById('fnameLabel').style.color = "#F00";
}
	
//phone
var phone = document.getElementById('txtPhone').value;
var strValidPhoneChars = "0123456789.-() ";
var strPhoneChar;

if (phone.length < 10){
	valid = 1;
	document.getElementById('phoneLabel').style.color = "#F00";
}
else if(phone.length > 16)
{
		valid = 1;
	document.getElementById('phoneLabel').style.color = "#F00";
}

else{
	for (i = 0; i < phone.length; i++)
      {
      strPhoneChar = phone.charAt(i);
      if (strValidPhoneChars.indexOf(strPhoneChar) == -1)
         {
		document.getElementById('phoneLabel').style.color = "#F00";
         valid = 1;
         }
      }
   }	
   
   
   phone = phone.replace(/\D/g, '');
   if (phone.length < 10){
	valid = 1;
	document.getElementById('phoneLabel').style.color = "#F00";
	}

   
   
   
   
 //fax
var fax = document.getElementById('txtFax').value;
var strValidfaxChars = "0123456789.-() ";
var strfaxChar;

	for (i = 0; i < fax.length; i++)
      {
      strfaxChar = fax.charAt(i);
      if (strValidfaxChars.indexOf(strfaxChar) == -1)
         {
		document.getElementById('faxLabel').style.color = "#F00";
         valid = 1;
         }
      }
if(fax.length > 16)
{
		valid = 1;
	document.getElementById('faxLabel').style.color = "#F00";
}
   
if(fax.length > 0 && fax.length < 16)
{	
	fax = fax.replace(/\D/g, '');
   if (fax.length < 10){
	valid = 1;
	document.getElementById('faxLabel').style.color = "#F00";
	}
}
 
 
//zip
var zip = document.getElementById('txtZip').value;
var strValidzipChars = "0123456789- ";
var strzipChar;

	for (i = 0; i < zip.length; i++)
      {
      strzipChar = zip.charAt(i);
      if (strValidzipChars.indexOf(strzipChar) == -1)
         {
		document.getElementById('zipLabel').style.color = "#F00";
         valid = 1;
         }
      }
	  
if(zip.length > 10)
{
		valid = 1;
	document.getElementById('zipLabel').style.color = "#F00";
}

if(zip.length > 0 && zip.length < 5)
{
		valid = 1;
	document.getElementById('zipLabel').style.color = "#F00";
}

if(zip.length > 5 && zip.length < 9)
{
		valid = 1;
	document.getElementById('zipLabel').style.color = "#F00";
}


//attendance
var attendance = document.getElementById('txtAttendance').value;
var strValidattendanceChars = "0123456789";
var strattendanceChar;

	for (i = 0; i < attendance.length; i++)
      {
      strattendanceChar = attendance.charAt(i);
      if (strValidattendanceChars.indexOf(strattendanceChar) == -1)
         {
		document.getElementById('attendanceLabel').style.color = "#F00";
         valid = 1;
         }
      }


   
//email
var address = document.getElementById('txtEmailAddress').value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

if(reg.test(address) == false || address.length == 0){
	valid = 1;
	document.getElementById('emailLabel').style.color = "#F00";
}	

if(valid == 1){	return false;}
else{ return true;}

}

