/*
+--------------------------------------------------------------------------
|   IP.Shoutbox v1.0.2
|   =============================================
|   by the IP.Shoutbox Team of:
|   Dean, Vadim and Terabyte
|   (c) 2008 Invision Power Services, Inc.
|   http://resources.invisionpower.com
|   =============================================
|   Web: http://forums.invisionpower.com
|   Licence Info: http://www.invisionboard.com/?license
+--------------------------------------------------------------------------
|   > $Date: 2008-12-15 23:34:33 +0100(lun, 15 dic 2008) $
|   > $Revision: 126 $
|   > $Author: terabyte $
|   > $Id: shoutbox.js 126 2008-12-15 22:34:33Z terabyte $
+--------------------------------------------------------------------------
|
|   > File: Javascript library
|   > Module continued by the IP.Shoutbox Team
|
+--------------------------------------------------------------------------
*/

// Define paths
var true_base_url = location.protocol+'//'+location.host,
true_base_full_url = location.protocol+'//www.'+location.host+location.pathname+'?',
shoutbox_loaded = false;

function shoutbox()
{
	// Without www
	if(true_base_url.match(/^http:\/\/www/) && !ipb_var_base_url.match(/^http:\/\/www/))
	{
		ipb_var_base_url = ipb_var_base_url.replace(/^http:\/\//, "http://www.");
	}
	
	// With www
	if(ipb_var_base_url.match(/^http:\/\/www/) && !true_base_url.match(/^http:\/\/www/))
	{
		location.href = location.href.replace(/^http:\/\//, "http://www.");
	}
	
	this.base_url = ipb_var_base_url+'autocom=shoutbox&req=ajax&';
	
	this.can_use          = 0;
	this.can_edit         = 0;
	this.members_refresh  = 15;
	this.shouts_refresh   = 30;
	this.hide_refresh     = 1;
	this.editor_height    = '125px';
	this.flood_limit      = 0;
	this.bypass_flood     = 0;
	this.my_last_shout    = 0;
	this.total_shouts     = 0;
	this.last_shout_id    = 0;
	this.inactive_timeout = 5;

	this.ajax_objs     = new Array();
	this.objs          = new Array();
	this.errors        = new Array();
	this.langs         = new Array();
	this.shout_history = new Array();
	
	this.month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	
	this.global_on     = false;
	this.enable_cmds   = true;
	this.skip_fade     = false;
	this.timeout_timer = null;
	this.shout_obj     = null;
	this._scrolled     = false;
	this.loaded        = false;
	this.mod_in_action = false;
	this.moderator     = false;
	this._inactive     = false;
	this.iprompt_lded  = false;
	this.popup_open    = false;
	this.view_archive  = true;
	
	this.mod_command     = '';
	this.mod_shout_id    = 0;
	this.force_update    = 0;
	
	this.time_minute = 60*1000;
	
	this.events_load_max_tries = 10;
	this.events_load_tries     = 0;
	this.events_loaded         = false;
	this.events_rte_loaded     = false;
}

shoutbox.prototype.submit_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	/**
	* Beta 3
	* Can only view shoutbox?
	*/
	if (!shoutbox.can_use)
	{
		return false;
	}
	
	if (this.blur)
	{
		this.blur();
	}
	
	if (!shoutbox.global_on)
	{
		shoutbox.editor_rte = IPS_editor[shoutbox.editor_id].is_rte;
	}
	
	var p = new Array();
	p['autocom']   = 'shoutbox';
	p['req']       = 'ajax';
	p['md5check']  = ipb_md5_check;
	p['shout']     = shoutbox.get_shout();
	p['type']      = 'submit';
	p['lastid']    = shoutbox.last_shout_id;
	p['global']    = (shoutbox.global_on) ? 1 : 0;
	
	if (p['shout'] == '')
	{
		shoutbox.shout_error(shoutbox.errors['blank_shout']);
		return;
	}
	
	if (p['shout'].length * 1024 > shoutbox.max_length)
	{
		shoutbox.shout_error(shoutbox.errors['shout_too_big']);
		return;
	}
	
	/**
	* Beta 3
	* Re-added flood check also JS side
	*/
	if (shoutbox.flood_limit && shoutbox.bypass_flood != 1 && shoutbox.my_last_shout )
	{
		var flood_check = shoutbox.get_timestamp()-shoutbox.my_last_shout;
		
		if (flood_check < shoutbox.flood_limit)
		{
			shoutbox.shout_error(shoutbox.errors['flooding'].replace('{#EXTRA#}', (shoutbox.flood_limit-flood_check)));
			return;
		}
	}
	
	var c = shoutbox.check_for_commands();
	
	if (c != null && c == 'doshout')
	{
		shoutbox.last_shout_id++;
		shoutbox.clear_shout();
		
		shoutbox.last_active = shoutbox.get_timestamp();
		shoutbox.my_last_shout = shoutbox.last_active;
		shoutbox.new_ajax('submit-shout', 'post', shoutbox.base_url, shoutbox.submit_shout_func, p);
	}
}

shoutbox.prototype.shout_obj_display = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		shoutbox.editor_rte = IPS_editor[shoutbox.editor_id].is_rte;
		if (shoutbox.editor_rte)
		{
			if (shoutbox.get_obj(shoutbox.editor_id+'_iframe'))
			{
				shoutbox.get_obj(shoutbox.editor_id+'_iframe').style.display = '';
			}
		}
	}

	catch(x){}
}

shoutbox.prototype.shout_obj_hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		shoutbox.editor_rte = IPS_editor[shoutbox.editor_id].is_rte;
		if (shoutbox.editor_rte)
		{
			if (shoutbox.get_obj(shoutbox.editor_id+'_iframe'))
			{
				shoutbox.get_obj(shoutbox.editor_id+'_iframe').style.display = 'none';
			}
		}
	}

	catch(x){}
}

shoutbox.prototype.check_for_commands = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	var s = shoutbox.get_shout();
	var a = s.split(' ');
	var m = new Array();

	if (!shoutbox.global_on)
	{
		try
		{
			if (shoutbox.editor_rte || IPS_editor[shoutbox.editor_rte].is_rte)
			{
				s = IPS_editor[shoutbox.editor_id].clean_html(s);
			}
		}

		catch(me){}
	}

	if (!shoutbox.valid_command_syntax(a[0], true))
	{
		return 'doshout';
	}

	if (!shoutbox.enable_cmds)
	{
		shoutbox.shout_error(shoutbox.errors['no_cmds_enabled']);
		return null;
	}
	else
	{
		switch (a[0])
		{
			case '/announce':
				if (shoutbox.can_access_acp)
				{
					var p = new Array();
					p['autocom']  = 'shoutbox';
					p['req']      = 'ajax';
					p['type']     = 'announce';
					p['md5check'] = ipb_md5_check;
					p['announce'] = s.substring(9);
					
					shoutbox.clear_shout();
					shoutbox.new_ajax('update-announce', 'post', shoutbox.base_url, shoutbox.update_announce_func, p);
				}
				else
				{
					shoutbox.clear_shout();
					shoutbox.shout_error(shoutbox.errors['no_acp_access']);
				}
				break;
			/**
			* RC1
			* Prune old shouts
			*/
			case '/prune':
				if (shoutbox.can_access_acp)
				{
					var p = new Array();
					p['autocom']  = 'shoutbox';
					p['req']      = 'ajax';
					p['type']     = 'prune';
					p['md5check'] = ipb_md5_check;
					p['days']     = s.substring(6);
					
					if (p['days'] != null && p['days'] != '')
					{
						shoutbox.clear_shout();
						shoutbox.new_ajax('prune-shouts', 'post', shoutbox.base_url, shoutbox.action_taken_func, p);
					}
					else
					{
						shoutbox.shout_error(shoutbox.errors['prune_invalid_number']);
					}
				}
				else
				{
					shoutbox.clear_shout();
					shoutbox.shout_error(shoutbox.errors['no_acp_access']);
				}
				break;
			/**
			* RC1
			* Ban members
			*/
			case '/ban':
				if (shoutbox.mod_perms['m_ban_members'])
				{
					var p = new Array();
					p['autocom']  = 'shoutbox';
					p['req']      = 'ajax';
					p['type']     = 'ban';
					p['md5check'] = ipb_md5_check;
					p['name']     = s.substring(4);
					
					if (p['name'] != null && p['name'] != '')
					{
						shoutbox.clear_shout();
						shoutbox.new_ajax('ban-member', 'post', shoutbox.base_url, shoutbox.action_taken_func, p);
					}
					else
					{
						shoutbox.shout_error(shoutbox.errors['mod_invalid_name']);
					}
				}
				else
				{
					shoutbox.clear_shout();
					shoutbox.shout_error(shoutbox.errors['mod_no_perm']);
				}
				break;
			/**
			* RC1
			* Unban members
			*/
			case '/unban':
				if (shoutbox.mod_perms['m_unban_members'])
				{
					var p = new Array();
					p['autocom']  = 'shoutbox';
					p['req']      = 'ajax';
					p['type']     = 'unban';
					p['md5check'] = ipb_md5_check;
					p['name']     = s.substring(6);
					
					if (p['name'] != null && p['name'] != '')
					{
						shoutbox.clear_shout();
						shoutbox.new_ajax('unban-member', 'post', shoutbox.base_url, shoutbox.action_taken_func, p);
					}
					else
					{
						shoutbox.shout_error(shoutbox.errors['mod_invalid_name']);
					}
				}
				else
				{
					shoutbox.clear_shout();
					shoutbox.shout_error(shoutbox.errors['mod_no_perm']);
				}
				break;
			case '/refresh':
				shoutbox.force_update = true;
				shoutbox.reload_shouts(true);
				shoutbox.clear_shout();
				break;
			case '/prefs':
				shoutbox.clear_shout();
				if (shoutbox.my_id > 0)
				{
					if (shoutbox.global_on)
					{
						shoutbox.set_action_and_reload('myprefs');
					}
					else
					{
						shoutbox.load_my_prefs();
					}
				}
				else
				{
					shoutbox.shout_error(shoutbox.errors['prefs_login']);
				}
				break;
			case '/archive':
				shoutbox.clear_shout();
				if (shoutbox.view_archive)
				{
					if (shoutbox.global_on)
					{
						shoutbox.set_action_and_reload('archive');
					}
					else
					{
						shoutbox.load_archive();
					}
				}
				else
				{
					shoutbox.shout_error(shoutbox.errors['no_archive_perm']);
				}

				break;
			case '/moderator':
				if (shoutbox.moderator)
				{
					if (shoutbox.valid_command_syntax(a[1]) && shoutbox.valid_command_syntax(a[2]))
					{
						t = a[1];
						d = a[2];

						var p = new Array();
						p['autocom']  = 'shoutbox';
						p['req']      = 'ajax';
						p['type']     = 'mod';
						p['do']       = 'load-cmd';
						p['md5check'] = ipb_md5_check;
						p['modtype']  = null;

						switch (t)
						{
							case 'shout':
								if (parseInt(d) > 0)
								{
									p['modtype'] = 'shout';
									p['shout']   = parseInt(d);
								}
								break;
							case 'member':
								p['modtype'] = 'member';
								
								if (parseInt(d) > 0)
								{
									p['memtype'] = 'number';
									p['member']  = parseInt(d);
								}
								else
								{
									p['memtype'] = 'string';
									p['member']  = d.toString();
								}
								break;
							default:
								break;
						}

						if (p['modtype'] != null && p['modtype'] != '')
						{
							shoutbox.clear_shout();
							if (shoutbox.global_on)
							{
								shoutbox.set_action_and_reload('mod|'+p['modtype']+'|'+((p['modtype'] == 'member') ? p['memtype']+'|'+p['member'] : p['shout']));
							}
							else
							{
								shoutbox.new_ajax('load-mod-opts', 'post', shoutbox.base_url, shoutbox.popup_dialog_process, p);
							}
						}
						else
						{
							shoutbox.shout_error(shoutbox.errors['invalid_command']);
						}
					}
					else
					{
						shoutbox.shout_error(shoutbox.errors['invalid_command']);
					}
				}
				else
				{
					shoutbox.clear_shout();
					shoutbox.shout_error(shoutbox.errors['mod_no_perms']);
				}
				
				break;
			default:
				return 'doshout';
		}
	}
}

shoutbox.prototype.update_announce_func = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		return;
	}
	
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	var a = shoutbox.get_obj('shoutbox-announcement');
	
	if (d=='<!--nothing-->' || d=='')
	{
		a.style.display = 'none';
		return;
	}
	else if (d.substring(0, 6) == "error-")
	{
		shoutbox.shout_error(d.substring(6));
		return;
	}
	else
	{
		a.style.display = 'block';
		
		a.innerHTML = d;
	}
}

/**
* RC1
* Used in:
* 	Prune old shouts
* 	Ban Members
* 	Unban Members
*/
shoutbox.prototype.action_taken_func = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		return;
	}
	
	alert (shoutbox.ajax_objs[x].xmlhandler.responseText);
	
	// 1.0.0 Final
	// Reload page if shouts are pruned
	if ( x == 'prune-shouts' )
	{
		window.location=window.location;
	}
}

