var count = 0;
var hand = 0;
var ns = (document.layers) ? true : false;
var ie  = (document.all) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function clickIE()
  {
  if (ie)
    {
    (message);
    return false;
    }
  }

function clickNS(ev)
  {
  if (ns||(document.getElementById&&!ie))
   	{
		if (ev.which==2||ev.which==3)
			{
			(message);
			return false;
			}
   	}
  }

function ignore()
  {
  return false;
  }

function ignoreOk()
  {
  return true;
  }

/*
if (ns)
	{
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
	}
else
	{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
	}
document.oncontextmenu = ignore;
*/

//------------------------------------------------------------------------------------
function isNumeric (text)
	{
	if (text.length == 0)
		return false;
	var ziffern="0123456789";
	for (var i=0; i < text.length; i++)
		{
		var c = text.charAt(i);
		if (ziffern.indexOf(c) == -1)
			return false;
		}
	return true;
	}

/*-------------------------------------------------------------------------------------
 * replaces the content of the element with id which with the text
 */
function replaceText (which, text)
	{
	if (ie)
	  {
	  var el = document.getElementById(which);
  	if ( el == null || el == "undefined" )
  	  return;
  	el.innerHTML = text;
	  }
	else if (ns6)
		{
		var over = document.getElementById([which]);
		var range = document.createRange();
		range.setStartBefore(over);
		var frag = range.createContextualFragment (text);
		while (over.hasChildNodes())
			{
			over.removeChild(over.lastChild);
			}
		over.appendChild (frag);
		}
	else
	  {
		document[which].document.write(text);
		document[which].document.close();
		}
	}

/*-------------------------------------------------------------------------------------
 * omits spaces on beginning and end of the text
 */
function trim(text)
  {
  while (text.length>0 && text.charAt(0)==' ')
    text = text.substring(1,text.length);
  while (text.length>0 && text.charAt(text.length-1)==' ')
    text = text.substring(0,text.length-1);
  return text;
  }

/*-------------------------------------------------------------------------------------
 * obtain the content of an element with the id which
 */
function getContentById (which)
	{
	if (ie)
    {
	  var el = document.getElementById(which);
  	if ( el == null || el == "undefined" )
  	  return "";
	  return el.innerText;
	  }
	else if (ns6)
		{
		var el = document.getElementById([which]);
  	if ( el == null || el == "undefined" )
  	  return "";
		return el.firstChild.nodeValue;
		}
	else
	  {
		return document[which].document;
		}
	}

//----------------------------------------------------------------------------------
function z2 (num)
	{
  var txt = "00" + num;
  return txt.substr (txt.length - 2, 2);
  }

//----------------------------------------------------------------------------------
function z4 (num)
	{
  var txt = "0000" + num;
  return txt.substr (txt.length - 4, 4);
  }

//----------------------------------------------------------------------------------
function addYear (myDate)
  {
  var originalMonth = myDate.getMonth ();
  myDate.setFullYear (myDate.getFullYear () + 1) ;
  if (myDate.getMonth () > originalMonth)
    myDate.setDate (0);
  }

function toDate (text)
	{
  var date = toDateObject (text);
  if (date == null)
    return "";
  else
    {
    var dd = date.getDate();
    var mm = date.getMonth() + 1;
    var yy = date.getFullYear();
    return "" + z2(dd) + "." + z2(mm) + "." + z4(yy);
    }
  }

function toDateObject (text)
  {
  if (text.length < 1)
		return null;

	var dd = 0;
	var mm = 0;
	var syy = "";
	var yy = 0;

	var da = text.split(".");
	if (da.length == 1)
	  {
	  var c = text.substr(0,1);
	  if (c == "+" || c == "-")
	    {
	    var diff = parseInt (text.substr(1), 10);
	    if (isNaN(diff))
	      diff = 0;
	    if (c == "-")
	      diff = - diff;
	    var date = new Date();
	    date.setTime (date.getTime() + diff * 24*60*60*1000);
	    return date;
	    }
	  if (text.length >= 6)
	    {
	    text = text.substr(0,2) + "." + text.substr(2,2) + "." + text.substr(4);
	    da = text.split(".");
	    }
	  else if (text.length > 4)
	    {
	    text = text.substr(0,2) + "." + text.substr(2);
	    da = text.split(".");
	    }
	  else if (text.length == 4)
	    {
	    text = "01.01." + text;
	    da = text.split(".");
	    }
	  }
	if (da.length < 2 || da.length > 3)
	  return null;

  dd = parseInt (da[0], 10);
 	mm = parseInt (da[1], 10);
 	if (da.length == 3)
	  {
	  syy = da[2];
  	yy = parseInt (syy, 10);
  	if (syy.length == 2)
  	  {
  	  syy = '20' + syy;
  	  yy = parseInt (syy, 10);
  	  if (yy - (new Date()).getFullYear() > 20)
  	    yy -= 100;
  	  }
    else if (isNaN(yy))
      yy = (new Date()).getFullYear();
	  }
  else
	  {
    yy = (new Date()).getFullYear();
	  }

	if (isNaN(dd) || isNaN(mm) || isNaN(yy))
		return null;
	if (dd < 1 || dd > 31 || mm < 1 || mm > 12 || yy < 1900)
	  return null;
	if (dd > 30 && (mm == 4 || mm == 6 || mm == 9 || mm == 11))
	  return null;
	if (mm == 2 && (dd > 29 || dd == 29 && !isLeap(yy)))
	  return null;

  return new Date (yy, mm - 1, dd);
	}

//----------------------------------------------------------------------------------
function toTime (text)
	{
	if (text.length < 1)
		return "";

	var hh = 0;
	var mm = 0;
	var ss = -1;

	var da = text.split(":");
	if (da.length == 1)
	  {
	  if (text.length == 4)
	    {
	    text = text.substr(0,2) + ":" + text.substr(2,2);
	    da = text.split(":");
	    }
	  else if (text.length == 3)
	    {
	    text = "0" + text.substr(0,1) + ":" + text.substr(1);
	    da = text.split(":");
	    }
	  else if (text.length <= 2)
	    {
	    text = text + ":00";
	    da = text.split(":");
	    }
	  }
	if (da.length == 3)
   	ss = parseInt (da[2], 10);
	else if (da.length != 2)
	  return "";

  hh = parseInt (da[0], 10);
 	mm = parseInt (da[1], 10);

	if (isNaN(hh) || isNaN(mm))
		return "";
	if (hh < 0 || hh > 23 || mm < 0 || mm > 59)
	  return "";
	return "" + z2(hh) + ":" + z2(mm) + ((!isNaN(ss)  &&  ss >= 0) ? (":" + z2(ss)) : "");
	}

//-------------------------------------------------------------------------------------
function isLeap (year)
	{
	if (year % 4 != 0)
	  return false;
	if (year % 100 != 0)
	  return true;
	if (year % 400 == 0)
	  return true;
	return false;
	}

//-------------------------------------------------------------------------------------
function OnlyNumber ()
	{
	if (event.keyCode < 45 || event.keyCode > 57)
		event.returnValue = false;
	}

//-------------------------------------------------------------------------------------
function init_form ()
	{
	if (typeof on_init != "undefined")
	  on_init();
	if (document.forms.length > 0)
	  {
    var frm = getEhypForm();
		for (var i = 0; i < frm.elements.length; i ++)
		  {
		  var el = frm.elements[i];
		  if (el.type != "hidden" && !el.disabled && el.style.display != "none")
		    {
		    el.focus();
		    break;
		  	}
		  }
		}
	if (typeof on_focus_init != "undefined")
	  on_focus_init();
	}

//-------------------------------------------------------------------------------------

var lastFocusElement;
var lastFocusElementFailed = false;

function fc (name, pattern, validator)
  {
  lastFocusElementFailed = false;
  var fld = firstInput (name);
  unmarkError (fld);
  if (pattern != "")
    reformat (fld, pattern);
  if (validator && typeof triggerValidation != "undefined")
    triggerValidation (fld, validator);
  }

function hasErrorClass (el)
  {
  if (el == null || typeof el == "undefined")
    return false;
  return (el.className.indexOf("error") == 0);
  }

function getRegularClass (el)
  {
  var rc = el.getAttribute ("regularClass");
  if (!rc)
    rc = "app";
  return rc;
  }

function fieldFocus (name)
  {
  var fld = firstInput (name);
  if (lastFocusElementFailed)
    lastFocusElement.focus ();
  else
    lastFocusElement = fld;
  }

function setCheck (el, name)
  {
  var hid = firstInput (name);
  hid.value = (el.checked) ? "on" : "off";
  }

function reformat (fld, frmt)
  {
  var val = fld.value;
  if (val == "")
    return;
  /*
   * In Date validation we do not erase an erroneous input, but
   * leave it unchanged to alert the user later on.
   */
  if (frmt.substr(0,1) == "^")
    reformatSpecial (fld, val, frmt);
  else if (frmt != "")
    {
    var f = new Formatter (frmt);
    fld.value = f.format (f.parse (val));
    }
  }


