function addsmile( id, content )
{
	var ar = document.getElementById(id);

	content = ' ' + content + ' ';
	
	/* IE */
	if (document.selection) {
		ar.focus();
		cursor = document.selection.createRange();
		cursor.text = content;
		
	} else if (ar.selectionStart || ar.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
		var startPos  = ar.selectionStart;
		var endPos    = ar.selectionEnd;
		var body      = ar.value;
		ar.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
		
	} else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
		ar.value += content;
	}
}

function addbbcode( id, type )
{
	var ar = document.getElementById(id);

	var content = ' [' + type + ']' + '[/' + type + ']';
	
	/* IE */
	if (document.selection) {
		ar.focus();
		cursor = document.selection.createRange();
		cursor.text = '[' + type + ']' + cursor.text + '[/' + type + ']';
		
	} else if (ar.selectionStart || ar.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
		var startPos  = ar.selectionStart;
		var endPos    = ar.selectionEnd;
		var body      = ar.value;
		ar.value = body.substring(0, startPos) + '[' + type + ']' + body.substring(startPos, endPos) + '[/' + type + ']' + body.substring(endPos, body.length);
		
	} else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
		ar.value += content;
	}
}

function uploading(form) {
	var uploading = false;
	var input = $(form).getElements("input");
	for( var i = 0; i < input.length; i++ ) {
		if( input[i].type && input[i].type == "file" ) {
			if( input[i].value != "" ) uploading = true;
		}
	}
	
	if( uploading )
	{
		setTimeout(function() {
			var el = $("uploading");
			if( el ) {
				el.setStyle("display", "block");
				el.setStyle("left", ($(window).getSize().x/2) - 220);
				el.setStyle("top", ($(window).getSize().y/2) - 220 + ($(window).getScrollSize().y/2));
				
				var img = el.getElement('img');
				img.setProperty('src', img.getProperty('src') + '?');
			}
		}, 10);
	}
}
