(function ($) {
    $(function () {
        // Perform call-back on click of accordion
        $("#documentation").click(function () {

            gvDocument.PerformCallback();
            var SFM_Ref_No = '';
            if (SFM_Ref_Number.GetValue() != null && SFM_Ref_Number.GetValue() != 'Select') {
                SFM_Ref_No = SFM_Ref_Number.GetValue();
                $('#btnAddDoc').show();
            }
        });
    })
})(jQuery);

function Download(Document_Path, SFM_Ref_No) {
    var url = $('#urlDownloadDoc').val() + "?Document_Path=" + Document_Path + "&SFM_Ref_No=" + SFM_Ref_No;
    $.ajax({
        type: 'POST',
        contentType: 'application.JSON',
        url: url,
        data: '',
        cache: false,
        success: function (data) {
            window.location = url;
        },
        error: function (xhr) {
            $('#PopDiv1').css('color', 'red');
            $("#PopDiv1").fadeIn();
            $("#PopDiv2").html('File not found');
            $("#PopDiv1").fadeOut(8000);
        }
    })
}
function DeleteDocumentIfCancel() {
    urlDeleteDocFile

    var url = $('#urlDeleteDocFile').val();
    $.ajax({
        type: 'POST',
        contentType: 'application.JSON',
        url: url,
        data: '',
        cache: false,
        success: function (data) {
            gvDocument.CancelEdit();
        },
        error: function (xhr) {

        }
    });
    gvDocument.CancelEdit();
}

function OnFileUPloadComplete(s, e) {
    if (e.callbackData != '') {
        alert(e.callbackData);
    }
    else {
        alert('The selected file was not uploaded!');
    }
};

function GetFileName() {
    var docName = Document_Name.GetText();
    $('#hdnDocName').val(docName);
};

/* Validate all field and Save Document */
function ValidateandSave() {
    var docName = Document_Name.GetText();
    var docType = DocumentType_Id.GetValue();
    if (docName == '' || docName == null || docType == '' || docType == null) {
        return false;
    }
    else {
        gvDocument.UpdateEdit();
        gvDocument.CancelEdit();
       // gvDocument.CancelEdit();
    }
}