var username = new Field('Username', 'username', 'freeform', true);
var password = new Field('Password', 'password', 'freeform', true);
var verifypassword = new Field('Verify Password', 'verifypassword', 'freeform', true);
var firstName = new Field('First Name', 'firstName', 'freeform', true);
var lastName = new Field('Last Name', 'lastName', 'freeform', true);
var email = new Field('E-Mail', 'email', 'email', true);
var altEmail = new Field('Alternate E-Mail', 'altEmail', 'email', false);
var country = new Field('Country', 'country', 'select', true);
var specialty = new Field('Specialty', 'specialty', 'select', true);
var customerSegment = new Field('Customer Segment', 'customerSegment', 'radio', true);
var classification= new Field('Classification', 'classification', 'select', true); 

var fields = new Array(username, password, verifypassword, firstName, lastName, email, altEmail,  specialty, customerSegment,classification, country);

function validateRegistration(form)
{
	
	if ( validate(form) )  {

		if ( form.password.value != form.verifypassword.value )  {
			alert("The password and verify password fields don't match.");
			form.password.focus();
			return false;
		}
		

		if( form.classification.selectedIndex == form.secondaryClassification.selectedIndex)
		{
			alert("Primary Classification cannot be the same as Secondary Classification");
			form.secondaryClassification.focus();
			return false;
		}

		if( form.specialty.selectedIndex == form.subSpecialty.selectedIndex)
		{
			alert("Primary Specialty cannot be the same as Secondary Specialty");
			form.subSpecialty.focus();
			return false;
		}

		if ( form.address.value == "" )   {
			alert("Address is required");
			form.address.focus();
			return false;
		}
		if ( !checkLineSize(form.address.value, 1, 35, 3) )  {
			alert("The address can be only three lines, 35 characters per line");
			form.address.focus();
			return false;
		}

		if ( form.city.value == "" )   {
			alert("City is required");
			form.city.focus();
			return false;
		}


		if ( !form.homePhoneIntl.checked && !checkMinimumSize(form.homePhone.value, 10, true) )  {
			alert("The home phone should be at least 10 digits if it is a domestic phone number.");
			form.inputHomePhone.focus();
			return false;
		}

		if ( !form.workPhoneIntl.checked && !checkMinimumSize(form.workPhone.value, 10, true) )  {
			alert("The work phone should be at least 10 digits if it is a domestic phone number.");
			form.inputWorkPhone.focus();
			return false;
		}

		if ( !form.faxNumberIntl.checked && !checkMinimumSize(form.faxNumber.value, 10, true) )  {
			alert("The fax number should be at least 10 digits if it is a domestic phone number.");
			form.inputFaxNumber.focus();
			return false;
		}

		if(form.degree.selectedIndex == 0)
		{
			if(form.advancedDegrees.selectedIndex>0)
			{
				alert("You cannot select None from the first Degree and a valid value from the second choice. Please update these values");	
				form.degree.focus();
				return false;
			}
		}
		if(form.certifications.selectedIndex == 0)
		{
			if(form.honoraryTitles.selectedIndex>0)
			{
				alert("You cannot select None from the first certification choice and a valid value from the second choice. Please update these values");	
				form.certifications.focus();
				return false;
			}
		}
		if(form.degree.selectedIndex > 0)
		{
			if(form.degree.selectedIndex == form.advancedDegrees.selectedIndex)
			{
				alert("You cannot have the same value for both degree choices. Please update these values");	
				form.degree.focus();
				return false;
			}
		}	
		if(form.certifications.selectedIndex > 0)
		{
			if(form.certifications.selectedIndex == form.honoraryTitles.selectedIndex)
			{
				alert("You cannot have the same value for both Certification choices. Please update these values");	
				form.certifications.focus();
				return false;
			}
		}				
    }  else  {
     	return false;
    }

	return true;

}


