                 , 500
         recFunc()
 
-    # Check if enter key is pressed.
-    onKeyUpMails: (event) ->
-        if event.which is 13 or event.keyCode is 13
-            @sendMail()
-
-    # Send mail via server to contacts selected for the sharing.
-    sendMail: (event) ->
-        mails = @$('#mails').val()
-        if mails.length is 0
-            alert "Please enter an email."
-        else
-            @$("a.sendmail").spin 'tiny'
-            @$("a.sendmail").css 'color', 'transparent'
-            @model.sendMail @getPublicUrl(), mails,
-                success: =>
-                    @$("a.sendmail").spin()
-                    @$("a.sendmail").css 'color', 'white'
-                    # TODO: translation
-                    msg = "Mail was successfully sent to: \n"
-                    mails = mails.split(',')
-                    for mail in mails
-                        msg = msg + "\n" + mail
-                    alert msg
-                error: (err) =>
-                    @$("a.sendmail").spin()
-                    @$("a.sendmail").css 'color', 'white'
-                    alert JSON.parse(err.responseText).error
 
     saveModel: (hash) ->
         promise = @model.save(hash)


    events: =>
        'click a.delete': @destroyModel
        'click a.changeclearance': @changeClearance
        'click a.addcontact': @addcontact
        'click a.sendmail': @sendMail
        'click a.add': @prepareContact
        'click a#rebuild-th-btn': @rebuildThumbs
        'keyup #mails': @onKeyUpMails

    getRenderData: ->
        clearance = @model.get 'clearance'
        clearance = 'private' unless clearance?
        clearanceHelpers = @clearanceHelpers clearance
        res = _.extend
            clearanceHelpers: clearanceHelpers
            photosNumber: @model.photos.length
        , @model.attributes
        res

            editable: @options.editable
            collection: @model.photos
            beforeUpload: @beforePhotoUpload

        # Do not run afterRender again when model changed.
        @model.on 'change', =>
            data = _.extend {}, @options, @getRenderData()
            @$el.html @template(data)
            @$el.find("#photos").append @galery.$el

        @galery.album = @model
        @galery.render()
