var qShoutboxDressup = function(currentUserId)
{
	var items = jQuery(".shoutbox-items div.shoutboxitem");
	items.each(function(i)
	{
		var item = jQuery(this);
		var img = jQuery(".bphoto", item);
		var login = jQuery("a.shoutuser", item);
		
		login.mouseover(function()
		{
			var pos = login.position();
			
			img.css("left", pos.left);
			img.css("top", pos.top + login.outerHeight());
			img.show();
		});
		
		login.mouseout(function()
		{
			img.hide();
		});

		if (currentUserId > 0)
		{
			var userId = parseInt((item.attr("id")).substring(1)); // u123 -> 123
			if (userId == currentUserId)
			{
				item.addClass("shighlight");
			}
		}
	});
}

var qShoutboxEdit = function(strings)
{
	var a = jQuery("<img src=\"" + strings.src + "\" class=\"img\" alt=\"\" />");
	
	var items = jQuery(".shoutbox-items div.shighlight");
	
	var ids = "";
	items.each(function(i)
	{
		ids = ids + "." + jQuery("span.kpen", this).attr("name");
	});
	ids = { "ids" : ids.substr(1) };
	
	if (ids.ids != "") {
		
		jQuery.getJSON("/" + strings.proc + "/qshoutbox/checkTimeout", ids, function(r) {
			function inArray(k, j) {
				for (i in k) {
					if (k[i] == j) return true;
				}
			}
			
			items.each(function(i) {
				if (inArray(r, jQuery("span.kpen", this).attr("name"))) {
					var item = this;
					var editing = false;
					var p = jQuery("span.kpen", item);
					var d, f, t, s;

					jQuery('span.message', this).editable('/' + strings.proc + '/qshoutbox/edit', {
						ajaxoptions: {cache: false},
						cssclass  : 'editable',
						type      : 'textarea',
						origtext  : jQuery('span.message', this).text(),
						name      : 'message',
						submitdata: {id: p.attr('name')},
						submit    : strings.submitChanges,
						tooltip   : '',
						width	  :	'202px',
						height	  :	'',
						maxlength : strings.maxlength,
						indicator : '<div class="qsbloader"/>'
					});
					
					var link = a.clone().click(function() {
						jQuery(this).parent().parent().find('span.message').click();
					});
					
					p.html(link);
				}
			});
		});
	}
}