shoutbox.prototype.submit_shout_func = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		/**
		* Beta 2
		* Show reloading and hide refresh button
		*/
		shoutbox.shouts_reloading_display();
		
		if (shoutbox.hide_refresh)
		{
			my_getbyid('shoutbox-refresh-button').style.display = 'none';
		}
		
		return;
	}
	
	shoutbox.shouts_reloading_hide();
	
	// Beta 3: hide inactive prompt if we are submitting a new shout
	if (shoutbox._inactive)
	{
		shoutbox.process_inactive_prompt(true);
	}
	
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.last_shout_id--;
		shoutbox.shout_error(d.substring(6));
		return;
	}
	else if (d.substring(0, 10) == "errorfull-")
	{
		shoutbox.last_shout_id--;
		shoutbox.shout_error(d.substring(10));
		return;
	}
	else
	{
		/**
		* 1.0.0 Final
		* Fix no shouts message
		*/
		if (shoutbox.total_shouts <= 0)
		{
			shoutbox.total_shouts = 1;
			
			var ns = shoutbox.get_obj('shoutbox-no-shouts-message');
			ns.style.display = 'none';
		}
		
		var o = shoutbox.get_obj('shoutbox-shouts');
		
		if (shoutbox.shout_order == 'asc')
		{
			o.innerHTML += d;
		}
		else
		{
			o.innerHTML = d+o.innerHTML;
		}
		
		shoutbox.skip_js = false;
		shoutbox.ajax_objs[x].execute_javascript(d);
		
		// Fix shout classes
		shoutbox.rewrite_shout_classes();
		
		// Setup latest ID/Class
		shoutbox.get_last_data();
	}
	
	if (shoutbox.can_use && shoutbox.my_prefs['display_refresh_button'] == 1)
	{
		my_getbyid('shoutbox-refresh-button').style.display = '';
	}
	
	try
	{
		/**
		* Beta 2
		* Restart timer
		*/
		clearTimeout(shoutbox.timeout_timer);
		shoutbox.timeout_timer = setTimeout("try{shoutbox.reload_shouts(true);}catch(e){}", shoutbox.timeout_convert(shoutbox.shouts_refresh));
		
		shoutbox.shouts_scroll_bottom();
	}
	
	catch(e) {}
}

shoutbox.prototype.valid_command_syntax = function(c, m)
{
	if (c != '' && typeof(c) != 'undefined' && c != null && c)
	{
		if (m == true)
		{
			c = c.toString();
			if (c.match(new RegExp("^/([a-zA-Z]+?)$", 'i')))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return true;
		}
	}

	return false;
}

shoutbox.prototype.set_action_and_reload = function(d)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (d != '' && typeof(d) != 'undefined' && d != null)
	{
		var url = shoutbox.base_url.replace('&req=ajax', '');
		
		ipsclass.my_setcookie('_shoutbox_jscmd', d);
		try
		{
			window.location = url.replace(/&$/ig, '');
		}

		catch(me)
		{
			window.location.href = url.replace(/&$/ig, '');
		}

		try
		{
			ipsclass.cancel_bubble_all(event || window.event);
		}

		catch(me){}
		return false;
	}

	return false;
}

shoutbox.prototype.popup_smilies = function()
{
	window.emoticon = shoutbox.emoticon;
	window.open(ipb_var_base_url+'act=legends&CODE=emoticons', 'Legends', 'width=250,height=500,resizable=yes,scrollbars=yes');

	return false;
}

shoutbox.prototype.popup_bbcode = function()
{
	window.open(ipb_var_base_url+'act=legends&CODE=bbcode', 'Legends', 'width=700,height=500,resizable=yes,scrollbars=yes');
	return false;
}

/**
* Add emoticons inside
* global shoutbox
*/
shoutbox.prototype.emoticon = function(c, id, u)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		shoutbox.update_shout_obj();
		shoutbox.shout_obj.value += ' '+c+' ';
	}
	
	return false;
}

/**
* Rewrite shouts class 
* (darkrow1 + row2)
*/
shoutbox.prototype.rewrite_shout_classes = function()
{
	var c      = 'row2';
	var shouts = my_getbyid('shoutbox-shouts');
	var rows   = shouts.getElementsByTagName('div');
	
	for (var i=0; i<rows.length; i++)
	{
		if (rows[i].style.display != 'none' && rows[i].id.substring(0,10) == 'shout-row-' && rows[i].id.substring(0,11) != 'shout-row-m')
		{
			c = (c == 'row2') ? 'row1' : 'row2';
			
			rows[i].className = c+' divpad';
		}
	}
}

shoutbox.prototype.trim = function(s)
{
	var c = new Array(' ', "\n", "\t", "\r");
	for (var i=0; i<c.length; i++)
	{
		while (s.substring(0, c[i].length) == c[i])
		{
			s = s.substring(c[i].length, s.length);
		}

		while (s.substring(s.length-c[i].length, s.length) == c[i])
		{
			s = s.substring(0, s.length-c[i].length);
		}
	}

	return s;

	s = s.replace(new RegExp("^\n{1,}", 'i'), '');
	s = s.replace(new RegExp("\n{1,}$", 'i'), '');
	s = s.replace(new RegExp("^\t{1,}", 'i'), '');
	s = s.replace(new RegExp("\t{1,}$", 'i'), '');
	s = s.replace(new RegExp("^\r{1,}", 'i'), '');
	s = s.replace(new RegExp("\r{1,}$", 'i'), '');

	return s;
}

shoutbox.prototype.shout_error = function(error)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	/**
	* Beta 3
	* Display an alert
	*/
	alert(error);
}

shoutbox.prototype.update_shout_obj = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox.global_on)
	{
		try
		{
			shoutbox.shout_obj = shoutbox.get_obj('shoutbox-global-shout');
		}

		catch(me){}
	}
	else
	{
		try
		{
			shoutbox.shout_obj = shoutbox.get_obj(shoutbox.editor_id+'_textarea');
		}

		catch(me){}
	}
}

shoutbox.prototype.clear_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.update_shout_obj();

	if (shoutbox.global_on)
	{
		if (shoutbox.shout_obj)
		{
			shoutbox.shout_obj.value = '';
			shoutbox.shout_obj.focus();
		}
	}
	else
	{
		try
		{
			shoutbox.editor_rte = IPS_editor[shoutbox.editor_id].is_rte;
			if (shoutbox.editor_rte)
			{
				IPS_editor[shoutbox.editor_id].editor_document.body.innerHTML = '';
				IPS_editor[shoutbox.editor_id].togglesource_post_show_html();
				IPS_editor[shoutbox.editor_id].editor_check_focus();
				IPS_editor[shoutbox.editor_id].set_context();
			}
			else
			{
				if (shoutbox.shout_obj)
				{
					shoutbox.shout_obj.value = '';
					shoutbox.shout_obj.focus();
				}
			}
		}

		catch(x)
		{
			try
			{
				if (!shouutbox.shout_obj && shoutbox.get_obj(shoutbox.editor_id+'_textarea'))
				{
					shoutbox.shout_obj       = shoutbox.get_obj(shoutbox.editor_id+'_textarea');
					shoutbox.shout_obj.value = '';
					shoutbox.shout_obj.focus();
				}
			}

			catch(y){}
		}
	}
}

shoutbox.prototype.get_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	shoutbox.update_shout_obj();

	var d = '';
	if (shoutbox.editor_rte && IPS_editor[shoutbox.editor_id])
	{
		d = IPS_editor[shoutbox.editor_id].editor_get_contents();
	}
	else
	{
		d = shoutbox.shout_obj.value;
	}

	d = shoutbox.trim(d);
	while (d.match(new RegExp("^(.+?)<br>$", 'i')))
	{
		d = d.replace(new RegExp("^(.+?)<br>$", 'i'), '$1');
	}

	d = shoutbox.trim(d);
	if (d.toLowerCase().substring(d.length-4, d.length) == '<br>')
	{
		d = d.substring(0, d.length-4);
	}

	d = shoutbox.trim(d);
	return d;
}

shoutbox.prototype.add_lang_string = function(k, v)
{
	shoutbox.langs[k] = v;
}

shoutbox.prototype.shouts_scroll_bottom = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	var o = shoutbox.get_obj('shoutbox-shouts', true);
	if (shoutbox.shout_order == 'asc')
	{
		o.scrollTop = o.scrollHeight-parseInt(shoutbox.read_style(o, 'height'))+500;
	}
	else
	{
		o.scrollTop = 0;
	}
}

/**
* Fixed in Beta 2
* Add fade effect to a div layer
*/
shoutbox.prototype.fade_object = function( div )
{
	//-----------------------------------------
	// Init vars
	//-----------------------------------------
	var color_items = "0123456789abcdef";
	var start_color = '#ffff66';
	var orig_color  = my_getbyid( div ).style.backgroundColor;
	var temp_end    = '#ffffff';
	var iter        = 20;
	var time        = 70;
	
	var rbeg = color_items.indexOf(start_color.substr(1,1))*16 + color_items.indexOf(start_color.substr(2,1));
	var gbeg = color_items.indexOf(start_color.substr(3,1))*16 + color_items.indexOf(start_color.substr(4,1));
	var bbeg = color_items.indexOf(start_color.substr(5,1))*16 + color_items.indexOf(start_color.substr(6,1));
	var rend = color_items.indexOf(temp_end.substr(1,1))*16    + color_items.indexOf(temp_end.substr(2,1));
	var gend = color_items.indexOf(temp_end.substr(3,1))*16    + color_items.indexOf(temp_end.substr(4,1));
	var bend = color_items.indexOf(temp_end.substr(5,1))*16    + color_items.indexOf(temp_end.substr(6,1));
	
	for ( i = 1, r = rbeg, g = gbeg, b = bbeg;
			i <= iter;
			r = Math.round(rbeg + i * ((rend - rbeg) / (iter-1))),
			g = Math.round(gbeg + i * ((gend - gbeg) / (iter-1))),
			b = Math.round(bbeg + i * ((bend - bbeg) / (iter-1))), i++
		)
	{
		hstr = '#' + color_items.charAt(Math.floor(r/16)) + color_items.charAt(r%16) + color_items.charAt(Math.floor(g/16)) + color_items.charAt(g%16) + color_items.charAt(Math.floor(b/16)) + color_items.charAt(b%16);
		
		setTimeout('var div = document.getElementById("'+div+'"); div.style.backgroundColor="'+hstr+'";', i*time);
	}
	
	setTimeout('var div = document.getElementById("'+div+'"); div.style.backgroundColor="'+orig_color+'";', (i+1)*time);
}

/**
* Beta 3
* Load moderator options
*/
shoutbox.prototype.mod_opts_load = function(id, a)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if ((!shoutbox.moderator && !shoutbox.can_edit) || shoutbox.mod_in_action)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		shoutbox.set_action_and_reload('mod|shout|'+id);
		return false;
	}
	
	if (a && shoutbox.in_archive)
	{
		shoutbox.popup_dialog_hide();
	}
	
	shoutbox.last_active = shoutbox.get_timestamp();
	
	shoutbox.in_mod = 1;
	shoutbox.popup_dialog_set_title('mod_opts');
	
	shoutbox.langs['popup_pre_status']  = shoutbox.langs['mod_opts_pre_status'];
	shoutbox.langs['popup_pre_content'] = shoutbox.langs['mod_opts_pre_content'];
	
	shoutbox.new_ajax('load-mod-opts', 'get', shoutbox.base_url+'type=mod&do=load&id='+id, shoutbox.popup_dialog_process);
	return false;
}

shoutbox.prototype.load_member_mod_opts = function(id)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.moderator || shoutbox.mod_in_action)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		shoutbox.set_action_and_reload('mod|member|number|'+id);
		return false;
	}
	
	shoutbox.in_mod = 1;
	shoutbox.popup_dialog_set_title('mod_opts');
	
	shoutbox.langs['popup_pre_status']  = shoutbox.langs['mod_opts_pre_status'];
	shoutbox.langs['popup_pre_content'] = shoutbox.langs['mod_opts_pre_content'];
	
	shoutbox.new_ajax('load-mod-opts', 'get', shoutbox.base_url+'type=mod&do=load-member&mid='+id, shoutbox.popup_dialog_process);
	menu_action_close();
	
	return false;
}

shoutbox.prototype.popup_show_loading = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		var l = shoutbox.get_obj('shoutbox-popup-loading');
		l.style.display = '';
		
		shoutbox.popup_show_loading_text();
		shoutbox.center_obj(l);
	}
	
	catch(me){}
}

shoutbox.prototype.popup_hide_loading = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		var l = shoutbox.get_obj('shoutbox-popup-loading');
		l.style.display = 'none';
		
		shoutbox.popup_loading_error_hide(true);
	}
	
	catch(me){}
}

shoutbox.prototype.popup_show_loading_text = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		var l = shoutbox.get_obj('shoutbox-popup-loading-text');
		l.style.display = '';
	}
	
	catch(me){}
}

shoutbox.prototype.popup_hide_loading_text = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		
		var l = shoutbox.get_obj('shoutbox-popup-loading-text');
		l.style.display = 'none';
	}
	
	catch(me){}
}

