// Open a window with the specified url
function openWindow( url ) {
	window.name='main';
	window.open( url, 'popup', 'dependent,resizable,scrollbars,width=460,height=450');
	return false;
}

// Insert smilie at cursor or end -- Naigler
// Adapted from insertAtCaret from http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
//function insert(text) {
//	var textEl = document.post.message;
//	if (textEl.createTextRange && textEl.caretPos) {
//		var caretPos = textEl.caretPos;
//		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
//		textEl.focus();
//	} else {
//		text = ' ' + text;
//		textEl.value  += text;
//		textEl.focus();
//	}
//}

function insert(text) {
	var txtarea = document.post.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

// Store the cursor position -- Naigler
// From http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret (textEl) {
	if (textEl.createTextRange) {
		textEl.caretPos = document.selection.createRange().duplicate();
	}
}