﻿function validateForm(thisForm){

	if ((document.thisForm.KeynoteLunch.checked)||(document.thisForm.PublicTSXWorkshop.checked)||(document.thisForm.NetworkingReception.checked)) {
	} else {	
		alert("Please choose the Events you wish to attend");
		return false;
	}


	if(""==document.thisForm.FirstName.value){
		alert("Please enter a value for the \"First Name\" field.");
		document.thisForm.FirstName.focus();
		return false;
	}
	
	if(""==document.thisForm.LastName.value){
		alert("Please enter a value for the \"Last Name\" field.");
		document.thisForm.LastName.focus();
		return false;
	}
	
	if(""==document.thisForm.Organization.value){
		alert("Please enter a value for the \"Organization\" field.");
		document.thisForm.Organization.focus();
		return false;
	}
	
	if(""==document.thisForm.Address1.value){
		alert("Please enter a value for the \"Address\" field.");
		document.thisForm.Address1.focus();
		return false;
	}
	
	if(""==document.thisForm.City.value){
		alert("Please enter a value for the \"City\" field.");
		document.thisForm.City.focus();
		return false;
	}
	
	if (document.thisForm.StateProvince.selectedIndex == 0){
		alert("Please select a value for \"State/Province.\"");
		document.thisForm.StateProvince.focus();
		return false;
	}
	
	if(""==document.thisForm.ZipPostalCode.value){
		alert("Please enter a value for the \"Zip/Postal Code\" field.");
		document.thisForm.ZipPostalCode.focus();
		return false;
	}
	
	if(""==document.thisForm.BusinessPhone.value){
		alert("Please enter a value for the \"Business Phone\" field.");
		document.thisForm.BusinessPhone.focus();
		return false;
	}
	
	if(""==document.thisForm.Email.value){
		alert("Please enter a value for the \"Email\" field.");
		document.thisForm.Email.focus();
		return false;
	} else {
	
	// Email Validation Javascript
	// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd
	
	// You have permission to copy and use this javascript provided that
	// the content of the script is not changed in any way.
	
		addr = document.thisForm.Email.value;
		man = 1;
		db = 1;
		
		if (addr == '' && man) {
		   if (db) alert('email address is mandatory');
		   return false;
		}
		
		if (addr == '') return true;
		var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
		for (i=0; i<invalidChars.length; i++) {
		   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		      if (db) alert('email address contains invalid characters');
		      return false;
		   }
		}
		for (i=0; i<addr.length; i++) {
		   if (addr.charCodeAt(i)>127) {
		      if (db) alert("email address contains non ascii characters.");
		      return false;
		   }
		}
		
		var atPos = addr.indexOf('@',0);
		if (atPos == -1) {
		   if (db) alert('email address must contain an @');
		   return false;
		}
		if (atPos == 0) {
		   if (db) alert('email address must not start with @');
		   return false;
		}
		if (addr.indexOf('@', atPos + 1) > - 1) {
		   if (db) alert('email address must contain only one @');
		   return false;
		}
		if (addr.indexOf('.', atPos) == -1) {
		   if (db) alert('email address must contain a period in the domain name');
		   return false;
		}
		if (addr.indexOf('@.',0) != -1) {
		   if (db) alert('period must not immediately follow @ in email address');
		   return false;
		}
		if (addr.indexOf('.@',0) != -1){
		   if (db) alert('period must not immediately precede @ in email address');
		   return false;
		}
		if (addr.indexOf('..',0) != -1) {
		   if (db) alert('two periods must not be adjacent in email address');
		   return false;
		}
		var suffix = addr.substring(addr.lastIndexOf('.')+1);
		if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
		   if (db) alert('invalid primary domain in email address');
		   return false;
		}
	}
	
	DelRadio = -1;
	for (i=document.thisForm.DelegateProfile.length-1; i > -1; i--) {
		if (document.thisForm.DelegateProfile[i].checked) {
		DelRadio = i; i = -1;
		}
	}
	if (DelRadio == -1) {
		alert("Please choose an option from the \"Delegate Profile List\"");
		return false;
	} else {
		if (document.thisForm.DelegateProfile[DelRadio].value=="Other"){
			if (document.thisForm.DelegateProfileOther.value=="") {
			alert("Please specify your \"Other\" Delegate Profile.");
			document.thisForm.DelegateProfileOther.focus();
			return false;
			}
		}
	}

}