shoutbox.prototype.popup_loading_error_display = function(m)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		shoutbox.popup_show_loading();
		shoutbox.popup_hide_loading_text();
		
		var l = shoutbox.get_obj('shoutbox-popup-loading');
		var o = shoutbox.get_obj('shoutbox-popup-loading-error-div');
		var c = shoutbox.get_obj('shoutbox-popup-loading-error-close');
		var t = shoutbox.get_obj('shoutbox-popup-loading-error-text');
		
		if (m.substring(0, 6) == "error-")
		{
			m = m.substring(6);
		}
		else if (m.substring(0, 10) == "errorfull-")
		{
			m = m.substring(10);
		}
		
		o.style.display = '';
		t.innerHTML     = m;
		c.onclick       = shoutbox.popup_loading_error_hide;
		
		shoutbox.center_obj(l);
		try{shoutbox.popup_loading_error_hide();}catch(e){}
	}
	
	catch(me){}
}

shoutbox.prototype.popup_loading_error_hide = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-loading-error-div');
		var t = shoutbox.get_obj('shoutbox-popup-loading-error-text');
		
		o.style.display = 'none';
		t.innerHTML     = '';
		
		if (x != true)
		{
			shoutbox.popup_hide_loading();
		}
	}
	
	catch(me){}
}

shoutbox.prototype.popup_dialog_display = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		shoutbox.display_shadow_bg(4);
		
		var o = shoutbox.get_obj('shoutbox-popup-div');
		var c = shoutbox.get_obj('shoutbox-popup-close');
		
		c.onclick       = shoutbox.popup_dialog_close;
		o.style.display = '';
		o.style.zIndex  = parseInt(shoutbox.read_style(shoutbox.get_obj('shoutbox-shadow-bg'), 'zIndex'))+1;
		
		shoutbox.center_obj(o);
		
		Drag.init(shoutbox.get_obj('shoutbox-popup-title'), o);
		o.onDrag = function()
		{
			shoutbox.resize_shadow_bg();
		}
		
		shoutbox.popup_open = true;
	}
	
	catch(me){}
}

shoutbox.prototype.popup_dialog_hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}
	
	try
	{
		shoutbox.hide_shadow_bg();
		
		var o = shoutbox.get_obj('shoutbox-popup-div');
		o.style.display = 'none';
		
		shoutbox.get_obj('shoutbox-popup-data').innerHTML = '';
		if (shoutbox.in_prefs || shoutbox.in_archive)
		{
			shoutbox._inactive = false;
			if (!shoutbox.is_inactive())
			{
				shoutbox.last_active = shoutbox.get_timestamp();
			}
		}
		
		shoutbox.popup_dialog_reset_width();
		shoutbox.popup_dialog_resize();
		shoutbox.popup_open = false;
	}
	
	catch(me){}
}

shoutbox.prototype.popup_dialog_message_display = function(m, s, x)
{
	if (!shoutbox_loaded || !shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}
	
	s = (s == true) ? true : false;
	x = (x == true) ? true : false;
	
	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-message-div');
		var c = shoutbox.get_obj('shoutbox-popup-message-close');
		var t = shoutbox.get_obj('shoutbox-popup-message-text');

		o.style.display = '';
		t.innerHTML     = m;

		if (s)
		{
			shoutbox.get_obj('shoutbox-popup-data-content').innerHTML = '';
			if (x)
			{
				c.onclick = function()
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_center();
				}

				try
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_center();
				}
				catch(e){}
			}
			else
			{
				c.onclick = function()
				{
					shoutbox.popup_dialog_message_hide();
				}

				try
				{
					shoutbox.popup_dialog_message_hide();
				}
				catch(e){}
			}
		}
		else
		{
			if (x)
			{
				c.onclick = function()
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_center();
					shoutbox.popup_dialog_reset();
				}

				try
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_reset();
					shoutbox.popup_dialog_center();
				}
				
				catch(e){}
			}
			else
			{
				c.onclick = function()
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_reset();
				}

				try
				{
					shoutbox.popup_dialog_message_hide();
					shoutbox.popup_dialog_reset();
				}
				
				catch(e){}
			}
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_message_hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-message-div');
		var t = shoutbox.get_obj('shoutbox-popup-message-text');

		o.style.display = 'none';
		t.innerHTML     = '';
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_error_display = function(m, s)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	s = (s == true) ? true : false;
	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-error-div');
		var c = shoutbox.get_obj('shoutbox-popup-error-close');
		var t = shoutbox.get_obj('shoutbox-popup-error-text');

		o.style.display = '';
		t.innerHTML     = m;

		if (s)
		{
			c.onclick = function()
			{
				shoutbox.popup_dialog_error_hide();
				shoutbox.popup_dialog_reset();
			}

			shoutbox.get_obj('shoutbox-popup-data-content').innerHTML = '';
			try
			{
				shoutbox.popup_dialog_error_hide();
				shoutbox.popup_dialog_reset();
			}
			
			catch(e){}
		}
		else
		{
			c.onclick = function()
			{
				shoutbox.popup_dialog_error_hide();
				shoutbox.popup_dialog_doset_status('_popup_cur_status');
			}

			shoutbox.add_lang_string('_popup_cur_status', shoutbox.popup_dialog_get_status());
			shoutbox.popup_dialog_doset_status('error');

			try
			{
				shoutbox.popup_dialog_error_hide();
				shoutbox.popup_dialog_doset_status('_popup_cur_status');
			}
			
			catch(e){}
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_error_hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-error-div');
		var t = shoutbox.get_obj('shoutbox-popup-error-text');

		o.style.display = 'none';
		t.innerHTML     = '';
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_close = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	if (shoutbox.in_mod)
	{
		shoutbox.in_mod        = 0;
		shoutbox.mod_shout_id  = 0;
		shoutbox.mod_member_id = 0;
		shoutbox.mod_command   = '';
		shoutbox.mod_in_action = false;
	}

	shoutbox.in_prefs    = false;
	shoutbox.in_archive  = false;
	shoutbox._inactive   = false;
	shoutbox.last_active = shoutbox.get_timestamp();

	shoutbox.popup_dialog_hide();
}

shoutbox.prototype.popup_dialog_center = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	shoutbox.center_obj(shoutbox.get_obj('shoutbox-popup-div'));
}

shoutbox.prototype.popup_dialog_get_status = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-status');
		return o.innerHTML;
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_set_status = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on || !this.id)
	{
		return false;
	}

	try
	{
		var t = shoutbox.langs[this.id+'-desc'];
		var o = shoutbox.get_obj('shoutbox-popup-status');

		if (shoutbox.mod_in_action)
		{
			o.innerHTML = shoutbox.langs['mod_loaded_confirm'];
		}
		else
		{
			o.innerHTML = t;
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_doset_status = function(id)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on || !id)
	{
		return false;
	}

	try
	{
		var t = shoutbox.langs[id];
		var o = shoutbox.get_obj('shoutbox-popup-status');

		o.innerHTML = t;
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_reset_status = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var t = shoutbox.langs['popup_pre_status'];
		var o = shoutbox.get_obj('shoutbox-popup-status');
	
		if (shoutbox.mod_in_action)
		{
			o.innerHTML = shoutbox.langs['mod_loaded_confirm'];
		}
		else
		{
			o.innerHTML = t;
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_set_title = function(id)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-title-text');
		o.innerHTML = shoutbox.langs[id];
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_set_width = function(w)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on || isNaN(w))
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-div');
		if (typeof(o.style.owidth) == 'undefined')
		{
			o.style.owidth = shoutbox.read_style(o, 'width');
		}

		o.style['width'] = w;
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_reset_width = function(w)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on || isNaN(w))
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-div');
		if (typeof(o.style.owidth) != 'undefined')
		{
			o.style.width = o.style.owidth;
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_resize = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		var p = shoutbox.get_page_size();
		var o = shoutbox.get_obj('shoutbox-popup-data');
		var x = Math.floor(p[3]*.8);

		o.style.height = '';
		if (o.offsetHeight > x)
		{
			o.style.height   = x+'px';
			o.style.overflow = 'auto';
		}
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_reset = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	if (shoutbox.in_mod)
	{
		shoutbox.mod_command   = '';
		shoutbox.mod_in_action = false;
	}

	if (!shoutbox.in_prefs)
	{
		shoutbox.popup_dialog_reset_content();
	}

	shoutbox.popup_dialog_reset_status();
}

shoutbox.prototype.popup_dialog_reset_content = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-popup-data-content');
		o.innerHTML = shoutbox.langs['popup_pre_content'];
	}

	catch(me){}
}

shoutbox.prototype.popup_dialog_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_show_loading();
		return;
	}

	shoutbox.popup_hide_loading();
	shoutbox.popup_dialog_display();

	var o = shoutbox.get_obj('shoutbox-popup-data');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	o.style.display = '';
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.popup_dialog_hide();
		shoutbox.popup_loading_error_display(d);
		return;
	}
	else
	{
		if (shoutbox.in_mod)
		{
			shoutbox.mod_shout_id  = 0;
			shoutbox.mod_member_id = 0;
			shoutbox.mod_command   = '';
			shoutbox.mod_in_action = false;
		}

		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);

		shoutbox.popup_dialog_reset();
		shoutbox.popup_dialog_resize();
		shoutbox.popup_dialog_center();
	}
}

shoutbox.prototype.mod_opts_get_edit_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.moderator && !shoutbox.can_edit)
	{
		return false;
	}

	var d = '';
	if (shoutbox.mod_editor_rte && IPS_editor[shoutbox.mod_editor_id])
	{
		d = IPS_editor[shoutbox.mod_editor_id].editor_get_contents();
	}
	else
	{
		d = shoutbox.mod_shout_obj.value;
	}

	return shoutbox.trim(d);
}

shoutbox.prototype.mod_opts_clear_edit_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.moderator && !shoutbox.can_edit)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	try
	{
		shoutbox.mod_editor_rte = IPS_editor[shoutbox.mod_editor_id].is_rte;
		if (shoutbox.mod_editor_rte)
		{
			IPS_editor[shoutbox.mod_editor_id].editor_document.body.innerHTML = '';
			IPS_editor[shoutbox.mod_editor_id].togglesource_post_show_html();
			IPS_editor[shoutbox.mod_editor_id].editor_check_focus();
			IPS_editor[shoutbox.mod_editor_id].set_context();
		}
		else
		{
			if (shoutbox.get_obj(shoutbox.mod_editor_id+'_textarea'))
			{
				shoutbox.mod_shout_obj       = shoutbox.get_obj(shoutbox.mod_editor_id+'_textarea');
				shoutbox.mod_shout_obj.value = '';
				shoutbox.mod_shout_obj.focus();
			}
		}
	}

	catch(x)
	{
		try
		{
			if (shoutbox.get_obj(shoutbox.mod_editor_id+'_textarea'))
			{
				shoutbox.mod_shout_obj       = shoutbox.get_obj(shoutbox.mod_editor_id+'_textarea');
				shoutbox.mod_shout_obj.value = '';
				shoutbox.mod_shout_obj.focus();
			}
		}

		catch(y){}
	}
}

shoutbox.prototype.mod_opt_do = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if ((!shoutbox.moderator && !shoutbox.can_edit ) || shoutbox.mod_in_action)
	{
		return false;
	}

	if (this.blur)
	{
		this.blur();
	}

	var c  = this.id.replace(/^mod-opt-(.+?)$/ig, '$1');
	var id = (shoutbox.mod_shout_id) ? shoutbox.mod_shout_id : shoutbox.mod_member_id;
	var tp = (shoutbox.mod_shout_id) ? 'shout' : 'member';
	
	// Se to true by default and set false if needed
	shoutbox.mod_in_action = true;
	
	switch (c)
	{
		case 'edit':
			shoutbox.mod_command   = 'edit';
			break;
		case 'delete':
			shoutbox.mod_command   = 'delete';
			break;
		case 'delete-all':
			shoutbox.mod_command   = 'delete-all';
			break;
		case 'ban':
			shoutbox.mod_command   = 'ban';
			break;
		case 'unban':
			shoutbox.mod_command   = 'unban';
			break;
		case 'delmod':
			shoutbox.mod_command   = 'remove-mod';
			break;
		case 'edit-history':
			shoutbox.mod_command   = 'edit-history';
			shoutbox.mod_in_action = false;
			break;
		default:
			shoutbox.mod_command   = '';
			shoutbox.mod_in_action = false;
			break;
	}

	shoutbox.last_active = shoutbox.get_timestamp();
	
	if (shoutbox.mod_command != '')
	{
		shoutbox.popup_dialog_doset_status('loading');
		shoutbox.new_ajax('load-mod-opt-act', 'get', shoutbox.base_url+'type=mod&do=mod-load&command='+shoutbox.mod_command+'&modtype='+tp+'&id='+id, shoutbox.mod_opt_do_process);
	}
}

