//////////////////////////////////////////
//           ajaximrpg 5.00             //
//       AJAX Instant Messenger         //
//  Copyright (c) 2006-2008, 2010-2012  //
//      Do not remove this notice       //
//////////////////////////////////////////

/**
 * IM Class
 *
 * @author Joshua Gross
 **/
var IM = {
};
Object.extend(IM, AjaxIM);


/**
 * A class to mantain an IM Window's guts.
 *
 * @author Joshua Gross
 **/
var IMWindow = Class.create(AjaxIMWindow);
IMWindow.addMethods({
   /**
    * Checks to see if there is a message, if there is,
    * send it to the server.
    *
    * @author Joshua Gross
    * @update Benjamin Hitchins
    **/
   send: function($super) {
      $super();
      var winId = this.getId();
      var sendBox = $(winId + '_sendBox');

      if (trim(sendBox.value).length > 0) {
         var message = sendBox.value;
         sendBox.value = '';
         var room = this.room;
         IM.sendMessage(user, room, message.replace(/&/g, "&amp;").replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, "<br/>"));

         Status.lastIM = new Date().getTime();
         if (typeof(Status) != 'undefined' && Status.wasSetAutoAway) {
            Status.set(1, Languages.get('available'));
         }
      }

      scrollToBottom(winId + '_rcvd');
      sendBox.focus();
   }
});

