

// Begin form validation

function ValForm(strForm) {
	if (_CF_checkCFForm_1(strForm)) {
		strForm.submit();
	}
}

function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;
    }
    

function _CF_hasValue(obj, obj_type)
    {
		if (obj_type == "TEXT" || obj_type == "PASSWORD")
		{
			if (obj.value.length == 0 || obj.value == null || obj.value =="") 
		  		return false;
			else 
		  		return true;
		}
		else if (obj_type == "SELECT")
		{
		    if (obj.name == "state") {
				for (i=0; i < obj.length; i++)
					{
				if (obj.options[0].selected)
					return false;
				}
			}
			else if (obj.name == "byear") {
				for (i=0; i < obj.length; i++)
					{
				if (obj.options[0].selected)
					return false;
				}
			}

		   	return true;	
		}
		//else if (obj_type == "RADIO")
		//{

		//   for (i=0; i < obj.length; i++)
		//    	{
		//		if (obj[i].checked)
		//			return true;
		//		}
		//   		return false;
		//}
		else if (obj_type == "CHECKBOX")
		{

			if (obj.checked)
				return true;
		}
		return false;
	}


function  _CF_checkCFForm_1(_CF_this)

    {

    if  (!_CF_hasValue(_CF_this.company, "TEXT" )) 
		if (_CF_this.firstname.value == "" && _CF_this.lastname.value == "" ) {
			{
			if  (!_CF_onError(_CF_this, _CF_this.company, _CF_this.company.value, "Please provide either a Company or First and Last Name.")){
			_CF_this.company.focus();
			_CF_this.company.select();
			return false;
			}
		}
	}
    if  (!_CF_hasValue(_CF_this.firstname, "TEXT" )) 
		if (_CF_this.company.value == "") {
			{
			if  (!_CF_onError(_CF_this, _CF_this.firstname, _CF_this.firstname.value, "Please provide a First Name.")){
			_CF_this.firstname.focus();
			_CF_this.firstname.select();
			return false;
			}
		}
	}
    if  (!_CF_hasValue(_CF_this.lastname, "TEXT" )) 
		if (_CF_this.company.value == "") {
			{
			if  (!_CF_onError(_CF_this, _CF_this.lastname, _CF_this.lastname.value, "Please provide a Last Name.")){
			_CF_this.lastname.focus();
			_CF_this.lastname.select();
			return false;
			}
		}
	}
	
    if (_CF_this.Degree.selectedIndex == 0)
    {
    	alert("Please provide a Degree.");
    	_CF_this.Degree.focus();
    	return false;
    }
    
    if (_CF_this.Specialty.selectedIndex == 0)
    {
	alert("Please provide a Profession.");
	_CF_this.Specialty.focus();
	return false;
    }
	
    if  (!_CF_hasValue(_CF_this.email, "TEXT" )) 

       {
        if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "Please provide an E-mail Address.")){
		_CF_this.email.focus();
		_CF_this.email.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.username, "TEXT" )) 

       {
        if  (!_CF_onError(_CF_this, _CF_this.username, _CF_this.username.value, "Please provide a username.")){
		_CF_this.username.focus();
		_CF_this.username.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.password, "TEXT" )) 

       {
        if  (!_CF_onError(_CF_this, _CF_this.password, _CF_this.password.value, "Please provide a Password.")){
		_CF_this.password.focus();
		_CF_this.password.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.password2, "TEXT" )) 

       {
        if  (!_CF_onError(_CF_this, _CF_this.password2, _CF_this.password2.value, "Please confirm your Password.")){
		_CF_this.password2.focus();
		_CF_this.password2.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.address1, "TEXT" )) 

        {
        if  (!_CF_onError(_CF_this, _CF_this.address1, _CF_this.address1.value, "Please provide an Address.")){
		_CF_this.address1.focus();
		_CF_this.address1.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.city, "TEXT" )) 

        {
        if  (!_CF_onError(_CF_this, _CF_this.city, _CF_this.city.value, "Please provide a City.")){
		_CF_this.city.focus();
		_CF_this.city.select();
		return false;
		}
		
	}
	
    if  (_CF_this.state.value =="") 

        {
        if (_CF_this.country.value == "United States" || _CF_this.country.value == "Canada"    ) {
			if  (!_CF_onError(_CF_this, _CF_this.state, _CF_this.state.value, "Please provide a State or Province.")){
			_CF_this.state.focus();
			return false;
			}
		}
		
	}
	else {
		if (_CF_this.other.value != "" && _CF_this.state.value != "Other") {
			alert("You have both a state and an \"other\" state.\nPlease choose one or the other.");
			_CF_this.other.focus();
			_CF_this.other.select();
			return false;
		}
	}
	
    if  (!_CF_hasValue(_CF_this.other, "TEXT" )) 

        {
        if (_CF_this.state.value == "Other") {
        if  (!_CF_onError(_CF_this, _CF_this.other, _CF_this.other.value, "Please provide Other State or Province.")){
		_CF_this.other.focus();
		_CF_this.other.select();
		return false;
		}
		}
		
	}
    if  (!_CF_hasValue(_CF_this.zip, "TEXT" )) 

        {
        if  (!_CF_onError(_CF_this, _CF_this.zip, _CF_this.zip.value, "Please provide a Postal Code.")){
		_CF_this.zip.focus();
		_CF_this.zip.select();
		return false;
		}
		
	}
    if  (!_CF_hasValue(_CF_this.country, "SELECT" ))

        {
        if  (!_CF_onError(_CF_this, _CF_this.country, _CF_this.country.value, "Please provide a Country.")){
		_CF_this.country.focus();
		return false;
		}
		
	}
