/* JavaScript */
var theSelection=false;

var clientPC=navigator.userAgent.toLowerCase();
var clientVer=parseInt(navigator.appVersion);
var is_ie=((clientPC.indexOf("msie")!=-1)&&(clientPC.indexOf("opera")==-1));
var is_nav=((clientPC.indexOf('mozilla')!=-1)&&(clientPC.indexOf('spoofer')==-1)&&(clientPC.indexOf('compatible')==-1)&&(clientPC.indexOf('opera')==-1)&&(clientPC.indexOf('webtv')==-1)&&(clientPC.indexOf('hotjava')==-1));
var is_moz=0;
var is_win=((clientPC.indexOf("win")!=-1)||(clientPC.indexOf("16bit")!=-1));
var is_mac=(clientPC.indexOf("mac")!=-1);

b_hlp="fetterText: [b]Text[/b]";
i_hlp="kursiver Text: [i]Text[/i]";
u_hlp="unterstrichener Text: [u]Text[/u]";
c_hlp="zentrierter Text: [center]Text[/center]";
r_hlp="rechsbündiger Text: [right]Text[/right]";
l_hlp="Aufzählung: [list]Text[/list]";
n_hlp="Numerierung: [list=o]Text[/list]";
a_hlp="Link einfügen: [url]www.domain.at[/url] oder [url]www.domain.at Linktext[/url]";
o_hlp="Schriftfarbe: [color=black]Text[/color]";
s_hlp="Schriftgröße: [size=11]normaler Text[/size]";

function hlp(help,hint){document.forms[0].elements['HinT'+hint].value=eval(help+"_hlp");}
function nohlp(hint){document.forms[0].elements['HinT'+hint].value="Markieren Sie den Text und formatieren Sie dann mit dem passenden Schalter.";}

aTag=new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[center]','[/center]','[right]','[/right]','[list]','[/list]','[list=o]','[/list]','[img]','[/img]','[url]','[/url]');

function fSty(el,bbopen,bbclose){
 var txtarea=document.forms[0].elements[el];
 txtarea.focus();
 theSelection=false;
 if((clientVer>=4) && is_ie && is_win){
  theSelection=document.selection.createRange().text;
  if(!theSelection){
   txtarea.value+=bbopen+bbclose;
   txtarea.focus();
   theSelection='';
   return;
  }
  document.selection.createRange().text=bbopen+theSelection+bbclose;
  txtarea.focus();
  return;
 }else if(txtarea.selectionEnd &&(txtarea.selectionEnd-txtarea.selectionStart>0)){
  mozWrap(txtarea, bbopen, bbclose);
  return;
 }else{
  txtarea.value+=bbopen+bbclose;
  txtarea.focus();
 }
 if(txtarea.createTextRange) txtarea.caretPos=document.selection.createRange().duplicate();
}

function fmt(el,no){
 var txtarea=document.forms[0].elements[el];
 txtarea.focus();
 theSelection=false;
 if((clientVer>=4)&& is_ie && is_win){
  theSelection=document.selection.createRange().text;
  if(theSelection){
   document.selection.createRange().text=aTag[no]+theSelection+aTag[no+1];
   txtarea.focus();
   theSelection='';
   return;
  }
 }else if(txtarea.selectionEnd && (txtarea.selectionEnd-txtarea.selectionStart>0)){
  mozWrap(txtarea,aTag[no],aTag[no+1]);
  return;
 }
 if (txtarea.createTextRange) txtarea.caretPos=document.selection.createRange().duplicate();
}

function mozWrap(txtarea,open,close){
 var selLength=txtarea.textLength; var selStart=txtarea.selectionStart; var selEnd=txtarea.selectionEnd;
 if(selEnd==1 || selEnd==2) selEnd=selLength;
 var s1=(txtarea.value).substring(0,selStart);
 var s2=(txtarea.value).substring(selStart,selEnd)
 var s3=(txtarea.value).substring(selEnd,selLength);
 txtarea.value=s1+open+s2+close+s3;
 return;
}