shoutbox.prototype.mod_opt_load_edit_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if ((!shoutbox.moderator && !shoutbox.can_edit) || shoutbox.mod_command != 'edit')
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('rte-toggle-side-panel-button-edit');
		var b = shoutbox.get_obj('shoutbox-moderator-edit-shout-data');
		var p = o.parentNode;

		p.innerHTML = b.innerHTML;
		b.innerHTML = '';
	}

	catch(me){}

	try
	{
		var o = shoutbox.get_obj('shoutbox-moderator-edit-shout-button');
		o.onclick = shoutbox.mod_opts_do_edit_shout;
	}

	catch(me){}

	try
	{
		var o = shoutbox.get_obj('shoutbox-moderator-edit-clear-button');
		o.onclick = shoutbox.mod_opts_clear_edit_shout;
	}

	catch(me){}

	try
	{
		var o = shoutbox.get_obj('shoutbox-moderator-edit-cancel-button');
		o.onclick = function()
		{
			shoutbox.popup_dialog_reset();
			shoutbox.popup_dialog_resize();
			shoutbox.popup_dialog_center();
		}
	}

	catch(me){}

	if (!IPS_editor[shoutbox.mod_editor_id].is_rte)
	{
		shoutbox.mod_shout_obj = shoutbox.get_obj(shoutbox.mod_editor_id+'_textarea');
	}

	var o = getElementsByClassName('rte-menu-button', '*', shoutbox.get_obj('shoutbox-moderator-edit-shout-editor'));
	if (o.length)
	{
		for (var i=0; i<o.length; i++)
		{
			if (o[i].id)
			{
				ipsmenu.menu_openfuncs[o[i].id] = "shoutbox.mod_opt_reposition_editor_menu('"+o[i].id+"')";
			}
		}
	}

	shoutbox.popup_dialog_center();
}

shoutbox.prototype.mod_opt_reposition_editor_menu = function(id)
{
	try
	{
		var t = shoutbox.get_offset_top(shoutbox.get_obj(id), shoutbox.get_obj('shoutbox-moderator-edit-shout-editor'))+shoutbox.get_obj(id).offsetHeight;
		var l = shoutbox.get_offset_left(shoutbox.get_obj(id), shoutbox.get_obj('shoutbox-moderator-edit-shout-editor'));

		try
		{
			if (is_safari)
			{
				t += 20;
			}
		}

		catch(ee)
		{
			if (is_safari)
			{
				t += 20;
			}
		}

		if (is_moz)
		{
			t -= 1;
		}

		ipsmenu.menu_registered[id].cid_menu_obj.style.left = l+'px';
		ipsmenu.menu_registered[id].cid_menu_obj.style.top  = t+'px';
	}

	catch(me){}
}

shoutbox.prototype.mod_opt_do_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_dialog_doset_status('loading');
		return;
	}

	shoutbox.popup_dialog_doset_status('mod_loaded_confirm');
	var o = shoutbox.get_obj('shoutbox-popup-data-content');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	if (m = d.match(new RegExp("^error-(.*)", 'i')))
	{
		shoutbox.mod_in_action = false;
		alert(m[1]);
		return false;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
}

shoutbox.prototype.mod_opts_do_confirm = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.moderator || !shoutbox.mod_in_action)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	var c = (this.id.match(/yes/ig)) ? true : false;
	if (c)
	{
		id = (shoutbox.mod_shout_id) ? shoutbox.mod_shout_id : shoutbox.mod_member_id;
		tp = (shoutbox.mod_shout_id) ? 'shout' : 'member';

		var p = new Array();
		p['autocom']  = 'shoutbox';
		p['req']      = 'ajax';
		p['type']     = 'mod';
		p['do']       = 'mod-perform';
		p['command']  = shoutbox.mod_command;
		p['modtype']  = tp;
		p['id']       = id;
		p['md5check'] = ipb_md5_check;

		shoutbox.popup_dialog_doset_status('processing');
		shoutbox.new_ajax('process-mod-opts', 'post', shoutbox.base_url, shoutbox.mod_opts_do_confirm_process, p);
	}
	else
	{
		shoutbox.popup_dialog_reset();
	}
}

shoutbox.prototype.mod_opts_do_edit_shout = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if ((!shoutbox.moderator && !shoutbox.can_edit) || !shoutbox.mod_in_action)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	var p = new Array();
	p['autocom']  = 'shoutbox';
	p['req']      = 'ajax';
	p['type']     = 'mod';
	p['do']       = 'mod-perform';
	p['command']  = shoutbox.mod_command;
	p['modtype']  = 'shout';
	p['id']       = shoutbox.mod_shout_id;
	p['shout']    = shoutbox.mod_opts_get_edit_shout();
	p['md5check'] = ipb_md5_check;

	if (p['shout'] == '')
	{
		alert(shoutbox.errors['blank_shout']);
		return;
	}

	if (p['shout'].length * 1024 > shoutbox.max_length)
	{
		shoutbox.popup_dialog_error_display(shoutbox.errors['shout_too_big']);
		return;
	}

	shoutbox.popup_dialog_doset_status('processing');
	shoutbox.new_ajax('process-mod-opts', 'post', shoutbox.base_url, shoutbox.mod_opts_do_confirm_process, p);
}

shoutbox.prototype.mod_opts_do_confirm_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_dialog_doset_status('processing');
		return;
	}
	
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (m = d.match(new RegExp("^error-(.*)", 'i')))
	{
		shoutbox.mod_in_action = false;
		shoutbox.popup_dialog_error_display(m[1]);
		
		return;
	}
	else
	{
		// We have any action to perform?
		if (shoutbox.mod_shout_id)
		{
			switch (shoutbox.mod_command)
			{
				case 'edit':
					my_getbyid('shout-row-'+shoutbox.mod_shout_id).innerHTML = d;
					d = shoutbox.langs['mod_shout_edited'];
					break;
				case 'delete':
					my_getbyid('shout-row-'+shoutbox.mod_shout_id).style.display = 'none';
					
					// Rewrite classes & Hide popup
					shoutbox.rewrite_shout_classes();
					shoutbox.popup_dialog_close();
					break;
				case 'delete-all':
					if (d != null && d.length > 0)
					{
						var temp_array = d.split(",");
						
						for (var i=0; i<temp_array.length; i++)
						{
							if ( my_getbyid('shout-row-'+temp_array[i]) )
							{
								my_getbyid('shout-row-'+temp_array[i]).style.display = 'none';
							}
						}
					}
					shoutbox.popup_dialog_close();
					break;
				default:
					break;
			}
		}
		
		shoutbox.popup_dialog_doset_status('processed');
		shoutbox.popup_dialog_message_display(d, false, true);
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
}

shoutbox.prototype.load_ajax_shouts = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.shouts_reloading_display();
		
		if (shoutbox.hide_refresh)
		{
			my_getbyid('shoutbox-refresh-button').style.display = 'none';
		}
		
		return;
	}
	
	shoutbox.shouts_reloading_hide();
	var o = shoutbox.get_obj('shoutbox-shouts');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (d != '' && d != '<!--nothing-->')
	{
		if (d.substring(0, 6) == "error-")
		{
			shoutbox.shout_error(d.substring(6));
			return;
		}
		else if (d.substring(0, 10) == "errorfull-")
		{
			shoutbox.shout_error(d.substring(10));
			return;
		}
		else
		{
			/**
			* 1.0.0 Final
			* Fix no shouts message
			*/
			if (shoutbox.total_shouts <= 0)
			{
				shoutbox.total_shouts = 1;
				
				var ns = shoutbox.get_obj('shoutbox-no-shouts-message');
				ns.style.display = 'none';
			}
			
			shoutbox.skip_js = true;
			shoutbox.ajax_objs[x].execute_javascript(d);
			shoutbox.skip_js = false;
			
			if (shoutbox.shout_order == 'asc')
			{
				o.innerHTML += d;
			}
			else
			{
				o.innerHTML = d+o.innerHTML;
			}
			
			shoutbox.ajax_objs[x].execute_javascript(d);
			shoutbox.force_update = 0;
			
			// Fix shout classes
			shoutbox.rewrite_shout_classes();
			
			// Setup latest ID/Class
			shoutbox.get_last_data();
			
			shoutbox.shouts_scroll_bottom();
		}
	}
	
	if (shoutbox.can_use && shoutbox.my_prefs['display_refresh_button'] == 1)
	{
		my_getbyid('shoutbox-refresh-button').style.display = '';
	}
	
	shoutbox.reload_shouts();
}

shoutbox.prototype.refresh_shouts = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.reload_shouts(true);
}

shoutbox.prototype.reload_shouts = function(dn)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	dn = (dn == true) ? true : false;
	
	/**
	* Beta 2
	* Fix timeout with clearTimeout
	*/
	clearTimeout(shoutbox.timeout_timer);
	
	if (dn)
	{
		var gl = '';
		var fc = '&force=0';
		
		if (shoutbox.global_on)
		{
			gl = '&global=1';
		}
		
		if (shoutbox.force_update)
		{
			fc = '&force=1';
		}
		
		// Setup latest ID/Class
		shoutbox.get_last_data();
		
		shoutbox.new_ajax('shouts', 'get', shoutbox.base_url+'type=shouts&lastid='+shoutbox.last_shout_id+gl+fc, shoutbox.load_ajax_shouts);
	}
	else if (shoutbox.is_inactive())
	{
		/**
		* Beta 2
		* Timeout removed because it was useless, we re-active the
		* shoutbox when we process inactive prompt
		* 
		* setTimeout("try{shoutbox.reload_shouts();}catch(e){}", 5000);
		*/
		return;
	}
	
	/**
	* Beta 2
	* Set again timeout if we are not inactive :O
	*/
	shoutbox.timeout_timer = setTimeout("try{shoutbox.reload_shouts(true);}catch(e){}", shoutbox.timeout_convert(shoutbox.shouts_refresh));
}

shoutbox.prototype.shouts_reloading_display = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	try
	{
		var s = shoutbox.get_obj('shoutbox-shouts');
		var o = shoutbox.get_obj('shoutbox-shouts-reloading');
		var i = o.getElementsByTagName('img')[0];
		
		o.style.position = 'absolute';
		o.style.display  = 'block';
		o.style.top      = '1px';
		o.style.padding  = '0px';
		o.style.margin   = '0px';
		
		if (s.scrollHeight > s.clientHeight)
		{
			o.style.right = '20px';
		}
		else
		{
			o.style.right = '1px';
		}
		
		shoutbox.set_opactity(o, 5);
	}
	
	catch(e){}
}

shoutbox.prototype.shouts_reloading_hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	try
	{
		var o = shoutbox.get_obj('shoutbox-shouts-reloading');
		o.style.display = 'none';
	}
	
	catch(e){}
}

shoutbox.prototype.set_opactity = function(o, v)
{
	try
	{
		o.style.opacity = v/10;
		o.style.filter  = 'alpha(opacity='+v*10+')';
	}
	
	catch(e){}
}

shoutbox.prototype.load_ajax_members = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		return;
	}
	
	var o = shoutbox.get_obj('shoutbox-members-viewing', true);
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.shout_error(d.substring(6));
		return;
	}
	else if (d.substring(0, 10) == "errorfull-")
	{
		shoutbox.shout_error(d.substring(10));
		return;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
	
	shoutbox.reload_members();
}

shoutbox.prototype.reload_members = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	mids = shoutbox.get_members_viewing_ids();
	if (!mids.length)
	{
		mids = new Array();
	}
	
	if (shoutbox.is_inactive())
	{
		setTimeout("try{shoutbox.reload_members();}catch(e){}", 5000);
	}
	else
	{
		setTimeout("try{shoutbox.new_ajax('members', 'get', '"+shoutbox.base_url+"type=members&ids="+mids.join(',')+"', "+shoutbox.load_ajax_members+");}catch(e){}", shoutbox.timeout_convert(shoutbox.members_refresh));
	}
}

shoutbox.prototype.reopen_current_menu = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (ipsmenu.menu_cur_open != null)
	{
		var open = ipsmenu.menu_cur_open;
		var obj  = shoutbox.get_obj(open, true);
		
		ipsmenu.menu_cur_open = null;
		ipsmenu.menu_registered[open].open(obj);
		
		if (ipsmenu.menu_over_css[open])
		{
			obj.className = ipsmenu.menu_over_css[open];
		}
	}
}

shoutbox.prototype.load_my_prefs = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id)
	{
		return false;
	}
	
	if (this.blur)
	{
		this.blur();
	}
	
	if (shoutbox.global_on)
	{
		shoutbox.set_action_and_reload('myprefs');
		return false;
	}
	
	shoutbox._inactive   = true;
	shoutbox.last_active = shoutbox.get_timestamp();
	
	shoutbox.in_prefs = true;
	shoutbox.popup_dialog_set_title('my_prefs');
	
	shoutbox.langs['popup_pre_status'] = shoutbox.langs['my_prefs_loaded'];
	
	shoutbox.new_ajax('load-my-prefs', 'get', shoutbox.base_url+'type=prefs&command=load', shoutbox.load_my_prefs_process);
	return false;
}

shoutbox.prototype.load_my_prefs_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_show_loading();
		return;
	}

	shoutbox.popup_hide_loading();
	shoutbox.popup_dialog_display();

	var o = shoutbox.get_obj('shoutbox-popup-data');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	o.style.display = '';
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.popup_dialog_hide();
		shoutbox.popup_loading_error_display(d);
		return;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);

		shoutbox.popup_dialog_resize();
		shoutbox.popup_dialog_center();
	}
}

