function checkData()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_firstname.value == "") {correct = false; alert("Please enter your first name.")}
if (document.Validate.user_lastname.value == "") {correct = false; alert("Please enter your last name.")}
if (document.Validate.user_address.value == "") {correct = false; alert("Please enter your address.")}
if (document.Validate.user_city.value == "") {correct = false; alert("Please enter your city.")}
if (document.Validate.user_state.value == "") {correct = false; alert("Please enter your state.")}
if (document.Validate.user_zip.value == "") {correct = false; alert("Please enter your zip.")}
if (document.Validate.user_email.value == "") {correct = false; alert("Please enter your Email.")}
else
{
	var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(document.Validate.user_email.value))){ correct = false; alert("Please enter a valid email address.");	 }
  else if(document.Validate.user_email.value.match(illegalChars)){ correct = false; alert("The email address contains illegal characters.");}  
  else
	{
		if (document.Validate.user_email2.value == "") {correct = false; alert("Please verify your Email.")}
		else if (document.Validate.user_email2.value != document.Validate.user_email.value) {correct = false; alert("Emails do not match.")}
	}
}

if (document.Validate.user_phone.value == "") {correct = false; alert("Please enter your Phone.")}
var checkbox_choices = 0;  //this part is hard coded
for (var counter = 14; counter < 30; counter++)
{
	if (document.Validate[counter].checked)
	{ 
		checkbox_choices = checkbox_choices + 1; 
		//alert(document.Validate[counter].name);
		//alert(counter);
	}
	
}
if( checkbox_choices == 0 )
{
	if (document.Validate.user_other_professional_designation.value == "" || document.Validate.user_other_professional_designation_code.value == "") 
	{
		correct = false; alert("Please choose your professional designation or fill in other and and enter code.")
	}	
}
if (document.Validate.user_name_of_practice.value == "") {correct = false; alert("Please enter name of practice.")}
if (document.Validate.user_years_practice.value == "") {correct = false; alert("Please enter years in practice.")}

if (correct){}
return correct

}

function checkData_user_admin_add()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_firstname.value == "") {correct = false; alert("Please enter your first name.")}
if (document.Validate.user_lastname.value == "") {correct = false; alert("Please enter your last name.")}
if (document.Validate.user_address.value == "") {correct = false; alert("Please enter your address.")}
if (document.Validate.user_city.value == "") {correct = false; alert("Please enter your city.")}
if (document.Validate.user_state.value == "") {correct = false; alert("Please enter your state.")}
if (document.Validate.user_zip.value == "") {correct = false; alert("Please enter your zip.")}
if (document.Validate.user_email.value == "") {correct = false; alert("Please enter your Email.")}
else
{
	var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(document.Validate.user_email.value))){ correct = false; alert("Please enter a valid email address.");	 }
  else if(document.Validate.user_email.value.match(illegalChars)){ correct = false; alert("The email address contains illegal characters.");}  
  else
	{
		if (document.Validate.user_email2.value == "") {correct = false; alert("Please verify your Email.")}
		else if (document.Validate.user_email2.value != document.Validate.user_email.value) {correct = false; alert("Emails do not match.")}
	}
}
if (document.Validate.user_phone.value == "") {correct = false; alert("Please enter your Phone.")}
var checkbox_choices = 0;  //this part is hard coded, in Admin there is no confirm email
for (var counter = 14; counter < 30; counter++)
{
	if (document.Validate[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }
	
}
if( checkbox_choices == 0 )
{
	if (document.Validate.user_other_professional_designation.value == "" || document.Validate.user_other_professional_designation.value == "") 
	{
		correct = false; alert("Please choose your professional designation.")
	}	
}
if (document.Validate.user_name_of_practice.value == "") {correct = false; alert("Please enter name of practice.")}
if (document.Validate.user_years_practice.value == "") {correct = false; alert("Please enter years in practice.")}


if (document.Validate.user_username.value == "") {correct = false; alert("Please enter your user name.")}

if (document.Validate.user_password.value == "") {correct = false; alert("Please enter your password.")}
else
{
	if(document.Validate.user_password.value.match(illegalChars))
	{ 
		correct = false; alert("This password contains illegal characters.");
	}  
	else
	{
		if (document.Validate.user_password2.value == "") 
		{
			correct = false; alert("Please verify your password.")
		}
		else if (document.Validate.user_password2.value != document.Validate.user_password.value)
		{
			correct = false; alert("Passwords do not match.")
		}
	}
}

var radio_choice = false;
for (counter = 0; counter < document.Validate.user_subscription.length; counter++)
{

if (Validate.user_subscription[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
correct = false; alert("Please choose the length of subscription.")
}

if (correct){}
return correct

}

function checkData_user_admin_edit()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_firstname.value == "") {correct = false; alert("Please enter your first name.")}
if (document.Validate.user_lastname.value == "") {correct = false; alert("Please enter your last name.")}
if (document.Validate.user_address.value == "") {correct = false; alert("Please enter your address.")}
if (document.Validate.user_city.value == "") {correct = false; alert("Please enter your city.")}
if (document.Validate.user_state.value == "") {correct = false; alert("Please enter your state.")}
if (document.Validate.user_zip.value == "") {correct = false; alert("Please enter your zip.")}
if (document.Validate.user_email.value == "") {correct = false; alert("Please enter your Email.")}
else
{
	var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(document.Validate.user_email.value))){ correct = false; alert("Please enter a valid email address.");	 }
  else if(document.Validate.user_email.value.match(illegalChars)){ correct = false; alert("The email address contains illegal characters.");}  
}
if (document.Validate.user_phone.value == "") {correct = false; alert("Please enter your Phone.")}
if (document.Validate.user_name_of_practice.value == "") {correct = false; alert("Please enter name of practice.")}
if (document.Validate.user_years_practice.value == "") {correct = false; alert("Please enter years in practice.")}


