
function isPhoneNumber(theElement) {
  // 650-506-7000 format
  str = theElement.value;
  if (str.length != 12) { 
    return false;
  }
  len = str.length;
  for (i = 0; i < len; i++) {
    c = str.charAt(i);
    if ((i == 3) || (i == 7)) {
      if (c != "-") { 
        return false; 
      }
    } else if ((c < "0") || (c > "9")) { 
      return false;
    }
  }
  return true;
}
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) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}
       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}
       	return false;	
	}
	}

function  _CF_checkMyForm(_CF_this)
    {
	
    if  (!_CF_hasValue(_CF_this.firstName, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.firstName, _CF_this.firstName.value, "Please enter your First Name."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.lastName, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.lastName, _CF_this.lastName.value, "Please enter your Last Name."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.state, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.state, _CF_this.state.value, "Please enter your State."))
            {
            return false; 
            }
        }
	// added by ew 8/30/04
	if (_CF_hasValue(_CF_this.contact, "RADIO")) {
		
		if(_CF_this.contact[1].checked && _CF_this.contact[1].value == "Email") {
			//alert("Email is selected");
			if  (!_CF_hasValue(_CF_this.email, "TEXT" )) {
				if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "Please enter your e-mail address if you would like to be contacted by e-mail.")){
					return false; 
				}
			}
		}
		
		if(_CF_this.contact[2].checked && _CF_this.contact[2].value == "US Mail") {
			//alert("US Mail is selected");
			if  (!_CF_hasValue(_CF_this.address, "TEXT" )) {
				if  (!_CF_onError(_CF_this, _CF_this.address, _CF_this.address.value, "Please enter your residence mailing address if you would like to be contacted by US Mail.")){
					return false; 
				}
			}
			if  (!_CF_hasValue(_CF_this.city, "TEXT" )) {
				if  (!_CF_onError(_CF_this, _CF_this.city, _CF_this.city.value, "Please enter your city if you would like to be contacted by US Mail.")){
					return false; 
				}
			}
			if  (!_CF_hasValue(_CF_this.zip, "TEXT" )) {
				if  (!_CF_onError(_CF_this, _CF_this.zip, _CF_this.zip.value, "Please enter your zip code if you would like to be contacted by US Mail.")){
					return false; 
				}
			}
		}
	
	}
	// end added by ew
    if  (!_CF_hasValue(_CF_this.full_timer, "RADIO" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.full_timer, _CF_this.full_timer.value, "Please enter if Full Timer or not."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.ownership, "RADIO" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.ownership, _CF_this.ownership.value, "Please enter the Intended Ownership."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.uscitizen, "RADIO" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.uscitizen, _CF_this.uscitizen.value, "Please enter if US Citizen or not."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.phone, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.phone, _CF_this.phone.value, "Please enter your Daytime Phone Number."))
            {
            return false; 
            }
        }
	if(!isPhoneNumber(_CF_this.phone)) {
			alert( "Please enter your phone number with an area code: XXX-XXX-XXXX");
			_CF_this.phone.focus();
			return false;
		}

    if  (!_CF_hasValue(_CF_this.year, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.year, _CF_this.year.value, "Please enter the Year."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.make, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.make, _CF_this.make.value, "Please enter the Make."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.model, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.model, _CF_this.model.value, "Please enter the Model."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.length, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.length, _CF_this.length.value, "Please enter the Length."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.horsepower, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.horsepower, _CF_this.horsepower.value, "Please enter the Total Horsepower."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.slideouts, "SELECT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.slideouts, _CF_this.slideouts.value, "Please enter Number of Slideouts."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.vehicle, "RADIO" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.vehicle, _CF_this.vehicle.value, "Please enter Type of Vehicle."))
            {
            return false; 
            }
        }

// PURCHASE INFO section validation here -- conditional
if (_CF_this.PurchaseOrRefinance.options[_CF_this.PurchaseOrRefinance.selectedIndex].value == "purchase") {

/*    if  (!_CF_hasValue(_CF_this.full_name_purchase, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.full_name_purchase, _CF_this.full_name_purchase.value, "Please enter your Full Name."))
            {
            return false; 
            }
        }
*/
    if  (!_CF_hasValue(_CF_this.sellers_name, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.sellers_name, _CF_this.sellers_name.value, "Please enter the Seller's Name."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.sellers_city, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.sellers_city, _CF_this.sellers_city.value, "Please enter the Seller's City."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.sellers_state, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.sellers_state, _CF_this.sellers_state.value, "Please enter the Seller's State."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.seller, "RADIO" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.seller, _CF_this.seller.value, "Please enter Type of Seller."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.purchase_price, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.purchase_price, _CF_this.purchase_price.value, "Please enter the Purchase Price."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.down_payment, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.down_payment, _CF_this.down_payment.value, "Please enter the Amount of Down Payment."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.delivery_date, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.delivery_date, _CF_this.delivery_date.value, "Please enter the Anticipated Delivery Date."))
            {
            return false; 
            }
        }

}// end if

// REFINANCE INFO section validation here -- conditional
if (_CF_this.PurchaseOrRefinance.options[_CF_this.PurchaseOrRefinance.selectedIndex].value == "refinance") {
/*    if  (!_CF_hasValue(_CF_this.full_name_refinance, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.full_name_refinance, _CF_this.full_name_refinance.value, "Please enter your Full Name."))
            {
            return false; 
            }
        }
*/
    if  (!_CF_hasValue(_CF_this.current_loan, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.current_loan, _CF_this.current_loan.value, "Please enter amount of current loan."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.length_remaining, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.length_remaining, _CF_this.length_remaining.value, "Please enter length of term remaining on current loan."))
            {
            return false; 
            }
        }

    if  (!_CF_hasValue(_CF_this.currently_titled, "TEXT" )) 
        {
        if  (!_CF_onError(_CF_this, _CF_this.currently_titled, _CF_this.currently_titled.value, "Please enter where RV is currently titled."))
            {
            return false; 
            }
        }
}// end if

    return true;
    }
