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 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 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 != 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);
	}

//-------------------------------------------------------------------------------------
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.focus();
		    break;
		  	}
		  }
		}
	if (typeof on_focus_init != "undefined")
	  on_focus_init();
	}

//-------------------------------------------------------------------------------------
function fc (name, pattern)
  {
  fcc (name, pattern, "app");
  }

var lastFocusElement;
var lastFocusElementFailed = false;

function fcc (name, pattern, newClass)
  {
  lastFocusElementFailed = false;
  var fld = firstInput (name);
 if (fld.className == "error")
   fld.className = newClass;
 if (pattern != "")
   reformat (fld, pattern);
  }

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;
  	  }
  	  
    if (frmt.substring(2, frmt.length) == "HH:mm")
    	{
	  	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.substring(2, frmt.length) == "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.");
		var el = firstInput(name);
		el.className="error";
		return setFocus(el, 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.");
		var el = firstInput(name);
		el.className="error";
		return setFocus(el, 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)
	{
	var el = inputField(name);
	if (el != null && isEmptyField(el))
		{
		el.className = "error";
    hasFocus = setFocus(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)
	{
		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 hasField (name) 
  {
  var el = firstInput (name);
  if (typeof el != "undefined" && el != null)
    return true;
  return false;
  }

//-------------------------------------------------------------------------------------
function getFieldValue (name)
  {
 	var el = firstInput (name);
 	if (!el || el == "undefined")
 	  return null;
	if (el.type == "select-one")
	  return el.options[el.selectedIndex].value;
  if (el.type == "radio")
    return getRadioButtonValue (el);
	return el.value;
  }

//-------------------------------------------------------------------------------------
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);
	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)
		{
		if(isArray(el))
			el = el[0];
		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
*/
function duplicateTabLine (topic, vcs, before, prefix)
  {
  duplicateTabLine_2 (topic, vcs, before, prefix, null);
  }

function duplicateTabLine_2 (topic, vcs, before, prefix, dontReplaceVcsAfter)
  {
	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);
    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 < trc.childNodes.length; i ++)
      {
      var td = trc.childNodes(i);
      td.innerHTML = td.innerHTML.split(oldVc).join (newVc);
  		}    
    }
  event.srcElement.onchange = ignoreOk;
  event.srcElement.value = value;
	//alert ("new tab " + tab.outerHTML);
  }

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


/*-------------------------------------------------------------------------------------
 * returns the input field of given name or an array, if multiply defined
 */
function inputField (name)
  {
  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)
  {
	var el = inputField(name);
	if (isArray(el))
		el = el[0];
	return el;
	}
 
var stdFloatFormatter = null;
function makeStdFloatFormatter()
  {
	if (stdFloatFormatter == null)
	  stdFloatFormatter = new Formatter("#.###,00");
	}

/*-------------------------------------------------------------------------------------
 * 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;
	if (stdFloatFormatter == null)
	  makeStdFloatFormatter();
	val = stdFloatFormatter.parseFloat(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;
	if (stdFloatFormatter == null)
	  makeStdFloatFormatter();
	val = stdFloatFormatter.parseFloat(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;
	val = el.value;
	if (val == null || val == "")	
		return null;
	if (stdFloatFormatter == null)
	  makeStdFloatFormatter();
	val = stdFloatFormatter.parseFloat(val);
	return 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;
	if (stdFloatFormatter == null)
	  makeStdFloatFormatter();
	val = stdFloatFormatter.parseFloat(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);
  }

/*-------------------------------------------------------------------------------------
 * simple Popup Window
 */
function simplePopupWindow (name, w, h, url)
	{
  options = "toolbar=no,menubar=no,locationbar=no,scrollbars=auto,resizable=yes,status=yes";
  return popupWindow (name, -1, -1, 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, w, h, maximize, options, url)
	{
  var w = window.open (url, name, options + ",width=" + w + ",height=" + h);
  if (w && w != "undefined")
    {
    if (maximize)
      maximizeWindow(w);
    else if (document.all)
      moveOnScreen (w);
    if (x != -1 && y != -1)
    	w.moveTo( x, y );
    w.focus();
    }
  return w;	  
  }	  
  
/*-------------------------------------------------------------------------------------
 * 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/b2bTermination - 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
  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 = 410;
    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 = 530;
    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 = 900;
    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 == "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=no,status=no";
  	}
  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 == "b2bTermination")
    {
    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";
  	}	
  	

  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")
	      maximizeWindow(w);
	    else if (document.all)
	      moveOnScreen (w);
      if (category == "app" )
      	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)
	{
	setNavFramePage(url,page,null);
	}
	
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)
	{
	setNavFramePageView(url,view,page,null);
	}
	
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)
	{
	setBotFramePage(url, showSave, null);
	}

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)
		{
		// for ie call the appropriate method on the element
		// for others (ns) workaraound is: scroll to bottom then up again
		//if(ie)
		//  {
		//	el.scrollIntoView();
		//	if (document.body.scrollLeft > 0)
		//	  document.body.scrollLeft = 0;
		//  }
		//else
			scrollTo(0,5000);
		el.focus();	
		hasFocus = true;
		}
	return hasFocus;
	}
	
/*
 * 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.width)
      w.moveBy (w.screen.width - (w.screenLeft + dx) - 10, 0);
    //alert ("top " + w.screenTop + " + height " + dy + " = " + (w.screenTop + dy) + ", limit " + w.screen.height);
    if (w.screenTop + dy > w.screen.height)
      w.moveBy (0, w.screen.height - (w.screenTop + dy) - 10);
    }
  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)
    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"];
  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;
    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);
  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);
  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 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 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]);
  }

