function configDropZone() {        
    var $fileInput = $('#file-input');
    var $dropZone = $('#dropZone');
    var $uploadForm = $('#upload-form');
    var taskId = $('#id').val();
    var serviceId = $('#serviceid').val();
    var typeId = $('#typeid').val();
    var statusId = $('#oldstatus').val() > 0 ? $('#oldstatus').val() : $('#currentStatusId').val();
    var taskToken = $('#taskToken').val();

    $('#dropzone').on("click", function () {
        $fileInput.trigger("click");
    });

    $fileInput.on("click", function (e) {
        e.stopImmediatePropagation();
    });

    var $uploadRows = $('ul#files');       
    
    $fileInput.damnUploader({
        url: 'Task/AddFilesOnCreateTask',
        dropBox: $dropZone,
        fieldName: "file",        
        dragEnterHandlerDropBox: dragEnter,
        dragLeaveHandlerDropBox: dragLeave
    });

    $('#dummyButton').on('click', function () {
        $fileInput.duStart();
    });

    // Creates queue table row with file information and upload status
    var createRowFromUploadItem = function (ui) {
        formchanged = true;
        var $newElem = $('<div class="progressHolder" style="width: 240px;"/>').appendTo($uploadRows);

        var $table = $('<table style="width: 100%;">');
        var $row = $('<tr/>');
        
        var $pbCell = $('<td style="border: 0px; width: 90%">');
        var $progressBar = $('<div id="progressbar-' + ui._id + '"/>');

        $progressBar.progressbar({ value: 0 });
        $progressBar.height(10);

        // Defining cancel button & its handler
        var $cancelBtn = $('<td><a id="cancel-' + ui._id + '" class="noul" href="#"><img src="img/trash.gif" title="' + CommonResources.Cancel + '"/></a></td>')
        .on('click', function () {        
            $row.empty().html('<i>' + CommonResources.Cancelled + '</i>');
            ui.cancel();
            return false;
        });        

        $progressBar.appendTo($pbCell);
        $pbCell.appendTo($row); // Status        
        $cancelBtn.appendTo($row); // Cancel button
        $row.appendTo($table);
        $table.appendTo($newElem);
      
        return $progressBar;
    };

    // File adding handler
    var fileAddHandler = function (e) {        
        var ui = e.uploadItem;
        var filename = ui.file.name || ""; // Filename property may be absent when adding custom data

        ui.addPostData('taskId', taskId);
        ui.addPostData('serviceId', serviceId);
        ui.addPostData('typeId', typeId);
        ui.addPostData('statusId', statusId);
        ui.addPostData('taskToken', taskToken);

        // Show info and response when upload completed
        var $progressBar = createRowFromUploadItem(ui);
        ui.completeCallback = function (success, data, errorCode) {        
            if (success) {
                var $data = $(data);
                $("#files > div.progressHolder > table > tbody > tr > td > #progressbar-" + ui._id).parents(".progressHolder").replaceWith($data);
                if (GLOBAL_taskFormHubObserver && GLOBAL_taskFormHubObserver.getBlocks()['mainfilelist'] && $data.is('[id]')) {
                    GLOBAL_taskFormHubObserver.getBlocks()['mainfilelist'].addDroppedFile($(data).attr('id').replace('newfile', ''));
                }
            } else {
                $("#files > div.progressHolder > table > tbody > tr > td > #progressbar-" + ui._id).parents(".progressHolder").replaceWith('<li>' + TaskResources.UploadFailed + '</li>');
            }
            if ($("#inputDropFileAndScreenshot").length > 0) {
                $('#inputDropFileAndScreenshot').valid();
            }
        };

        // Updating progress bar value in progress callback
        ui.progressCallback = function (percent) {            
            $progressBar.progressbar({ value: percent });
            if (percent == 100)
                $('#cancel-'+ui._id).remove();
        };
    };

    $fileInput.on({
        'du.add': fileAddHandler,        
    });

    function dragEnter() {
        $("#dropZone").css('background-color', '#ccc');
        return false;
    }

    function dragLeave() {
        $("#dropZone").css('background-color', '');
    }

    function cancelUpload() {
        $fileInput.duCancelAll();
    }
}