function reformatSpecial (fld, val, frmt)
  {
  if (frmt.substr(0,2) == "^H")
  	{
  	var tmpTime = toTime(val);
  	if (tmpTime != "")
  		fld.value = tmpTime;
  	else
  	  alert( "Bitte geben Sie die Uhrzeit in der Form HH:MM ein." );
  	}
  else if (frmt.substr(0,2) == "^d")
  	{
  	var sepPos = frmt.indexOf (" H"); //separates date and time
  	if (sepPos != -1)
  	  {
  	  var frmtDate = frmt.substr (0, sepPos);
  	  var frmtTime = "^d" + frmt.substr (sepPos+1,frmt.length);
  	  sepPos = val.indexOf (" ");
  	  if (sepPos == -1)
  	    {
  	    alert( "Bitte geben Sie Datum und Uhrzeit in der Form " + frmt.substr (2, 99) + " ein." );
  	    return;
  	    }
  	  var valDate = val.substr (0, sepPos);
  	  var valTime = val.substr (sepPos+1,val.length);
      fld.value = valDate;
      reformat (fld, frmtDate);
      valDate = fld.value;
      if (valDate != "")
        {
        fld.value = valTime;
        reformat (fld, frmtTime);
        valTime = fld.value;
        if (valTime != "")
          fld.value = valDate + " " + valTime;
        else
          fld.value = "";
        }
      return;
  	  }

    var sfrm = frmt.substring(2, frmt.length);
    if (sfrm == "HH:mm"  ||  sfrm == "HH:mm:ss")
    	{
	  	var tmpTime = toTime(val);
	  	if (tmpTime != "")
	  		fld.value = tmpTime;
	  	else
	  	  alert( "Bitte geben Sie die Uhrzeit in der Form HH:MM ein." );
    	}
    else if (sfrm == "MM.yyyy")
    	{
    	var tmpDate = toDate("01." + val);
    	if (tmpDate != "")
    		fld.value = tmpDate.substring(3, tmpDate.length);
    	else
    		{
    		fld.value = repairDate (fld, "01." + val);
    		}
    	}
  	else
  		{
  		var tmpDate = toDate (val);
    	if (tmpDate != "")
    		fld.value = tmpDate;
    	else
    		{
    		fld.value = repairDate (fld, val);
    		}
    	}
  	}
  else if (frmt.substr(0,2) =="^R")
    {
    if(window.RegExp)
      {
      var regexp = new RegExp(frmt.substring(2, frmt.length), "g");
      var a = regexp.exec(val);
      if(a && a != "undefined")
        fld.value=a[0];
      else
        fld.value="";
      }
    }
  else if (frmt.substr(0,5) =="^blzf")
  	{
  	// BLZ formatter
		val = val.split(" ").join("");
  	if (window.RegExp)
  		{
  		// Browser knows regular expressions
	  	var regexp = new RegExp(frmt.substring(5, frmt.length), "g");
			while (val.length < 8)
				val = "0" + val;
			var a = regexp.exec(val);
	  	if (a && a != "undefined")
	  		{
				if (a.length > 8)
					a = a.substring (0,8);
				fld.value=a[0];
				}
	  	else
	  		fld.value="";
	  	}
		}
  else if (frmt.substr(0,4) =="^blz")
  	{
  	// BLZ formatter
		val = val.split(" ").join("");
  	if (window.RegExp)
  		{
  		// Browser knows regular expressions
	  	var regexp = new RegExp(frmt.substring(4, frmt.length), "g");
			var a = regexp.exec(val);
			if (a && a != "undefined")
	  		{
				if (a.length > 8)
					a = a.substring (0,8);
				fld.value=a[0];
				}
			else
	  		fld.value="";
	  	}
	  else
	  	{
	  	// browser doesn't know regular expressions
			while (val.length < 8)
				val = "0" + val;
			if (isNaN(val))
				fld.value="";
			else
				fld.value=val;
	  	}
  	}
  else if (frmt.substr(0,2) =="^z")
  	{
	  // zip formatter
  	if(window.RegExp)
  		{
  		// Browser knows regular expressions
	  	var regexp = new RegExp(frmt.substring(2, frmt.length), "g");
			while (val.length < 5)
				val += "0";
			var a = regexp.exec(val);
	  	if(a && a != "undefined")
	  		fld.value=a[0];
	  	else
	  		fld.value="";
	  	}
	  else
	  	{
	  	// browser doesn't know regular expressions
			while (val.length < 5)
				val += "0";
			if (isNaN(val))
				fld.value="";
			else
				fld.value=val;
	  	}
  	}
  else if (frmt.substr(0,3) =="^fn")
  	{
	  fld.value = goodFirstname (val);
  	}
  else if (frmt.substr(0,3) =="^ln")
  	{
	  fld.value = goodLastname (val);
  	}
  }

/*-------------------------------------------------------------------------------------
 * Validates the named fields content according to a regular expression
 * specified in frmt (with prefix ^r)
 * returns false if validation fails!
*/
function validateToRegexp(name, frmt)
	{
	var el = firstInput(name);
	var val = el.value;
	if(window.RegExp && val != "" && frmt.substring(0,2) == "^r")
		{
		// Browser knows regular expressions - if not: do nothing
  	var regexp = new RegExp(frmt.substring(2, frmt.length), "g");
		var a = regexp.exec(val);
  	if(a && a != "undefined")
  		{
  		el.value=a[0];
  		return true;
  		}
  	else
 			return false;
  	}
  	return true;
	}

/*-------------------------------------------------------------------------------------
 * Validates the named fields content according to a regular expression
 * specified in frmt (with prefix ^r)
 * generating an email specific errormessage
 * returns false if validation succeeds, meaning the focus has not been changed!
*/
function validateEmail(name, frmt)
	{
	if (!validateToRegexp(name,frmt))
		{
		alert("Die von Ihnen eingegebene E-Mail-Adresse ist nicht gültig. Bitte korrigieren Sie.");
		return markError (firstInput(name), false);
		}
	return false;
	}

/*-------------------------------------------------------------------------------------
 * Validates the named fields content according to a regular expression
 * specified in frmt (with prefix ^r)
 * generating an unspecific errormessage
 * returns false if validation succeeds, meaning the focus has not been changed!
*/
function validateRegexp (name, frmt)
	{
	if (!validateToRegexp (name,frmt))
		{
		alert("Die Eingabe entspricht nicht dem erforderlichen Format. Bitte korrigieren Sie.");
		return markError (firstInput (name), false);
    }
	return false;
	}

/*-------------------------------------------------------------------------------------
 * Checks the fill status of a input field
 * if not filled the field is marked red and if the focus has not been set before
 * (as determined by the hasFocus variable)
 * returns false if validation succeeds, meaning the focus has not been changed!
*/
function validateFilledField (name, hasFocus)
	{
	return validateFilledElement (inputField (name), hasFocus);
	}

function validateFilledElement (el, hasFocus)
	{
  if (el != null && isEmptyField (el))
    {
    if (getElementType (el) != "radio")
      hasFocus = markError (firstField (el), hasFocus);
    }
  return hasFocus;
  }

//-------------------------------------------------------------------------------------
function repairDate(fld, val)
	{
  alert ("Das eingegebene Datum '" + val + "' konnte nicht erkannt werden. Bitte geben Sie ein gültiges Datum ein.");
  lastFocusElementFailed = true;
  return "";

	var name = "cal_" + fld.name;
	var el = null;
	if (document.getElementById)
    el = document.getElementById(name);
	else
	 	el = document[name];
  if (!el)  //no repair
    return "";
  if (!confirm ("Das eingegebene Datum '" + val + "' konnte nicht erkannt werden. Möchten Sie einen Kalender zur Auswahl des Datums verwenden?"))
    return "";
  el.onclick();
  return fld.value; //will be filled later on by click handler (i.e. calendar control)
	}

//-------------------------------------------------------------------------------------
function isArray(obj)
	{
	if (typeof obj != "undefined" && obj != null)
		return (typeof(obj.length)!="undefined" && typeof(obj.type)=="undefined");
	else
		return false;
	}

//-------------------------------------------------------------------------------------
function showConditional (section, on)
	{
	for (var i = 1; i < 999; i ++)
	  if (!setVisibility(section + i, on))
	    return false;
	}

function blockDisplay()
	{
  return (window.netscape) ? "table-row" : "block";
	}

function styleDisplay(on)
	{
	if (on)
	  return (window.netscape) ? "table-row" : "block";
	return "none";
	}

/*-------------------------------------------------------------------------------------
 * sets the visibility of the element with the id name according to the boolean on flag
 * if the element is a TR and it is displayed in the IE then all child-TDs visibility
 * is set too
 */
function setVisibility(name, on)
	{
	var el = null;
	if (document.getElementById)
    el = document.getElementById(name);
  else
  	el = document[name];
  if (typeof el == "undefined" || el == null)
    return false;
	if (on)
    el.style.display = (window.netscape) ? "table-row" : "block";
  else
    el.style.display = "none";
	if(ie && el.tagName == "TR")
		{
		var cells = el.cells;
		for (var  i = 0; el.cells[i]; i++)
			{
			if (on)
			  el.cells[i].style.display = (window.netscape) ? "table-row" : "block";
			else
			  el.cells[i].style.display = "none";
			}
		}
	return true;
	}