if (document.Validate.user_username.value == "") {correct = false; alert("Please enter your user name.")}

if (document.Validate.user_password.value != "")
{
	if (document.Validate.user_password.value.length < 6) {correct = false; alert("Password needs to be six characters or more.")}
  else if(document.Validate.user_password.value.match(illegalChars))
	{ 
		correct = false; alert("This password contains illegal characters.");
	}  
	else
	{
		if (document.Validate.user_password2.value == "") 
		{
			correct = false; alert("Please verify your password.")
		}
		else if (document.Validate.user_password2.value != document.Validate.user_password.value)
		{
			correct = false; alert("Passwords do not match.")
		}
	}
}
/*
var radio_choice = false;
for (counter = 0; counter < document.Validate.user_subscription.length; counter++)
{

if (Validate.user_subscription[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
correct = false; alert("Please choose the length of subscription.")
}
*/

if (correct){}
return correct

}


function checkData_up()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_username.value == "") {correct = false; alert("Please enter your user name.")}

if (document.Validate.user_password.value == "") {correct = false; alert("Please enter your password.")}
else
{
	
	if (document.Validate.user_password.value.length < 6) {correct = false; alert("Password needs to be six characters or more.")}
  else if(document.Validate.user_password.value.match(illegalChars))
	{ 
		correct = false; alert("This password contains illegal characters.");
	}  
	else
	{
		if (document.Validate.user_password2.value == "") 
		{
			correct = false; alert("Please verify your password.")
		}
		else if (document.Validate.user_password2.value != document.Validate.user_password.value)
		{
			correct = false; alert("Passwords do not match.")
		}
	}
}

	if (!document.Validate.agree.checked)
	{ 
			correct = false; alert("You must check the 'Agree' box in order to proceed.");
	}

if (correct){}
return correct

}

function checkData_login()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_username.value == "") {correct = false; alert("Please enter your user name.")}

if (document.Validate.user_password.value == "") {correct = false; alert("Please enter your password.")}

	if (!document.Validate.agree.checked)
	{ 
			correct = false; alert("You must check the 'Agree' box in order to proceed.");
	}

if (correct){}
return correct

}

function checkData_billing()
{
var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.user_billing_firstname.value == "") {correct = false; alert("Please enter your first name.")}
if (document.Validate.user_billing_lastname.value == "") {correct = false; alert("Please enter your last name.")}
if (document.Validate.user_billing_address.value == "") {correct = false; alert("Please enter your address.")}
if (document.Validate.user_billing_city.value == "") {correct = false; alert("Please enter your city.")}
if (document.Validate.user_billing_zip.value == "") {correct = false; alert("Please enter your zip.")}
/*
var radio_choice = false;
for (counter = 0; counter < document.Validate.user_subscription.length; counter++)
{

if (Validate.user_subscription[counter].checked)
radio_choice = true; 
}

if (!radio_choice)
{
correct = false; alert("Please choose the length of subscription.")
}
*/
	var cctype_selection = document.Validate.user_billing_cctype.selectedIndex;
  if( checkCreditCard (document.Validate.user_billing_ccnum.value,document.Validate.user_billing_cctype.options[cctype_selection].value)) {
  	//do nothing
  } 
  else 
  {
  	alert (ccErrors[ccErrorNo]);
  	correct = false;	
  }
  
if (document.Validate.user_billing_cvv.value == "") {correct = false; alert("Please enter the CVV number.")}  
  

if (correct){}
return correct
}


