/**
 * shoutit
 *
 * @version      1.1
 * @author       Gabriel Freinbichler
 * @link         http://www.cmods-dev.de
 * @copyright    Copyright (C) 2007 by Gabriel Freinbichler
 * @license      http://www.gnu.org/copyleft/gpl.html GNU General Public License
 */


/*
 * ---------------------------------------------------------------------------------------------------------
 * javascript stuff
 * ---------------------------------------------------------------------------------------------------------
 */

function initShoutItEventHandler()
{
$('shoutitsend').observe('click', saveData, false);
$('shoutitsend').observe('keypress', saveData, false);
}

function initShoutItEventHandlerAdmin()
{
$('shoutitclear').observe('click', clearData, false);
$('shoutitclear').observe('keypress', clearData, false);
}

var loadData = new Ajax.PeriodicalUpdater(
		             'shoutit_content', 
  	                 'index.php?module=shoutit&type=ajax&func=getmessages',
	                 {
	                  method: 'get',
	                  frequency: 5
			 		 }
	                 );
	                 
function saveData()
{
loadData.stop();				  
new Ajax.Request("index.php?module=shoutit&type=ajax&func=reply", {
  parameters: {
    message: $F('shoutitmessage')
  }
}
); 
loadData.start();
 
$('shoutitmessage').value = '';
$('shoutitmessage').focus();
}

function clearData()
{
  loadData.stop();	
 new Ajax.Request("index.php?module=shoutit&type=ajax&func=clear", 
 				  {method:"post"
				  }
				  );
loadData.start();
}
