function ersetzen( incomming, zuersetzen, durch ) {
	var out = incomming.split( zuersetzen );
	return out.join( durch );
}
function OpenPreview() {
	var thema; var text; var zitat;
	if( document.forms[0].thema.value )
		thema = document.forms[0].thema.value;
	if( document.forms[0].text.value )
		text = ersetzen(document.forms[0].text.value, "\n", "<br>");
	try {
		zitat = ersetzen(document.forms[0].zitattext.value, "\n", "<br>");
	}
	catch( e ) {
		zitat = '';
	}
	openWindow('forum_preview.php?thema=' + thema + '&text=' + text + '&zitattext=' + zitat, 'Vorschau', 'width=400,height=350,scrollbars=yes');
}
function openWindow(theURL,winName,features)
	{
	NewWindow = window.open(theURL,winName,features);
	NewWindow.focus();
	}
function Smilie(Text) {
	tarea = document.forms[0].text;
	if (tarea.createTextRange) { //IE
		tarea.focus();
		document.selection.createRange().duplicate().text = Text;
	}
	else if (document.getElementById && !document.all) { //MOZ
		selEnd = tarea.selectionEnd;
		txtLen = tarea.value.length;
		txtbefore = tarea.value.substring(0,selEnd);
		txtafter =  tarea.value.substring(selEnd, txtLen);
		tarea.value = txtbefore + ' ' + Text + ' ' + txtafter;
	}
	tarea.focus();
}

