function regValid() {

    var Temp     = document.regform.email 
    var AtSym    = Temp.value.indexOf('@')
    var Period   = Temp.value.lastIndexOf('.')
    var Space    = Temp.value.indexOf(' ')
    var Length   = Temp.value.length - 1   


// first name

 				if (document.regform.f_name.value == "") 
			{
				alert("Please enter your first name here.");
				document.regform.f_name.focus();
				return false;
			}
			
// lastname
			
			 	if (document.regform.l_name.value == "") 
			{
				alert("Please enter your last name here.");
				document.regform.l_name.focus();
				return false;
			}
				
// email	
			
             if ((AtSym < 1) || (Period <= AtSym+1) ||  (Period == Length ) || (Space  != -1)) 
 
    {  
	alert("You have entered an improperly formatted email address. \n It should be in the format 'you@yourbiz.com'.");
	Temp.focus();
	return false;
	}

	
// username
	
		if (document.regform.username.value == "") 
			{
				alert("Please enter your user name here.");
				document.regform.username.focus();
				return false;
			}

//username - any invalid characters??


          var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
         var excludePW=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;

	if(document.regform.username.value.search(exclude) != -1)
	{
		alert("Sorry, you cannot use special characters in your username!\n Letters and numbers only, please.");
		return false;
	}
	

			
			
//password
	
             if (document.regform.password.value.length < 4 || document.regform.password.value.length > 12)
	                 {
	                    alert("Sorry, your password must be between 4 and 12 characters long.");
	                    document.regform.password.focus();
	                    return false;
	                 }
	
	
	
//password - any invalid characters??
	
	        	if(document.regform.password.value.search(excludePW) != -1)
           	{
		         alert("Sorry, you cannot use special characters in your password!\n Letters and numbers only, please.");
		         return false;
	             }
	
	
//password match	
		
		
	               if (document.regform.password.value != document.regform.password2.value) 
	                {
	                alert("Sorry, your passwords must match!");
                   document.regform.password.focus();
	                return false;
	                }
		
//city
	
		if (document.regform.city.value == "") 
			{
				alert("Please enter your city here.");
				document.regform.city.focus();
				return false;
			}		
			
//country

yrCountry = document.regform.country_id.selectedIndex
	
 		if (document.regform.country_id.options[yrCountry].value == "--" )
			{
				alert("Please select your country from the list.");
					document.regform.country_id.focus();
				return false;
			}	
			
			
	//affilation
	
 		if (document.regform.affiliation.value == "") 
			{
				alert("Please enter your professional affilation here.");
				document.regform.affiliation.focus();
				return false;
			}	
			
			
	//degree

yrDegree = document.regform.degree_id.selectedIndex
	
 		if (document.regform.degree_id.options[yrDegree].value == "" )
			{
				alert("Please select your degree from the list.");
				document.regform.degree_id.focus();
				return false;
			}			
					
				
		
	
	//specialty

yrSpec = document.regform.specialty_id.selectedIndex
	
 		if (document.regform.specialty_id.options[yrSpec].value == "" )
			{
				alert("Please select your specialty from the list.");
				document.regform.specialty_id.focus();
				return false;
			}			
					
					
//years of practice

yrPrac = document.regform.years_of_practice.selectedIndex
	
 		if (document.regform.years_of_practice.options[yrPrac].value == "" )
			{
				alert("Please tell us approximately how many years you have been practicing.");
				document.regform.years_of_practice.focus();
				return false;
			}	
			
			//how did you hear

yrHear = document.regform.referral_type_id.selectedIndex
	
 		if (document.regform.referral_type_id.options[yrHear].value == "" )
			{
				alert("Please tell us how you heard about us.");
				document.regform.referral_type_id.focus();
				return false;
			}	
				
	}	
