	var LifeForm = Class.create();
	LifeForm.prototype =
	{
		initialize: function(form_id){
			this.name									= form_id;
			this.form_elements				= $$(".error");
			this.phone_area_count			=	1;
			this.phone_station_count	=	1;
			
			this.initializeRequiredFields();
			this.initializeEvents();
		},

		/*************************************************
		 *initialize the validations for required elements
		 */
		initializeRequiredFields : function(){
			//coverage section (applicant)
			$("gender1_error").addClassName("validate-one-selected");
			$("dob1_on_error").addClassName("validate-dob");
			$("insured1_height_error").addClassName("validate-height");
			$("insured1_weight_error").addClassName("validate-weight");
			
			//contact info section
			$("first_name_error").addClassName("validate-alpha");
			$("last_name_error").addClassName("validate-alpha");
			
			if($("address1_city_error") != null){
				$("address1_city_error").addClassName("validate-alpha");
			}
			
			if($("address1_state_error") != null){
				$("address1_state_error").addClassName("validate-state");
			}
			
			if($("address1_zip_error") != null){
				$("address1_zip_error").addClassName("validate-zip");
			}
			
			$("phone1_error").addClassName("validate-phone");
			$("email1_error").addClassName("validate-email");
			$("is_smoker1_error").addClassName("validate-one-selected");
			$("privacy_policy_error").addClassName("validate-checked");
		},

		/***************************************************************************************************
		 *add event listeners for submit button, return key and custom onclick/onchange
		 */
		initializeEvents : function(){
			Event.observe(document, "keypress", this.validateOnReturnKey.bindAsEventListener(this));
			Event.observe("submit", "click", this.validateFields.bindAsEventListener(this));
			
			Event.observe("phone1_area", "keyup", this.autoTab.bindAsEventListener(this));
			Event.observe("phone1_exchange", "keyup", this.autoTab.bindAsEventListener(this));
			
			
			Event.observe("phone1_area", "keypress", this.removeStay.bindAsEventListener(this));
			Event.observe("phone1_exchange", "keypress", this.removeStay.bindAsEventListener(this));
		},

		validateFields: function(e){
			var form			= new Validator(this.form_elements);
			var is_valid	= form.isFormValid();
			if(!is_valid) Event.stop(e);
		},

		validateOnReturnKey: function(e){
			if(e.keyCode == Event.KEY_RETURN){
				this.validateFields(e);
				Event.stop(e);
			}
		},
		
		removeStay: function(e){
			if(e.keyCode != Event.KEY_TAB){
				$(Event.element(e)).removeClassName("stay");
			}
		},
		
		autoTab: function(e){
			var element	=	Event.element(e);
			if (!(/(stay)/i.test($(element).className))){
				if($(element).maxLength == $F(element).length){
					var next_element	=	$(element).next();
					next_element.focus();
					$(element).addClassName("stay");
				}
			}
		}
	}
		
	if (!(BrowserDetect.browser == "Explorer" && BrowserDetect.version < 6)) {
		Event.observe(window, "load", function() {
			var life_form = new LifeForm();
		});
	}