shoutbox.prototype.my_prefs_save = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	shoutbox._inactive   = true;
	shoutbox.last_active = shoutbox.get_timestamp();

	if (this.blur)
	{
		this.blur();
	}

	var p = new Array();
	p['autocom']  = 'shoutbox';
	p['req']      = 'ajax';
	p['type']     = 'prefs';
	p['command']  = 'save';
	p['md5check'] = ipb_md5_check;
	p['prefs_gsb'] = (shoutbox.get_obj('my_prefs_gsb_y').checked) ? 1 : 0;
	p['prefs_ets'] = (shoutbox.get_obj('my_prefs_ets_y').checked) ? 1 : 0;
	p['prefs_eqc'] = (shoutbox.get_obj('my_prefs_eqc_y').checked) ? 1 : 0;
	p['prefs_drb'] = (shoutbox.get_obj('my_prefs_drb_y').checked) ? 1 : 0;
        //-------------------------------
	//-IBM- IP.Shoutbox Enhancement
	//-------------------------------
	p['prefs_sbfc'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbfc_y').value);
	p['prefs_sbfw'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbfw_y').value);
	p['prefs_sbms'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbms_y').value);
	p['prefs_sbfs'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbfs_y').value);
	p['prefs_sbff'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbff_y').value);
	p['prefs_sbtd'] = shoutbox.trim(shoutbox.get_obj('my_prefs_sbtd_y').value);

	shoutbox.my_prefs['global_display']         = p['prefs_gsb'];
	shoutbox.my_prefs['enter_key_shout']        = p['prefs_ets'];
	shoutbox.my_prefs['enable_quick_commands']  = p['prefs_eqc'];
	shoutbox.my_prefs['display_refresh_button'] = p['prefs_drb'];
        //-------------------------------
	//-IBM- IP.Shoutbox Enhancement
	//-------------------------------
	shoutbox.my_prefs['sbfc']  = p['prefs_sbfc'];
	shoutbox.my_prefs['sbfw'] = p['prefs_sbfw'];
	shoutbox.my_prefs['sbmstatus'] = p['prefs_sbms'];
	shoutbox.my_prefs['sbfs']  = p['prefs_sbfs'];
	shoutbox.my_prefs['sbff'] = p['prefs_sbff'];
	shoutbox.my_prefs['sbtd'] = p['prefs_sbtd'];

	shoutbox.popup_dialog_doset_status('saving_prefs');
	shoutbox.new_ajax('my-prefs-save', 'post', shoutbox.base_url, shoutbox.my_prefs_save_process, p);
}

shoutbox.prototype.my_prefs_save_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_dialog_doset_status('saving_prefs');
		return;
	}
	
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (m = d.match(new RegExp("^error-(.*)", 'i')))
	{
		shoutbox.popup_dialog_error_display(m[1]);
		return;
	}
	else
	{
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
	
	/**
	* Beta 3
	* Hide popup after save
	*/
	setTimeout("shoutbox.popup_dialog_close()", 1000);
}

shoutbox.prototype.my_prefs_restore = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id || shoutbox.global_on)
	{
		return false;
	}

	if (this.blur)
	{
		this.blur();
	}

	shoutbox._inactive   = true;
	shoutbox.last_active = shoutbox.get_timestamp();

	var p = new Array();
	p['autocom']  = 'shoutbox';
	p['req']      = 'ajax';
	p['type']     = 'prefs';
	p['command']  = 'restore';
	p['md5check'] = ipb_md5_check;

	shoutbox.popup_dialog_doset_status('saving_prefs');
	shoutbox.new_ajax('my-prefs-save', 'post', shoutbox.base_url, shoutbox.my_prefs_restore_process, p);
}

shoutbox.prototype.my_prefs_restore_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_dialog_doset_status('saving_prefs');
		return;
	}

	var o = shoutbox.get_obj('shoutbox-popup-data');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	if (m = d.match(new RegExp("^error-(.*)", 'i')))
	{
		shoutbox.popup_dialog_error_display(m[1]);
		return;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
	
	/**
	* Beta 3
	* Hide popup after save
	*/
	setTimeout("shoutbox.popup_dialog_close()", 1000);
}

shoutbox.prototype.load_archive = function(t)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on)
	{
		return false;
	}

	if (shoutbox.in_prefs || shoutbox.in_archive || shoutbox.in_mod)
	{
		shoutbox.popup_dialog_close();
	}

	if (typeof(t) != 'undefined' && t != null && t.blur)
	{
		t.blur();
	}

	shoutbox._inactive  = true;
	shoutbox.in_archive = true;
	shoutbox.popup_dialog_set_title('sb_archive');

	shoutbox.langs['popup_pre_status'] = shoutbox.langs['sb_archive_loaded'];

	shoutbox.new_ajax('load-archive', 'get', shoutbox.base_url+'type=archive&command=load', shoutbox.load_archive_process);
	return false;
}

shoutbox.prototype.load_archive_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_show_loading();
		return;
	}

	shoutbox.popup_hide_loading();
	shoutbox.popup_dialog_display();

	var o = shoutbox.get_obj('shoutbox-popup-data');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	o.style.display = '';
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.popup_dialog_hide();
		shoutbox.popup_loading_error_display(d);
		return;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);

		shoutbox.popup_dialog_resize();
		shoutbox.popup_dialog_center();
	}
}

shoutbox.prototype.archive_get_dropdowns = function(t, v)
{
	if (t != 'start' && t != 'end')
	{
		return new Array();
	}

	var a = new Array
	(
		shoutbox.get_obj('filter_'+t+'_month'),
		shoutbox.get_obj('filter_'+t+'_day'),
		shoutbox.get_obj('filter_'+t+'_year'),
		shoutbox.get_obj('filter_'+t+'_hour'),
		shoutbox.get_obj('filter_'+t+'_minute'),
		shoutbox.get_obj('filter_'+t+'_meridiem')
	);

	if (v == true)
	{
		for (var i=0; i<a.length; i++)
		{
			a[i] = a[i].options[a[i].selectedIndex].value;
		}
	}

	return a;
}

shoutbox.prototype.archive_set_dropdown_option = function(o, v)
{
	if (o.options.length > 0)
	{
		for (var i=0; i<o.options.length; i++)
		{
			if (o.options[i].value == v)
			{
				o.selectedIndex = i;
				break;
			}
		}
	}
}

shoutbox.prototype.archive_filter = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	if (this.blur)
	{
		this.blur();
	}

	shoutbox._inactive   = true;
	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.langs['popup_pre_status'] = shoutbox.langs['filtered'];

	var p = new Array();
	p['autocom']  = 'shoutbox';
	p['req']      = 'ajax';
	p['type']     = 'archive';
	p['command']  = 'filter';
	p['md5check'] = ipb_md5_check;
	p['start']    = shoutbox.archive_get_dropdowns('start', true);
	p['end']      = shoutbox.archive_get_dropdowns('end', true);
	p['member']   = shoutbox.trim(shoutbox.get_obj('filter_member_name').value);

	if (p['member'].indexOf(',') > 0)
	{
		var x = new Array();
		var m = p['member'].split(',');

		for (var i=0; i<m.length; i++)
		{
			m[i] = shoutbox.trim(m[i]);
			if (m[i] == '' || m[i].length < 3)
			{
				continue;
			}

			x[x.length] = m[i];
		}

		if (x.length <= 0)
		{
			shoutbox.popup_dialog_error_display(shoutbox.errors['member_names_too_short']);
			return false;
		}
	}
	else if (p['member'].length > 0 && p['member'].length < 3)
	{
		shoutbox.popup_dialog_error_display(shoutbox.errors['member_name_too_short']);
		return false;
	}

	shoutbox.archive_cur_filter = p;

	shoutbox.popup_dialog_doset_status('filtering');
	shoutbox.new_ajax('filter-archive', 'post', shoutbox.base_url, shoutbox.archive_filter_process, p);

	return false;
}

shoutbox.prototype.archive_filter_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		shoutbox.popup_dialog_doset_status('filtering');
		return;
	}

	shoutbox.popup_dialog_doset_status('filtered');
	var o = shoutbox.get_obj('shoutbox-archive-shouts');
	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;

	if (m = d.match(new RegExp("^error-(.*)", 'i')))
	{
		shoutbox.popup_dialog_error_display(m[1]);
		return;
	}
	else
	{
		o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);

		shoutbox.popup_dialog_resize();
		shoutbox.popup_dialog_center();
		shoutbox.archive_update_floaters();

		if (is_opera)
		{
			shoutbox.archive_update_floaters();
		}
	}
}

shoutbox.prototype.archive_quick_filter = function(t, h)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	if (h.blur)
	{
		h.blur();
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	var d = new Date();
	var s = shoutbox.archive_get_dropdowns('start', false);
	var e = shoutbox.archive_get_dropdowns('end', false);

	switch (t)
	{
		case 'today':
			shoutbox.archive_set_dropdown_option(s[0], d.getMonth()+1);
			shoutbox.archive_set_dropdown_option(s[1], d.getDate());
			shoutbox.archive_set_dropdown_option(s[2], d.getFullYear());
			shoutbox.archive_set_dropdown_option(s[3], 12);
			shoutbox.archive_set_dropdown_option(s[4], 0);
			shoutbox.archive_set_dropdown_option(s[5], 'am');

			shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
			shoutbox.archive_set_dropdown_option(e[1], d.getDate());
			shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
			shoutbox.archive_set_dropdown_option(e[3], 11);
			shoutbox.archive_set_dropdown_option(e[4], 59);
			shoutbox.archive_set_dropdown_option(e[5], 'pm');

			shoutbox.get_obj('filter_member_name').value = '';
			shoutbox.archive_filter();
			break;
		case 'yesterday':
			var m = d.getMonth()+1;
			var a = d.getDate();
			var y = d.getFullYear();

			if (a == 1)
			{
				if (m == 1)
				{
					m  = 12;
					y -= 1;
				}
				else
				{
					m -= 1;
				}

				a = shoutbox.month_days(m-1);
			}
			else
			{
				a -= 1;
			}

			shoutbox.archive_set_dropdown_option(s[0], m);
			shoutbox.archive_set_dropdown_option(s[1], a);
			shoutbox.archive_set_dropdown_option(s[2], y);
			shoutbox.archive_set_dropdown_option(s[3], 12);
			shoutbox.archive_set_dropdown_option(s[4], 0);
			shoutbox.archive_set_dropdown_option(s[5], 'am');

			shoutbox.archive_set_dropdown_option(e[0], m);
			shoutbox.archive_set_dropdown_option(e[1], a);
			shoutbox.archive_set_dropdown_option(e[2], y);
			shoutbox.archive_set_dropdown_option(e[3], 11);
			shoutbox.archive_set_dropdown_option(e[4], 59);
			shoutbox.archive_set_dropdown_option(e[5], 'pm');

			shoutbox.get_obj('filter_member_name').value = '';
			shoutbox.archive_filter();
			break;
		case 'month':
			shoutbox.archive_set_dropdown_option(s[0], d.getMonth()+1);
			shoutbox.archive_set_dropdown_option(s[1], 1);
			shoutbox.archive_set_dropdown_option(s[2], d.getFullYear());
			shoutbox.archive_set_dropdown_option(s[3], 12);
			shoutbox.archive_set_dropdown_option(s[4], 0);
			shoutbox.archive_set_dropdown_option(s[5], 'am');

			shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
			shoutbox.archive_set_dropdown_option(e[1], shoutbox.month_days[d.getMonth()]);
			shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
			shoutbox.archive_set_dropdown_option(e[3], 11);
			shoutbox.archive_set_dropdown_option(e[4], 59);
			shoutbox.archive_set_dropdown_option(e[5], 'pm');

			shoutbox.get_obj('filter_member_name').value = '';
			shoutbox.archive_filter();
			break;
		case 'all':
		case 'mine':
			dd = new Date(shoutbox.oldest_shout);
			hr = dd.getHours();
			md = '';

			if (hr < 12)
			{
				md = 'am';
				if (hr == 0)
				{
					hr = 12;
				}
			}
			else if (hr > 12)
			{
				md  = 'pm';
				hr -= 12;
			}

			shoutbox.archive_set_dropdown_option(s[0], dd.getMonth()+1);
			shoutbox.archive_set_dropdown_option(s[1], dd.getDate());
			shoutbox.archive_set_dropdown_option(s[2], dd.getFullYear());
			shoutbox.archive_set_dropdown_option(s[3], hr);
			shoutbox.archive_set_dropdown_option(s[4], dd.getMinutes());
			shoutbox.archive_set_dropdown_option(s[5], md);

			shoutbox.archive_set_dropdown_option(e[0], d.getMonth()+1);
			shoutbox.archive_set_dropdown_option(e[1], d.getDate());
			shoutbox.archive_set_dropdown_option(e[2], d.getFullYear());
			shoutbox.archive_set_dropdown_option(e[3], 11);
			shoutbox.archive_set_dropdown_option(e[4], 59);
			shoutbox.archive_set_dropdown_option(e[5], 'pm');

			if (t == 'mine')
			{
				shoutbox.get_obj('filter_member_name').value = shoutbox.my_dname;
			}
			else
			{
				shoutbox.get_obj('filter_member_name').value = '';
			}

			shoutbox.archive_filter();
			break;
		default:
			break;
	}

	return false;
}

