$(function() {
    $('#{field}_upload').uploadify({
        'formData'    : {'{session_name}': "{session_data}"},
        'buttonText': '{ln_btn_upload}',
        'multi'    : false,
        'fileTypeDesc': '{item_fileTypeDesc}',
        'fileTypeExts': '{item_fileTypeExts}',
        'swf': '/assets/plugins/uploadify3.2/uploadify.swf',
        'uploader': '{actions_link}',
        'onUploadStart': function() {
            $("#{field}_upload").uploadify("settings", 'formData', {upload_action: 'add_image', field: '{field}'});
        },
        'onUploadSuccess': function(file, data) {
            data = jQuery.parseJSON(data);
            if (data['success'] !== undefined && data['success'] === 'true') {
                refresh_image(data['field'], data['img_name'], data['img_block']);
                $('#{field}_upload').uploadify('settings', 'scriptData', {'{session_name}' : '"' + data['session'] + '"'} );
            } else {
                alert(data['msg']);
            }
        },
        'onUploadComplete' : function(file) {
            if ('{auto_open}' === 't') {
                setTimeout(function(){
                    $('.crop[rel="{field}"]').attr('remove_btn', '1').click();
                }, 100);
            }
        }
    });
});