var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {

     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  
  cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
	cards [2] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};               
  cards [3] = {name: "AmEx", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};

	cards [4] = {name: "DinersClub", 
               length: "14,", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
	cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "Enroute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
               
  cards [8] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
               
  // Establish card type
  cardType = cardname;
  
  /*var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  */
  // If card type not found, report an error
  if (cardType == '') {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
  
  // Check that the number is numeric, although we do permit a space to occur  
  // every four digits. 
  var cardNo = cardnumber
  var cardexp = /^([0-9]{4})\s?([0-9]{4})\s?([0-9]{4})\s?([0-9]{1,4})$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardexp.exec(cardNo);
  cardNo = RegExp.$1 + RegExp.$2 + RegExp.$3 + RegExp.$4;
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}


function checkData_faq()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.faq_question.value == "") {correct = false; alert("Please enter your question.")}

if (correct){}
return correct

}

function checkData_sitesearch()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.searchform.search_value.value == "") {correct = false; alert("Please enter a keyword.")}

if (correct){}
return correct

}

function checkData_eaveds()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.eaveds.search_value.value == "") {correct = false; alert("Please enter a keyword.")}

if (correct){}
return correct

}


function checkData_thera()
{

var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.thera.search_value.value == "") {correct = false; alert("Please enter a keyword.")}

if (correct){}
return correct

}



/*

function checkData_admin(mode)
{
var mode = mode	
var correct = true
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (document.Validate.student_firstname.value == "") {correct = false; alert("Please enter your first name.")}
if (document.Validate.student_lastname.value == "") {correct = false; alert("Please enter your last name.")}
if (document.Validate.student_email.value == "") {correct = false; alert("Please enter your Email.")}
else
{
	var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(document.Validate.student_email.value))){ correct = false; alert("Please enter a valid email address.");	 }
  else if(document.Validate.student_email.value.match(illegalChars)){ correct = false; alert("The email address contains illegal characters.");}  
}

if( mode == 'add')
{
	if (document.Validate.student_password.value == "") {correct = false; alert("Please enter your Password.")}
	else
	{
		if (document.Validate.student_password.value.length < 6) {correct = false; alert("Password needs to be six characters or more.")}
	  else if(document.Validate.student_password.value.match(illegalChars)){ correct = false; alert("Password contains illegal characters.");}  
	}	
}
else if( mode == 'edit')
{
	if (document.Validate.student_password.value != "")
	if (document.Validate.student_password.value.length < 6) {correct = false; alert("Password needs to be six characters or more.")}
	else if(document.Validate.student_password.value.match(illegalChars)){ correct = false; alert("Password contains illegal characters.");}  
	
}	
		
var selection = document.Validate.is_employee.selectedIndex;
if (document.Validate.is_employee.options[selection].value == "Yes")
{
	if (document.Validate.location_employee_id.value == "") {correct = false; alert("Please indicate the name of the center which you work at.")}
}

if (correct){}
return correct
}


function checkData_class()
{
var correct = true

var selection = document.Validate.subject_id.selectedIndex;
if (document.Validate.subject_id.options[selection].value == "")
{
	correct = false; alert("Please choose a subject.");
}
var selection = document.Validate.instructor_id.selectedIndex;
if (document.Validate.instructor_id.options[selection].value == "")
{
	correct = false; alert("Please choose an instructor.");
}
var selection = document.Validate.location_id.selectedIndex;
if (document.Validate.location_id.options[selection].value == "")
{
	correct = false; alert("Please choose a lcoation.");
}
var selection = document.Validate.class_status.selectedIndex;
if (document.Validate.class_status.options[selection].value == "")
{
	correct = false; alert("Please choose status.");
}

var selection_month = document.Validate.Month.selectedIndex;
var selection_day = document.Validate.Day.selectedIndex;
var selection_year = document.Validate.Year.selectedIndex;
var selection_hour = document.Validate.Hour.selectedIndex;
var selection_minute = document.Validate.Minute.selectedIndex;
var msg = "Please choose the following:\n\n"; 
var ale = false;
if (document.Validate.Month.options[selection_month].value == "")
{
	msg += " Month\n"; ale = true;
}
if (document.Validate.Day.options[selection_day].value == "")
{
	msg += " Day\n"; ale = true;
}
if (document.Validate.Year.options[selection_year].value == "")
{
	msg += " Year\n"; ale = true;
}
if (document.Validate.Hour.options[selection_hour].value == "")
{
	msg += " Hour\n"; ale = true;
}
if (document.Validate.Minute.options[selection_minute].value == "")
{
	msg += " Minute\n"; ale = true;
}
if( ale == true  )
{ 
	alert(msg)
  correct = false; 
}

if (correct){}
return correct
}

function location_code_show() {
location_combo.style.display='block';
}

function location_code_hide() {
location_combo.style.display='none';
}

function location_code(){
	
	var selection = document.Validate.is_employee.selectedIndex;
	if (document.Validate.is_employee.options[selection].value == "Yes")
	{
   location_code_show(); 
  }
	else
	{
   location_code_hide(); 
  }
}

*/