function setSpanVisibility(name, on)
	{
  var el = document.getElementById(name);
  if (!el)
    return false;
  el.style.display = on ? "inline" : "none";
  for (var i = 0; i < el.childNodes.length; i ++)
    {
    var sub = el.childNodes[i];
    if (sub.tagName == "SELECT")
	  	sub.style.display = on ? "inline" : "none";
    }
  el = document.getElementById("l_" + name);
  if (el)
	  el.style.display = on ? "inline" : "none";
	el = document.getElementById("helpspan_" + name);
  if (el)
	  el.style.display = on ? "inline" : "none";
	return true;
	}

/*-------------------------------------------------------------------------------------
 * sets the visibility of the element with the id name according to the boolean on flag
 * if the element is a TR and it is displayed in the IE then all child-TDs visibility
 * is set too
 */
function enableElementById(name, on)
	{
		if (document.getElementById)
	    el = document.getElementById(name);
	  else
	  	el = document[name];
	  if (el == null || typeof el == "undefined")
	    return false;
    el.disabled = !on;
		return true;
	}

/*-------------------------------------------------------------------------------------
 * sets the visibility of the inline element with the id name according to the boolean on flag
 * is set too
 */
function setVisibilityInline(name, on)
	{
		if (document.getElementById)
	    el = document.getElementById(name);
	  else
	  	el = document[name];
	  if (typeof el == "undefined" || el == null)
	    return false;
		if (on)
	    el.style.display = "inline";
	  else
	    el.style.display = "none";
		return true;
	}

//-------------------------------------------------------------------------------------
function setCondBoolean (section, name, onval)
  {
	var on = getCondValue (name, onval);
	showConditional (section, on);
	return on;
  }

//-------------------------------------------------------------------------------------
function buttonClick (name)
	{
	var el = document.getElementById (name);
	if (el == null || el.type != "button" || el.value == "Bitte warten")
		return false;
	el.disabled = true;
	el.origValue = el.value;
	el.value = "Bitte warten";
	return true;
	}

//-------------------------------------------------------------------------------------
function enableButton(name)
	{
	var el = document.getElementById(name);
	if (el == null || el.type != "button" || el.value != "Bitte warten")
		return false;
	el.disabled = false;
	el.value = el.origValue;
	return true;
	}

//-------------------------------------------------------------------------------------
function hasField (name)
  {
  var el = firstInput (name);
  if (typeof el != "undefined" && el != null)
    return true;
  return false;
  }

//-------------------------------------------------------------------------------------
function getFieldType (name)
  {
  return getElementType (inputField (name));
  }

function getElementType (el)
  {
  el = firstField (el);
  if (!el || typeof el == "undefined")
    return null;
  return el.type;
  }

//-------------------------------------------------------------------------------------
function getFieldValue (name)
  {
  return getElementValue (inputField (name));
  }

function getElementValue (el)
  {
  if (!el || typeof el == "undefined")
    return null;
  var elType = getElementType (el);
  if (elType == "radio")
    return getRadioButtonValue (el);
  el = firstField (el);
  if (elType == "select-one")
	  return el.value;
	return el.value;
  }

function getSelectDisplayValue (el)
  {
  if (el == null || typeof el == "undefined")
    return null;
  return el.options[el.selectedIndex].text;
  }

//-------------------------------------------------------------------------------------
function getRadioButtonValue (radioElement)
  {
  if (typeof radioElement.length == "undefined")
    return radioElement.value;
  for (var i = 0; i < radioElement.length; i++)
    {
    if (radioElement[i].checked)
      return radioElement[i].value;
    }
  return null;
  }

//-------------------------------------------------------------------------------------
function getCondValue (name, onval)
  {
  var myval = getFieldValue (name);
  if (myval == null)
  	return false;
	if (onval)
		return (myval == onval);
	return (myval != null && myval != "" && myval != "0" && myval != 0)
  }

/*-------------------------------------------------------------------------------------
 * show section if element with the name is not zero
*/
function setCondNonZero(section, name)
  {
 	var el = inputField (name);
 	if (typeof el != "undefined" && el != null)
 		{
 		var val = 0;
 		if(!isNaN(el.value))
 			val = parseFloat(el.value)
 		var on = el.value != 0;
		showConditional (section, on);
		return on;
		}
	return false;
  }

/*-------------------------------------------------------------------------------------
 * set field display according to the on parameter
*/
function displayField (fieldname, on)
  {
 	var f = inputField (fieldname);
  if (f == null || typeof f == "undefined")
    return;
  var display = on ? "inline" : "none";
  if (isArray(f))
    {
    f[0].style.display = display;
    f[1].style.display = display;
  	}
  else
		f.style.display = display;
  }


/*-------------------------------------------------------------------------------------
 * deletes the content of the named field
 * if it exists and the boolean flag 'on' is set to false (meaning the field is not
 * displayed)
 * if there is an array of fields with this name, only the first element is emptied,
 * assuming, this is a periodical amount input field with the value being the first element.
*/
function condDeleteFieldValue (name, on)
	{
	if(on)
		return;
	var el = inputField(name);
	if (typeof el != "undefined" && el != null)
		{
		el = firstField (el);
		if (el)
			el.value = "";
		}
	}

/*-------------------------------------------------------------------------------------
 * This is the duplicateTabLine adapted to use by netscape and only by netscape.
 * Moved here from antrag\capital.vm
 */
function duplicateTabLineNS (topic, vcs, before, prefix, e)
  {
  duplicateTabLineNS_2 (topic, vcs, before, prefix, e, null);
  }

function duplicateTabLineNS_2 (topic, vcs, before, prefix, e, dontReplaceVcsAfter)
  {
	var vc = parseInt(vcs.substring(1,vcs.length-1));
	var value = e.target.value;
	e.target.value = "";

  var tr = document.getElementById(topic + "Row" + vc);
  var trc = tr.cloneNode(true);
  trc.id = topic + "Row" + (vc+1);
	if (before)
		{
  	var tbefore = document.getElementById(before);
		tr.parentNode.insertBefore (trc, tbefore);
		}
	else
		{
		tr.parentNode.appendChild (trc);
		}
  var oldVc = "[" + vc + "]";
  var newVc = "[" + (vc+1) + "]";
	var seqId = document.getElementById(topic + "Seq" + oldVc);
	if (seqId != null)
		{
		var idNodes = document.getElementsByName(seqId.name);
		if (idNodes.length == 1)
			{
			var seqClone = seqId.cloneNode(true);
			seqClone.setAttribute("id", topic + "Seq" + newVc);
			seqClone.name = seqClone.name.split(oldVc).join (newVc);
			seqId.parentNode.appendChild(seqClone);
			}
		}
	var tds = trc.getElementsByTagName("TD");
  for (var i = 0; i < tds.length; i ++)
    {
    var td = tds[i];
    if (typeof td.innerHTML != "undefined" && td.innerHTML != "undefined")
      {
    	td.innerHTML = td.innerHTML.split(oldVc).join (newVc);
      if (dontReplaceVcsAfter != null)
        td.innerHTML = td.innerHTML.split(dontReplaceVcsAfter + newVc).join (dontReplaceVcsAfter + oldVc);
    	}
		}
  if (prefix)
    {
    oldVc = prefix + vc;
    newVc = prefix + (vc+1);
    for (var i = 0; i < tds.length; i ++)
      {
      var td = tds[i];
	    if (typeof td.innerHTML != "undefined" && td.innerHTML != "undefined")
				td.innerHTML = td.innerHTML.split(oldVc).join (newVc);
	  	}
    }
  e.target.onchange = ignoreOk;
	e.target.value = value;
  }

/*-------------------------------------------------------------------------------------
 * duplicates a table line - purely for ie, only to be used for backoffice functionality
 *
 * sample definition of addPreSuffixes = {"noDefaultVcReplace":true,"noReplaceOnChange":true, "containsCond":"XX",
 *    "psList":[{"prefix":"p1", "suffix":"s1"},
 *              {"prefix":"p2", "suffix":"s2"}]};
*/
function duplicateTabLine (topic, vcs, before, prefix, addPreSuffixes)
  {
  duplicateTabLine_2 (topic, vcs, before, prefix, null, addPreSuffixes);
  }

