function validateinfo() {
  var colour = '#f0f0f0';
  var colour2 = '#FF7D00';
  var x = document.contact;
  var salutation = x.salutation.value;
  var firstname = x.first.value;
  var lastname = x.last.value;
  var email = x.email.value;
  var email_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var comments = x.comments.value;

  if (salutation == 0) {
    x.salutation.style.backgroundColor = colour;
	x.salutation.focus();
	alert("Please Select A Salutation");
	return false;
  }

  if (firstname == '') {
	x.first.style.backgroundColor = colour;
	x.first.style.borderColor = colour2;
	x.first.focus();
	alert("Please Enter A Firstname");
	return false;
  }
  if (lastname == '') {
	x.last.style.backgroundColor = colour;
	x.last.style.borderColor = colour2;
	x.last.focus();
	alert("Please Enter A Lastname");
	return false;
  }
  if (email_filter.test(email));
  else {
    x.email.style.backgroundColor = colour;
    x.email.style.borderColor = colour2;
    x.email.focus();
 	alert("Please Enter A Valid Email Address");
	return false;
  }

  if (comments == '') {
 	x.comments.style.backgroundColor = colour;
	x.comments.style.borderColor = colour2;
	x.comments.focus();
	alert("Please enter general comments");
	return false;
  }		
}

function setok(y,form) {
  var colour = '#FFFFFF';
  var colour2 = '#848484';

  var x = document[form];
  x[y].style.backgroundColor = colour;
  x[y].style.borderColor = colour2;
}

function validateaddsite(){
  var colour = '#f0f0f0';
  var colour2 = '#FF7D00';
  var x = document.addsite;

  var salutation = x.salutation.value;
  var firstname = x.first.value;
  var lastname = x.last.value;
  var email = x.email.value;
  var email_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

  var main_section = x.main_section.value;
  var other_section = x.other_section.value;
  var website_name = x.website_name.value;
  var website_address = x.website_address.value;
  var description = x.description.value;

  if (salutation == 0) {
	x.salutation.style.backgroundColor = colour;
	x.salutation.focus();
	alert("Please Select A Salutation");
	return false;
  }
  
  if (firstname == '') {
	x.first.style.backgroundColor = colour;
	x.first.style.borderColor = colour2;
	x.first.focus();
	alert("Please Enter A Firstname");
	return false;
  }
  if (lastname == '') {
	x.last.style.backgroundColor = colour;
	x.last.style.borderColor = colour2;
	x.last.focus();
	alert("Please Enter A Lastname");
	return false;
  }
  if (email_filter.test(email));
  else {
	x.email.style.backgroundColor = colour;
	x.email.style.borderColor = colour2;
	x.email.focus();
	alert("Please Enter A Valid Email Address");
	return false;
  }

  if (main_section == 0) {
    x.main_section.style.backgroundColor = colour;
	x.main_section.focus();
	alert("Please select a subject section for the website you are wanting to add");
	return false;
  }
  else if (main_section == 'Oth' && other_section == ''){
	x.other_section.style.backgroundColor = colour;
	x.other_section.style.borderColor = colour2;
	x.other_section.focus();
    alert("Please enter the new section name you would like the website to appear under");
	return false;
  }
  if (website_name == '') {
	x.website_name.style.backgroundColor = colour;
	x.website_name.style.borderColor = colour2;
	x.website_name.focus();
	alert("Please enter the name of the website");
	return false;
  }	

  if (website_address == '') {
	x.website_address.style.backgroundColor = colour;
	x.website_address.style.borderColor = colour2;
	x.website_address.focus();
	alert("Please enter a website address");
	return false;
  }

  if (description == '') {
	x.description.style.backgroundColor = colour;
	x.description.style.borderColor = colour2;
	x.description.focus();
	alert("Please enter a general description for the website you would like added");
	return false;
  }
}

function registration() {
  var colour = '#f0f0f0';
  var colour2 = '#FF7D00';
  var x = document.register;
  var salutation = x.salutation.value;
  var firstname = x.first.value;
  var lastname = x.last.value;
  var email = x.email.value;
  var email_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var street = x.street.value;
  var suburb = x.suburb.value;
  var city = x.city.value;

  if (salutation == 0) {
    x.salutation.style.backgroundColor = colour;
	x.salutation.focus();
	alert("Please Select A Salutation");
	return false;
  }

  if (firstname == '') {
	x.first.style.backgroundColor = colour;
	x.first.style.borderColor = colour2;
	x.first.focus();
	alert("Please Enter A Firstname");
	return false;
  }
  if (lastname == '') {
	x.last.style.backgroundColor = colour;
	x.last.style.borderColor = colour2;
	x.last.focus();
	alert("Please Enter A Lastname");
	return false;
  }
  if (email_filter.test(email));
  else {
    x.email.style.backgroundColor = colour;
    x.email.style.borderColor = colour2;
    x.email.focus();
 	alert("Please Enter A Valid Email Address");
	return false;
  }

  if (street == '') {
	x.street.style.backgroundColor = colour;
	x.street.style.borderColor = colour2;
	x.street.focus();
	alert("Please Enter A Street");
	return false;
  }
  if (suburb == '') {
	x.suburb.style.backgroundColor = colour;
	x.suburb.style.borderColor = colour2;
	x.suburb.focus();
	alert("Please Enter A Suburb");
	return false;
  }
  if (city == '') {
	x.city.style.backgroundColor = colour;
	x.city.style.borderColor = colour2;
	x.city.focus();
	alert("Please Enter A City");
	return false;
  }

}

function special_subs() {
  var colour = '#f0f0f0';
  var colour2 = '#FF7D00';
  var x = document.subscription;
  var salutation = x.salutation.value;
  var firstname = x.first.value;
  var lastname = x.last.value;
  var email = x.email.value;
  var email_filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var street = x.street.value;
  var suburb = x.suburb.value;
  var city = x.city.value;
  var N =0;
  
  if (salutation == 0) {
    x.salutation.style.backgroundColor = colour;
	x.salutation.focus();
	alert("Please Select A Salutation");
	return false;
  }

  if (firstname == '') {
	x.first.style.backgroundColor = colour;
	x.first.style.borderColor = colour2;
	x.first.focus();
	alert("Please Enter A Firstname");
	return false;
  }
  if (lastname == '') {
	x.last.style.backgroundColor = colour;
	x.last.style.borderColor = colour2;
	x.last.focus();
	alert("Please Enter A Lastname");
	return false;
  }
  if (email_filter.test(email));
  else {
    x.email.style.backgroundColor = colour;
    x.email.style.borderColor = colour2;
    x.email.focus();
 	alert("Please Enter A Valid Email Address");
	return false;
  }

  if (street == '') {
	x.street.style.backgroundColor = colour;
	x.street.style.borderColor = colour2;
	x.street.focus();
	alert("Please Enter A Street");
	return false;
  }
  if (suburb == '') {
	x.suburb.style.backgroundColor = colour;
	x.suburb.style.borderColor = colour2;
	x.suburb.focus();
	alert("Please Enter A Suburb");
	return false;
  }
  if (city == '') {
	x.city.style.backgroundColor = colour;
	x.city.style.borderColor = colour2;
	x.city.focus();
	alert("Please Enter A City");
	return false;
  }

  if(x.MIR.checked) {
	N++;
  }

  if(x.MYR.checked) {
	N++;
  }

  if(x.RES.checked) {
	N++;
  }

  if(x.TDS.checked) {
	N++;
  }

  if((N != 2) && (N != 3)) {
	alert('You must select two or three services you would like to subscribe to');
	return false;
  }
}