//   if  (!_CF_hasValue(_CF_this.ssn, "TEXT" )) 
//
//        {
//        if (_CF_this.country.value == "United States") {
//			if  (!_CF_onError(_CF_this, _CF_this.ssn, _CF_this.ssn.value, "Please provide a Social Security Number.")){
//			_CF_this.ssn.focus();
//			_CF_this.ssn.select();
//			return false;
//			}
//		}		
//	}
/*   if  (!_CF_hasValue(_CF_this.profession, "TEXT" )) 

        {
        if  (!_CF_onError(_CF_this, _CF_this.profession, _CF_this.profession.value, "Please provide a Profession.")){
		_CF_this.profession.focus();
		_CF_this.profession.select();
		return false;
		}
		
	}
*/

	// Begin password check
	
	password1 = document.myForm.password.value;
	password2 = document.myForm.password2.value;

	if (password1.length < 4) {
	alert ("\nPassword must be at least four characters long! \nPlease re-enter your password.")
	document.myForm.password.focus();
	document.myForm.password.select();
	return false;
	}
	if (password1.length > 10) {
	alert ("\nPassword must be no more than ten characters long! \nPlease re-enter your password.")
	document.myForm.password.focus();
	document.myForm.password.select();
	return false;
	}
	if (password1 != password2) {
	alert ("\nYou did not enter the same password twice. \nPlease re-enter your password.")
	document.myForm.password.focus();
	document.myForm.password.select();
	return false;
	}
	else return true;

	// End password check

}


// Begin zip code validation
function validateZIP() {
var valid = "0123456789-";
var hyphencount = 0;
var fieldval = document.myForm.zip.value
var field = document.myForm.zip
//if (fieldval.length < 1) {
//alert("Please provide zip code.");
//document.myForm.zip.focus();
//return false;
//}
if (fieldval.length!=5 && fieldval.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code."); document.myForm.zip.focus(); return false;
}
for (var i=0; i < fieldval.length; i++) { temp = "" + fieldval.substring(i, i+1); if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again."); field.focus(); return false;
}
if ((hyphencount > 1) || ((fieldval.length==10) && ""+fieldval.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
field.focus();
field.select();
return false;
}
}
return true;
}
//  End zip code validation



// Begin e-mail check
function emailCheck() {
txt=document.myForm.email.value;
if (txt.length == 0) {
alert("Please provide E-mail Address. ");
document.myForm.email.focus();
return false;
}
if (txt.indexOf("@")<3){
alert("I'm sorry. This e-mail address seems wrong. Please" +" check the prefix and '@' sign.");
document.myForm.email.focus();
return false;
}
//else if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5) &&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5) &&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)){ alert("I'm sorry. This email address seems wrong. Please" +" check the suffix for accuracy. (It should include a " +".com, .edu, .net, .org, .gov or .mil)");
//document.myForm.email.focus();
//return false;
//}
return true;
}
// End e-mail check



// Begin password check
function checkPw(form) {
password1 = document.myForm.password.value;
password2 = document.myForm.password2.value;

if (password1.length < 4) {
alert ("\nPassword must be at least four characters long! \nPlease re-enter your password.")
document.myForm.password.focus();
document.myForm.password.select();
return false;
}
if (password1.length > 10) {
alert ("\nPassword must be no more than ten characters long! \nPlease re-enter your password.")
document.myForm.password.focus();
document.myForm.password.select();
return false;
}
if (password1 != password2) {
alert ("\nYou did not enter the same password twice. \nPlease re-enter your password.")
document.myForm.password.focus();
document.myForm.password.select();
return false;
}
else return true;
}
// End password check

//-->