function duplicateTabLine_2 (topic, vcs, before, prefix, dontReplaceVcsAfter, addPreSuffixes)
  {
	var vc = parseInt(vcs.substring(1,vcs.length-1));
  var value = event.srcElement.value;
  event.srcElement.value = "";
  var tr = document.getElementById(topic + "Row" + vc);
  var trc = tr.cloneNode(true);
  trc.id = topic + "Row" + (vc+1);
	if (before)
		{
  	var tbefore = document.getElementById(before);
		tr.parentNode.insertBefore (trc, tbefore);
		}
	else
		tr.parentNode.appendChild (trc);
  var oldVc = "[" + vc + "]";
  var newVc = "[" + (vc+1) + "]";
  for (var i = 0; i < trc.childNodes.length; i ++)
    {
    var td = trc.childNodes(i);
    if (!addPreSuffixes || !addPreSuffixes.noDefaultVcReplace)
    {
      td.innerHTML = td.innerHTML.split(oldVc).join (newVc);
    }    
    if (addPreSuffixes && (!addPreSuffixes.containsCond || td.innerHTML.indexOf(addPreSuffixes.containsCond) >= 0))
      {
      for (var addpsIdx = 0; addpsIdx < addPreSuffixes.psList.length; addpsIdx++)
        {
        var oldReplStr = addPreSuffixes.psList[addpsIdx].prefix + vc + addPreSuffixes.psList[addpsIdx].suffix;
        var newReplStr = addPreSuffixes.psList[addpsIdx].prefix + (vc+1) + addPreSuffixes.psList[addpsIdx].suffix;
        td.innerHTML = td.innerHTML.split(oldReplStr).join (newReplStr);
        }
      }
    if (dontReplaceVcsAfter != null)
      td.innerHTML = td.innerHTML.split(dontReplaceVcsAfter + newVc).join (dontReplaceVcsAfter + oldVc);
		}
  if (prefix)
    {
    oldVc = prefix + vc;
    newVc = prefix + (vc+1);
    for (var i = 0; i < trc.childNodes.length; i ++)
      {
      var td = trc.childNodes(i);
      td.innerHTML = td.innerHTML.split(oldVc).join (newVc);
  		}
    }
  if (!addPreSuffixes || !addPreSuffixes.noReplaceOnChange)
    event.srcElement.onchange = ignoreOk;
  event.srcElement.value = value;
	//alert ("new tab " + tab.outerHTML);
  }

/*-------------------------------------------------------------------------------------
 * checks an form field for emptyness
 */
function isEmptyField (el)
	{
  var elType = getElementType (el);
  if (elType == "radio")
    {
    var value = getRadioButtonValue (el);
    return (value == null || value == "");
    }
  el = firstField (el);
  if (elType.substring(0,1) == "s")
    return (el.selectedIndex == 0 && (el.value == "" || el.value=="Bitte wählen")) ||
            el.selectedIndex < 0;
  else if (elType.substring(0,1) == "c")
  	return (!el.checked);
	else
  	return (getElementValue (el) == "");
	}


/*-------------------------------------------------------------------------------------
 * returns the input field of given name or an array, if multiply defined
 */
function inputField (name)
  {
  if (name.indexOf(":") != -1)
    {
    var a = name.split(':');
    return document.forms[a[0]].elements[a[1]];
    }
  for (var i = 0; i < document.forms.length; i ++)
    {
    var el = document.forms[i].elements[name];
    if (el)
      return el;
    }
  return null;
  }

/*-------------------------------------------------------------------------------------
 * returns the input field of given name. If multiply defined, return first matching
 */
function firstInput (name)
  {
  return firstField (inputField (name));
  }

function firstField (el)
  {
  if (isArray (el))
    el = el[0];
  return el;
  }

var stdFloatFormatter = null;

function makeStdFloatFormatter ()
  {
	if (stdFloatFormatter == null)
	  stdFloatFormatter = new Formatter("#.###,00");
	}

function getStdFloatFormatter ()
  {
  makeStdFloatFormatter ();
  return stdFloatFormatter;
  }

/*-------------------------------------------------------------------------------------
 * returns the amount of a periodical value casted to a given period
 */
function getPeriodicalAmount (name, targetPeriod)
  {
	var el = inputField (name);
	if (isArray(el))
		{
		period = el[1].value;
		el = el[0];
		}
	else
		period = null;
	val = el.value;
	if (val == null || val == "")
		return null;
	val = getStdFloatValue (val);
	if (period != null)
		val = recalcPeriodical (val,period, targetPeriod);
	return val;
	}

/*-------------------------------------------------------------------------------------
 * returns the period of a periodical amount
 */
function getPeriod (name)
  {
	var el = inputField (name);
	if (isArray(el))
		return el[1].value;
	return null;
	}

/*-------------------------------------------------------------------------------------
 * returns the monthly amount of a periodical value, replacing 0 for null
 */
function getMonthlyAmount (name)
  {
	var el = inputField (name);
	if (typeof el == "undefined" || el == null)
	  return 0;
	if (isArray(el))
		{
		period = el[1].value;
		el = el[0];
		}
	else
		period = null;
	val = el.value;
	if (val == null || val == "")
		return 0;
	val = getStdFloatValue (val);
	if (period != null)
		val = recalcPeriodical (val,period, "pm");
	return val;
	}

/*-------------------------------------------------------------------------------------
 * returns the float value of a numeric field
 */
function getFloatValue (name)
  {
	var el = firstInput (name);
	if (el == null || el == "undefined")
	  return 0;
  return getElementFloatValue (el);
  }

function getElementFloatValue (el)
  {
  var val = el.value;
	if (val == null || val == "")
		return null;
  return getStdFloatValue (val);
  }

function getStdFloatValue (val)
  {
  makeStdFloatFormatter ();
  return stdFloatFormatter.parseFloat (val);
  }

/*-------------------------------------------------------------------------------------
 * set a field to empty
 */
function makeEmpty (name)
  {
	var el = firstInput (name);
	if ( el == null || el == "undefined" )
	  return;
	el.value = "";;
	}

/*-------------------------------------------------------------------------------------
 * returns the float value of a numeric field, replacing empty fields by 0
 */
function getFloatNumeric (name)
  {
  var val = getFloatValue (name);
  if (val == null)
    return 0;
  return val;
  }


/*-------------------------------------------------------------------------------------
 * returns the float value of a span field, replacing empty fields by 0
 */
function getSpanValue (name)
  {
  var fld = document.getElementById(name);
  if (typeof fld == "undefined" || fld == null)
    return 0;
	var val = fld.innerHTML;
	if (val == null || val == "")
		return 0;
	val = getStdFloatValue (val);
  if (val == null)
    return 0;
  return val;
  }


/*-------------------------------------------------------------------------------------
 * recalcs a periodical value from source period
 * to target period
 */
function recalcPeriodical (val, pSource, pTarget)
	{
	var tfactor = getPeriodicalFactor(pTarget);
	var sfactor = getPeriodicalFactor(pSource);
	return val / sfactor * tfactor;
	}

/*-------------------------------------------------------------------------------------
 * obtains the numeric factor for a given period
 * pa = 12
 * ph = 6
 * pq = 3
 * pm = 1
 */
function getPeriodicalFactor(p)
	{
		if (p=="pa")
		  return 12;
		else if (p=="pm")
		  return 1;
		else if (p=="pq")
		  return 3;
		else if (p=="ph")
		  return 6;
		return 0;
	}


/*-------------------------------------------------------------------------------------
 * maximize a window
 */
function maximizeWindow (win)
  {
  win.moveTo(0,0);
  if (document.all)
    win.resizeTo(screen.availWidth,screen.availHeight);
  else if (document.layers||document.getElementById)
    {
    if (win.outerHeight < screen.availHeight || win.outerWidth < screen.availWidth)
      {
      win.outerHeight = screen.availHeight;
      win.outerWidth = screen.availWidth;
      }
    }
  }

/*-------------------------------------------------------------------------------------
 * prefix-function: determines wheter "text" startsWith "prefix"
 */
function startsWith (text, prefix)
  {
  if (prefix == null)
    return true;
  if (text == null)
    return false;
  return (text.length >= prefix.length) && (text.substring(0, prefix.length) == prefix);
  }

 /*
 * invokes a popup window
 * name = Name of window
 * category = popup category, decides over sizes, options etc.
 * url = URL to invoke
 * returns window handle
 */
