function bindNotification(){
  $("#notification_button").click(function(e){
    e.preventDefault();
    
    if($('#notification_checkbox:checked').val()){
      var serializedForm = $("#ilmoitus-keskusteluista").serialize();
      var requestURI = eZSitePath + "/ezjscore/call/handlenotification::"+ $('#notification_type').val() +"::?http_accept=json";
      var currentnode = $('#notification_node').val();
      
      $('#ilmoitus-keskusteluista-loader').show();
      $('#ilmoitus-keskusteluista').hide();
      
      $.post( requestURI, serializedForm, function(data) {
        
        var result = data['content'];
        
        if ( result == 'Success' ) {
          
          $.get( eZSitePath + '/ezjscore/call/parts::right_column_forum_notification::' + currentnode + '?http_accept=html', function(data) {
            $('#notification_area').html( data );
            bindNotification();
          });         
        } else {
          // alert(result);
          $('#ilmoitus-keskusteluista-loader').hide();
          $('#ilmoitus-keskusteluista').show();
        }
      }, 'json' );
      
      return false;
    }
  });
}

$(document).ready(function(){
  bindNotification();
});
