function showExtraField(callback) { return function () { // Get fieldset we want to show }; } function checkFields(){ var $moreToShow = $('#'+$('#service input').val()) // Hide everything $('.more').hide(); // Show the neccessary $moreToShow.show(); // Focus first input $moreToShow.find('input:first').trigger('focus'); } $(function(){ $(document.body).click(function(){ $('#service ul').hide() }) $('#service .current').click(function(){ $('#service ul').toggle() return false }) $('#service li').click(function(){ $('#service input').val($(this).data('value')) $('#service .current').html($(this).html()) checkFields() }) // Select box functionality $(document.body).on('click', 'div.fake_select li', function(){ var $this=$(this) var $select = $this.closest('div.fake_select') var $popup = $select.closest('.popup-content') var $call_box = $select.next('.number-placeholder').show().children('.please-call') var number = $this.data('number') $call_box.show().find('#call_number').html(number) $popup.find('.terms').each(function(){ var $this=$(this) $this.toggle($this.data('number')==number) }) $select.find('.default>span').html($this.html()) $select.find('ul').hide() }) $(document.body).on('click', 'div.fake_select .default', function(){ var $this=$(this) $this.next().toggle() }) $('.support_contact_link').magnificPopup({ items:{ type:'inline', src:'#support_contact' }, closeBtnInside:false }) })