function pop (name, category, url)
	{
	// app        - b2c/b2b online Antrag
	// boApp      - bo Antrag
	// appInfo    - Kompaktinfo mit Befehlsicons für 1 Antrag
	// appInfo2   - Kompaktinfo mit Befehlsicons für 1 Antrag, an versetzter Position
	// b2bCockpit - b2b Cockpit für Antrag
	// boAppList  - Kompaktinfo mit Befehlsicons für mehrere Anträge
	// broker     - Kompaktinfo mit Befehlslinks für Broker
	// brokerEdit - Broker Stammdaten erfassen/ändern
	// kohi       - Kontakthistorie / Wiedervorlage erfassen/ändern
	// fopsy      - neues Fopsy Fenster
	// doclist		- Unterlagenliste für b2c/b2b
  // employeeData - Mitarbeiterstammdatenanzeige
  // isMonitor  - Versicherungsservice StatusMonitor/Kundendaten
  // isProduct  - Versicherungsservice Produkt anlegen
  // contractData - Vertragsdaten abändern
  // editVacation - Urlaubsantrag bearbeiten
	// help				- b2c Hilfefenster
	// message		- Meldungsfenster
	// genInfo		- b2c/b2b allgemeiner Dialog
	// legal			- b2c Datenschutz und Sicherheitsinformationen
	// contact		- b2c/b2b Kontaktinformationen
	// poll				- b2c Ihre Meinung
	// phone			- Direktwahl Telefonliste
	// boMail			- Backoffice Mail
	// form				- pdf or html form from form server. Not centered to avoid access denied as ie tries to center before loading is finished.
	// phoneWatch	- telephone watcher popup
	// quickFind  - Schnellsuche
	// quickList	- Suche mit Liste als Ergebnis (scrollt)
	// newMessage - Nachricht an BoUser
	// quickNew   - Neuanlage Adresssatz
	// brokerPoll - Broker Befragungen: Liste und Erfassungsformular
	// myTask     - Serviceteam new Task
	// myGuideline - brokerCaseGuidelines
  // ipacket    - Infopaket erfassen
	// b2bapp     - b2b Antrag
	// report			- Bericht
	// smallRep		- kleiner Bericht
	// boCalc			- BO (Excel) Rechner. External Link, not centered to avoid access denied
	// log        - Logbuch
	// merge      - Antragsveschmelzung
	// reassign		- "Priorisiern" Maske
	// rechner		- Rechner wie in Website
	// note		    - Notizfenster
	// fileList	  - Dateiliste fopsy
	// cvs	      - cvs log or diff
	// cvsRefresh - cvs refresh and deploy status display
	// news				- Einzel-News Popup (Prohyp)
	// newsEdit   - Einzel-News Popup (BO)
	// prodPrint  - Druckansicht Produkte (Prohyp)
	// hrCockpit  - Bewerbercockpit
	// hrRating   - Bewerberbewertung
	// hrPoll     - Feedback-Form zur Online-Bewerbung
	// hitList    - Liste der Einzelergebnisse der Suchmaschinen
	// pInfo      - Providerinfo Hauptfenster
	// allPinfo   - Providerinfos aller Provider
	// priceproviders      - Liste der Anbieter von Preis/Miet/Wert-Informationen
	// ppScreen            - Website einer der Anbieter
  // closingLetter       - Abschlussbriefpopup
  // appsOverview        - Schlüsselungsüberischt
  // termination/b2bCancelCase - Terminationseiten
  // confirmDocuments    - Unterlageneingang (bei Prohyp Professional Fällen)
  // selectReportDetails - Details im Prohyp Professional Report
  // reportDesc          - Beschreibung von TopReport/Auswertung
  // reportRequest       - Reporting-Anfrage
  // reportExecution     - Manuelles Anstossen der Reports
  // scoringDetails      - wie der name schon sagt
  // editBrokerProfile   - Vermittlerprofile und Accounts im backoffice
  // monthlyIncome   - Durchnittslohnberechnung
  // diba   - DiBa Rollout Form
  // elearning   - eLearning Videos
  // statusmonitor - bo Statusmonitor
	// pmCockpit - PM Cockpit
	// providerQueue - Warteschlange eines Providers
  var options = "";
  var dx = 100;
  var dy = 100;
  var x = 0;
  var y = 0;
  var extLink = false;
  if (category == "app")
    {
    dx = 800;
    dy = 600;
    x = (screen.width / 2) - 400;
    if ( x < 0 ) x = 0;
    y = (screen.height / 2) - 300;
    if ( y < 0 ) y = 0;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "appIH")
 {
    dx = 800;
    dy = 700;
    x = (screen.width / 2) - 400;
    if ( x < 0 ) x = 0;
    y = (screen.height / 2) - 300;
    if ( y < 0 ) y = 0;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  }
  else if (category == "boApp")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "appInfo")
    {
    dx = 900;
    dy = 220;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "appInfo2")
    {
    dx = 900;
    dy = 220;
    options = "top=230,left=50,toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
	  else if (category == "appInfo3")
    {
    dx = 900;
    dy = 220;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "boAppList")
    {
    dx = 900;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=auto,resizable=yes,status=yes";
  	}
  else if (category == "monthlyIncome")
    {
    dx = 600;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=auto,resizable=no,status=no";
  	}
  else if (category == "broker")
    {
    dx = 880;
    dy = 530;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "bids")
    {
    dx = 1000;
    dy = 530;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "doclist")
    {
    dx = 650;
    dy = 530;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "employeeData")
    {
    dx = 1000;
    dy = 750;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes";
  	}
  else if (category == "isMonitor")
    {
    dx = 1000;
    dy = 750;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes";
  	}
  else if (category == "ehyplogin")
    {
    dx = 450;
    dy = 170;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes";
  	}
  else if (category == "isProduct")
    {
    dx = 500;
    dy = 350;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes";
  	}
  else if (category == "contractData")
    {
    dx = 590;
    dy = 370;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=no, status=yes";
  	}
  else if (category == "editVacation")
    {
    dx = 540;
    dy = 315;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "brokerEdit")
    {
    dx = 780;
    dy = 700;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "kohi")
    {
    dx = 950;
    dy = 700;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "fopsy")
    {
    dx = 950;
    dy = 680;
    options = "toolbar=yes,menubar=yes,locationbar=yes,scrollbars=auto,resizable=yes,status=yes";
  	}
  else if (category == "help")
    {
    dx = 400;
    dy = 300;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "message")
    {
    dx = 430;
    dy = 208;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=no,status=no";
  	}
  else if (category == "question")
    {
    dx = 400;
    dy = 110;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "genInfo")
    {
    dx = 420;
    dy = 450;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "legal")
    {
    dx = 520;
    dy = 500;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "contact")
    {
    dx = 610;
    dy = 700;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "poll")
    {
    dx = 500;
    dy = 500;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "phone")
    {
    dx = 700;
    dy = 400;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "boMail")
    {
    dx = 1010;
    dy = 600;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "boCalc")
    {
    dx = 700;
    dy = 400;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
    extLink = true;
  	}
  else if (category == "form")
    {
    dx = 850;
    dy = 600;
    options = "toolbar=yes,menubar=yes,locationbar=yes,scrollbars=yes,resizable=yes,status=yes";
    extLink = true;
  	}
  else if (category == "phoneWatch")
    {
    dx = 600;
    dy = 240;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=no,status=no";
  	}
  else if (category == "quickFind")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "quickList")
    {
    dx = 950;
    dy = 650;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "fileList")
    {
    dx = 950;
    dy = 700;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "brokerPoll")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "newMessage")
    {
    dx = 600;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "quickNew")
    {
    dx = 780;
    dy = 700;
    options = "top=5,left=5,toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "buiApp")
    {
    dx = 800;
    dy = 550;
    options = "top=50,left=50,toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "myTask")
    {
    dx = 1050;
    dy = 720;
    options = "top=5,left=5,toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "myGuideline")
    {
    dx = 900;
    dy = 720;
    options = "top=5,left=5,toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "ipacket")
    {
    dx = 600;
    dy = 650;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "b2bapp")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "b2bShortapp")
    {
    dx = 960;
    dy = 720;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "dibaDirectApp")
    {
    dx = 800;
    dy = 810;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "proloLead")
    {
    dx = 960;
    dy = 715;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "report")
    {
    dx = 900;
    dy = 600;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "smallRep")
    {
    dx = 700;
    dy = 600;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "log")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "prognosis")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "cvs")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
    extLink = true;
  	}
  else if (category == "cvsRefresh")
    {
    dx = 600;
    dy = 500;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=no";
  	}
  else if (category == "merge")
    {
    dx = 800;
    dy = 300;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "brokerStat")
    {
    dx = 950;
    dy = 300;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "reassign")
    {
    dx = 500;
    dy = 450;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "rechner")
    {
    dx = 700;
    dy = 500;
    options = "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1";
  	}
  else if (category == "chart")
    {
    dx = 600;
    dy = 630;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "note")
    {
    dx = 700;
    dy = 500;
    options = "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1";
  	}
  else if (category == "hrCockpit")
    {
    dx = 900;
    dy = 550;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=auto,resizable=yes,status=yes";
  	}
  else if (category == "hrRating")
    {
    dx = 600;
    dy = 320;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=no,status=no";
  	}
  else if (category == "hrPoll")
    {
    dx = 510;
    dy = 580;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "bwk")
    {
    dx = 800;
    dy = 700;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=auto,resizable=yes,status=yes";
  	}
  else if (category == "b2bcockpit")
    {
    dx = 970;
    dy = 440;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "news")
    {
    dx = 500;
    dy = 450;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=no,status=no";
  	}
  else if (category == "newsEdit")
    {
    dx = 800;
    dy = 600;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=no,status=no";
  	}
  else if (category == "sitemap")
    {
    dx = 900;
    dy = 450;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=no";
  	}
  else if (category == "prodPrint")
    {
    dx = 600;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
    }
  else if (category == "hitList")
    {
    dx = 900;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "allPinfo")
    {
    dx = 600;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "pInfo")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=yes,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "assumptions")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=no";
  	}
  else if (category == "submissions")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "taskKsAP" || category == "taskKsAPVE")
    {
    dx = 900;
    dy = 700;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "taskKsAU")
    {
    dx = 700;
    dy = 210;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "taskKsVE")
    {
    dx = 600;
    dy = 500;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "extern")
    {
    dx = 185;
    dy = 218;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "window")
    {
    var w = window.open (url, name);
    w.focus();
    return w;
    }
  else if (category == "priceproviders")
    {
    dx = 500;
    dy = 440;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=no,status=no";
  	}
  else if (category == "ppScreen")
    {
    dx = 950;
    dy = 680;
    options = "toolbar=yes,menubar=yes,locationbar=yes,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "infoBox")
    {
    dx = 1010;
    dy = 720;
    options = "toolbar=yes,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "closingLetter")
    {
    dx = 700;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "termination")
    {
    dx = 670;
    dy = 340;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "b2bCancelCase")
    {
    dx = 670;
    dy = 400;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "confirmDocuments")
    {
    dx = 670;
    dy = 340;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "appsOverview")
    {
    dx = 800;
    dy = 340;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "selectReportDetails")
    {
    dx = 900;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "reportDesc")
    {
    dx = 700;
    dy = 340;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "reportRequest")
    {
    dx = 700;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "reportMonitor")
    {
    dx = 800;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "reportExecution")
    {
    dx = 800;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "scoringDetails")
    {
    dx = 700;
    dy = 630;
    options = "resizable=yes, scrollbars=yes, menubar=yes, toolbar=yes";
  	}
  else if (category == "editBrokerProfile")
    {
    dx = 1000;
    dy = 600;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "creditProtocol")
    {
    dx = 1000;
    dy = 700;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "diba")
    {
    dx = 780;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "cconsors")
    {
    dx = 820;
    dy = 700;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "elearning")
    {
    dx = 656;
    dy = 500;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}	
  else if (category == "addLoan")
    {
    dx = 450;
    dy = 800;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}	
  else if (category == "ehypMailerTextForm")
    {
    dx = 600;
    dy = 670;
    options = "location=no, menubar=no, toolbar=no, resizable=yes, scrollbars=yes, status=yes";
  	}
  else if (category == "ehypMailerWindow")
    {
    dx = 1010;
    dy = 600;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
  	}
  else if (category == "statusmonitor")
    {
    dx = 850;
    dy = 800;
    options = "toolbar=no,menubar=yes,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
    }
  else if (category == "dibaProcessDetails")
    {
    dx = 650;
    dy = 650;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
  	}
  else if (category == "pmCockpit")
    {
    dx = 1010;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=no,resizable=yes,status=yes";
    }
  else if (category == "providerQueue")
    {
    dx = 1010;
    dy = 600;
    options = "toolbar=no,menubar=no,locationbar=no,scrollbars=yes,resizable=yes,status=yes";
    }

  var w = window.open (url, name, options + ",width=" + dx + ",height=" + dy);
  if (w && w != "undefined")
    {
    if (!extLink)
    	{
      if (category == "boApp" || category == "b2bapp" || category == "log" || category=="editVacation" || category=="reportMonitor" || category=="ehypMailerWindow")
	      maximizeWindow(w);
	    else if (document.all)
	      moveOnScreen (w, dx, dy);
			}
    w.focus();
    }
  return w;
	}

/*-------------------------------------------------------------------------------------
 * simple Popup Window
 */
function simplePopupWindow (name, w, h, url, doCenter, scrollbars)
	{
	if (scrollbars)
	  scrollbars = "yes";
	else
	  scrollbars = "auto";
  var x = -1;
  var y = -1;
  if (doCenter)
    {
    x = (screen.width / 2) - (w / 2);
    y = (screen.height / 2) - (h / 2) - 50;
    }
  var options = "toolbar=no,menubar=no,locationbar=no,scrollbars="+scrollbars+",resizable=yes,status=yes";
  return popupWindow (name, x, y, w, h, false, options, url );
  }
 
/*-------------------------------------------------------------------------------------
 * invokes a popup window
 * name = Name of window
 * url = URL to invoke
 * returns window handle
 */
function popupWindow (name, x, y, width, height, maximize, options, url)
	{
  var w = window.open (url, name, options + ",width=" + width + ",height=" + height);
  if (w && w != "undefined")
    {
    if (maximize)
      maximizeWindow(w);
    else if (document.all)
      moveOnScreen (w, width, height);
    if (x != -1 && y != -1)
    	w.moveTo( x, y );
    w.focus();
    }
  return w;
  }

/*-------------------------------------------------------------------------------------
  
/*-------------------------------------------------------------------------------------
 * sets the b2c app navigation frame to the correct page
 * page = number of page (1 = start)
 */

function setNavFramePage (url,page,params)
	{
	if (params == null || params == "undefined")
		params = "";
	parent.appnav.location.href = url + "?view=appNav&page=" + page + params;
	}


/*-------------------------------------------------------------------------------------
 * sets the prohyp app navigation frame to the correct page
 * page = number of page (1 = start)
 */

function setNavFramePageView (url,view,page,params)
	{
	if (params == null || params == "undefined")
		params = "";
	parent.appnav.location.href = url + "?view="+view+"&page=" + page + params;
	}

/*-------------------------------------------------------------------------------------
 * sets the b2c app bottom frame to the correct
 * param new (show 'Unterbrechen & Speichern' or not)
 */

function setBotFramePage (url, showSave, params)
	{
	if (params == null || params == "undefined")
		params = "";
	if(parent.appbot != null)
		parent.appbot.location.href = url + "?view=bottomNav&showSave=" + showSave + params;
	}


/*-------------------------------------------------------------------------------------
 * for active-passive-grey field pairs.
 * disables the field called otherName
 * and fills it with the value calculated from the baseName fields value and
 * the name fields value using the calc formula.
 * In calc the baseName value has to be called base and the name value has to
 * be called val.
 */
function changeState(name, otherName, baseName, calc, pattern)
 	{
	var f = new Formatter(pattern);
 	var field = firstInput (name);
 	var otherField = firstInput (otherName);
 	var baseField = firstInput (baseName);
 	// empty - so enable both
	if(field.value == "")
		{
		field.className="app";
		otherField.value="";
		otherField.className="app";
		}
	else
	  {
		field.className="app";
		otherField.className="disabled";
		var val = f.parseFloat(field.value);
		var base = 0;
		if(!baseField || baseField == "undefined")
			base = f.parseFloat(getContentById(baseName));
		else
			base = f.parseFloat(baseField.value);
		otherField.value=f.format(String(eval(calc)));
 		}
	}

/*-------------------------------------------------------------------------------------
 * this function is called by onKeyPress and onChange events of textareas.
 * it grows the field to accepts all the text without scrolling
 */

function growArea(name)
  {
  var el = firstInput (name);
  if (el.clientHeight < el.scrollHeight)
	  {
	  if (el.scrollHeight > 80)
	  	{
	  	var pel = el.parentNode;
	  	if (el.clientWidth < pel.clientWidth - 6)
	  		el.style.width = pel.clientWidth - 6;
	  	}
	  el.style.height = el.scrollHeight + 10;
		}
  }

/*-------------------------------------------------------------------------------------
 * Submits the 0th form of the documents forms collection on pressing the enter button
 * Should be called in the onKeyPress event of either a specific form element or the body
 */
function submitOnEnter(e)
	{
	var keycode;
	if (window.event)
		{
		// ie
		keycode = window.event.keyCode;
		}
	else if (e)
		{
		// netscape
		keycode = e.which;
		}
	else
		{
		// something else. ignore it.
		return true;
		}

	if (keycode == 13)
	   {
	   getEhypForm().submit();
	   return false;
	   }
	else
	   return true;
	}


/* ******************************************************************
 * In the case of conditional fields this function has to be called
 * in the body tags onKeyDown event. Thus the Cursor is set correctly
 * and the netscape crash upon setting the focus on a removed field
 * is avoided.
 */
function filterTab(e)
	{
	var keycode;
	var el;
	if (window.event)
		{
		//return true;
		// ie
		keycode = window.event.keyCode;
		el = window.event.srcElement;
		}
	else if (e)
		{
		// netscape
		keycode = e.which;
		el = e.target;
		}
	else
		{
		// something else. ignore it.
		return true;
		}
	if (keycode == 9)
		{
		if (el.onchange && el.onchange != 'undefined')
			el.onchange();
		return true;
		}
	}

/*
 * sets the focus on the element and scrolls the page so the element
 * aligns with the top.
 */
function setFocus(el, hasFocus)
	{
	if (!hasFocus)
		{
    window.scrollTo (0, el.offsetTop - 1);
	  el.focus();
		}

	return true;
	}

/*
 * methods for field error handling
 */
function markError (el, hasFocus)
  {
  var cn = el.className;
  if (!cn)
    cn = "";
  if (!el.getAttribute("regularClass"))
    el.setAttribute("regularClass", cn)
  el.className = "errorNeutralName";
  return setFocus (el, hasFocus);
  }

function markErrorField (fieldName, hasFocus)
  {
  return markError (firstInput (fieldName), hasFocus);
  }

function unmarkError (el)
  {
  if (hasErrorClass (el))
    el.className = getRegularClass (el);
  }

function unmarkErrorField (fieldName)
  {
  unmarkError (firstInput (fieldName));
  }

function makeFirstErrorText (newText, text)
  {
  if (text != null && text != "")
    return text;
  return newText;
  }

function makeFilledErrorText (newTxt, text)
  {
  if (text == null || text == "")
    return newTxt;
  return "Bitte füllen Sie die markierten Felder aus.";
  }

function checkElementFilled (el, errText, text)
  {
  if (el != null && isEmptyField (el))
    {
    markError (el, text != null);
    text = makeFilledErrorText (errText, text);
    }
  return text;
  }

function checkFieldFilled (name, errText, text)
  {
	return checkElementFilled (inputField (name), errText, text);
  }

/*
 * check whether an input control doesn't have too many charcters.
 * If it does, shorten the text accordingly.
 * This function should be called onKeyDown and onKeyUp.
 */
function textMax (limit)
	{
  var el = event.srcElement;
	if (el.value.length > limit)
		el.value = el.value.substring(0, limit);
  }


/*
 * return the absolute screen pos of an element
 */
function getAbsolutePos (el)
  {
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent)
	  {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	  }
	return r;
  }