shoutbox.prototype.archive_update_floaters = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-archive-shouts-div');
		var r = shoutbox.get_obj('shoutbox-archive-pages-floater');
		
		if ( shoutbox.shout_pages == 0 )
		{
			r.style.display   = 'none';
			return false;
		}
		
		r.style.display   = '';
		r.style.marginTop = o.scrollTop+'px';
		r.style.zIndex    = 30;

		if (o.scrollHeight > 0)
		{
			r.style.right = '16px';
		}
		else
		{
			r.style.right = '0px';
		}

		if (is_opera)
		{
			shoutbox.archive_update_floaters();
		}
	}

	catch(me){}
}

shoutbox.prototype.archive_update_pager = function(p)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		var d = shoutbox.get_obj('shoutbox-archive-pages-data');
		var h = '';

		shoutbox.cur_page = p;
		if (p > 1)
		{
			h += "<span onclick='shoutbox.archive_goto_prev_page()' style='cursor:pointer'>&laquo;</span>&nbsp;";
		}

		h += shoutbox.langs['page']+" <span id='shoutbox-archive-page-changer'>"+p+'</span> '+shoutbox.langs['of']+' '+shoutbox.shout_pages;
		if (p < shoutbox.shout_pages)
		{
			h += "&nbsp;<span onclick='shoutbox.archive_goto_next_page()' style='cursor:pointer'>&raquo;</span>";
		}

		d.innerHTML = h;

		var o = shoutbox.get_obj('shoutbox-archive-page-changer');
		shoutbox.add_event(o, 'dblclick', shoutbox.archive_change_page_init);
	}

	catch(me){}
}

shoutbox.prototype.archive_change_page_init = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	if (shoutbox.get_obj('shoutbox-archive-page-changer-input'))
	{
		try
		{
			shoutbox.get_obj('shoutbox-archive-page-changer-input').parentNode.removeChild(shoutbox.get_obj('shoutbox-archive-page-changer-input'));
		}

		catch(me){}
	}

	shoutbox.allow_keys = new Array(8, 13, 27, 35, 36, 37, 39, 46);
	for (var i=48; i<58; i++)
	{
		shoutbox.allow_keys[shoutbox.allow_keys.length] = i;
	}

	var o = shoutbox.get_obj('shoutbox-archive-page-changer');
	var i = document.createElement('input');
	var w = o.offsetWidth;

	o.cur_page  = Math.round(o.innerHTML);
	o.innerHTML = '';

	i.id                = 'shoutbox-archive-page-changer-input';
	i.className         = 'row2';
	i.value             = parseInt(o.cur_page);
	i.style['padding']  = 0;
	i.style['margin']   = '-2px 0 0 0';
	i.style['border']   = 0;
	i.style['width']    = parseInt(w)+'px';
	i.setAttribute('maxlength', shoutbox.shout_pages.toString().length);

	o.appendChild(i);

	var i = shoutbox.get_obj('shoutbox-archive-page-changer-input');
	shoutbox.add_event(i, 'blur', shoutbox.archive_change_page_process);
	shoutbox.add_event(i, 'keydown', shoutbox.archive_change_page_keydown);
	shoutbox.remove_event(o, 'dblclick', shoutbox.archive_change_page_init);

	i.focus();
	i.select();

	shoutbox.in_archive_page_change = true;
}

shoutbox.prototype.archive_change_page_keydown = function(e)
{
	if (document.all)
	{
		if (e && window.event && e._skip != true)
		{
			e = window.event;
		}
	}

	if (!e || e == null || typeof(e) == 'undefined')
	{
		return;
	}

	try
	{
		shoutbox.last_active = shoutbox.get_timestamp();
	}

	catch(me){}

	if (document.layers)
	{
		var alt   = (e.modifiers&Event.ALT_MASK) ? true : false;
		var ctrl  = (e.modifiers&Event.CONTROL_MASK) ? true : false;
		var shift = (e.modifiers&Event.SHIFT_MASK) ? true : false;
		var key   = e.which;
	}
	else
	{
		var alt   = e.altKey;
		var ctrl  = e.ctrlKey;
		var shift = e.shiftKey;

		if (document.all)
		{
			var key = e.keyCode;
		}
		else
		{
			if (e.keyCode > 0)
			{
				var key = e.keyCode;
			}
			else if (e.which > 0)
			{
				var key = e.which;
			}
		}
	}

	var obj = (e.srcElement) ? e.srcElement : e.target;
	if (is_safari || (is_ns && is_moz))
	{
		if (obj.nodeType == 3 && e.target.parentNode.nodeType == 1)
		{
			obj = e.target.parentNode;
		}
	}

	if (ipsclass.in_array(key, shoutbox.allow_keys) == false)
	{
		ipsclass.cancel_bubble_all(e);
		return false;
	}

	switch (key)
	{
		case 13:
			ipsclass.cancel_bubble_all(e);
			shoutbox.archive_change_page_process();
			return false;

			break;
		case 27:
			shoutbox.just_closed_archive_page = true;
			ipsclass.cancel_bubble_all(e);
			shoutbox.archive_change_page_cancel();
			return false;

			break;
		default:
			return true;
	}

	ipsclass.cancel_bubble_all(e);
	return false;
}

shoutbox.prototype.archive_change_page_process = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	shoutbox.in_archive_page_change = false;

	var o = shoutbox.get_obj('shoutbox-archive-page-changer');
	var i = shoutbox.get_obj('shoutbox-archive-page-changer-input');
	var p = parseInt(i.value);

	if (p <= 0 || p > shoutbox.shout_pages)
	{
		p = o.cur_page;
	}

	i.parentNode.removeChild(i);
	o.cur_page  = null;
	o.innerHTML = p;

	if (p == o.cur_page)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.archive_cur_filter['page'] = p;

	shoutbox.popup_dialog_doset_status('filtering');
	shoutbox.new_ajax('filter-archive', 'post', shoutbox.base_url, shoutbox.archive_filter_process, shoutbox.archive_cur_filter);
	shoutbox.add_event(o, 'dblclick', shoutbox.archive_change_page_init);
}

shoutbox.prototype.archive_change_page_cancel = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	shoutbox.in_archive_page_change = false;

	var o = shoutbox.get_obj('shoutbox-archive-page-changer');
	var i = shoutbox.get_obj('shoutbox-archive-page-changer-input');
	var p = o.cur_page;

	i.parentNode.removeChild(i);
	o.cur_page  = null;
	o.innerHTML = p;

	shoutbox.add_event(o, 'dblclick', shoutbox.archive_change_page_init);
	return false;
}

shoutbox.prototype.archive_goto_prev_page = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	var p = shoutbox.cur_page;
	var t = shoutbox.shout_pages;
	var n = Math.floor(p-1);

	if (n < 1)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.archive_cur_filter['page'] = n;

	shoutbox.popup_dialog_doset_status('filtering');
	shoutbox.new_ajax('filter-archive', 'post', shoutbox.base_url, shoutbox.archive_filter_process, shoutbox.archive_cur_filter);
}

shoutbox.prototype.archive_goto_next_page = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.view_archive || shoutbox.global_on || !shoutbox.in_archive)
	{
		return false;
	}

	var p = shoutbox.cur_page;
	var t = shoutbox.shout_pages;
	var n = Math.floor(p+1);

	if (n > t)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox.archive_cur_filter['page'] = n;

	shoutbox.popup_dialog_doset_status('filtering');
	shoutbox.new_ajax('filter-archive', 'post', shoutbox.base_url, shoutbox.archive_filter_process, shoutbox.archive_cur_filter);
}

shoutbox.prototype.update_members_viewing_total = function(t)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-members-viewing-total');
		o.innerHTML = parseInt(t);
	}

	catch(e){}
}

/**
* Get latest shout ID
* originally this function was "get_shouts"ids"
*/
shoutbox.prototype.get_last_data = function()
{
	var temp    = 0;
	var shouts  = my_getbyid('shoutbox-shouts');
	var rows    = shouts.getElementsByTagName('div');
	
	for (var i=0; i<rows.length; i++)
	{
		if (rows[i].style.display != 'none' && rows[i].id.substring(0,10) == 'shout-row-' && rows[i].id.substring(0,11) != 'shout-row-m')
		{
			temp = parseInt(rows[i].id.substring(10));
			
			if ( temp > shoutbox.last_shout_id )
			{
				shoutbox.last_shout_id = temp;
			}
		}
	}
	
	return;
}

shoutbox.prototype.get_members_viewing_ids = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	var a = new Array();
	var o = shoutbox.get_obj('shoutbox-members-viewing');
	var c = o.childNodes;

	for (var i=0; i<c.length; i++)
	{
		if (c[i].nodeName == 'DIV' && c[i].id.match(/member-viewing-(\d+)$/ig))
		{
			a[a.length] = c[i].id.replace(/member-viewing-(\d+)$/ig, '$1');
		}
	}

	return a;
}

shoutbox.prototype.get_timestamp = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	var d = (typeof(x) != 'undefined' && x != null && x != '') ? new Date(x) : new Date();
	var t = d.getTime();

	return Math.floor(t/1000);
}

shoutbox.prototype.members_viewing_fade = function(a)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.enable_fade)
	{
		return false;
	}

	if (a != null && a.length)
	{
		for (var i=0; i<a.length; i++)
		{
			if (!isNaN(a[i]) && a[i] != shoutbox.my_id)
			{
				shoutbox.fade_object('member-viewing-'+a[i]);
			}
		}
	}
}

shoutbox.prototype.shouts_fade = function(a)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.enable_fade)
	{
		return false;
	}
	
	if (a != null && a.length > 0)
	{
		for (var i=0; i<a.length; i++)
		{
			shoutbox.fade_object('shout-row-'+a[i]);
		}
	}
}

shoutbox.prototype.update_prefs_shout_area = function(d)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	var h = parseInt(d.h);
	shoutbox.new_ajax('update-prefs-shout-area', 'get', shoutbox.base_url+'type=prefs&command=shout-area&height='+h, shoutbox.update_prefs_shout_area_process);
}

shoutbox.prototype.update_prefs_shout_area_process = function(x)
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	if (!shoutbox.ajax_objs[x].readystate_ready_and_ok())
	{
		return;
	}

	var d = shoutbox.ajax_objs[x].xmlhandler.responseText;
	
	if (d.substring(0, 6) == "error-")
	{
		shoutbox.shout_error(d.substring(6));
		return;
	}
	else if (d.substring(0, 10) == "errorfull-")
	{
		shoutbox.shout_error(d.substring(10));
		return;
	}
	else if (d.substring(0, 7) == "ignore-")
	{
		return;
	}
	else
	{
		//o.innerHTML = d;
		shoutbox.ajax_objs[x].execute_javascript(d);
	}
}

shoutbox.prototype.update_prefs_global_shout_area = function(d)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!shoutbox.my_id)
	{
		return false;
	}

	shoutbox.last_active = shoutbox.get_timestamp();

	var h = parseInt(d.h);
	shoutbox.new_ajax('update-prefs-global-shout-area', 'get', shoutbox.base_url+'type=prefs&command=global-shout-area&height='+h, shoutbox.update_prefs_shout_area_process);
}

shoutbox.prototype.timeout_convert = function(t)
{
	t = parseInt(t);
	t = t*1000;

	return t;
}

shoutbox.prototype.scroll_shoutbox_top = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		var o = shoutbox.get_obj('shoutbox-wrapper');
	}

	catch(e)
	{
		var o;
	}

	if (o)
	{
		var t = _get_obj_toppos(o);
		if (t)
		{
			scroll(0, t);
		}
	}
}

shoutbox.prototype.scroll_page_up = function()
{
	window.scrollBy(0, -3);
}

shoutbox.prototype.scroll_page_down = function()
{
	window.scrollBy(0, 3);
}

shoutbox.prototype.rect = function(x, y, w, h)
{
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
}

shoutbox.prototype.init_shouts_resize = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	var ss = shoutbox.get_obj('shoutbox-shouts');
	var sr = shoutbox.get_obj('shouts-resizer');

	if (is_ie)
	{
		//sr.style.margin       = 0;
		sr.style.marginTop    = '5px';
		ss.style.marginBottom = '-6px';

		shoutbox.get_obj('shoutbox-shouts-td').style.paddingBottom = '0px';
	}

	if (!shoutbox.my_id)
	{
		sr.style.cursor = 'default';
		return false;
	}

	Resize.init(sr, ss, true, false);

	ss.min_height = 100;
	ss.Resizing   = function(d)
	{
		shoutbox.shouts_scroll_bottom();
	}

	ss.Resize_end = function(d)
	{
		shoutbox.update_prefs_shout_area(d);
	}
}
shoutbox.prototype.init_global_resize = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	var sso = shoutbox.get_obj('shoutbox-shouts');
	var srh = shoutbox.get_obj('shouts-global-resizer-height');

	if (!shoutbox.my_id)
	{
		srh.style.cursor = 'default';
		return false;
	}

	Resize.init(srh, sso, true, false);

	var x = shoutbox.get_obj('shoutbox-global-wrapper');
	var w = parseInt(x.offsetWidth);
	var n = Math.floor(w*.2);

	sso.min_height = 100;
	sso.Resizing   = function(d)
	{
		shoutbox.shouts_scroll_bottom();
	}

	sso.Resize_end = function(d)
	{
		shoutbox.update_prefs_global_shout_area(d);
	}
}

