function tyCheck(form,tmatch) {
	for(i=0;i<form.length;i++)
		if(form.elements[i].name.match(tmatch))
			form.elements[i].checked=true;
}
function tyUnCheck(form,tmatch) {
	for(i=0;i<form.length;i++)
		if(form.elements[i].name.match(tmatch))
			form.elements[i].checked=false;
}

function tyFormOptions() {
	elements=arguments[0]?arguments[0]:this.options;
	for(var i=0;i<elements.length;i++) {
		if(elements[i].value && document.getElementById(elements[i].value)!=null) {
			if(elements[i].checked || elements[i].selected)
				document.getElementById(elements[i].value).style.display='block';
			else
				document.getElementById(elements[i].value).style.display='none';
		}
	//alert(document.getElementsByName(elements[i].value));
		else if(elements[i].value && document.getElementsByName(elements[i].value).length>0) {
			for(section in document.getElementsByName(elements[i].value)) {
				if(elements[i].checked || elements[i].selected) {
					section.style.display='block';
				}
				else
					section.style.display='none';
			}
		}
	}
}

// calendar functions

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  cal.callCloseHandler();
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format) {
  var el = document.getElementById(id);
  if (calendar != null) {
    // we already have some calendar created
    calendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(false, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    calendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  calendar.setDateFormat(format);    // set the specified date format
  calendar.parseDate(el.value);      // try to parse the text in field
  calendar.sel = el;                 // inform it what input field we use
  calendar.showAtElement(el);        // show the calendar below it

  return false;
}

function getLeft(l) {
	if (l.offsetParent) return (l.offsetLeft + getLeft(l.offsetParent));
	else return (l.offsetLeft);
}

function getTop(l) {
	if (l.offsetParent) return (l.offsetTop + getTop(l.offsetParent));
	else return (l.offsetTop);
}

var i;
function windowOpen(url,para) {
	i++;
	if(!para)	para='width=500,height=400,dependent=yes,status=no,resizable=yes';
	window.open(url,'tyo'+i,para);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
          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=MM_findObj(n,d.layers[i].document);
          if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v4.32
  //Copyright 1998 Macromedia, Inc. All rights reserved.
  var i,j,s,aLayer,retVal,curDrag=null,curLeft,curTop,OP=window.opera;
  var d=document,IE=(d.all),NS4=d.layers;NS6=(!IE&&d.getElementById&&!OP),NS=(NS4||NS6);
  if (!IE&&!NS) return false;
	retVal = true; if(!OP&&IE&&event)event.returnValue=true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = MM_findObj(objName); if (!curDrag) return false;
    if (!d.allLayers) { d.allLayers = new Array();
      with (d) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
        for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
          with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
      } else {
       if (NS6) { var all = getElementsByTagName("span");
          for (i=0;i<all.length;i++) {s=all[i].style;if(s&&(s.position||s.pixelTop))allLayers[allLayers.length]=all[i]}
          all = getElementsByTagName("div");}
        for (i=0;i<all.length;i++) {s=all[i].style;if(s&&(s.position||s.pixelTop))allLayers[allLayers.length]=all[i]}
    } }
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
		curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
    if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
    curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
    if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    d.onmousedown = MM_dragLayer; d.onmouseup = MM_dragLayer;
    if(NS)d.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent=((NS)?objName.type:event.type);
    if (theEvent=='mousedown') {
      var mouseX=(NS)?objName.pageX:((OP)?event.x+pageXOffset:event.clientX+d.body.scrollLeft);
      var mouseY=(NS)?objName.pageY:((OP)?event.y+pageYOffset:event.clientY+d.body.scrollTop);
      var maxDragZ=null; d.MM_maxZ = 0;
      for (i=0; i<d.allLayers.length; i++) { aLayer = d.allLayers[i];
        var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
        if (aLayerZ > d.MM_maxZ) d.MM_maxZ = aLayerZ;
        var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (!NS4) { parentLayer = (NS6)?aLayer.parentNode:aLayer.parentElement;
            while (parentLayer != null && (parentLayer.style.position || OP)) {
              parentL += parseInt(parentLayer.offsetLeft); parentT += parseInt(parentLayer.offsetTop);
              parentLayer = (NS6)?parentLayer.parentNode:parentLayer.parentElement;
          } }
          var tmpX=mouseX-(((NS4)?pageX:((NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
          var tmpY=mouseY-(((NS4)?pageY:((NS6)?parseInt(style.top):style.pixelTop) +parentT)+MM_hTop);
          if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS4)?clip.width :((OP)?style.pixelWidth:offsetWidth));
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.height:((OP)?style.pixelHeight:offsetHeight));
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        d.onmousemove = MM_dragLayer; if (NS4) d.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
        curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
        if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        d.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          eval('curDrag.'+((NS4)?'':'style.')+'zIndex=d.MM_maxZ+1');
          if (!curDrag.MM_dropBack) d.MM_maxZ++; }
        retVal = false; if(!NS4&&!NS6) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
			if (d.MM_curDrag) with (d.MM_curDrag) {
        var mouseX = (NS)?objName.pageX :((OP)?event.x+pageXOffset: event.clientX + d.body.scrollLeft);
        var mouseY = (NS)?objName.pageY :((OP)?event.y+pageYOffset: event.clientY + d.body.scrollTop);
        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
        with (Math){
						if (MM_bL!=null)newLeft=max(newLeft,MM_bL);if(MM_bR!=null)newLeft=min(newLeft,MM_bR);
            if (MM_bT!=null)newTop=max(newTop ,MM_bT);if(MM_bB!=null)newTop=min(newTop ,MM_bB);
				}
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS4){
					left = Math.max(newLeft,0);
					top = Math.min(Math.max(newTop,window.scrollY),((window.innerHeight+window.scrollY)-50));
				}else if (NS6){
					style.left = Math.max(newLeft,0)+'px';
					style.top = Math.min(Math.max(newTop,window.scrollY),((window.innerHeight+window.scrollY)-50))+'px';
				}else{
					style.pixelLeft = Math.max(newLeft,0);
					if((document.body.offsetHeight+document.body.scrollTop)>50){
						style.pixelTop=Math.min(Math.max(newTop,document.body.scrollTop),((document.body.offsetHeight+document.body.scrollTop)-50));
					}else{
						style.pixelTop=Math.max(newTop,document.body.scrollTop);
					}
				}

        if (MM_dragJS) eval(MM_dragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      d.onmousemove = null;
      if (NS){d.releaseEvents(Event.MOUSEMOVE);d.captureEvents(Event.MOUSEDOWN);}
			document.onmousemove = getMousePos;
      if (d.MM_curDrag) with (d.MM_curDrag) {
				if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-((NS4)?left:(NS6)?parseInt(style.left):style.pixelLeft),2)+
             Math.pow(MM_targT-((NS4)?top:(NS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol) {
          if (NS4) {left = MM_targL; top = MM_targT;}
          else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      d.MM_curDrag = null;
    }
    if (NS&&!OP) d.routeEvent(objName);
  }

	if(document.getElementById('editMenue')!=null)
		setcookie();

	return retVal;
}

var d=document;
var OP=window.opera?true:false, IE=d.all?true:false, NS4=d.layers?true:false,NS6=(!IE && d.getElementById && !OP),NS=(NS4||NS6);
var tyMouseLeft,tyMouseTop;

function getMousePos(e){
	if(e){
		tyMouseLeft = (NS) ? e.pageX : ((OP) ? event.x + pageXOffset : event.clientX + d.body.scrollLeft);
		tyMouseTop  = (NS) ? e.pageY : ((OP) ? event.y + pageYOffset : event.clientY + d.body.scrollTop);
         }
}

function tyHelp(obj,dx,dy,relative){
	var dx=isNaN(dx)?0:dx;
	var dy=isNaN(dy)?0:dy;
	var relative= (relative==true?true:false);

	tyMouseLeft=isNaN(tyMouseLeft)?0:tyMouseLeft;
	tyMouseTop=isNaN(tyMouseTop)?0:tyMouseTop;

	//Versuch an der mitte des documents auszurichten
	if(relative){
		if(window.innerHeight){
			dx=dx+Math.floor(window.innerWidth/2);
			dy=dy+Math.floor(window.innerHeight/2);
		}else if(document.body.offsetHeight){
			dx=dx+Math.floor(document.body.offsetWidth/2);
			dy=dy+Math.floor(document.body.offsetHeight/2);
		}
	}

	//für die Toolbar
	if(document.getElementById('editMenue')){
		if(obj.substring(0,6)=='tyStyl' || obj.substring(0,6)=='tyFont' || obj.substring(0,6)=='tyTabl'){
			var tb=document.getElementById('editMenue');
			dx=dx-parseInt(tb.style.left);
			dy=dy-parseInt(tb.style.top);
		}
	}



	if(document.getElementById(obj)){
		elem=document.getElementById(obj);

		elem.style.left = (relative?dx:Math.max(tyMouseLeft+dx,0))+'px';
		elem.style.top  = (relative?dy:Math.max(tyMouseTop+dy,0))+'px';

		if(elem.style.display=='none' || elem.style.display=='')
			elem.style.display='block';
		else{
			elem.style.display='none';
		}
	}
}

function tyShowHelp(id,dx,dy,relative) {
	var helpBar='tyHelpBar'+id;
	var helpContainer='tyHelpContent'+id;

	if(document.getElementById(helpBar)==null || document.getElementById(helpContainer)==null)
		return false;

	if(document.getElementById(helpContainer).style.display == "none" || document.getElementById(helpContainer).style.display == "") {

		tyHelp(helpBar,dx,dy,relative);
		tyHelp(helpContainer,dx,dy+20,relative);

		MM_dragLayer(helpBar,'',0,0,0,0,true,false,-1,-1,-1,-1,false,false,0,'',false,'document.getElementById("'+helpContainer.toString()+'").style.zIndex=parseInt(document.getElementById("'+helpBar.toString()+'").style.zIndex);document.getElementById("'+helpContainer.toString()+'").style.left=parseInt(document.getElementById("'+helpBar.toString()+'").style.left)+"px";document.getElementById("'+helpContainer.toString()+'").style.top=parseInt(document.getElementById("'+helpBar.toString()+'").style.top)+20+"px";');
	} else {
		tyHelp(helpBar,dx,dy,relative);
		tyHelp(helpContainer,dx,dy+20,relative);
	}
}

//toolbar

var allowedTag=new Array();
var ixed_pretop=-1;
var preSaveImage="tb_content_save";

// Cookie zur Speicherung der Position der schwebenden Menüleiste
//Position als Array im Cookie speichern
function setcookie(){

	position = new Array();
	position[0];
	position[1];
	if(navigator.appName=="Microsoft Internet Explorer"){
		position[0] = Math.max(parseInt(document.all.editMenue.style.left),0);                //IE
		position[1] = Math.max(parseInt(document.all.editMenue.style.top)-document.body.scrollTop,0);
	}else{
		if(navigator.appVersion.substring(0,1)<5){                //Netscape vor 6
			position[0] = document.editMenue.left;
			position[1] = document.editMenue.top;
		}else{
			position[0] = Math.max(parseInt(document.getElementById("editMenue").style.left),0);
			position[1] = Math.max(parseInt(document.getElementById("editMenue").style.top)-window.scrollY,0);
		}
	}

	document.cookie = "showBar=showTbBarMenu," + showTbBarMenu + "|tyCONpos,"+ position + "; path=/";
}

function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' '){
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0){
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

//Den im Cookie gespeicherten Wert auslesen
function getposition(){
	var wert;
	var cookieString;

	if(document.cookie){
		cookieString = readCookie('showBar');
		if(cookieString) {
			trenn = cookieString.split("|");
			for(i=0;i<trenn.length;i++){
				if(trenn[i].match(/tyCONpos,/)){
					wert=trenn[i].split(",");
				}
			}
		}
	}
	if(wert){
		if(wert[1]<0){
			wert[1]=0;
		}

		if(wert[2]<0){
			wert[2]=0;
		}else{
			if(document.all){
		 		if(wert[2]>document.body.offsetHeight && (document.body.offsetHeight+document.body.scrollTop)>50)
					wert[2]=Math.max(document.body.offsetHeight-55,0);
		 	}else{
			 	if(wert[2]>window.innerHeight)
					wert[2]=Math.max(window.innerHeight-55,0);
		 	}
		}

		if(navigator.appName=="Microsoft Internet Explorer" && document.all.editMenue){
			document.all.editMenue.style.left = wert[1] + "px";
			document.all.editMenue.style.top = wert[2] + "px";
		}else{
			if(navigator.appVersion.substring(0,1)<5 && document.editMenue){
				document.editMenue.left = wert[1];
				document.editMenue.top = wert[2];
			}else{
				document.getElementById("editMenue").style.left = wert[1] + "px";
				document.getElementById("editMenue").style.top = wert[2] + "px";
			}
		}
	}
}

//wechselt display
function toggleDisplay(did,display){
	if(did!='' && document.getElementById(did)!=null){
		if(display){
			document.getElementById(did).style.display=display;
			if(display=="block" && !document.all){
				try{
					document.addEventListener("keypress", keyPressHandler, true);
				}catch(e){}
			}
		}else{
			if(document.getElementById(did).style.display=='none' || document.getElementById(did).style.display==''){
				document.getElementById(did).style.display='block';
				if(!document.all){
					try{
						document.addEventListener("keypress", keyPressHandler, true);
					}catch(e){}
				}
			}else{
				document.getElementById(did).style.display='none';
			}
		}
	}
}

// festpinnen der menueleiste
function ixed_timer() {
	if(ixed_pretop==-1){
		ixed_pretop=0;
	}else{
	 	var ixed_top=ixed_pretop;
		if(document.all){
			ixed_top=document.body.scrollTop;
		}else{
			ixed_top=window.scrollY;
		}

		if(document.all){
			if(document.all.editMenue){
				if(document.body.offsetHeight==0){
					return false;
				}
				if(ixed_top!=ixed_pretop) {
					ixed_dif=0.3*(ixed_top-ixed_pretop);
					if(ixed_dif>0){
						ixed_dif=Math.ceil(ixed_dif);
					}else{
						ixed_dif=Math.floor(ixed_dif);
					}
					document.all.editMenue.style.pixelTop+=ixed_dif;
					ixed_pretop+=ixed_dif;
					if(document.all.editMenue.style.pixelTop<0){
						document.all.editMenue.style.pixelTop=0;
						ixed_pretop=0;
					}
				}
			}
		}else{
			if(document.getElementById('editMenue')){
				if(ixed_top!=ixed_pretop) {
					ixed_dif=0.2*(ixed_top-ixed_pretop);
					if (ixed_dif>0) ixed_dif=Math.ceil(ixed_dif);
					else ixed_dif=Math.floor(ixed_dif);
					document.getElementById('editMenue').style.top=parseInt(document.getElementById('editMenue').style.top)+ixed_dif+'px';
					ixed_pretop+=ixed_dif;
				}
			}
		}
	}
	setTimeout('ixed_timer()',30);
}
setTimeout('ixed_timer()',1000);

//ende toolbar

document.onmousemove = getMousePos;
