     else
       videoIdx = vidCount + 1
 
-    console.log videoIdx + " video"
     $(e.target).siblings('.progress').find('.video-progress-bar').removeAttr("style")
     $(e.target).siblings('.progress').addClass('hidden')
 

    else
      photoIdx = imgCount + 1

    console.log photoIdx + " photo"

    $(e.target).siblings('.progress').find('.photo-progress-bar').removeAttr("style")
    $(e.target).siblings('.progress').addClass('hidden')

    $photoPreviewContainer = $(e.target).siblings('.photo-preview-container')
    $photoPreviewContainer.append "<div class='photo-preview'>" + $.cloudinary.image(data.result.public_id, format: data.result.format, version: data.result.version, crop: 'fill', width: 350).prop('outerHTML') + "</div>"
    addTexareaForUpload("photo", data, photoIdx, $photoPreviewContainer)


  # handle errors
  $('.cloudinary-fileupload.survey-photo-upload').bind 'fileuploadfail', (e, data) ->

    addTexareaForUpload("document", data, docIdx, $documentPreviewContainer)
    if data.result.format != "pdf" && data.result.format != "png" && data.result.format != "jpg"
      $('.document-preview img:last').attr('src', '/assets/file-icon.png')

  # validating upload format. If fomat to supported then handle error
    if data.result.format != undefined
