/* Replacement for German characters in javascript
	Chr	Replacement
	ä	\344
	ö	\366
	ü	\374
	Ä	\304
	Ö	\326
	Ü	\334
	ß	\337
*/

// function for UBB code
if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.userAgent.indexOf("Opera") ==-1)
	ie=true;
else
	ie=false;
var isSelected=false;
var toinsertObj='';

function TagButtons(){
	outputtxt='&nbsp;<input class="wmfc" type="button" value="[B]" onclick="insertTag(\'[B]\',\'[/B]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[I]" onclick="insertTag(\'[I]\',\'[/I]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[IMG]" onclick="insertTag(\'[IMG]\',\'[/IMG]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[URL]" onclick="insertTag(\'[URL]\',\'[/URL]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[LIST]" onclick="insertTag(\'[LIST]\',\'[/LIST]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[*]" onclick="insertTag(\'[*]\',\'\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[QUOTE]" onclick="insertTag(\'[QUOTE]\',\'[/QUOTE]\')"> ';
	outputtxt+='<input class="wmfc" type="button" value="[CODE]" onclick="insertTag(\'[CODE]\',\'[/CODE]\')"><br />';
	document.write(outputtxt);
	outputtxt='';
}

function write_emoticon(e) {
	output='<tr><td class="wmalright">Wie ist der&nbsp;<br />Beitrag gemeint:</td><td><table border="0" cellspacing="0" cellpadding="3"><tr>';
	alt=new Array("Lachen","Traurig / Enttaeuscht","\304rgerlich","Flame / B\366se","Wichtig","Haehhh??","Zwinkernd","Danke!","Info!","Idee!");
	for (i=1;i<=10;i++){
		output=output+'<td wmalcent"><input type="radio" name="em" value="'+i+'"';
		if (e==i)
			output=output+' checked="checked"';
		output=output+' /><br /><img src="'+imgsrc+i+'.gif" hspace="2" alt="'+alt[i-1]+'" /></td>';
	}
	output=output+'<td class="wmalcent"><input type="radio" name="em" value="0"';
	if (e==0)
		output=output+' checked="checked"';
	output=output+' /><br />&nbsp;K.A.</td></tr></table></td></tr>';	
	document.write(output);
}

function markSelection(thistextObj){
	if (toinsertObj!=thistextObj)
		toinsertObj=thistextObj
	if(typeof document.selection != 'undefined')
		thisSelection=document.selection.createRange();
}

function insertTag(tvs,tve){
	if (toinsertObj=='')
		return
	toinsertObj.focus();
	if(typeof document.selection != 'undefined'){
		range_text_length = thisSelection.text.length;
		thisSelection.text = tvs+thisSelection.text+tve;
		if (range_text_length==0)
			thisSelection.move('character', -tve.length);
		thisSelection.select();
	}
	else if(typeof toinsertObj.selectionStart != 'undefined'){
		sec_start = toinsertObj.selectionStart;
		sec_end = toinsertObj.selectionEnd;
		sec_insText = toinsertObj.value.substring(sec_start,sec_end);
		toinsertObj.value = toinsertObj.value.substr(0, sec_start) + tvs + sec_insText + tve + toinsertObj.value.substr(sec_end);
		new_pos=0;
		if (sec_insText.length==0)
			new_pos = sec_start + tvs.length;
		else
			new_pos = sec_start+tvs.length+sec_insText.length+tve.length;
		toinsertObj.selectionStart=new_pos;
		toinsertObj.selectionEnd=new_pos;
	}
	else{
		toinsertObj.value+=tvs + tve;
	}
}

function DoSmilie(addSmile) 
{
	var revisedMessage;
	var currentMessage = document.f1.message.value;
	revisedMessage = currentMessage+addSmile;
	document.f1.message.value=revisedMessage;
	document.f1.message.focus();
}

function chk_len(){
	ev=document.f1.message.value;
	ev=ev.replace(/^\s+/g,'').replace(/\s+$/g,'');
	postlen=ev.length;
	alert('Ihre Nachricht ist '+postlen+' Zeichen lang.');
}

imgsrc='http://f3.webmart.de/i/';
function write_smilies(paid,code){
output='<table class="wmtbl"><tr><td class="wmalright"></td></tr>';
	if(paid && code){
		output=output+'<tr><td class="wmalright"><a href="javascript: DoSmilie(\' :) \');"><img src="'+imgsrc+'1.gif" hspace="5" vspace="3" border="0" alt="Lachen" /></a><a href="javascript: DoSmilie(\' :( \');"><img src="'+imgsrc+'2.gif" hspace="5" vspace="3" border="0" alt="Traurig / Enttäuscht" /></a><a href="javascript: DoSmilie(\' :mad: \');"><img src="'+imgsrc+'4.gif" hspace="5" vspace="3" border="0" alt="Flame / Böse" /></a><br /><a href="javascript: DoSmilie(\' ;) \');"><img src="'+imgsrc+'7.gif" hspace="5" vspace="3" border="0" alt="Zwinkernd" /></a><a href="javascript: DoSmilie(\' :D \');"><img src="'+imgsrc+'11.gif" hspace="5" vspace="3" border="0" alt="Freude" /></a><a href="javascript: DoSmilie(\' :o \');"><img src="'+imgsrc+'12.gif" hspace="5" vspace="3" border="0" alt="Verwundert" /></a></td></tr>';
	}
	else
		output=output+'<tr><td><br /><br /><br /><br /><br /><br /></td></tr>';
	output=output+'<tr><td class="wmalright">';
	if (code){
		output=output+'<a href="http://i.xeu.de/w/f/forumcode.htm" target="_blank">Forum-Code</a><br />'
	}
	output=output+'<a href="javascript:chk_len();">Beitragslänge</a></td></tr></table>';
	document.write(output);
}