// JavaScript Document
 var Gagent = false;
	function validate(register) {
		
		try
		{

        if (Gagent) {
		    myLearned = -1;
			myPrice = -1;
			myBedroom = -1;
			myType = -1;
			myResidence = -1;
			myReason = -1;
            bSaving = false; // reset
			goemail = true;
            var msg = '';
			theForm = document.getElementById('reg3');
			
			if (theForm.phone_number.value == '') {
                msg += 'Phone is missing.\n';
            }
			if (theForm.phone_number.value.search(/[0-9]|[0-9]/)==-1) {
                msg += 'Only numbers accepted ex: 2125551212  .\n';
            }
			
			if (theForm.first_name.value == '') {
                msg += 'First Name is missing.\n';
            }
			
			if (theForm.first_name.value.search(/[a-z]|[A-Z]/)==-1) {
                msg += 'Only letters accepted.\n';
            }
			
			if (theForm.last_name.value == '') {
                msg += 'Last Name is missing.\n';
            }
			if (theForm.last_name.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.password.value == '') {
                msg += 'Password is missing.\n';
			 }
				
				
			if (theForm.bed_rooms.selectedIndex == 0) {
                msg += 'Please select # of bedrooms.\n';
            }
			if (theForm.bath_rooms.selectedIndex == 0) {
                msg += 'Please select # of bathrooms.\n';
            }
			
			if (theForm.type_home_to_buy_list.selectedIndex == 0) {
                msg += 'Please select type of property.\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 );
          }
   
		}