var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput()
{
	if(currentlyActiveInputRef){
		currentlyActiveInputRef.className = currentlyActiveInputClassName;
	}
	currentlyActiveInputClassName = this.className;
	this.className = 'inputHighlighted';
	currentlyActiveInputRef = this;
	
	
}

function blurActiveInput()
{
	this.className = currentlyActiveInputClassName;
	
	
}


function initInputHighlightScript()
{
	var tags = ['INPUT','TEXTAREA'];
	
	for(tagCounter=0;tagCounter<tags.length;tagCounter++){
		var inputs = document.getElementsByTagName(tags[tagCounter]);
		for(var no=0;no<inputs.length;no++){
			if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;
			
			if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && (inputs[no].type.toLowerCase()=='text' || inputs[no].type.toLowerCase()=='password' || inputs[no].type.toLowerCase()=='reset' || inputs[no].type.toLowerCase()=='submit'))){
				inputs[no].onfocus = highlightActiveInput;
				inputs[no].onblur = blurActiveInput;
			}
		}
	}
}
function checkel(which){
  if (which.style&&intended.test(which.tagName)){
    if (ns6&&eventobj.nodeType==3)
      eventobj=eventobj.parentNode.parentNode
  return true
}
else
  return false
}
function highlight(e){
  eventobj=ns6? e.target : event.srcElement
  if (previous!=''){
    if (checkel(previous))
      previous.style.backgroundColor=''
    previous=eventobj
    if (checkel(eventobj))
      eventobj.style.backgroundColor=highlightcolor
}
else{
  if (checkel(eventobj))
    eventobj.style.backgroundColor=highlightcolor
  previous=eventobj
  }
}
function newcontent(code) {
	document.Formular.contentText.value += code;
	document.Formular.contentText.focus();
}

function fieldFocus(form,field) {
	eval('document.'+form+'.'+field+'.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();
}