/*
 * move the window so that it is Visible on the screen
 */
function moveOnScreen (w, dx, dy)
  {
  try
    {
    //alert ("left " + w.screenLeft + " + width " + dx + " = " + (w.screenLeft + dx) + ", limit " + w.screen.width);
    if (w.screenLeft + dx > w.screen.availWidth)
      {
      var maxOffset = -1 * w.screenLeft + 5;
      var offset = w.screen.availWidth - (w.screenLeft + dx) - 10;
      w.moveBy (Math.max (offset, maxOffset), 0);
      }
    //alert ("top " + w.screenTop + " + height " + dy + " = " + (w.screenTop + dy) + ", limit " + w.screen.height);
    if (w.screenTop + dy > w.screen.availHeight)
      {
      var maxOffset = -1 * w.screenTop + 23;
      var offset = w.screen.availHeight - (w.screenTop + dy) - 10;
      w.moveBy (0, Math.max (offset, maxOffset));
      }
    }
  catch (e)
    {
    }
  }

/*
 * refresh the opener window by calling its refreshFunc or submitting its refresh form
 */
function refreshOpener(closemyself)
  {
  if (window.opener != null)
    {
    var func = findRefreshFunc (window.opener);
    if (func != null)
      func();
    else
      {
      var form = findForm (window.opener, "refresh");
      if (form != null)
        form.submit();
      }
    }
  if (closemyself)
    {
    if (ie)
      window.open('','_self','');
    window.close();
    }
  }