shoutbox.prototype.editor_switch = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox.global_on)
	{
		return false;
	}

	shoutbox.eswitch_funced  = false;
	shoutbox.new_editor_mode = (IPS_editor[shoutbox.editor_id].is_rte) ? 0 : 1;

	if (shoutbox.new_editor_mode == 1)
	{
		shoutbox.editor_switch_loop();
	}
}

shoutbox.prototype.editor_switch_loop = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox.global_on)
	{
		return false;
	}

	if (shoutbox.eswitch_funced)
	{
		return false;
	}

	var r = false;
	if (IPS_editor[shoutbox.editor_id] != null)
	{
		if (IPS_editor[shoutbox.editor_id].initialized)
		{
			shoutbox.editor_rte = IPS_editor[shoutbox.editor_id].is_rte;
			if (IPS_editor[shoutbox.editor_id].is_rte)
			{
				r = true;

				shoutbox.remove_event(IPS_editor[shoutbox.editor_id].editor_document, 'keypress', shoutbox.keypress_handler_iframe);
				shoutbox.add_event(IPS_editor[shoutbox.editor_id].editor_document, 'keypress', shoutbox.keypress_handler_iframe);

				if (is_ie)
				{
					shoutbox.remove_event(IPS_editor[shoutbox.editor_id].editor_document, 'keydown', shoutbox.keydown_handler_iframe);
					shoutbox.add_event(IPS_editor[shoutbox.editor_id].editor_document, 'keydown', shoutbox.keydown_handler_iframe);
				}
			}
		}
	}

	if (!r)
	{
		shoutbox.editor_switch_loop();
	}
	else
	{
		shoutbox.update_shout_obj();
	}
}

shoutbox.prototype.add_event = function(o, t, f)
{
	if (o.addEventListener)
	{
		o.addEventListener(t, f, false);
	}
	else if (o.attachEvent)
	{
		o.attachEvent('on'+t, f);
	}
	else
	{
		eval(o+'.on'+t+' = '+f);
	}
}

shoutbox.prototype.remove_event = function(o, t, f)
{
	if (o.removeEventListener)
	{
		o.removeEventListener(t, f, false);
	}
	else if (o.detachEvent)
	{
		o.detachEvent('on'+t, f);
	}
	else
	{
		eval(o+'.on'+t+' = null');
	}
}

shoutbox.prototype.init_events = function()
{
	if (!shoutbox.events_loaded)
	{
		shoutbox.events_loaded = true;
		shoutbox.add_event(document, 'keypress', shoutbox.keypress_handler);

		//window.addEventListener('blur', shoutbox.blur_handler, true);
	}

	if (!shoutbox.global_on && shoutbox.events_load_tries < shoutbox.events_load_max_tries && !shoutbox.events_rte_loaded)
	{
		shoutbox.events_load_tries++;
		try
		{
			if (IPS_editor[shoutbox.editor_id].is_rte)
			{
				shoutbox.add_event(IPS_editor[shoutbox.editor_id].editor_document, 'keypress', shoutbox.keypress_handler_iframe);
				if (is_ie)
				{
					shoutbox.add_event(IPS_editor[shoutbox.editor_id].editor_document, 'keydown', shoutbox.keydown_handler_iframe);
				}
			}

			//IPS_editor[shoutbox.editor_id].editor_document.addEventListener('mousedown', shoutbox.mousedown_handler, true);
			//IPS_editor[shoutbox.editor_id].editor_window.addEventListener('blur', shoutbox.blur_handler, true);
			shoutbox.events_rte_loaded = true;
		}

		catch(e)
		{
			try
			{
				shoutbox.init_events();
			}
			catch(e){}
		}
	}
}

shoutbox.prototype.keydown_handler_iframe = function(e)
{
	if (document.all)
	{
		if (IPS_editor[shoutbox.editor_id].editor_window.event)
		{
			e = IPS_editor[shoutbox.editor_id].editor_window.event;
			e._skip = true;
		}

		if (e.keyCode == 13)
		{
			e._sbrte = true;
			shoutbox.keypress_handler(e);
		}
	}
}

shoutbox.prototype.keypress_handler_iframe = function(e)
{
	if (document.all)
	{
		if (IPS_editor[shoutbox.editor_id].editor_window.event)
		{
			e = IPS_editor[shoutbox.editor_id].editor_window.event;
			e._skip = true;
		}
	}

	e._sbrte = true;
	shoutbox.keypress_handler(e);
}

shoutbox.prototype.keypress_handler = function(e)
{
	if (document.all)
	{
		if (e && window.event && e._skip != true)
		{
			e = window.event;
		}
	}

	if (!e || e == null || typeof(e) == 'undefined')
	{
		return;
	}

	try
	{
		shoutbox.last_active = shoutbox.get_timestamp();
	}

	catch(me){}

	var ret = true;
	if (document.layers)
	{
		var alt   = (e.modifiers&Event.ALT_MASK) ? true : false;
		var ctrl  = (e.modifiers&Event.CONTROL_MASK) ? true : false;
		var shift = (e.modifiers&Event.SHIFT_MASK) ? true : false;
		var key   = e.which;
	}
	else
	{
		var alt   = e.altKey;
		var ctrl  = e.ctrlKey;
		var shift = e.shiftKey;

		if (document.all)
		{
			var key = e.keyCode;
		}
		else
		{
			if (e.keyCode > 0)
			{
				var key = e.keyCode;
			}
			else if (e.which > 0)
			{
				var key = e.which;
			}
		}
	}
	
	var obj = (e.srcElement) ? e.srcElement : e.target;
	if (is_safari || (is_ns && is_moz))
	{
		if (obj.nodeType == 3 && e.target.parentNode.nodeType == 1)
		{
			obj = e.target.parentNode;
		}
	}

	if (typeof(obj.id) == 'undefined')
	{
		obj.id = '';
	}

	if (shoutbox.popup_open && key != 27)
	{
		return true;
	}
	else
	{
		if (shoutbox.popup_open && key == 27)
		{
			if (shoutbox.in_archive && shoutbox.just_closed_archive_page)
			{
				shoutbox.just_closed_archive_page = false;
				return true;
			}
			else
			{
				shoutbox.popup_dialog_close();
			}
		}
		else if (shoutbox.my_prefs['enter_key_shout'] == 1 && (obj.id == 'shoutbox-global-shout' || obj.id == shoutbox.editor_id+'_textarea' || e._sbrte == true) && !shift && !alt && !ctrl && key == 13)
		{
			shoutbox.submit_shout();
			
			ipsclass.cancel_bubble_all(e);
			return false;
		}
		else if (((alt && key == 13) || (ctrl && key == 13)))
		{
			shoutbox.submit_shout();

			ipsclass.cancel_bubble_all(e);
			return false;
		}
	}

	return true;
}

shoutbox.prototype.mousedown_handler = function(e)
{
	//e = ipsclass.cancel_bubble(e, true);
	if (shoutbox.shout_history_displayed == true)
	{
		try
		{
			if (e.button == 2 || e.button == 3)
			{
				return;
			}
		}

		catch(x){}

		shoutbox.shout_history_hide();
	}
}

shoutbox.prototype.blur_handler = function(e)
{
	if (shoutbox.shout_history_displayed == true)
	{
		shoutbox.shout_history_hide();
	}
}

shoutbox.prototype.insert_at_cursor = function(o, v)
{
	if (document.selection && is_ie)
	{
		o.focus();
		s = document.selection.createRange();
		s.text = v;
	}
	else if (o.selectionStart || o.selectionStart == '0')
	{
		var s = o.selectionStart;
		var e = o.selectionEnd;

		o.value = o.value.substring(0, s)+v+o.value.substring(e, o.value.length);
	}
	else
	{
		o.value += v;
	}
}

shoutbox.prototype.up_mmenu_index = function(id)
{
	try
	{
		var o = shoutbox.get_obj(id+'_menu');
		o.style.zIndex = '150';
	}

	catch(me){}
}

shoutbox.prototype.read_style = function(o, n)
{
	if (o.style[n])
	{
		return o.style[n];
	}
	else if (o.currentStyle)
	{
		return o.currentStyle[n];
	}
	else if (document.defaultView && document.defaultView.getComputedStyle)
	{
		var s = document.defaultView.getComputedStyle(o, null);
		return s.getPropertyValue(n);
	}
	else
	{
		return null;
	}
}

shoutbox.prototype.truebody = function()
{
	return (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
}

shoutbox.prototype.get_obj = function(id, f)
{
	shoutbox.load_obj(id, f);
	return shoutbox.objs[id];
}

shoutbox.prototype.load_obj = function(id, f)
{
	f = (f == false) ? false : true;
	if (shoutbox.objs[id] == null || shoutbox.objs[id] == '' || f == true)
	{
		shoutbox.objs[id] = my_getbyid(id);
	}
}

shoutbox.prototype.center_obj = function(o, p, is)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (!o)
	{
		return false;
	}

	is = (is) ? true : false;

	var sx = self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft)   || document.body.scrollLeft;
	var sy = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop)    || document.body.scrollTop;
	var dw = self.innerWidth  || (document.documentElement && document.documentElement.clientWidth)  || document.body.clientWidth;
	var dh = self.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight;

	if (p)
	{
		dw = p.offsetWidth;
		dh = p.offsetHeight;
	}

	var ew = o.offsetWidth;
	var eh = o.offsetHeight;
	var x  = (is) ? Math.round(dw/2)-(ew/2) : Math.round(dw/2)-(ew/2)+sx;
	var y  = (is) ? Math.round(dh/2)-(eh/2) : Math.round(dh/2)-(eh/2)+sy;

	o.style.left = x+'px';
	o.style.top  = y+'px';
}

shoutbox.prototype.update_js_prefs = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.my_id)
	{
		return false;
	}
	
	// Update Refresh button
	my_getbyid('shoutbox-refresh-button').style.display = (shoutbox.my_prefs['display_refresh_button'] == 1) ? '' : 'none';
	
	shoutbox.enable_cmds = (shoutbox.my_prefs['enable_quick_commands'] == 1) ? true : false;
}

shoutbox.prototype.new_ajax = function(id, t, u, f, p)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	shoutbox.ajax_objs[id] = null;
	shoutbox.ajax_objs[id] = new ajax_request();
	shoutbox.ajax_objs[id].onreadystatechange(function(){f(id)});

	if (t == 'get')
	{
		shoutbox.ajax_objs[id].process(u, 'GET');
	}
	else if (t == 'post')
	{
		shoutbox.ajax_objs[id].process(u, 'POST', shoutbox.ajax_objs[id].format_for_post(p));
	}
}

shoutbox.prototype.resize_shoutbox = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox.global_on)
	{
		return false;
	}

	var w = 0;
	var o = shoutbox.get_obj('shoutbox-wrapper');

	if (typeof(parent.window.innerWidth) == 'number')
	{
		w = parent.window.innerWidth;
	}
	else if (parent.document.documentElement && parent.document.documentElement.clientWidth)
	{
		w = parent.document.documentElement.clientWidth;
	}
	else if (parent.document.body && parent.document.body.clientWidth)
	{
		w = parent.document.body.clientWidth;
	}

	if (o && w < 1400)
	{
		o.style.width = '100%';
	}
}

shoutbox.prototype.get_offset_left = function(o, p)
{
	var l = 0;
	if (o.offsetParent)
	{
		while (o.offsetParent)
		{
			if (p != null && o == p)
			{
				break;
			}

			l += o.offsetLeft;
			o = o.offsetParent;
		}
	}
	else if (o.x)
	{
		l += o.x;
	}

	return l;
}

shoutbox.prototype.get_offset_top = function(o, p)
{
	var t = 0;
	if (o.offsetParent)
	{
		while (o.offsetParent)
		{
			if (p != null && o == p)
			{
				break;
			}

			t += o.offsetTop;
			o = o.offsetParent;
		}
	}
	else if (o.y)
	{
		t += o.y;
	}

	return t;
}

shoutbox.prototype.is_inactive = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox._inactive)
	{
		return true;
	}

	var a = shoutbox.get_timestamp();
	var b = shoutbox.last_active;
	var c = parseInt(a-b);
	var d = (c/60)*shoutbox.time_minute;
	var e = shoutbox.inactive_timeout*shoutbox.time_minute;
	
	if (d >= e)
	{
		shoutbox._inactive = true;
		shoutbox.display_inactive_prompt();
		
		return true;
	}
	else
	{
		shoutbox._inactive = false;
		return false;
	}
}

shoutbox.prototype.process_inactive_prompt = function(refresh)
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (this.blur)
	{
		this.blur();
	}

	shoutbox.hide_inactive_prompt();
	
	// Reset inactivity - Beta 2
	shoutbox.last_active = shoutbox.get_timestamp();
	shoutbox._inactive   = false;
	
	// Beta 2: refresh shouts after inactivity 
	// Beta 3: refresh only if we are not submitting a new shout
	refresh = (refresh == true) ? true : false;
	
	if (!refresh)
	{
		shoutbox.refresh_shouts();
	}
}

