$(document).ready(function () {
    //add and remove vehicle fields
    var addButton = $('#add-field'); //Add button selector
    var wrapper = $('.added-fields'); //Input field wrapper
    var x = 1;
    var fieldHTML = '<div class="">' +
        '<button type="button" id="remove-button"> <i class="fa fa-trash"></i> </button>' +
        '<div class="guestDetails_input">\n' +
        '  <div class="guestDetails_inputLabel">Insured Item <span class="error">*</span></div>\n' +
        '    <div class="guestDetails_input">\n' +
        '       <input type="text" name="name[]" class="input-text-height" size="40" placeholder="Enter Insured Item Name" autocomplete="off">\n' +
        '    </div>\n' +
        '</div>\n' +
        '<div class="guestDetails_input">\n' +
        '  <div class="guestDetails_inputLabel">Sum Insured <span class="error">*</span></div>\n' +
        '    <div class="guestDetails_input">\n' +
        '       <input type="text" name="sum-insured[]" class="input-text-height" size="20" placeholder="Enter Sum Insured" autocomplete="off">\n' +
        '    </div>\n' +
        '</div>\n' +
        '<div class="guestDetails_input">\n' +
        '  <div class="guestDetails_inputLabel">Rate/Basic Premium <span class="error">*</span></div>\n' +
        '    <div class="guestDetails_input">\n' +
        '        <input type="text" name="rate[]" class="input-text-height" size="20" placeholder="Enter Basic Premium/Rate" autocomplete="off">\n' +
        '    </div>\n' +
        '</div>\n' +
        '    <div class="guestDetails_inputDivider input_divider1"></div>';

    //Once add button is clicked
    $(addButton).click(function(){
        x++; //Increment field counter

        $(wrapper).append(fieldHTML); //Add field html

    });
    //Once remove button is clicked
    $(wrapper).on('click', '#remove-button', function(e){
        e.preventDefault();
        $(this).parent('div').remove(); //Remove field html
        x--; //Decrement field counter
    });
});
