function EndpointTab(elementIdPrefix, element, resultHandler, _this) {
    _this.submitButton = $('#' + elementIdPrefix + '-submit-button');

    _this.element = element;
    _this.resultHandler = resultHandler;

    _this.updateSearchUrl = function () {
        $('#' + elementIdPrefix + '-url').text(_this.getRequestFromFields().toString());
    }

    _this.getRequestFromFields = function() {
        var apiRequest = new ApiQuery();
        apiRequest.endpoint = "/" + _this.getEndpointPath();
        for(var index = 0; index < _this.params.length; index ++) {
            var param = _this.params[index];
            apiRequest.setParam(param, $( '#' + elementIdPrefix + '-' + param + '-input').val());
        }

        apiRequest.setParam("api-key", $("#api-key-input").val());

        return apiRequest;
    }

    _this.updateFieldsFromRequest = function(apiRequest) {
        for(var index = 0; index < _this.params.length; index ++) {
            var param = _this.params[index];
            $( '#' + elementIdPrefix + '-' + param + '-input').val(apiRequest.getParam(param) ? apiRequest.getParam(param) : "");
        }
        

        $("#api-key-input").val(apiRequest.getParam('api-key'));

        _this.updateSearchUrl();
        
        resultHandler.updateResults(apiRequest);

        $(".input-group", element).allfield("update");


    }

    _this.updateFragmentFromFields = function() {
        $(window).attr('location', "#" + _this.getRequestFromFields().getPath());
    }

    _this.fieldChanged = function() {
        _this.updateSearchUrl();

    }

    $('.date-picker', element).datepicker({ dateFormat: 'yy-mm-dd' } );

    function updateLocation() {
        var apiRequest = _this.getRequestFromFields();
        $(window).attr('location', "#" + apiRequest.getPath());
    }

    _this.submitButton.click(updateLocation);
    element.keyup(function(e) {
        if (e.keyCode == '13') {
            updateLocation();            
        }
    });


    $(".input-group", element).allfield();


    element.keyup(function () {_this.fieldChanged()});
    element.change(
        function(e) {
            //update text inputs with 'all' checkboxes
            _this.fieldChanged();
            $(".input-group", element).allfield("update");
        }
    );

}