shoutbox.prototype.display_inactive_prompt = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	if (shoutbox.iprompt_lded)
	{
		return false;
	}

	try
	{
		if (shoutbox.popup_open)
		{
			shoutbox.popup_dialog_hide();
		}

		if (!shoutbox.global_on)
		{
			shoutbox.display_shadow_bg();
		}

		var o = shoutbox.get_obj('shoutbox-inactive-prompt');
		o.style.display = '';

		if (!shoutbox.global_on)
		{
			o.style.zIndex = parseInt(shoutbox.read_style(shoutbox.get_obj('shoutbox-shadow-bg'), 'zIndex'))+1;
		}

		var t = shoutbox.get_obj('shoutbox-inactive-timeout');
		t.innerHTML = shoutbox.inactive_timeout;

		if (shoutbox.global_on)
		{
			shoutbox.center_obj(o, o.parentNode, true);
			var o = shoutbox.get_obj('shoutbox-shouts');
			o.style.display = 'none';
		}
		else
		{
			shoutbox.center_obj(o);
		}

		shoutbox.iprompt_lded = true;
	}

	catch(me){}
}

shoutbox.prototype.hide_inactive_prompt = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}

	try
	{
		if (shoutbox.global_on)
		{
			var o = shoutbox.get_obj('shoutbox-shouts');
			o.style.display = 'block';
		}
		else
		{
			shoutbox.hide_shadow_bg();
		}

		var o = shoutbox.get_obj('shoutbox-inactive-prompt');
		o.style.display = 'none';

		shoutbox.iprompt_lded = false;
	}

	catch(me){}
}

shoutbox.prototype.display_shadow_bg = function(x)
{
	try
	{
		var p = shoutbox.get_page_size();
		var o = shoutbox.get_obj('shoutbox-shadow-bg');
		o.style.display = '';
		o.style.height  = p[1]+'px';

		if (!isNaN(x))
		{
			o.style.opacity = x/10;
			o.style.filter  = 'alpha(opacity='+(x*10)+')';

			if (is_moz)
			{
				var s = o.getAttribute('style');
				if (s.match(new RegExp("-moz-opacity", 'ig')))
				{
					s = s.replace(new RegExp("-moz-opacity:(\d+)(;?)", 'ig'), "-moz-opacity:"+(x/10));
				}
				else
				{
					if (s != '')
					{
						s += ';';
					}

					s += "-moz-opacity:"+(x/10);
				}

				o.setAttribute('style', s);
			}
		}
	}

	catch(me){}
}

shoutbox.prototype.hide_shadow_bg = function()
{
	try
	{
		var o = shoutbox.get_obj('shoutbox-shadow-bg');
		o.style.display = 'none';
	}

	catch(me){}
}

shoutbox.prototype.resize_shadow_bg = function(x)
{
	try
	{
		var p = shoutbox.get_page_size();
		var o = shoutbox.get_obj('shoutbox-shadow-bg');

		o.style.height = p[1]+'px';
	}

	catch(me){}
}

shoutbox.prototype.get_page_size = function()
{
	var x;
	var y;
	var ww;
	var wh;
	var pw;
	var ph;
	
	if (window.innerHeight && window.scrollMaxY)
	{
		x = document.body.scrollWidth;
		y = window.innerHeight+window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	
	if (self.innerHeight)
	{
		ww = self.innerWidth;
		wh = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		ww = document.documentElement.clientWidth;
		wh = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		ww = document.body.clientWidth;
		wh = document.body.clientHeight;
	}
	
	pw = x;
	ph = y;
	
	if (y < wh)
	{
		ph = wh;
	}
	
	if (x < ww)
	{	
		pw = ww;
	}
	
	return new Array(pw, ph, ww, wh);
}

shoutbox.prototype.initiate = function()
{
	if (shoutbox.can_use && !shoutbox.global_on)
	{
		var o = shoutbox.get_obj('rte-toggle-side-panel-button');
		var b = shoutbox.get_obj('shoutbox-submit-data');
		var d = b.innerHTML;
		var p = o.parentNode;
		
		b.parentNode.removeChild(b);
		p.innerHTML += d;
	}
	
	try
	{
		var o = shoutbox.get_obj(shoutbox.editor_id+'_cmd_switcheditor');
		if (o)
		{
			shoutbox.add_event(o, 'click', shoutbox.editor_switch);
		}
	}
	
	catch(me){}
	
	if (shoutbox.can_use)
	{
		var bts =
		[
			['shoutbox-submit-button' , shoutbox.submit_shout],
			['shoutbox-clear-button'  , shoutbox.clear_shout],
			['shoutbox-refresh-button', shoutbox.refresh_shouts],
			['shoutbox-myprefs-button', shoutbox.load_my_prefs],
			['shoutbox-smilies-button', shoutbox.popup_smilies],
			['shoutbox-bbcode-button' , shoutbox.popup_bbcode]
		];
		
		for (var x=0; x<bts.length; x++)
		{
			try
			{
				var o = shoutbox.get_obj(bts[x][0]);
				shoutbox.add_event(o, 'click', bts[x][1]);
			}
			
			catch(me){}
		}
	}
	else
	{
		shoutbox.my_id = 0;
		shoutbox.hide_refresh = 0;
		shoutbox.view_archive = 0;
	}
	
	if (!shoutbox.my_id && shoutbox.can_use)
	{
		my_getbyid('shoutbox-myprefs-button').style.display = 'none';
	}
	
	if (shoutbox.global_on)
	{
		shoutbox.shout_obj = shoutbox.get_obj('shoutbox-global-shout', true);
	}
	else
	{
		if (shoutbox.can_use && !IPS_editor[shoutbox.editor_id].is_rte)
		{
			shoutbox.shout_obj = shoutbox.get_obj(shoutbox.editor_id+'_textarea');
		}
	}
	
	shoutbox_loaded = true;
	
	if (shoutbox.global_on)
	{
		shoutbox.init_global_resize();
	}
	else
	{
		shoutbox.init_shouts_resize();
	}
	
	shoutbox.last_active = shoutbox.get_timestamp();
	
	shoutbox.resize_shoutbox();
	shoutbox.init_events();
	
	/**
	* 1.0.0 Final
	* Update shouts view (class, scroll, etc)
	*/
	shoutbox.update_js_prefs();
	shoutbox.rewrite_shout_classes();
	shoutbox.get_last_data();
	shoutbox.shouts_scroll_bottom();
	
	if (!shoutbox.global_on)
	{
		shoutbox.new_ajax('members', 'get', shoutbox.base_url+'type=members&ids=first-load', shoutbox.load_ajax_members);
		try
		{
			shoutbox.scroll_shoutbox_top();
		}
		catch(e){}
	}
	else
	{
		// Global shoutbox is hidden?
		if(my_getbyid('fo_shoutbox-global').style.display == 'none')
		{
			// Block refresh
			return;
		}
	}
	
	/**
	* 1.0.0 Final
	* Set timer because we already
	* load shouts on display
	*/
	shoutbox.reload_shouts(false);
}

/**
* Beta 2
* Show global shoutbox & refresh shouts
*/
shoutbox.prototype.show = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.global_on)
	{
		return false;
	}
	
	togglecategory('shoutbox-global', 0);
	if (!shoutbox._inactive)
	{
		shoutbox.refresh_shouts();
	}
}

/**
* Beta 2
* Hide global shoutbox & stop refresh
*/
shoutbox.prototype.hide = function()
{
	if (!shoutbox_loaded)
	{
		return false;
	}
	
	if (!shoutbox.global_on)
	{
		return false;
	}
	
	togglecategory('shoutbox-global', 1);
	clearTimeout(shoutbox.timeout_timer);
}

function start_shoutbox()
{
	try
	{
		shoutbox = new shoutbox;
	}
	
	catch(e)
	{
		setTimeout("start_shoutbox()", 50);
	}
}

start_shoutbox();

function getElementsByClassName(c, t, e)
{
	t = t || '*';
	e = e || document;

	var x = e.getElementsByTagName(t);
	if (!c.length && t == '*' && e.all)
	{
		x = e.all;
	}

	var a = new Array();
	var d = (c.indexOf('|') != -1) ? '|' : ' ';
	var z = c.split(d);    

	for (var i=0, j=x.length; i<j; i++)
	{                         
		var ac = x[i].className.split(' ');   
		if (d == ' ' && z.length > ac.length)
		{
			continue;
		}

		var y = 0;
		cloop:
			for (var k=0, l=ac.length; k<l; k++)
			{
				for (var m=0, n=z.length; m<n; m++)
				{
					if (z[m] == ac[k])
					{
						y++;
					}

					if ((d == '|' && y == 1) || (d == ' ' && y == z.length))
					{
						a.push(x[i]); 
						break cloop;
					}
				}
			}
	}

	return a; 
}

Array.prototype.push = function(v)
{
	this[this.length] = v;
}

var Resize =
{
	obj     : null,
	objloop : null,
	int     : null,

	init : function(o, oRoot, ho, wo, minX, maxX, minY, maxY)
	{
		o.onmousedown = Resize.start;
		o.hmode       = true;
		o.vmode       = true;
		o.root        = (oRoot && oRoot != null) ? oRoot : o;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX = (typeof minX != 'undefined') ? minX : null;
		o.minY = (typeof minY != 'undefined') ? minY : null;
		o.maxX = (typeof maxX != 'undefined') ? maxX : null;
		o.maxY = (typeof maxY != 'undefined') ? maxY : null;

		o.h_only = false;
		o.w_only = false;

		o.root.Resizing = new Function();

		ho = (ho == true) ? true : false;
		wo = (wo == true) ? true : false;

		if (ho == true)
		{
			o.h_only = true;
		}
		else if (wo == true)
		{
			o.w_only = true;
		}
	},

	start : function(e)
	{
		var o = Resize.obj = Resize.objloop = this;
		e     = Resize.fixE(e);
		var y = parseInt((o.vmode) ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt((o.hmode) ? o.root.style.left : o.root.style.right );

		o.lastMouseX = o.startMouseX = e.clientX;
		o.lastMouseY = o.startMouseY = e.clientY;

		var obj = Resize.data();
		var rec = new shoutbox.rect(obj.x, obj.y, obj.w, obj.h);
		o.oh    = rec.h;
		o.ow    = rec.w;

		if (o.hmode)
		{
			if (o.minX != null) o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null) o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		}
		else
		{
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode)
		{
			if (o.minY != null) o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null) o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		}
		else
		{
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove = Resize.resize;
		document.onmouseup   = Resize.end;

		return false;
	},

	resize : function(e)
	{
		e     = Resize.fixE(e);
		var o = Resize.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y   = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x   = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var h   = parseInt(o.root.offsetHeight);
		var t   = (document.all) ? shoutbox.truebody().scrollTop : window.pageYOffset;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		var rec = Resize.data();
		if (Resize.obj.h_only == true)
		{
			ajh     = ey-o.startMouseY;
			rec.h   = o.oh+ajh;

			if (!isNaN(o.root.min_height) && o.root.min_height > 0)
			{
				if (rec.h < o.root.min_height)
				{
					rec.h = o.root.min_height;
				}
			}

			rec.ho = true;
			if (ey >= 0 && ey <= 3)
			{
				Resize.int = setInterval(Resize.resizeloop, 1);
				shoutbox.scroll_page_up();
			}
			else
			{
				if (Resize.int)
				{
					clearInterval(Resize.int);
				}
			}

			Resize.obj.root.style['height'] = rec.h+'px';
		}
		else if (Resize.obj.w_only == true)
		{
			ajw     = ex-o.startMouseX;
			rec.w   = o.ow+ajw;

			if (!isNaN(o.root.min_width) && o.root.min_width > 0)
			{
				if (rec.w < o.root.min_width)
				{
					rec.w = o.root.min_width;
				}
			}

			rec.wo = true;
			if (!isNaN(o.root.max_width) && o.root.max_width > 0)
			{
				if (rec.w > o.root.max_width)
				{
					rec.w = o.root.max_width;
				}
			}

			Resize.obj.root.style['width'] = rec.w+'px';
		}
 
		Resize.obj.lastMouseX	        = ex;
		Resize.obj.lastMouseY	        = ey;
		Resize.obj.root.Resizing(rec);

		return false;
	},

	resizeloop : function(e)
	{
		Resize.obj = Resize.obj_loop;
		Resize.resize(e);
	},

	end : function(e)
	{
		document.onmousemove = null;
		document.onmouseup   = null;

		Resize.obj.root.Resize_end(Resize.data());

		Resize.obj     = null;
		Resize.objloop = null;

		if (Resize.int)
		{
			clearInterval(Resize.int);
		}
	},

	data : function(e)
	{
		var oo = Resize.obj.root;
		var xx = Resize.style(oo, 'left');
		var yy = Resize.style(oo, 'top');
		var ww = Resize.style(oo, 'width');
		var hh = Resize.style(oo, 'height');

		if (hh <= 0)
		{
			hh = oo.offsetHeight;
		}

		if (ww <= 0)
		{
			ww = oo.offsetWidth;
		}

		return new shoutbox.rect(xx, yy, ww, hh);
	},

	style : function(o, n)
	{
		if (!o)
		{
			return 0;
		}

		if (!o.style)
		{
			return 0;
		}

		var t;
		var s = o.style;

		try
		{
			eval("t = parseInt(s."+n+", 10);");
		}

		catch(e)
		{
			return 0;
		}

		if (isNaN(t))
		{
			t=0;
		}

		return t;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
}
