	function ProzessWorker(formname,action,procedure,functionnumber,parameter,formaction,formactionparam,showobjectnavi){
		try
		{
		      document.getElementById("action").value = action;
		      document.getElementById("procedure").value = procedure;
	          document.getElementById("functionnumber").value = functionnumber;
	          
	          if(document.getElementById("parameter").value != '') {
	            if(parameter == 'clear') {
	              document.getElementById("parameter").value = ''
	            } else if(parameter != '') {
	              document.getElementById("parameter").value = parameter;
	            }
	          } else {
	            if(parameter == 'clear') {
	              document.getElementById("parameter").value = '';
	            } else {
	              document.getElementById("parameter").value = parameter;
	            }
	          }
	          
	          document.getElementById("formaction").value = formaction;
	          document.getElementById("formactionparam").value = formactionparam;
	          if(showobjectnavi == true) {
	            document.getElementById("showobjectnavi").value = showobjectnavi;
	          } else {
	            document.getElementById("showobjectnavi").value = '';
	          }
		}
		catch(e)
		{
	          alert("Action konnte nicht gesetzt werden!");	
		}
		document.forms[formname].submit(); 
	}
		
		
	function CloseMessage() {
	  document.getElementById("messages").style.visibility = 'hidden';
	}
	
	// formatiert einen string als waehrung erlaubt kommata und punkte als dezimaltrenner und auch tausendertrenner, wenn der dezimaltrenner ein komma ist
	// ausgaeformat: '5.432,10'
	// Args:
	// input string
	// dec: wenn vorhanden wird tausendertrennpunkt eingefuegt
	
	function formatMoney(input,trenner)
	{
	  var t0,t2,i;
	  var t1=new Array();
	  var retval = 'falsche Eingabe';
	  var filler = ' ';
	  var len = 3;
	
	  if (input.match(',') && input.split('.'))
	  { t0 = input.replace(/\./g,'').split(','); }
	  else if (input.match(','))
	  { t0 = input.split(','); }
	  else
	  { t0 = input.split('.'); }
	
	  if (!t0[0]) { t0[0]=0; }
	  if (!t0[1]) { t0[1]=0; }
	
	  if (isNaN(t0[0]) || isNaN(t0[1]))
	  { return retval; }
	
	  if (t0[1].length>2)
	  {
	    t0[1] = parseFloat(t0[1].substr(0,2)+'.'+t0[1].substr(2))
	    t0[1] = parseInt(Math.round(t0[1]));
	  }
	  else if (t0[1]<10)
	  { t0[1] += '0'; }
	
	  if (t0[0].length>3 && trenner)
	  {
	    for (i=t0[0].length-3;i>=(-(t0[0].length%3+1));i-=3)
	    {
	      if (i>=0) { t2=i; len =3; }
	      else { t2=0; len = t0[0].length%3; } 
	      t1[t1.length] = t0[0].substr(t2,len);
	    }
	    t0[0] = t1.reverse().join('.');
	  }
	  return t0.join(',');
	}
	
	
	// �berpr�ft die m�glichen Eingaben eines Eingabefeldes
	function checkType(e, field, type)
	{
	
	  var key = (window.Event) ? e.which : e.keyCode;
	    
	  if(key == 9 || key == 8 || (key <= 40 && key >=37) || key == 46)
	  {
	    return true;
	  }
	  else
	  {
	    switch(type)
	    {
	      case 1, 2, 6: // JN, Text, Memo
	        return true;
	        break;
	      case 3: // Zahl
	        if((key >= 48 && key <= 57) || (key >= 96 && key <= 105))
	        {
	          return true;
	        }
	        else
	        {
	          return false;
	        }
	        break;
	      case 4: // Nachkommazahl
	        if((key >= 48 && key <= 57) || (key >= 96 && key <= 105))
	        {
	          return true;
	        }
	        else
	        {
	          if(field.value.indexOf(',') == -1 && (key == 188 || key == 110))
	          {
	            return true;
	          }
	          else
	          {
	            return false;
	          }
	        }
	        break;
	      case 5: // Datum
	        if((key >= 48 && key <= 57) || (key >= 96 && key <= 105) || key == 190)
	        {
	          return true;
	        }
	        else
	        {
	          return false;
	        }
	        break;
	    }
	  }
	}
	
	// �berpr�ft ob ein String numerisch ist
	function IsNumeric(sText)
	{
	   var ValidChars = "0123456789.,";
	   var IsNumber=true;
	   var Char;
	
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;
	   
	   }
	
	
	
	
	
	
	// liest und setzt Ort nach einer eingegebene Postleitzahl
	function GetOrtByPLZ(FieldPLZ, FieldOrt)
	{
	  var url = "ajax/AjaxGetOrtByPLZ?PLZ="+FieldPLZ.value;
	  var responseObject = doSimpleXMLHttpRequest(url);
	  responseObject.addCallback(SetOrtByPLZ,FieldPLZ,FieldOrt);	
	}	
	
	function SetOrtByPLZ(FieldPLZ,FieldOrt,resp)
	{
	  var orte =  eval('(' + resp.responseText + ')');
	  if(orte.count == 1)
	  {
	  	FieldPLZ.value = orte.ort[0].plz;
	  	FieldOrt.value = orte.ort[0].ort;
	  }
	  else if(orte.count > 1)
	  {
	    ortselector = window.open("","ortselector","width=450,height=200,resizable=no,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	    ortselector.document.writeln("<html>");
	    ortselector.document.writeln("<head>");
	    ortselector.document.writeln("<style type=\"text/css\" media=\"all\"> @import \"pages/css/dialog.css\";</style>");
	    ortselector.document.writeln("<SCRIPT LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\">");
	    ortselector.document.writeln("  <!--");
	    ortselector.document.writeln("    function setOrt(plz,ort)");
	    ortselector.document.writeln("    {");
		ortselector.document.writeln("		targetitemplz.value = plz;");    
		ortselector.document.writeln("		targetitemort.value = ort;");
		ortselector.document.writeln("		top.close();");
		ortselector.document.writeln("		return false;");
	    ortselector.document.writeln("    }");
	    ortselector.document.writeln("  //-->");
	    ortselector.document.writeln("</SCRIPT>");   
	    ortselector.document.writeln("</head>");
	    ortselector.document.writeln("<body>");
	    ortselector.document.writeln("  <table class=\"list\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">");
	    ortselector.document.writeln("    <thead>");
	    ortselector.document.writeln("      <tr>");
	    ortselector.document.writeln("        <th width=\"100\"/>Ort</th>");
	    ortselector.document.writeln("        <th width=\"100\"/>Zusatz</th>");
	    ortselector.document.writeln("        <th width=\"100\"/>Vorwahl</th>");        
	    ortselector.document.writeln("        <th width=\"200\">Aktionen</th>");
	    ortselector.document.writeln("      </tr>");
	    ortselector.document.writeln("    </thead>");   
	    ortselector.document.writeln("    <tbody>");
	    for(i=0;i < orte.count;i++)
	    {
	      ortselector.document.writeln("      <tr>");
	      ortselector.document.writeln("        <td>"+orte.ort[i].ort+"</td>");
	      ortselector.document.writeln("        <td>"+orte.ort[i].zusatz+"</td>");      
	      ortselector.document.writeln("        <td>"+orte.ort[i].vorwahl+"</td>");      
	      ortselector.document.writeln("        <td><a href=\"JavaScript:setOrt('"+orte.ort[i].plz+"','"+orte.ort[i].ort+"');\" class=\"positive\">&uuml;bernehmen</a>&nbsp;</td>");
	      ortselector.document.writeln("      </tr>");
	    }
	    ortselector.document.writeln("    </tbody> ");
	    ortselector.document.writeln("  </table>");
	    ortselector.document.writeln("</body>");
	    ortselector.document.writeln("</html>");
	    ortselector.document.close();
	    ortselector.targetitemplz = FieldPLZ;
	    ortselector.targetitemort = FieldOrt;    
	  }
	}	
	
	
	
	// Suchroutine
	function SearchDialog(SearchId,SearchType)
	{
	  search = window.open("SearchDialog.action?Id="+SearchId+"&Type="+SearchType,"search","width=750,height=400,resizable=no,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	}
	
	
	
	// Divs ein / ausblenden
	function show_objekt(objekt)
	{
	    var bShowing = eval('document.getElementById("'+objekt+'").style.display');
	    if(objekt != "IDBANTR")
	    {
	      //var bShowing2 = eval('document.getElementById("I'+objekt+'").style.display');
	      var bShowing2 = "none";
	    }
	    else
	    {
	      bShowing2 = "none";
	    }
	    if((bShowing == "none") && bShowing2 == "none")
	    {
	      eval('document.getElementById("'+objekt+'").style.display = ""');
	    }
	    else
	    {
	      eval('document.getElementById("'+objekt+'").style.display = "none"');
	      if(objekt != "IDBANTR")
	      {
	        //eval('document.all.I'+objekt+'.style.display = "none"');
	      }
	    }
	}
	
	function toggle_objekt(objekt)
	{
	
	    //var bShowing = eval('document.all.'+objekt+'.style.display');
	    if (bShowing == "none")
	    {
	      eval('document.getElementById("'+objekt+'").style.display = ""');
	
	      if(objekt.substr(0,3) == "IID")
	      {
	        var test = eval('document.getElementById("'+objekt.substr(1,objekt.length-1)+'").style.display');
	        if (test == "")
	        {
	          eval('document.getElementById("'+objekt.substr(1,objekt.length-1)+'").style.display = "none"');
	        }
	      }
	      if(objekt.substr(0,2) == "ID")
	      {
	        var test = eval('document.getElementById("I'+objekt+'").style.display');
	        if (test == "")
	        {
	          eval('document.getElementById("I'+objekt+'").style.display = "none"');
	        }
	      }
	    }
	}
	
	
	
	function setPointer(theRow, thePointerColor)
	{
	  if (thePointerColor == '' || typeof(theRow.style) == 'undefined')
	  {
	    return false;
	  }
	  if (typeof(document.getElementsByTagName) != 'undefined')
	  {
	    var theCells = theRow.getElementsByTagName('td');
	  }
	  else if (typeof(theRow.cells) != 'undefined')
	  {
	    var theCells = theRow.cells;
	  }
	  else
	  {
	    return false;
	  }
	  var rowCellsCnt  = theCells.length;
	  for (var c = 0; c < rowCellsCnt; c++)
	  {
	    theCells[c].style.backgroundColor = thePointerColor;
	//    theCells[c].setAttribute("class",thePointerColor);
	  }
	  return true;
	}
	
	var oldLink = null;
	// code to change the active stylesheet
	function setActiveStyleSheet(link, title) {
	  var i, a, main;
	  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	      a.disabled = true;
	      if(a.getAttribute("title") == title) a.disabled = false;
	    }
	  }
	  if (oldLink) oldLink.style.fontWeight = 'normal';
	  oldLink = link;
	  link.style.fontWeight = 'bold';
	  return false;
	}
	
	// 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.
	  //changeField(cal.sel);
	  //if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3")) {
	  if (cal.dateClicked ) {
	    // if we add this call we close the calendar on single-click.
	    // just to exemplify both cases, we are using this only for the 1st
	    // and the 3rd field, while 2nd and 4th will still require double-click.
	    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
	//  cal.destroy();
	  _dynarch_popupCalendar = null;
	}
	
	// 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, showsTime, showsOtherMonths) {
	
	  var el = document.getElementById(id);
	 
	  if (_dynarch_popupCalendar != null) {
	    // we already have some calendar created
	    _dynarch_popupCalendar.hide();                 // so we hide it first.
	  } else {
	    // first-time call, create the calendar.
	    var cal = new Calendar(1, null, selected, closeHandler);
	    // uncomment the following line to hide the week numbers
	    // cal.weekNumbers = false;
	    if (typeof showsTime == "string") {
	      cal.showsTime = true;
	      cal.time24 = (showsTime == "24");
	    }
	    if (showsOtherMonths) {
	      cal.showsOtherMonths = true;
	    }
	   
	    _dynarch_popupCalendar = cal;                  // remember it in the global var
	    cal.setRange(1900, 2070);        // min/max year allowed.
	    cal.create();
	  }
	
	  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
	  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
	  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
	
	  // the reference element that we pass to showAtElement is the button that
	  // triggers the calendar.  In this example we align the calendar bottom-right
	  // to the button.
	 
	    _dynarch_popupCalendar.showAtElement(el.nextSibling,  "Br");        // show the calendar
	    
	  return false;
	}
	
	var MINUTE = 60 * 1000;
	var HOUR = 60 * MINUTE;
	var DAY = 24 * HOUR;
	var WEEK = 7 * DAY;
	
	// If this handler returns true then the "date" given as
	// parameter will be disabled.  In this example we enable
	// only days within a range of 10 days from the current
	// date.
	// You can use the functions date.getFullYear() -- returns the year
	// as 4 digit number, date.getMonth() -- returns the month as 0..11,
	// and date.getDate() -- returns the date of the month as 1..31, to
	// make heavy calculations here.  However, beware that this function
	// should be very fast, as it is called for each day in a month when
	// the calendar is (re)constructed.
	function isDisabled(date) {
	  var today = new Date();
	  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
	}
	
	function flatSelected(cal, date) {
	  var el = document.getElementById("preview");
	  el.innerHTML = date;
	}
	
	function showFlatCalendar() {
	  var parent = document.getElementById("display");
	
	  // construct a calendar giving only the "selected" handler.
	  var cal = new Calendar(0, null, flatSelected);
	
	  // hide week numbers
	  cal.weekNumbers = false;
	
	  // We want some dates to be disabled; see function isDisabled above
	  cal.setDisabledHandler(isDisabled);
	  cal.setDateFormat("%A, %B %e");
	
	  // this call must be the last as it might use data initialized above; if
	  // we specify a parent, as opposite to the "showCalendar" function above,
	  // then we create a flat calendar -- not popup.  Hidden, though, but...
	  cal.create(parent);
	
	  // ... we can show it here.
	  cal.show();
	}
	
	
	function enter(event, formname, action, procedure, functionnumber, parameter, formaction, formactionparam, showobjectnavi)
	{
	 	if (event.keyCode == 13)
	    {
	    	ProzessWorker(formname,action,procedure,functionnumber,parameter,formaction,formactionparam, showobjectnavi); 
	    }
	};
	
	function setAnredenMaske(anrede,el_titel,el_vname,el_name,el_titel2,el_zusatz1,el_zusatz2,lbl_titel,lbl_vname,lbl_name,lbl_titel2,lbl_zusatz1,lbl_zusatz2,waititem)
	{
		setWaitItem(waititem);
	    var param = "?typ=1011&parameter=" + anrede;
	    var responseObject = doSimpleXMLHttpRequest("getParameter.php" + param);
	    responseObject.addCallback(setMaskeByAnrede,anrede,el_titel,el_vname,el_name,el_titel2,el_zusatz1,el_zusatz2,lbl_titel,lbl_vname,lbl_name,lbl_titel2,lbl_zusatz1,lbl_zusatz2,waititem);
	    responseObject.addErrback(showError,waititem);
	};
	
	function showError(waititem,err) {
	  setWaitItem(waititem);
	  logError(err); 
	  logger.debuggingBookmarklet(); 
	}
	
	function setWaitItem(waititem) {
		if(waititem != "" && waititem != null) {
			if(document.getElementById(waititem).style.visibility == "hidden") {
				document.getElementById(waititem).style.visibility = "visible";
			} else {
				document.getElementById(waititem).style.visibility = "hidden";
			}
		}	
	}
	
	function setMaskeByAnrede(anrede,el_titel,el_vname,el_name,el_titel2,el_zusatz1,el_zusatz2,lbl_titel,lbl_vname,lbl_name,lbl_titel2,lbl_zusatz1,lbl_zusatz2,waititem,resp) {
      var xml = resp.responseText;
      var xmlDOMDocument = Spry.Utils.stringToXMLDoc(xml);
      var root = xmlDOMDocument.getElementsByTagName("items")[0];
      var items = root.getElementsByTagName("item");

      lbl_titel2.innerHTML = "";        
  	  el_titel2.style.visibility = "hidden";

  	  lbl_vname.innerHTML = "Vorname:";
	  lbl_name.innerHTML = "Nachname:";
      lbl_zusatz1.innerHTML = "";
	  lbl_zusatz2.innerHTML = "";     	  
      
      
      if(items.length > 0) {
        var item = items[0];
        if(item.childNodes.item(0).firstChild != null){
          var id = item.childNodes.item(0).firstChild != null ? item.childNodes.item(0).firstChild.nodeValue : "";
          var text = item.childNodes.item(1).firstChild != null ? item.childNodes.item(1).firstChild.nodeValue : "";
          var tv1 = item.childNodes.item(2).firstChild != null ? item.childNodes.item(2).firstChild.nodeValue : "";
          var tv2 = item.childNodes.item(3).firstChild != null ? item.childNodes.item(3).firstChild.nodeValue : "";
          var maske1 = item.childNodes.item(4).firstChild != null ? item.childNodes.item(4).firstChild.nodeValue : "";
          var maske2 = item.childNodes.item(5).firstChild != null ? item.childNodes.item(5).firstChild.nodeValue : "";
          var maske3 = item.childNodes.item(6).firstChild != null ? item.childNodes.item(6).firstChild.nodeValue : "";
          var maske4 = item.childNodes.item(7).firstChild != null ? item.childNodes.item(7).firstChild.nodeValue : "";
          var maske5 = item.childNodes.item(8).firstChild != null ? item.childNodes.item(8).firstChild.nodeValue : "";
          var art = item.childNodes.item(9).firstChild != null ? item.childNodes.item(9).firstChild.nodeValue : "";
          var art_person = item.childNodes.item(10).firstChild != null ? item.childNodes.item(10).firstChild.nodeValue : "";
          
      	            
          if(art==1)  { //natürliche Person
          	el_titel2.value = "";        	  
        	lbl_vname.innerHTML = "Vorname:";
        	lbl_name.innerHTML = "Nachname:";

        	lbl_zusatz1.innerHTML = maske2;
        	lbl_zusatz2.innerHTML = maske3;        	
          } else if(art == 2) { // juristische Person
          	el_titel2.value = "";
          	lbl_vname.innerHTML = maske1;
        	lbl_name.innerHTML = maske2;        	  
          } else if(art == 3) { // zwei Personen
          	lbl_vname.innerHTML = maske2;
        	lbl_name.innerHTML = maske1;        	 
        	lbl_titel2.innerHTML = "Titel:";           
          	el_titel2.style.visibility = "visible";  
          	lbl_zusatz1.innerHTML = maske4;
        	lbl_zusatz2.innerHTML = maske3;              	
          }
        }
      }
      setWaitItem(waititem);        
	}
	
	function sprintf() {
	 if( sprintf.arguments.length < 2 ) {
	  return;
	 }
	 var data = sprintf.arguments[ 0 ];
	 for( var k=1; k<sprintf.arguments.length; ++k ) {
	  switch( typeof( sprintf.arguments[ k ] ) )
	  {
	   case 'string':
	    data = data.replace( /%s/, sprintf.arguments[ k ] );
	    break;
	   case 'number':
	    data = data.replace( /%d/, sprintf.arguments[ k ] );
	    break;
	   case 'boolean':
	    data = data.replace( /%b/, sprintf.arguments[ k ] ? 'true' : 'false' );
	    break;
	   default:
	    break;
	  }
	 }
	 return( data );
	}
	
	
			  
