$(function() {
	// bind the form fields to the cookie. Cookie will autofill
	$('#fname, #lname, #email, #phone, #contact_preference_phone, #contact_preference_email, #entity_type_broker, #entity_type_principal, #company, #office_phone, #cell_phone , #business_contact_preference_office, #business_contact_preference_office').cookieBind({expiresAt: new Date(2021, 1, 1)});
	
	// manage the radio buttons. Check the cookie, then mark the correct radio selection.
	// contact preferences
	if($.cookies.get('contact_preference') == 'phone') {
		$('#contact_preference_phone').attr('checked', 'checked');
	}
	else if($.cookies.get('contact_preference') == 'email') {
		$('#contact_preference_email').attr('checked', 'checked');
	}
	
	// business contact
	if($.cookies.get('business_contact_preference') == 'office') {
		$('#business_contact_preference_office').attr('checked', 'checked');
	}
	else if($.cookies.get('business_contact_preference') == 'mobile') {
		$('#business_contact_preference_mobile').attr('checked', 'checked');
	}
	
	// entity type
	if($.cookies.get('entity_type') == 'broker') {
		$('#entity_type_broker').attr('checked', 'checked');
	}
	else if($.cookies.get('entity_type') == 'principal') {
		$('#entity_type_principal').attr('checked', 'checked');
	}
});