function findRefreshFunc (win)
  {
  if (typeof win.refreshFunc != "undefined")
    return win.refreshFunc;
  for (var i = 0; i < win.frames.length; i++)
    {
    var f = findRefreshFunc (win.frames[i]);
    if (f != null)
      return f;
    }
  return null;
  }

function findForm (win, name)
  {
  var f = win.document.forms[name];
  if (f != null && f != "undefined")
    return f;
  for (var i = 0; i < win.frames.length; i++)
    {
    f = findForm (win.frames[i], name);
    if (f != null)
      return f;
    }
  return null;
  }

function getEhypForm()
  {
  if (document.forms.length <= 1)
    return document.forms[0];
  if ((typeof myEhypForm != "undefined") && myEhypForm)
    return document.forms[myEhypForm];
  if (document.forms["ehyp"])
    return document.forms["ehyp"];
  if (document.forms["appform"])
    return document.forms["appform"];
  return document.forms[0];
  }

function submitAsUrl()
  {
  var frm = getEhypForm();
  var url = frm.action;
  var connect = "?";
  if (url.indexOf("?") != -1)
    connect = "&";
  for (var i = 0; i < frm.elements.length; i ++)
    {
    var el = frm.elements[i];
    if (el.type == "button")
      continue;
    if (el.type == "checkbox"  &&  !el.checked)
      continue;
    url += connect;
    connect = "&";
    url += el.name;
    url += "=";
    var val = getFieldValue (el.name);
    if (val)
      {
      //Vorsicht: zerschiesst die Umlaute - lieber lassen
      //url += encodeURIComponent (val);
      url += val;
      }
    }
  document.location.href = url;
  }

function setRadioButton (name, value)
  {
	var el = inputField(name);
	if (isArray(el))
	  {
	  for (var i = 0; i < el.length; i++)
    	if (el[i].value == value)
    		{
    		el[i].checked = true;
    		break;
    		}
    }
	else if (el.value == value)
		el.checked = true;
	}

function setFieldValue (name, value)
  {
  var el = firstInput (name);
  setElementValue (el, value);
  }

function setElementValue (el, value)
  {
  if (!el)
    return;
	if (el.type == "radio")
		{
		setRadioButton (name, value);
		return;
		}
	else if (el.type == "select-one")
	  {
    for (var j = 0; j < el.options.length; j ++)
      {
      var option = el.options[j];
      if (option.value == value)
        {
        option.selected = true;
        break;
        }
      }
	  }
	else
  	el.value = value;
  }

function reloadFieldOptions(fieldName, allOptions)
  {
  var field = firstInput (fieldName);
  reloadElementOptions (field, allOptions);
  }

function reloadElementOptions(field, allOptions)
  {
  for (var i=0; i<allOptions.length; i++)
    {
    var thisValue = allOptions[i][1];
    var alreadyShown = false;
    for (var j=0; j<field.options.length; j++)
      {
      if (field.options[j].value == thisValue)
        {
        alreadyShown = true;
        break;
        }
      }
    if (!alreadyShown)
      field.options[field.options.length] = new Option(allOptions[i][0], thisValue);
    }
  }

function replaceFieldOptions (field, allOptions)
  {
  var maxLength = Math.max (field.options.length, allOptions.length);
  for (var i=maxLength-1; i>=0; i--)
    {
    if (i<allOptions.length)
      field.options[i] = new Option (allOptions[i][0], allOptions[i][1]);
    else
      field.options[i] = null;
    }
  }

function hideFieldOptions(fieldName, hideOptions)
  {
  var field = firstInput (fieldName);
  for (var i=field.options.length-1; i>=0; i--)
    {
    var thisValue = field.options[i].value;
    if (contains (hideOptions, thisValue))
      field.options[i] = null;
    }
  }

function append (base, delimiter, appendix)
  {
  if (!base || base.length == 0)
    return appendix;
  if (!appendix || appendix.length == 0)
    return base;
  return base + (!delimiter ? "" : delimiter) + appendix;
  }

function contains(array, value)
  {
  for (var i=0; i<array.length; i++)
    if (array[i] == value)
      return true;
  return false;
  }

function optionsContainValue (options, value)
  {
  return (optionsIndexOfValue (options, value)>-1);
  }

function optionsIndexOfValue (options, value)
  {
  for (var i=0; i<options.length; i++)
    if (options[i].value == value)
      return i;
  return -1;
  }

function toggleAdditionalOption (thisField, optionValue, optionText, switchOn)
  {
  if ( thisField )
    {
	  var optionIndex = optionsIndexOfValue (thisField.options, optionValue);
	  if ( switchOn )
	    {
	    if ( optionIndex == -1 )
	      thisField.options[thisField.options.length] = new Option (optionText, optionValue);
	    }
	  else
	    {
	    if ( optionIndex > -1 )
	      thisField.options[optionIndex] = null;
	    }
	  }
  }

function isInPopup ()
  {
	if ((window.opener))
	  return true;
	if (parent != window && parent.frames.length > 0)
	  return true;
  return false;
  }

function goodFirstname (text)
  {
  return goodName (text, true);
  }

function goodLastname (text)
  {
  return goodName (text, false);
  }

function goodName (text, eachword)
  {
  if (!text || text == "")
    return text;
  if (text != text.toLowerCase())
    return text;
  var words = text.split(" ");
  for (var i = 0; i < words.length; i++)
    if (eachword || i == words.length-1)
      {
      var word = words[i];
      var names = word.split("-");
      for (var j = 0; j < names.length; j++)
        names[j] = capFirst(names[j]);
      words[i] = names.join("-");
      }
  text = words.join(" ");
  return text;
  }

function capFirst (text)
  {
  return text.substring(0, 1).toUpperCase() + text.substr(1);
  }

var noEncodeChars = " -_.*!'()öäüÖÄÜß";
function urlEncodeFormData (url)
  {
  var result = "";
  var start = 0;
  var end = 0;
  for (var i = 0; i < url.length; ++i)
    {
    var ch = url.charAt (i);
    if ('0' <= ch && ch <= '9' || 'A' <= ch && ch <= 'Z' || 'a' <= ch && ch <= 'z' || noEncodeChars.indexOf (ch) >= 0)
      ++end;
    else
      {
      if (start != end)
        result += url.slice (start, end);
      start = end = i + 1;
      result += encodeUTF8 (url.charCodeAt (i));
    	}
    }
  if (start != end)
    result += url.slice (start, end);
  return result.replace (/ /, "+");
  }

