var App_Form_Element_Contact = { init: function(id){ App_Form_Element_Contact.hideAll($('select[name*=' + id + ']'), id); $('select[name*=' + id + ']').bind('change', function (){ App_Form_Element_Contact.change(this, id); }); $('select[name*=' + id + ']').each(function(){ App_Form_Element_Contact.change(this, id); }); }, hideAll: function(element, id) { $(element).parent().find('#' + id + '_mailing_adress, #' + id + '_contact_info, #' + id + '_adress_other' ).hide() }, change: function(element, id) { App_Form_Element_Contact.hideAll(element, id); var value = $(element).val(); if (value == 'address'){ $(element).parent().children('#' + id + '_mailing_adress').show(); } else if (value == 'other'){ $(element).parent().children('#' + id + '_adress_other').show(); } else { $(element).parent().children('#' + id + '_contact_info').show(); } } }