function newcontent(code) {
	document.Formular.contentText.value += code;
	document.Formular.contentText.focus();
}

function format(format) {
	if (format == 'b') ptext="dick.";
	if (format == 'i') ptext="kursiv.";
	if (format == 'u') ptext="unterstrichen.";
	if (format == 'center') ptext="zentriert.";
	if (format == 'big') ptext="gross.";
	if (format == 'small') ptext="klein.";
	text = prompt("Bitte tragen Sie den Text ein, welcher "+ptext+" geschrieben werden soll.","");
	if (text != "" && text != null) {
		code = "<"+format+">"+text+"</"+format+">";
		newcontent(code);
	}
}

function list(format) {
	text = prompt("Tragen Sie bitte die erste Zeile ein.","");
	if (text != "" && text != null) {
		code = "<"+format+">";
		while (text != "" && text != null) {
			code += "<li>"+text+"</li>";
			text = prompt("Tragen Sie bitte die naechste Zeile ein. (andernfalls leer lassen)","");
		}
		code += "</"+format+">";
		newcontent(code);
	}
}

function link() {
	text = prompt("Bitte tragen Sie die Adresse ein.","http://");
	if (text != "" && text != null) {
		code = "<a class=\"content\" href=\""+text+"\" target=\"_blank\">";
		text2 = prompt("Tragen Sie bitte Name oder Beschreibung.","");
		if (text2 == "" || text2 == null) text2 = text;
		code += text2+"</a>";
		newcontent(code);
	}
}

function swapImgRestore() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',+resizable+'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function goLink(mylink) {
   if(mylink == "empty") {
      document.forms[0].reset();
      document.forms[0].elements[0].blur();
      return;
   }
   else {
         top.document.location.href = mylink;
         document.forms[0].reset();
         document.forms[0].elements[0].blur();
        }
   }

function goFrameLink(mylink) {
   if(mylink == "empty") {
      document.forms[0].reset();
      document.forms[0].elements[0].blur();
      return;
   }
   else {
         self.document.location.href = mylink;
         document.forms[0].reset();
         document.forms[0].elements[0].blur();
        }
}

function changePage() {
	setTimeout ("changeP()", 3000);
}

function changeP() {
	parent.location.reload();
}

var _editor_url = "/admin/htmlarea/";
var editor = null;
function initEditor() {
  var tas = document.getElementsByTagName("textarea");

  for(var i = tas.length; i > 0; i--){
  	 editor = new HTMLArea(tas[i-1]);
  	 editor.registerPlugin("TableOperations");
	 editor.config.pageStyle = "@import url(../css/definition.css);";
	 editor.generate();
  	}
  return false;
}