var doEncodeChars = "\n\r\a\t";
function urlEncodeSpecialChars (url)
  {
  var result = "";
  var start = 0;
  var end = 0;
  for (var i = 0; i < url.length; ++i)
    {
    var ch = url.charAt (i);
    if (doEncodeChars.indexOf (ch) >= 0)
      {
      if (start != end)
        result += url.slice (start, end);
      start = end = i + 1;
      result += encodeUTF8 (url.charCodeAt (i));
    	}
    else
    	end++;
    }
  if (start != end)
    result += url.slice (start, end);
  return result.replace (/ /, "+");
  }

var hexDigits = [48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70];
function encodeUTF8 (code)
  {
  if (code < 128)
    return String.fromCharCode (37, hexDigits[code >> 4], hexDigits[code & 0xF]);
  else if (code < 0x800)
    return String.fromCharCode (37, hexDigits[0xC | (code >> 10)], hexDigits[(code >> 6) & 0xF], 37, hexDigits[0x8 | ((code >> 4) & 0x3)], hexDigits[code & 0xF]);
  else if (code < 0x10000)
    return String.fromCharCode (37, 69, hexDigits[(code >> 12) & 0xF], 37, hexDigits[0x8 | ((code >> 10) & 0x3F)], hexDigits[(code >> 6) & 0xF], 37, hexDigits[0x8 | ((code >> 4) & 0x03)], hexDigits[code & 0x0F]);
  }

var matchText = "";
var lastKeyHit = null;

function typingMatch ()
	{
  return; // for now, it doesn't work because of IE bug
	if (!window.event)
	  return; // for netscape, who does it correctly by itself
  var evt = window.event;
  var c = evt.keyCode;
  //println ("key up " + lastKeyPressed);
  var k = makeChar (c);
  if (k == "")
    return;
  var ms = (new Date()).getTime();
  if (lastKeyHit < ms - 1100)
    matchText = "";
  lastKeyHit = ms;
  matchText += k;
  var s = evt.srcElement;
  for (var i = 0; i < s.options.length; i ++)
    if (s.options[i].text.toLowerCase().indexOf(matchText) == 0)
      {
      s.selectedIndex  = i;
      break;
      }
  evt.cancelBubble = true;
  evt.returnValue = false;
	}

function typingSearch ()
	{
  return; // for now, it doesn't work because of IE bug
	if (!window.event)
	  return; // for netscape, who does it correctly by itself
  var evt = window.event;
  var s = evt.srcElement;
  var c = evt.keyCode;
  var k = makeChar (c);
  if (k == "")
    return;
  var ms = (new Date()).getTime();
  if (lastKeyHit < ms - 1100)
    matchText = "";
  lastKeyHit = ms;
  matchText += k;
  for (var i = 0; i < s.options.length; i ++)
    if (s.options[i].text.toLowerCase().indexOf(matchText) != -1)
      {
      s.selectedIndex  = i;
      break;
      }
  evt.cancelBubble = true;
  evt.returnValue = false;
	}

function makeChar (c)
  {
  if (c >= 65 && c <= 90)
    return String.fromCharCode(c).toLowerCase();
  if (c >= 48 && c <= 57)
    return String.fromCharCode(c);
  switch (c)
    {
    case 222: return "ä";
    case 186: return "ü";
    case 192: return "ö";
    case 219: return "ß";
    case 190: return ".";
    case 188: return ",";
    case 189: return "-";
    case 55: return "/";
    case 32: return " ";
    }
  return "";
  }

 function convertUmlaute2Html ( text )
   {
   text = text.replace ( "ü", /&uuml;/ );
   text = text.replace ( "Ü", /&Uuml;/ );
   text = text.replace ( "ä", /&auml;/ );
   text = text.replace ( "Ä", /&Auml;/ );
   text = text.replace ( "ö", /&ouml;/ );
   text = text.replace ( "Ö", /&Ouml;/ );
   text = text.replace ( "ß", /&szlig;/ );
   return text;
   }

var _tooltipposx;
var _tooltipposy;
var _tooltiptimer = null;
var _tooltipstr;
var _tooltipwho = null;
var _tooltipdiv = null;



function showToolTip (event, str)
  {
  showToolTipExt (event, str, 5000);
  }



function showToolTipExt(event, str, displayTime)
  {
  if (_tooltipdiv == null)
    {
    _tooltipdiv = document.createElement ("div");
    _tooltipdiv.style.visibility = "hidden";
    _tooltipdiv.style.display = "none";
    _tooltipdiv.style.background = "#FFFFDD";
    _tooltipdiv.style.padding = "1px";
    _tooltipdiv.style.fontFamily = "verdana";
    _tooltipdiv.style.fontSize = "8pt";
    _tooltipdiv.style.border = "1px solid black";
    document.body.appendChild (_tooltipdiv);
    }

  if (!event)
    event = window.event;
  _tooltipposx = event.clientX;
  _tooltipposy = event.clientY;
  _tooltipstr = str;
  _tooltipwho = (typeof event.target != 'undefined') ? event.target : event.srcElement;

  if (_tooltiptimer != null)
    {
    _noDelayToolTip();
    _showToolTip();
    }
   else
    _tooltiptimer = window.setTimeout ("_showToolTip()", 1000);

  }



function _showToolTip()
  {

  _tooltipdiv.innerHTML = _tooltipstr;

  _tooltipdiv.style.visibility = "visible";
  _tooltipdiv.style.display = "block";
  _tooltipdiv.style.position = "absolute";

  var pos = _getToolTipScreenPos ();

  _tooltipdiv.style.top = pos[1];
  _tooltipdiv.style.left = pos[0];

  _tooltiptimer = window.setTimeout ("_hideToolTip()", 5000);

  }



function _getToolTipScreenPos()
  {

  var oleft = _tooltipposx + 5;
  var otop = _tooltipposy + 5;
 
  if (_tooltipwho)
    {
    otop = 5;

    obj = _tooltipwho;
    do
      {
       if (obj.scrollTop)
         otop -= obj.scrollTop;
       }
       while (obj = obj.parentNode);

    obj = _tooltipwho;
    do
      {
      otop = otop + obj.offsetTop;
      }
      while (obj = obj.offsetParent);

    otop += _tooltipwho.offsetHeight;

    if ((otop + _tooltipdiv.offsetHeight) > document.body.clientHeight)
      otop = otop - _tooltipdiv.offsetHeight - _tooltipwho.offsetHeight - 5;
    }
  else
    if ((otop + _tooltipdiv.offsetHeight) > document.body.clientHeight)
      otop = _tooltipposy - _tooltipdiv.offsetHeight - 5

  if ((oleft + _tooltipdiv.offsetWidth) > document.body.clientWidth)
     oleft = document.body.clientWidth - _tooltipdiv.offsetWidth - 1;

  return [oleft, otop];
  }



function hideToolTip()
  {
  if (_tooltiptimer != null)
    {
    var bd = _tooltipdiv.style.visibility != "hidden";
    _hideToolTip ();
    if (bd)
     _tooltiptimer = window.setTimeout ("_noDelayToolTip()", 1500);
    }
  }

function _hideToolTip()
  {

   _noDelayToolTip ();

  _tooltipdiv.style.visibility = "hidden";
  _tooltipdiv.style.display = "none";

  }

function _noDelayToolTip ()
  {

   window.clearTimeout(_tooltiptimer);
  _tooltiptimer = null;

  }

function maxfuturepayout(){
	var dDate = new Date();
	var iCurrDateMonth = parseInt(dDate.getFullYear()*12)+parseInt(dDate.getMonth()+1)
	
	if(getFieldValue("cse.venture.originalFunding.payoutDate")){
		var sPayoutDate = getFieldValue("cse.venture.originalFunding.payoutDate");
		}
	if(getFieldValue("br.payoutDate")){
		var sPayoutDate = getFieldValue("br.payoutDate");
		}		
	if(getFieldValue("year") && getFieldValue("month")){
		var iForwDateMonth = parseInt(getFieldValue("year")*12)+parseInt(getFieldValue("month"));
		}
	else{
		var sPayoutDateSplit = sPayoutDate.split(".");
		var iForwDateMonth = parseInt(sPayoutDateSplit[2]*12)+parseInt(sPayoutDateSplit[1]);
	}

	if(getFieldValue ("cse.venture.reason") != "Umschuld"){  	
  	if(parseInt(iForwDateMonth-iCurrDateMonth)>24){//max. 24 month till payout date  		
  		alert('Leider liegt das Auszahlungsdatum zu weit in der Zukunft. Die aktuellen Konditionen können wir Ihnen lediglich für die Darlehensauszahlung in bis zu 24 Monaten anbieten. Wollen Sie ein bestehendes Darlehen verlängern, so wählen Sie bitte als Vorhaben "Anschlussfinanzierung".');
  		return false;
  		}
  	else{
  		return true;
  		}
  	}  
	}