// JavaScript Document

function beforeCommentSave( addId )
{
  try
  {
    alignDivPopup( 'loadingPopup' );
    $( 'loadingPopup' ).show();

    Effect.toggle( 'commentDIV'+addId,'blind' );

  }
  catch ( e ) {}
}

function afterCommentSave( controller, model, id, addId )
{
  try
  {
    new Ajax.Updater( controller + '_comments' + addId,
                      '/' + controller + '_comments/comments_by_ajax/' + id,
                      { asynchronous: true,
                        evalScripts: true,
                        onComplete: function(request, json)
                          {  if ( $( model + 'CommentCount' + addId ) )      $( model + 'CommentCount' + addId ).innerHTML++;
                             if ( $( model + 'CommentCountOpen' + addId ) )  $( model + 'CommentCountOpen' + addId ).innerHTML++;
                             if ( $( controller+'_comments_teaser'+addId ) ) Effect.BlindUp( controller+'_comments_teaser' + addId );
                             Effect.BlindDown( controller + '_comments' + addId );
                             $( controller + '_comments_header' + addId ).hide();
                             $( controller + '_comments_header_open' + addId ).show();
                             $( 'loadingPopup' ).hide(); },
                        requestHeaders: ['X-Update', controller + '_comments' + addId] }
                     );
  }
  catch ( e ) {}
}
