
function HTMLHelper_getTextArea(){
  ta = document.getElementById("HTMLHelperTextArea");
  if(ta==null)
    ta = window.parent.document.getElementById("HTMLHelperTextArea");
  return ta;
}

function HTMLHelper_addKey(){
  ta = HTMLHelper_getTextArea();
  //IE support
  if(document.selection){
    ta.focus();
    sel = document.selection.createRange();
    sel.text = "HTMLHELPERREPLACE";
  }
  //MOZILLA/NETSCAPE support
  else if(ta.selectionStart || ta.selectionStart == '0'){
    var startPos = ta.selectionStart;
    var endPos = ta.selectionEnd;
    ta.value = ta.value.substring(0,startPos) + "HTMLHELPERREPLACE" + ta.value.substring(endPos,ta.value.length);
  }
  else
    ta.value += HTMLHelperKey;
}

function HTMLHelper_replaceKey(txt){
  ta = HTMLHelper_getTextArea();
  var tmp = ta.value.replace(/HTMLHELPERREPLACE/,txt);
  ta.value = tmp;
  ta.focus();
}

function HTMLHelper_addText(txt){
  HTMLHelper_addKey();
  HTMLHelper_replaceKey(txt);
  return false;
}

function HTMLHelper_addBold(){
  var a;
  HTMLHelper_addKey();
  a = prompt("Fett-Text","");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<b>"+a+"</b>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addItalic(){
  var a;
  HTMLHelper_addKey();
  a = prompt("Kursiv-Text","");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<i>"+a+"</i>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addUnderline(){
  var a;
  HTMLHelper_addKey();
  a = prompt("Unterstrichener Text","");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<u>"+a+"</u>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addCenter(){
  var a;
  HTMLHelper_addKey();
  a = prompt("Zentrierter-Text","");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<center>"+a+"</center>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addHr(){
  HTMLHelper_addKey();
  HTMLHelper_replaceKey("<hr>");
}

function HTMLHelper_addPicture(){
  var a,b;
  HTMLHelper_addKey();
  a = prompt("Bild-URL","http://");
  b = prompt("Link-URL","http://");
  if(a!=null && a!=""){
    if(b=="http://" || b=="" || b==null)
      HTMLHelper_replaceKey("<center><img src=\""+a+"\"></center>");
    else
      HTMLHelper_replaceKey("<center><a href=\""+b+"\"><img src=\""+a+"\"></a></center>");
  }
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addLink(){
  var a,b;
  HTMLHelper_addKey();
  b = prompt("Titel/Text/Bild des Links:","");
  a = prompt("URL des Links:","http://");
  if(a!=null && b!=null && a!="" && b!="")
    HTMLHelper_replaceKey("<a href=\""+a+"\">"+b+"</a>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addEmail(){
  var a,b;
  HTMLHelper_addKey();
  a = prompt("Email-Adresse","");
  b = prompt("Titel der Email-Adresse:","");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<a href=\"mailto:"+a+"\">"+b+"</a>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addYouTube(){
  var a,b;
  HTMLHelper_addKey();
  a = prompt("YouTube Key","");
  if(a!=null && a!="")
  //HTMLHelper_replaceKey("<object width=\"640\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + a + "\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/" + a + "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"640\" height=\"385\"></embed></object>");
    HTMLHelper_replaceKey("<object width=\"640\" height=\"385\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + a + "\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/" + a + "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"640\" height=\"385\"></embed></object>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addButtonLink(){
  var a,b;
  HTMLHelper_addKey();
  a = prompt("Text","");
  b = prompt("Link","http://");
  if(a!=null && a!="" && b!=null && b!="http://" && b!="")
    HTMLHelper_replaceKey("<span class=\"buttonlink\"><a class=\"bold font20 nodeco\" href=\"" + b + "\">" + a + "</a></span>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addFontFamily(fam){
  var a;
  HTMLHelper_addKey();
  a = prompt("Text","Platzhalter");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<span style=\"font-family: "+fam+";\">"+a+"</span>");
  else
    HTMLHelper_replaceKey("");
}

function HTMLHelper_addFont(fsize){
  var a;
  HTMLHelper_addKey();
  a = prompt("Schriftgr&ouml;&szlig;e "+fsize,"");
  if(a!=null && a!="")
    HTMLHelper_replaceKey("<span style=\"font-size: "+fsize+"pt;\">"+a+"</span>");
  else
    HTMLHelper_replaceKey("");
}

