// JavaScript Document
 var bSaving = false;
	function validate(register) {
		
		try
		{

        if (bSaving) {
		    myLearned = -1;
			myPrice = -1;
			myBedroom = -1;
			myType = -1;
			myResidence = -1;
			myReason = -1;
            bSaving = false; // reset
			goemail = true;
            var msg = '';
			theForm = document.getElementById('form1');
			
			if (theForm.firstName.value == '') {
                msg += 'First Name is missing.\n';
            }
			if (theForm.firstName.value.search(/[a-z]|[A-Z]/)==-1) {
                msg += 'Only letters accepted.\n';
            }
			if (theForm.lastName.value == '') {
                msg += 'Last Name is missing.\n';
            }
			if (theForm.lastName.value.search(/[a-z]|[A-Z]/)==-1) {
                msg += 'Only letters accepted.\n';
            }
			if (theForm.email.value == '') {
                msg += 'Email is missing.\n';
				goemail = false
            }
			
			
			if (theForm.homeAreaCode.value == '' || theForm.homeAreaCode.value.length != 3) {
                msg += 'Invalid home phone area code.\n';
            }
			if (theForm.homePhFirst3.value == '' || theForm.homePhFirst3.value.length != 3) {
                msg += 'Invalid first 3 digits of your home phone number.\n';
            }
			if (theForm.homePhLast4.value == '' || theForm.homePhLast4.value.length != 4) {
                msg += 'Invalid last 4 digits of your home phone number.\n';
            }
			
			/*
			if (theForm.altAreaCode.value == '' || theForm.altAreaCode.value.length != 3) {
                msg += 'Invalid alternate phone area code.\n';
            }
			if (theForm.altPhFirst3.value == '' || theForm.altPhFirst3.value.length != 3) {
                msg += 'Invalid first 3 digits of your alternate phone number.\n';
            }
			if (theForm.altPhLast4.value == '' || theForm.altPhLast4.value.length != 4) {
                msg += 'Invalid last 4 digits of your alternate phone number.\n';
            }
			
			if (theForm.CellAreaCode.value == '' || theForm.CellAreaCode.value.length != 3) {
                msg += 'Invalid cell phone area code.\n';
            }
			if (theForm.cellPhFirst3.value == '' || theForm.cellPhFirst3.value.length != 3) {
                msg += 'Invalid first 3 digits of your cell phone number.\n';
            }
			if (theForm.cellPhLast4.value == '' || theForm.cellPhLast4.value.length != 4) {
                msg += 'Invalid last 4 digits of your cell phone number.\n';
            }*/
			
			
			if (theForm.bestTimeToCall.selectedIndex == 0) {
                msg += 'Please select the best time to call you.\n';
            }			
			
			
			if (theForm.address.value == '') {
                msg += 'Address is missing.\n';
            }
			if (theForm.city.value == '') {
                msg += 'City is missing.\n';
            }
			if (theForm.state.selectedIndex == 0) {
                msg += 'State is missing.\n';
            }
			if (theForm.zipCode.value == '' || theForm.zipCode.value.length != 5) {
                msg += 'Invalid or missing zipcode.\n';
            }
			if (theForm.country.selectedIndex == 0) {
                msg += 'Country is missing.\n';
            }
			if (theForm.High_School.selectedIndex == 0) {
                msg += 'Please select your High School graduation year.\n';
            }
			if (theForm.WestWood_CurrentLevel.selectedIndex == 0) {
                msg += 'Please select your current level of education.\n';
            }
			
			
			
			/*if (test=true) {
                msg += 'You must be 18 years or older.\n';
            }		*/	    
            
			  var inputgrp = theForm.over18;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "Are you over 18 years old?\n";
					
			/*var inputgrp = theForm.Price_Range;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "You must select an option from Price Range.\n";
					
			var inputgrp = theForm.bedrooms;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "You must select an option from Bedrooms.\n";*/
					
		/*var inputgrp = document.contact.Type_Of_Residence;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "You must select an option from Type of Residence.\n";*/
					
					/*
			var inputgrp = document.contact.Reason_for_Purchase;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "You must select an option from Reason for Purchase.\n";
					
			var inputgrp = document.contact.Residence;
              var idx = inputgrp.length - 1;
              do
                 if (inputgrp[idx].checked)
                 break;
             while (idx--);
             if (idx < 0)
                    msg += "You must select an option from Residence.\n"; 						
	
	*/
	
			  str = theForm.email.value
			  checkdot = str.indexOf(".")
			  checkarb = str.indexOf("@")
			  checkspc = str.indexOf(" ")
			  if(goemail){
              if((checkdot<=-1) || (checkarb<=-1) || (checkspc>0)) {
			  msg += 'Please use a valid Email Address.\n';
			  }
			  }

            if (msg != '') {
                msg = 'The following errors were found:\n\n' + msg;
                alert(msg);
                return false;
            } else {
                return true;
            }
        } else {
            return true;
        }
		
		}
          catch( expError )
          {
               alert( location.href + "\n" +
                      "MyFunction( )\n" +
                      expError.number + "\n" +
                      expError.description );
          }
   
		}