// global
var NetScape = (navigator.appName == 'Netscape' &&  navigator.userAgent.indexOf('Netscape') > 0)? true:false;
var FireFox = (navigator.appName == 'Netscape' && navigator.userAgent.indexOf('Firefox') > 0)? true:false;
var Mozilla = (navigator.appName == 'Netscape' && navigator.userAgent.indexOf('Netscape') < 0 && navigator.userAgent.indexOf('Firefox') < 0)? true:false;
var Opera = (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') > 0)? true:false;
var MSIE = (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 0)? true:false;

var LogonUser = "";
var sValuesFromServer;
var sNextField;

// debug
var debuglevel = 0;
var kbwindow;
var wLogon;
var docWindow;

// *************************************************************
// print type of navigator 
// *************************************************************
function printNav ()
	{
	if (FireFox) alert("FIREFOX");
	if (Mozilla) alert("MOZILLA");
	if (NetScape) alert("NETSCAPE");
	if (Opera) alert("OPERA");
	if (MSIE) alert ("MSIE");
	alert("AppName  : " + navigator.appName);
	alert("UserAgent: " + navigator.userAgent);
	}
	

// *************************************************************
// handler for key pressed
// *************************************************************
// keystroke
function keyDown(DnEvents)	 // handles keypress
   {
   // determines whether Netscape or Internet Explorer
   key = (navigator.appName == 'Netscape') ? DnEvents.which : window.event.keyCode;
   if (key == 13)	 // enter key pressed
      {
      if (sNextField == 'done' || sNextField == 'submit')  // submit, we finished all fields
	     {
		 if (sNextField == 'done') parent.vNextPage();
		 sNextField = "";
	     return true;
		 }
      else
         { // we're not done yet, send focus to next box
		 if (sNextField.length > 0) 
		    {
		    actfrm = parent.sGetCurrentForm();
			var oField = oGetFieldObject(document, actfrm, sNextField);
			if (oField == null)
				{
				sNextField = "";
				return false;
				}
            eval('document.' + actfrm + '.' + oField + '.focus()');
            return false;
			}
         }
      }

//   if (key == 8)	 // backspace key pressed
//      {
//      parent.vGoBack();
//      }
   }

// *************************************************************
// handler for mouse right
// *************************************************************
function right(e)
   {
   if (navigator.appName == 'Netscape' && (e.which == 3))
      {
//      alert("BASE Online, Copyright © Boll und Partner Software GmbH");
      return false;
      }
   else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
      {
      alert("BASE Online, Copyright © Boll und Partner Software GmbH");
      return false;
      }
   return true;
   }

// *************************************************************
// print output
// *************************************************************
function printform()
   {
//   if(document.all)
//      {
//      self.focus();
//      var OLECMDID_PRINT = 6;
//      var OLECMDEXECOPT_DONTPROMPTUSER = 2;
//      var OLECMDEXECOPT_PROMPTUSER = 1;
//      var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
//      document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
//      WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
//      WebBrowser1.outerHTML = '';
//      }
    window.print();
    }

function xprintform ()
	{
	alert(self.location.href);
    p = window.open('about:Druckansicht', 'Ausdruck', "toolbar=no,resizable=no,menubar=no,top=0,left=0,width=100,height=100,left=5000,top=0"); 
    if (p)
	   { 
       p.document.location.replace(self.location.href); 
       p.print(); 
       p.close(); 
       } 
	}
	
// *************************************************************
// server values
// *************************************************************
function vSetValuesFromServer (sValue)
	{
	if (debuglevel > 10) window.alert (">>vSetValuesFromServer, values=" + sValue);
	sValuesFromServer = sValue;
	}

function vGetValuesFromServer ()
	{
	if (debuglevel > 10) window.alert (">>vGetValuesFromServer, values=" + sValuesFromServer);
	return(sValuesFromServer);
	}

function vErrorMessage ()
	{
	window.alert ("Es ist ein Fehler aufgetreten!");
	return(true);
	}
// *************************************************************
// layer functions
// *************************************************************
// *************************************************************
// set layer descriptors
// *************************************************************
function vSetTitleLayer (sForm)
	{
	if (debuglevel > 10) window.alert (">>vSetTitleLayer");
	title_layer = sForm;
	}

function vSetNaviLayer (sForm)
	{
	if (debuglevel > 10) window.alert (">>vSetNaviLayer");
	navi_layer = sForm;
	}

function vSetInfoLayer (sForm)
	{
	if (debuglevel > 10) window.alert (">>vSetInfoLayer");
	info_layer = sForm;
	if (statliste != null)
		{
		if ((statliste[0] == "Anmeldung") && (numpages == 1) && (currentpage == 0))
			{
			vSetStatusInfoText (0);
			}
		}
	}

function vSetLoginLayer (sForm, sLayerName)
	{
	if (debuglevel > 10) window.alert (">>vSetLoginLayer");
	login_layer = sForm;
	statliste = new oCreateStatListe(3);
	statliste[0] = "Anmeldung";
	numpages = 1;
	vSetStatusInfoText (0);
    vShowLayer (login_layer,sLayerName);
	sFormname = "frm_" + sLayerName;
	vFormInit(login_layer.document, sFormname);
	}

function vSetMainLayer (sForm, iVorgang)
	{
	var sLayerName;
	
	if (debuglevel > 10) window.alert (">>vSetMainLayer");
	main_layer = sForm;
	vInitGlobalVars();
	vSetAntrag(iVorgang);
	currentpage = 0;
	sLayerName = formliste[currentpage];
	vShowLayer (main_layer,sLayerName);
	sFormname = "frm_" + sLayerName;
	vFormInit(main_layer.document, sFormname);
	}

function oGetLayerID(oForm, sLayer)
	{
	var LayerID;

	if (document.all)
		{
		LayerID = oForm.document.all[sLayer];
 		}
	else if (document.getElementById)
		{
		LayerID = oForm.document.getElementById(sLayer);
		}
	return(LayerID);
	}

function vHideLayer (sForm, sLayerName)
	{
	var oForm;
	var sFormName  = "frm_" + sLayerName;
	var oForm;
	var LayerID = oGetLayerID(main_layer,sLayerName);
	
	if (debuglevel > 20) window.alert ("vHideLayer, Name=" + sLayerName + " FORM=" + sFormName);
	
	LayerID.style.visibility = "hidden";

	oForm = oGetFormObject(main_layer.document, sFormName);
	vDisableEnableControls (oForm,true);

	return;
	}


function vShowLayer (sForm, sLayerName)
	{
	var oForm;
	var sFormName  = "frm_" + sLayerName;
	var LayerID = oGetLayerID(sForm,sLayerName);
	
	if (debuglevel > 20) window.alert ("vShowLayer, Name=" + sLayerName + " FORM=" + sFormName);

    oForm = oGetFormObject(sForm.document, sFormName);
	vDisableEnableControls (oForm,false);
		
	LayerID.style.visibility = "visible";

	return;
	}


function vHandleLayer (sLayerName, sType)
	{
	var LayerID;
	var sForm = eval("main_layer.document.frm_" + sLayerName);

	LayerID = oGetLayerID(main_layer, sLayerName);
	LayerID.style.visibility = sType;
	return;
	}

function vDisableEnableControls (oForm,bDisable)
	{
	var i;
	
    // window.alert (">> vDisableEnableControls. Form=" + oForm.name);
	// window.alert (">> vDisableEnableControls. ElementCount=" + oForm.elements.length);
	for (i = 0; i < oForm.elements.length; i++)
		{
		if (oForm.name == "frm_d_Besitzstand_amt")
			{
			if (oForm.elements[i].type != "hidden")
				{
				if (oForm.elements[i].name == "req_besitzstandok")
					{
					oForm.elements[i].disabled = bDisable;
					}
				}	
			}
		else
			{
			if (oForm.elements[i].type != "hidden")
				{
				oForm.elements[i].disabled = bDisable;
				}
			}
		}
	}
	

// *************************************************************
// form functions
// *************************************************************
function oGetFormObject (oDocument, sFormName)
	{
	var oForm;
	var i;

	if (oDocument == null) return (null);
	
	for (i = 0; i < oDocument.forms.length; i++)
		{
		oForm = oDocument.forms[i];
		if (oForm.name.toLowerCase() == sFormName.toLowerCase())
			{
			return (oForm);				
			}
		}
	return (null);
	}

function oGetFieldObject (oDocument, sFormName, sFieldName)
	{
	var oForm;
	var index;

	if (oDocument == null) return (null);
	oForm = oGetFormObject (oDocument, sFormName);
	if (oForm == null) return (null);
	
	index = SearchFormVar(oForm, sFieldName);
	if (index >=0) return (oForm.elements[index].name);
	else return (null);
	}

function sGetFormInitString (oDocument, sFormName)
	{
	var oForm;
	var j;

	oForm = oGetFormObject(oDocument, sFormName);
	if (oForm == null) return ("");
	
	sHelp = oForm.elements[0].name + "; ";
	for (j = 0; j < oForm.elements.length; j++)
		{
		if (oForm.elements[j].name.toUpperCase() == "FORMINIT")
			{
			return (oForm.elements[j].value);
			}
		}
	return (sHelp);				
	}

function vSetFormFocus(oDocument, sFormName, sField)
	{
	var oForm;
	var j;
	var index;
	
	if (debuglevel > 20) window.alert (">>vSetFormFocus, field=" + sField);

    oForm = oGetFormObject(oDocument, sFormName);
	if (oForm == null) return;
	
	for (j = 0; j < oForm.elements.length; j++)
		{
		index = SearchFormVar(oForm, sField);
		if (index >= 0)
			{
			if (debuglevel > 20) window.alert(oForm.elements[index].name);
			var element = oForm.elements[index];
			if (debuglevel > 20) window.alert (">>vSetFormFocus, form= " + oForm.name + ", field=" + sField);
			if (debuglevel > 20) window.alert (">>vSetFormFocus, element.type = " + element.type);
			if (element.type != "hidden")	element.focus();
			else sGetStatusMessage(element.name.toLowerCase());
			if (element.type == "text")
				{
				if (element.length > 0) element.select();
				}
			return;
			}
		}
	return;
	}

// *************************************************************
// array functions
// *************************************************************
function oCreateFormListe (size)
	{
	if (debuglevel > 10) window.alert (">>oCreateFormListe");
	if (size+"" == "undefined" || size == null)
	   return null;
	this.length = size;
	for (var i = 0; i < size; i++)
		{
		this[i] = null;
		}
	numpages = size;
	return this;
	}

function oCreateStatListe (size)
	{
	if (debuglevel > 10) window.alert (">>oCreateStatListe");
	if (size+"" == "undefined" || size == null)
	   return null;
	this.length = size;
	for (var i = 0; i < size; i++)
		{
		this[i] = null;
		}
	return this;
	}

function oCreateMsgListe (size)
	{
	if (debuglevel > 10) window.alert (">>oCreateStatListe");
	if (size+"" == "undefined" || size == null)
	   return null;
	this.length = size;
	for (var i = 0; i < size; i++)
		{
		this[i] = null;
		}
	return this;
	}


// *************************************************************
// display functions
// *************************************************************
function sGetStatusMessage (sFieldName)
	{
	var	i;
	var sText;
	var bFound = false;
	var sNField = '';
	
	if (msgliste == null)
		{
		window.alert (">> internal error, msgliste not initialized!");
		return;
		}
		
	var sField = sFieldName;
	if (Mid(sField, 1, 4) == "req_")
		{
		sField = Mid(sField, 5, Len(sField));
		}
	if (Mid(sField, 1, 4) == "opt_")
		{
		sField = Mid(sField, 5, Len(sField));
		}
	if (Mid(sField, 1, 5) == "date_")
		{
		sField = Mid(sField, 6, Len(sField));
		}
		
	for (i = 0; i < msgliste.length; i++)
		{
		if (msgliste[i] == null) break;
		sText = Split(msgliste[i],";");
		// window.alert ("0:" + sText[0] + " 1:" + sText[1] + " 2:" + sText[2]);
		if (sText[0] == sField)
			{
			bFound = true;
			break;
			}
		}

	if (bFound)
		{
		if (sFieldName.indexOf("req_") >= 0) sText[1] = sText[1] + " (Pflichtfeld)"
		vSetStatusBarText (sText[1]);
		if (sText[3] != null) sNField = sText[3];
		}
	else
		{
		StrConv(sField, 3);
		vSetStatusBarText (sField);
		}
	return (sNField);
	}

function vSetStatusBarText (sText)
	{
	var LayerID;
	var sLayerName = "d_StatusZeile";

	if (debuglevel > 10) window.alert (">>vSetStatusBarText: " + sText);	
	
	if (navi_layer == null) return;
	
	LayerID = oGetLayerID(navi_layer, sLayerName);
	LayerID.innerHTML = sText;
	}

function vSetStatusInfoText (iPage)
	{
	var LayerID;
	var sLayerName = "d_StatusInfo";
	var sText;
	var i;
	var iActivePage = iPage;
	
	if (debuglevel > 10) window.alert (">>vSetStatusInfoText, Page=" + iPage);
	
	if (info_layer == null) return;
	
	sText = "<table>";
	for (i = 0; i < numpages; i++)
		{
		sText = sText + "<tr><td class="
		if (i == iActivePage)
			{
			sText = sText + "'statustext-active'>"
			}
		else
			{
			sText = sText + "'statustext-gray'>"
			}
		sText = sText + statliste[i];
		sText = sText + "</td></tr>";
		}
	sText = sText + "</table>";
		
	LayerID = oGetLayerID(info_layer,sLayerName);
	LayerID.innerHTML = sText;
    
	vSetLogonStatus ();
	}

function vSetLogonStatus ()
	{
	var LayerID;
	var sLayerName = "d_StatusFenster";
	var sText = "";
	var i;
	var sLogonStatus;
	
	if (debuglevel > 10) window.alert (">>vSetLogonStatus");
	
	if (info_layer == null) return;
	
//	sText = '<a href="javascript:wSecurityLogon(' + "'BAULogin.html'" + ');"><img src="images/Logon.gif" alt="Anmeldung" name="Anmeldung" vspace="5" hspace="5" width="18" height="20" border="0"></a>';
	sText = sText + "<table>";
	sText = sText + "<tr><td class='statustext-active'>";
	sText = sText + "<br>";
	sLogonStatus = sGetLogonStatus();
	sText = sText + sLogonStatus;
	sText = sText + "</td></tr>";
	sText = sText + "</table>";
		
	LayerID = oGetLayerID(info_layer,sLayerName);
	LayerID.innerHTML = sText;
	}


function wSecurityLogon (sURL)
	{
     var sTITLE = "Anmeldung";
     var iWidth = 350;
     var iHeight = 180;
     var ixPos = (screen.availWidth - iWidth) / 2;
     var iyPos = (screen.availHeight - iHeight) / 2;

 	 var sParams	= "toolbar=no,"
			+ "location=no,"
			+ "directories=no,"
			+ "status=no,"
	 		+ "menubar=no,"
			+ "scrollbars=no,"
			+ "fullscreen=no,"
			+ "resizable=no,"
			+ "width="   + iWidth + ","
			+ "height="  + iHeight + ","
			+ "screenX=" + ixPos + ","
			+ "screenY=" + iyPos;
	
	wLogon = window.open(sURL, sTITLE, sParams);
	wLogon.moveTo (ixPos,iyPos);
	wLogon.focus();
	}

function openKontrollBlatt (sURL)
	{
	var sTITLE = "Kontrollblatt";
    var iWidth = 600;
    var iHeight = 800;

	var sParams	= "toolbar=no,"
			+ "location=no,"
			+ "directories=no,"
			+ "status=no,"
	 		+ "menubar=no,"
			+ "scrollbars=no,"
			+ "fullscreen=no,"
			+ "resizable=yes,"
			+ "width=" + iWidth + ","
			+ "height=" + iHeight;
//	alert(sParams);
	kbwindow = window.open( sURL, sTITLE, sParams);
	kbwindow.focus();
	}

function sGetRadioValue( radioObject )
{ 
	var value = null;

	// Validate parameter value
//***	if (radioObject+"" == "undefined" || radioObject == null)
	if (radioObject == null)
		return "";
	for (var i=0; i < radioObject.length; i++) { 
		if (radioObject[i].checked) { 
			value = radioObject[i].value;
			break;
		} 
	} // end for loop 
	
	return value;
}
// end sGetRadioValue


/**************************************************************
 SearchFormVar, CG 10.10.2001
 Überpr&uuml;ft ob der angegebene Feldname auf der HTML-Form ist
 und gibt dessen Index zur&uuml;ck
***************************************************************/
function SearchFormVar(formObj, field)
{
var i;
var index = -1;
var item = field.toLowerCase();
var req_item = "req_" + item;
var opt_item = "opt_" + item;
var date_item = "date_" + item;
var req_date_item = "req_date_" + item;
var opt_date_item = "opt_date_" + item;

for (i=0; i<formObj.elements.length; i++)
   {
   // store the form element in a new object to make life easier
   var element = formObj.elements[i];
   var FormItem = element.name.toLowerCase();
   if (FormItem == item || FormItem == req_item || FormItem == opt_item || FormItem == date_item || FormItem == req_date_item || FormItem == opt_date_item)
      {
      index = i;
      break;
      }
   }
   return index;
}

// **************************************************************
function ResetAllFormVars(docObj)
	{
	for (var i = 0; i < docObj.forms.length; i++)
		{
		ResetFormVar(docObj.forms[i]);
		}
	}


function ResetFormVar(formObj)
	{
	var i;
	var index;
	var req_item = "req_";
	var opt_item = "opt_";
	var date_item = "date_";
	var req_date_item = "req_date_";
	var opt_date_item = "opt_date_";

	for (i=0; i<formObj.elements.length; i++)
		{
		var element = formObj.elements[i];
		var FormItem = element.name.toLowerCase();
		
		index = 0;
		if (FormItem.indexOf(req_item) >= 0) index = 1;
		if (FormItem.indexOf(opt_item) >= 0) index = 2;
		if (FormItem.indexOf(date_item) >= 0) index = 3;
		if (FormItem.indexOf(req_date_item) >= 0) index = 4;
		if (FormItem.indexOf(opt_date_item) >= 0) index = 5;
		
		// window.alert ("TEST: " + FormItem + ", Index=" + index);
		if (index > 0)
			{
			if (element.type == "text" || element.type == "hidden") element.value = "";
			if (element.type == "select-one" || element.type == "select-multiple") element.selectedIndex = 0;
			if (element.type == "checkbox" || element.type == "radio") element.checked = false;
			}
		}	
	}



/**************************************************************
 ReplaceFormVar, CG 10.10.2001
 ersetzt alle auf der HTML-Form befindlichen Feldinhalte durch
 die &uuml;bergebenen Parameter (?name1=value1&name2=value2...)
***************************************************************/
function ReplaceFormVar(formObj, href)
{
var j;
var name = "";
var value = "";
var help = "";
var element;
var start = InStr(href, "?");
if (start == 0) return (-1);
var data = Mid(href, start+1, Len(href)-start+1);
var aNameVal = Split(data, "&");

if (debuglevel > 10) window.alert (">>ReplaceFormVar");
for (var i=0;i<aNameVal.length; i++)
   {
   start = InStr(aNameVal[i], "=");
   if (start > 0) 
      {
      name = Left(aNameVal[i], start-1);
      value = Mid(aNameVal[i], start+1, Len(aNameVal[i])-start+1);
      index = SearchFormVar(formObj, name);
      if (index >= 0)
         {
     	 if (debuglevel > 10) window.alert(formObj.elements[index].name);
      	 element = formObj.elements[index];
         if (debuglevel > 10) window.alert("Form: " + formObj.name + "Name: " + element.name + ", Type: " + element.type + ", " + value + "-" + URLDecode(value));
            
         if (element.type == "text" || element.type == "hidden"  || element.type == "textarea") element.value = URLDecode(value);
         if (element.type == "select-one" || element.type == "select-multiple")
			{
			help = URLDecode(value);
			for (j = 0; j < element.length; j++)
				{
				if (element.options[j].value == help)
					{
					element.selectedIndex = j;
					}
				}
			}
          
         if (element.type == "checkbox" || element.type == "radio")
            {
            element.checked = false;
			var oField = eval(formObj.name + '.' + element.name);
			for (var k=0; k < oField.length; k++)
				{
				   if (oField[k].value == URLDecode(value))
				      {
					  oField[k].checked = true;
					  break;
					  }
				}
            }
         }
      }
   }
}

/**************************************************************
 ReplaceAllFormVars, CG 20.09.2002
 ersetzt in allen auf der HTML-Seite befindlichen Forms die
 Feldinhalte durch
 die &uuml;bergebenen Parameter (?name1=value1&name2=value2...)
***************************************************************/
function ReplaceAllFormVars(docObj, href)
{
   for (var i = 0; i < docObj.forms.length; i++)
      {
      ReplaceFormVar(docObj.forms[i], href);
      }
}

/**************************************************************
 StoreAllFormVars, CG 23.09.2002
 speichert alle Feldinhalte aller Forms eines Dokumentes in
 einem String des Formats ?name1=value1?name2=value2...
***************************************************************/
function StoreAllFormVars(docObj, oForm)
{
   var element;
   var saveData = "";
   var i;
   var j;
   var k;
   var bData = true;
   var bStoreFormVars = false;
   var formname;
//   window.alert (">>StoreAllFormVars");
   for (i=0; i<docObj.forms.length; i++)
      {
//      window.alert ("Form: " + docObj.forms[i].name);
      formname = Mid(docObj.forms[i].name, 5, docObj.forms[i].name.length - 4)
      bStoreFormVars = false;
	  if (formliste == null) return;
      for (j=0; j<formliste.length; j++)
         {
         if (formname == formliste[j])
            {
            bStoreFormVars = true;
            break;
            }
         }
      if (bStoreFormVars)
         {
//         window.alert ("Form: " + docObj.forms[i].name);
         for (j=0; j<docObj.forms[i].elements.length; j++)
            {
            element = docObj.forms[i].elements[j];
            var sFormItem = element.name.toLowerCase();
            bData = false;
//            window.alert ("Field: " + docObj.forms[i].elements[j].name);
            if (Mid(sFormItem, 1, 4) == "opt_")
                {
                sFormItem = Mid(sFormItem, 5, Len(sFormItem));
                bData = true;
                }
            if (Mid(sFormItem, 1, 4) == "req_")
                {
                sFormItem = Mid(sFormItem, 5, Len(sFormItem));
                bData = true;
                }
            if (Mid(sFormItem, 1, 5) == "date_")
                {
                // sFormItem = Mid(sFormItem, 6, Len(sFormItem));
                bData = true;
                }
            if (bData)
               {   
               savedItem="";
			   if (debuglevel > 10) window.alert("Name: " + element.name + ", Type: " + element.type);
               if (element.type == "text" || element.type == "textarea" || element.type == "hidden") savedItem = URLEncode(element.value);
				   
               if (element.type == "select-one" || element.type == "select-multiple")
                  {
                  savedItem = URLEncode(element[element.selectedIndex].value);
                  }
			   if (element.type == "radio")
                  {
				  bData = false;
                  savedItem = URLEncode(element.value);
				  if (element.checked) bData = true;
                  }
			   if (element.type == "checkbox")
                  {
				  if (element.checked) savedItem = URLEncode(element.value);
                  }
               if (bData) saveData = saveData + sFormItem + "=" + savedItem + "|";
//             window.alert("Value: " + element.value);
               }
            }
         }
      }

//	window.alert("saveData: " + saveData);
//	window.alert("Anzahl Forms: " + docObj.forms.length);
//	window.alert("Forms: " + docObj.forms[docObj.forms.length-1].name);
//     docObj.forms[docObj.forms.length-1].GDATA1.value = saveData;
	oForm.GDATA1.value = saveData;

   return;
}


/**************************************************************
 openFDFFile, CG 10.10.2001
 redirected zur angegeben URL
***************************************************************/
function openFDFFile(href)
{
	var aHref = Split(href, "?");
	var aNameVal = Split(aHref[1], "=");
	var sDokument = aNameVal[1];
	Redirect(sDokument);
}

/**************************************************************
 openDOCFile, CG 21.04.2005
 redirected zur angegeben URL
***************************************************************/
function openDOCFile(sURL)
{
	var sTITLE = "Download aktuelle Daten...";
    var iWidth = 60;
    var iHeight = 80;
	var sParams	= "toolbar=no,"
			+ "location=no,"
			+ "directories=no,"
			+ "status=no,"
	 		+ "menubar=no,"
			+ "scrollbars=no,"
			+ "fullscreen=no,"
			+ "resizable=yes,"
			+ "width=" + iWidth + ","
			+ "height=" + iHeight;
//	docWindow = window.open( sURL, sTITLE, sParams);
//	docWindow.focus();
//	docWindow.close();
	Redirect(sURL);
}


/**************************************************************
 Redirect, CG 10.10.2001
 redirected zur angegeben URL
***************************************************************/
function Redirect(href)
	{
	if (debuglevel > 10) window.alert('Redirect: ' + href);
    if (NetScape) window.location=href;
//		else window.navigate(href);
//      else window.location.href=href;
  	else location.replace(href);
	}

function isOlderThan50 (Birthday)
	{

	var sYear = Abs(Right(Birthday, 4));
	var iYear = parseInt(sYear) + 50;
	sYear = iYear.toString();
	var NewDate = new DataClassDate ();
	NewDate.Year = sYear;
	NewDate.Month = Mid(Birthday, 4, 2);
	NewDate.Day = Mid(Birthday, 1, 2);
	
	// Check for valid date
	Data = new DataClassDate ();
	if (Data.Compare (NewDate) >= 0)
		{
		return 1;
		}
	return 0;

	}
/**************************************************************
 Abs: Returns a value of the same type that is passed to it 
      specifying the absolute value of a number.

 Parameters:
      Number = The required number argument can be any valid 
               numeric expression. If number contains Null, 
               false is returned; if it is an uninitialized 
               variable, false is returned.

 Returns: Long
***************************************************************/
function Abs(Number)
{
	Number = Number.toLowerCase();
	RefString = "0123456789.-";

	if (Number.length < 1) 
		return (false);

	for (var i = 0; i < Number.length; i++) 
	{
		var ch = Number.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}

	if (Number < 0)
		return (Number * -1)

	return Number;
}

/**************************************************************
 Len: Returns a Long containing the number of characters in a 
      string or the number of bytes required to store a 
      variable.

 Parameters:
      string = Any valid string expression. If string contains 
               null, false is returned.

 Returns: Long
***************************************************************/
function Len(string)
{
	if (string == null)
		return (false);

	return String(string).length;
}

/**************************************************************
 Chr: Returns a String containing the character associated 
      with the specified character code.

 Parameters:
      CharCode = Long that identifies a character.

 Returns: String
***************************************************************/
function Chr(CharCode)
{
	return String.fromCharCode(CharCode);
}

/**************************************************************
 Asc: Returns an Integer representing the character code 
      corresponding to the first letter in a string

 Parameters:
      String = The required string argument is any valid 
               string expression. If the string if not in 
               the range 32-126, the function return ZERO

 Returns: Integer
***************************************************************/
function Asc(string)
{
	var symbols = " !\"#$%&'()*+'-./0123456789:;<=>?@";
	var loAZ = "abcdefghijklmnopqrstuvwxyz";
	symbols += loAZ.toUpperCase();
	symbols += "[\\]^_`";
	symbols += loAZ;
	symbols += "{|}~";
	var loc;
	loc = symbols.indexOf(string);
	if (loc > -1)
	{ 
		Ascii_Decimal = 32 + loc;
		return (32 + loc);
	}
	return (0);
}

/**************************************************************
 LTrim: Returns a String containing a copy of a specified 
        string without leading spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 RTrim: Returns a String containing a copy of a specified 
        string without trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 RTrim: Returns a String containing a copy of a specified 
        string without both leading and trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function Trim(String)
{
	if (String == null)
		return (false);

	return RTrim(LTrim(String));
}

/**************************************************************
 Left: Returns a String containing a specified number of 
       characters from the left side of a string.

 Parameters:
      String = String expression from which the leftmost 
               characters are returned. If string contains null, 
               false is returned.
      Length = Numeric expression indicating how many characters 
               to return. If 0, a zero-length string ("") is 
               returned. If greater than or equal to the number 
               of characters in string, the entire string is 
               returned. 

 Returns: String
***************************************************************/
function Left(String, Length)
{
	if (String == null)
		return (false);

	return String.substr(0, Length);
}

/**************************************************************
 Right: Returns a String containing a specified number of 
        characters from the right side of a string.

 Parameters:
      String = String expression from which the leftmost 
               characters are returned. If string contains null, 
               false is returned.
      Length = Numeric expression indicating how many characters 
               to return. If 0, a zero-length string ("") is 
               returned. If greater than or equal to the number 
               of characters in string, the entire string is 
               returned. 

 Returns: String
***************************************************************/
function Right(String, Length)
{
	if (String == null)
		return (false);

    var dest = '';
    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	String = dest;
	String = String.substr(0, Length);
	dest = '';

    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	return dest;
}

/**************************************************************
 Mid: Returns a String containing a specified number of 
      characters from a string

 Parameters:
      String = String expression from which characters are 
               returned. If string contains null, false is 
               returned.
      Start  = Number. Character position in string at which 
               the part to be taken begins. If Start is 
               greater than the number of characters in 
               string, Mid returns a zero-length string ("").
      Length = Number of characters to return. If omitted 
               false is returned. 

 Returns: String
***************************************************************/
function Mid(String, Start, Length)
{
	if (String == null)
		return (false);

	if (Start > String.length)
		return '';

	if (Length == null || Length.length == 0)
		return (false);

	return String.substr((Start - 1), Length);
}

/**************************************************************
 InStr: Returns a Long specifying the position of the first 
        occurrence of one string within another. Is String1
        or String2 are null, false is returned.

 Parameters:
      String1 = String expression being searched.
      String2 = String expression sought

 Returns: Integer
***************************************************************/
function InStr(String1, String2)
{
	var a = 0;

	if (String1 == null || String2 == null)
		return (false);

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	a = String1.indexOf(String2);
	if (a == -1)
		return 0;
	else
		return a + 1;
}

/**************************************************************
 Sgn: Returns an Integer indicating the sign of a number. If
      Integer is not a number the functions return false.

 Parameters:
      Integer = The number argument can be any valid numeric 
                expression.

 Returns: Integer       -1 If Integer < 0
                         0 If Integer = 0
                         1 If Integer > 0
                     false If Parameter IS NOT NUMERIC
***************************************************************/
function Sgn(Integer)
{
	Number = Integer.toLowerCase();
	RefString = "0123456789-";

	if (Number.length < 1) 
		return (false);

	for (var i = 0; i < Number.length; i++) 
	{
		var ch = Number.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	if (Integer < 0)
		return (-1);
	else if (Integer == 0)
		return (0);
	else
		return (1);
}

/**************************************************************
 LBound: Returns a Long containing the smallest available 
         subscript for the indicated dimension of an array

 Parameters:
      array = Array to verify

 Returns: Integer       (-1 if Array does not contain
                            any subscript)
***************************************************************/
function LBound(array)
{
	var i = 0;
	var temp = '';

	if (array.length == 0)
		return (-1);

	for (i = 0; i < array.length; i++)
	{
		temp = array[i]
		if (temp != null)
		{
			var temp = i;
			return temp;
		}
	}
	return (-1);
}

/**************************************************************
 UBound: Returns a Long containing the largest available 
         subscript for the indicated dimension of an array

 Parameters:
      array = Array to verify

 Returns: Integer       (-1 if Array does not contain
                            any subscript)
***************************************************************/
function UBound(array)
{
	return (array.length - 1);
}

/**************************************************************
 Join: Returns a string created by joining a number of 
       substrings contained in an array.

 Parameters:
      array     = One-dimensional array containing substrings 
                  to be joined
      Delimiter = String character used to separate the 
                  substrings in the returned string. 
                  If delimiter is a zero-length string (""), 
                  all items in the list are concatenated 
                  with no delimiters. 

 Returns: String
***************************************************************/
function Join(array, Delimiter)
{
	var temp = '';

	if (array.length == 0)
		return '';

	if (Delimiter.length == 0)
		Delimiter = ' ';

	for (var i = 0; i < array.length; i++)
	{
		temp = temp + array[i]
		if (i < array.length - 1)
			temp = temp + Delimiter;
	}
	return temp;
}

/**************************************************************
 ReturnString: Returns a String containing a repeating 
               character string of the length specified

 Parameters:
      Number    = Length of the returned string. If number 
                  is less than 1, false is returned.
      Character = Character code specifying the character or 
                  string expression whose first character is 
                  used to build the return string. If character 
                  contains null, false is returned. 

 Returns: String
***************************************************************/
function ReturnString(Number, Character)
{
	var temp = '';

	if (Number < 1)
		return (false);

	if (Character.length == 0)
		return (false);

	if (Character.length > 1)
		Character = Character.charAt(0);

	for (var i = 0; i < Number; i++)
	{
		temp = temp + Character
	}

	return temp;
}

/**************************************************************
 Split: Returns a zero-based, one-dimensional array containing 
        a specified number of substrings

 Parameters:
      Expression = String expression containing substrings and 
                   delimiters. If expression is a zero-length 
                   string(""), Split returns an empty array, 
                   that is, an array with no elements and no 
                   data.
      Delimiter  = String character used to identify substring 
                   limits. If delimiter is a zero-length 
                   string (""), a single-element array 
                   containing the entire expression string 
                   is returned.

 Returns: String
***************************************************************/
function Split(Expression, Delimiter)
{
	var temp = Expression;
	var a, b = 0;
	var array = new Array();

	if (Delimiter.length == 0)
	{
		array[0] = Expression;
		return (array);
	}

	if (Expression.length == '')
	{
		array[0] = Expression;
		return (array);
	}

	Delimiter = Delimiter.charAt(0);

	for (var i = 0; i < Expression.length; i++) 
	{
		a = temp.indexOf(Delimiter);
		if (a == -1)
		{
			array[i] = temp;
			break;
		}
		else
		{
			b = (b + a) + 1;
			var temp2 = temp.substring(0, a);
			array[i] = temp2;
			temp = Expression.substr(b, Expression.length - temp2.length);
		}
	}

	return (array);
}

/**************************************************************
 Space: Returns a String consisting of the specified number 
        of spaces

 Parameters:
      Number = Number of spaces you want in the string.

 Returns: String
***************************************************************/
function Space(Number)
{
	var temp = '';

	if (Number < 1)
		return '';

	for (var i = 0; i < Number; i++)
	{
		temp = temp + ' ';
	}
	return temp;
}

/**************************************************************
 Replace: Returns a string in which a specified substring has 
          been replaced with another substring a specified 
          number of times.

 Parameters:
      Expression = String expression containing substring to 
                   replace
      Find       = Substring being searched for.
      Replace    = Replacement substring.

 Returns: String
***************************************************************/
function Replace(Expression, Find, Replace)
{
	var temp = Expression;
	var a = 0;

	for (var i = 0; i < Expression.length; i++) 
	{
		a = temp.indexOf(Find);
		if (a == -1)
			break
		else
			temp = temp.substring(0, a) + Replace + temp.substring((a + Find.length));
	}

	return temp;
}

/**************************************************************
 IsChar: Returns a Boolean value indicating whether an 
         expression can be evaluated as a character (this 
         not only includes alpha chars but all symbols such as
         @#$%^&|\_+-/*="!?,.:;'(){}<>[]

 Parameters:
    - Expression = Variant containing a numeric expression or 
                   string expression.

 Returns: Boolean
***************************************************************/
function IsChar(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "0123456789";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a != -1)
			return (false);
	}
	return(true);
}

/**************************************************************
 IsNumber: Returns a Boolean value indicating whether an 
           expression can be evaluated as a number (this
           includes values like $15,656.00)

 Parameters:
      Expression = Variant containing a numeric expression or 
                   string expression.

 Returns: Boolean
***************************************************************/
function IsNumber(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "0123456789.-";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	return(true);
}

/**************************************************************
 IsAlphanumeric: Returns a Boolean value indicating whether an 
                 expression can be evaluated as a number or
                 char.

 Parameters:
      Expression = Variant containing a numeric expression or 
                   string expression.

 Returns: Boolean
***************************************************************/
function IsAlphanumeric(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = "abcdefghijklmnopqrstuvwxyz0123456789 ";

	if (Expression.length < 1) 
		return (false);

	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
	}
	return(true);
}

/**************************************************************
 ReverseString: Returns a string in which the character order 
                of a specified string is reversed

 Parameters:
      Expression = The expression argument is the string whose 
                   characters are to be reversed. If expression 
                   is a zero-length string (""), a zero-length 
                   string is returned. If expression is null,
                   false is returned.

 Returns: String
***************************************************************/
function ReverseString(Expression)
{
	if (Expression == null)
		return (false);

    var dest = '';
    for (var i = (Expression.length - 1); i >= 0; i--)
		dest = dest + Expression.charAt(i);
    return dest;
}

/**************************************************************
 StrConv: Returns a String converted as specified in the
          Parameters Section.

 Parameters:
      String     = String expression to be converted.
      Conversion = Number specifying the type of conversion 
                   to perform.
                   1 = TO UPPER CASE
                   2 = to lower case
                   3 = To Proper Case
                   If Conversion is null or not specified 1
                   is set as default.

 Returns: String
***************************************************************/
function StrConv(String, Conversion)
{
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	if (Conversion == null || Conversion.length == 0)
		Conversion = '1';

	if (Conversion != '1' && Conversion != '2' && Conversion != '3')
		Conversion = '1';

	if (Conversion == '1')
		return String.toUpperCase();

	if (Conversion == '2')
		return String.toLowerCase();

	//Proper Case
	tmpStr = String.toLowerCase();
	strLen = tmpStr.length;
	if (strLen > 0)
	{
		for (index = 0; index < strLen; index++)
		{
			if (index == 0)
			{
				tmpChar = tmpStr.substring(0, 1).toUpperCase();
				postString = tmpStr.substring(1, strLen);
				tmpStr = tmpChar + postString;
			}
			else
			{
				tmpChar = tmpStr.substring(index, index + 1);
				if (tmpChar == " " && index < (strLen - 1))
				{
					tmpChar = tmpStr.substring(index + 1, index + 2).toUpperCase();
					preString = tmpStr.substring(0, index + 1);
					postString = tmpStr.substring(index + 2,strLen);
					tmpStr = preString + tmpChar + postString;
				}
			}
		}
	}
	return tmpStr;
}

/**************************************************************
 OpenURL: Return a concatenated string with all the 'objects
          values' contained in a FORM HTML in the format:
          page_to_redirect.html/asp?object1=xxxx&object2=yyyyy&...

 Parameters:
      URL  = URL to redirect
      Form = Form name (be sure not to use QUOTES when passing
             the Form name)

 Returns: URL

 Example: var redirect = OpenURL('mytest.asp', frmMyForm)
          alert(redirect)
          window.nagivate(redirect)
***************************************************************/
function OpenURL(URL, Form)
{
	if (URL.length == 0 || URL == null)
		return (false);

	var form_length = Form.elements.length;
	var myform = Form;
	var mytype = '';
	var temp = URL + '?';

	for (var i = 0; i < form_length; i++)
	{
		mytype = myform.elements[i].type
		mytype = mytype.toLowerCase();
		if (mytype == 'text' || mytype == 'hidden' || mytype == 'select-one' ||
		    mytype == 'checkbox' || mytype == 'radio' || mytype == 'select-multiple')
		{
			var t = myform.elements[i].name
			if (t == null || t == '')
				t = myform.elements[i].id
			if (mytype == 'text' || mytype == 'hidden')
				temp = temp + t + "=" + escape(myform.elements[i].value);
			else if (mytype == 'checkbox' || mytype == 'radio')
				temp = temp + t + "=" + escape(myform.elements[i].checked);
			else if (mytype == 'select-one' || mytype == 'select-multiple')
				temp = temp + t + "=" + escape(myform.elements[i][myform.elements[i].selectedIndex].value);
			if (i < form_length - 1)
				temp = temp + "&";
		}
	}
	temp = temp.substring(temp, temp.length - 1)

	return temp;
} 


/* ======================================================================
FUNCTION:	URLDecode
 
INPUT:		str (string): the string to be decoded

RETURN:  	URL-decoded version of str;
				returns null if invalid arguments were passed

DESC:		This function augments the default JavaScript/JScript unescape 
		function.  unescape does not handle literal '+' characters embedded 
		in URLs.  This function pre-processes a URL-encoded string by 
		converting all '+' characters to spaces, and then calls unescape to
		complete the decode process.
====================================================================== */
function URLDecode ( str ) {
	var resultStr = "";

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";
	
	// Loop through each char in string and replace '+' with ' '
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) == "+")
			resultStr += " ";
		else
			resultStr += str.charAt(i);
	}
	
	return unescape(resultStr);
}  // END URLDecode

/* ======================================================================
FUNCTION:	URLEncode
 
INPUT:		str (string): the string to be encoded

RETURN:  	URL-encoded version of str;
		returns null if invalid arguments were passed

DESC:		This function augments the default JavaScript/JScript escape 
		function.  unescape does not handle literal ' ' characters embedded 
		in URLs.  This function pre-processes a URL-decoded string by 
		converting all ' ' characters to '+', and then calls escape to
		complete the encode process.
====================================================================== */
function URLEncode ( str ) {
	var resultStr = "";

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";
	
	// Loop through each char in string and replace ' ' with '+'
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ")
			resultStr += "+";
		else
			resultStr += str.charAt(i);
	}
	
	return (escape(resultStr));
}  // END URLEncode


// //////////////////////////////////////////////////////////////////////////////////////
// Check Forms
// //////////////////////////////////////////////////////////////////////////////////////
sAlertMessage = '';
sCheckedElements = '';

function checkForm(form, bSubmit, sErrorImagePath, sGoodImagePath, bCustomCheck){

	if (bSubmit == null) bSubmit = false;
	
	// initialize the variables for this run of the function
	sAlertMessage = '';
	bReturn = true;
	iFocusElement = -1;
	sCheckedElements = '';
	
	for (i=0; i < form.elements.length; i++){
		// store the form element in a new object to make life easier
		var item = form.elements[i]
	
		// check to see if the item is required
		if (item.name.indexOf("req_") >= 0 || item.name.indexOf("opt_date_") >= 0 ) {
			// find out what type of entry it is
			bErr = false;
			switch (item.type) {
				case 'button':
					// no error checking - should never get here
					break;
				case 'checkbox':
					if (!checkCheckbox(item, form)) {
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						bReturn = false;
						bErr = true;
					}
					break;
				case 'file':
					// no error checking
					break;
				case 'hidden':
					// no error checking
					break;
				case 'password':
					// error check, including check for the confirmation box
					// passwords are a special case of type Text, so use the same check mechanism
					if (!checkText(item, form))
						{
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						// set the focus, if it has not already been set
						if (iFocusElement == -1) {
							iFocusElement = i;
						}
						bReturn = false;
						bErr = true;
						}
					else
						{
						// check the length of the password as well
						if (!checkLength(item, 4))
							{
							// add a semi-custom error message.
							sAlertMessage = sAlertMessage + 'Ihre PIN muss vierstellig eingegeben werden. \n';
							// set the focus, if it has not already been set
							if (iFocusElement == -1) iFocusElement = i;
							bReturn = false;
							bErr = true;
							}
						}
					
					break;
				case 'radio':
					if (!checkCheckbox(item, form)) {
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						bReturn = false;
						bErr = true;
					}
					break;
				case 'reset':
					// no error checking - should never get here
					break;
				case 'select-one':
					if (!checkSelect(item, form)) {
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						// set the focus, if it has not already been set
						if (iFocusElement == -1) {
							iFocusElement = i;
						}
						bReturn = false;
						bErr = true;
					}
					break;
				case 'select-multiple':
					if (!checkSelect(item, form)) {
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						// set the focus, if it has not already been set
						if (iFocusElement == -1) {
							iFocusElement = i;
						}
						bReturn = false;
						bErr = true;
					}
					break;
				case 'submit':
					// no error checking - should never get here
					break;
				case 'text':
					// error check, including check for a confirmation box
					if (item.name.indexOf("req_date_") >= 0 || item.name.indexOf("opt_date_") >= 0)
						{
						if ((item.name.indexOf("req_date_") >= 0) || (item.name.indexOf("opt_date_") >= 0 && item.value.length > 0))
						if (!IsDate(item))
							{
							addMessage(item, form);
							// set the focus, if it has not already been set
							if (iFocusElement == -1)
								{
								iFocusElement = i;
								}
							bReturn = false;
							bErr = true;
                                                        }
                                                 }
					else
						{
					
						if (!checkText(item, form))
							{
							// found a bad entry, add the error message, swap the image, set the over-all form value to bad
							addMessage(item, form);
							// set the focus, if it has not already been set
							if (iFocusElement == -1)iFocusElement = i;
							bReturn = false;
							bErr = true;
							}
						else
							{
							// check if we need special checks for Email Characters - always named "mail" after the user property
							if (stripKeys(item.name).toLowerCase() == 'email')
								{
								if (!checkEmail(item))
									{
									addMessage(item, form);
									if (iFocusElement == -1) iFocusElement = i;
									bReturn = false;
									bErr = true;
									}
								}
							}
						}
						break;

				case 'textarea':
					// error check, including check for a confirmation box
					if (!checkText(item, form)) {
						// found a bad entry, add the error message, swap the image, set the over-all form value to bad
						addMessage(item, form);
						// set the focus, if it has not already been set
						if (iFocusElement == -1) {
							iFocusElement = i;
						}
						bReturn = false;
						bErr = true;
					}
					break;
				default:
					// no error checking - should never get here
					break;
			}
		}
	}
	
	// look for and run any custom error checking routines
	if (bCustomCheck) {
		// make sure that the function really exists
		if (customCheck) {
			// run the custom check function, and test it's properties
			var oCustomCheck = new customCheck(form, sGoodImagePath, sErrorImagePath);
			if (!oCustomCheck.pass){
				// if the custum check routine found an error
				// set the overall error check to failure
				bReturn = false;
				// and add the custom message to the string
				sAlertMessage = sAlertMessage + oCustomCheck.message;
			}
		}
	}
	
	if (!bReturn) alert(sAlertMessage);
	if (iFocusElement >= 0)	form.elements[iFocusElement].focus();

	if (bReturn && bSubmit)	form.submit();
	return bReturn;
	}

// Primary Element Check Routines

function checkCheckbox(item, form) {
	// also used for radio buttons, since they behave the same way, and have the same properties
	
	/* Radio Buttons and Check boxes behave in an unusual manner.  When looping through the form
	   element by element like this, each entry is its own entity with no relation to any others,
	   even with the same name. Because we want to check the complete array of elements with the 
	   same name, we have to actually check the form by element name, rather than element number.
	   To prevent duplicate checks, we will keep the names of all checked elements in a global 
	   string, and add each new name checked to the string.  If an item name is already in that 
	   string, it will not be checked again. */
	   
	// set the local variables
	bLocValid = false;
		
	if (sCheckedElements.indexOf(item.name+',') < 0) {
		// hasn't been previously checked.  Add the name to the list and perform checks.
		sCheckedElements = sCheckedElements + item.name + ',';
		
		// because a checkbox could be one item, or many we first have to see if there is only one item and it is checked
		// if not, then we check to see if there are any items in the array that are checked
		if (eval('form.'+item.name+'.length')) {
			// loop through the individual memembers of the checkbox, looking for one that is checked (stop as soon as one is found)
			for (j=0; j < eval('form.'+item.name+'.length'); j++) {
				if (eval('form.'+item.name+'['+j+'].checked')){
					bLocValid = true;
					break;
				}
			}
		} else {
			// only one item
			if (item.checked) {
				bLocValid = true;
			}
		}
	} else {
		// has already been checked - return true.  Any false entries will have already been caught, and we don't want to give duplicate warnings.
		bLocValid = true;
	}

	return bLocValid;
	
}

function checkSelect(item) {
	/*
	  Assumes that the first option item is NOT a valid if it has no defined value.  Note that JavaScript and the DOM descriminate
	  between the VALUE and the TEXT of an option.  ASP makes the TEXT the VALUE when the form is posted, when no VALUE is set.
	*/
	// set the local variables
	bLocValid = true;
	
	if (item.selectedIndex < 0) {
		// -1 is returned if NOTHING is selected (most common in IE 5 where no default selected option exists)
		bLocValid = false;
	}
	if (item.selectedIndex == 0) {
		// if the first item in the list does not have a value, it is not intended as a valid selection, but is probably instructional like "Choose One"
		if (item.options[0].value == '') {
			bLocValid = false;
		}
	}
	return bLocValid;
}

function checkText(item, form)
	{
	// set the local variables
	var bLocValid = true;
	var sTemp;
	
	if (item.value.length < 1)
		{
		return false;
		}

	// check the value to make sure that it contains something other than white space characters
	// reset the valid value - this test will set it to positive only if it finds a good character
	bLocValid = false;
	// only check the first 100 characters at most - could result in a false negative, but hey,if they don't type a character in the first 100, is it REALLY a false negative?
	if (item.value.length < 100)
		{
		iLength = item.value.length;
		}
	else
		{
		iLength = 100;
		}
		
	for (var j=0; j < iLength; j++)
		{
		sTemp = item.value.substring(j, j+1);
		if (sTemp != ' ' && sTemp != '\n' && sTemp != '\f' && sTemp != '\r' && sTemp != '\t')
			{
			bLocValid = true;
			break;
			}
		}
	
	// see if you can figure out a way to do length constrains (max and min characters)
	
	if (bLocValid)
		{
		// check to see if a confirmation is required, and if it is valid
		if (!checkConfirm(item, form))
			{
			bLocValid = false;
			}
		}
		
	return bLocValid;
	}

// Secondary Element Check Routines

function checkConfirm(item, form) {
	// set  the local varaibles
	bConfirm = true;
	
	// look to see if there is a confirm field for the field being checked
	// if so, check to see that they are the same
	if (eval('form.conf_'+stripKeys(item.name))) {
		if (eval('form.conf_'+stripKeys(item.name)+'.value') != item.value) {
			bConfirm = false;
		}
	}
	
	return bConfirm;
}

function checkEmail (item) {
	// look for the required characters "@" & "." in the email value 
	if (item.value.indexOf("@") < 0 || item.value.indexOf(".") < 0) {
		return false;
	} else {
		// be really picky and look at the positions of the "@" and the 
		return true;
	}
}

function checkLength(item, iMin, iMax) {
	/* This routine is primarily for use by custom error checking, but is also in use by password.
	   Can only be used on text-type items (text, textarea, password)
	   If iMin is defined, checks for a minimum number of characters
	   If iMax is defined, checks for a maximum number of characters
	*/
	
	bLocValid = true;
	
	if (iMin && iMin != ''){
		if (item.value.length < iMin){
			bLocValid = false;
		}
	}
	if (iMax && iMax != ''){
		if (item.value.length > iMax){
			bLocValid = true;
		}
	}
	
	return bLocValid;
}

// Helper Routines

function stripKeys(sTemp) {
	// strip out all the key values from a form element name
	// keys are xxxx_ eg req_ or up_
	sRet = sTemp.substring(sTemp.lastIndexOf("_")+1);
	
	return sRet;
}


function sGetErrorMessage (sFieldName)
	{
	var	i;
	var sText;
	var sErrorMessage;
	var bFound = false;
	
	if (debuglevel > 20) window.alert (">> sGetErrorMessage for field " + sFieldName);
	
	var sField = sFieldName;
	if (Mid(sField, 1, 4) == "req_")
		{
		sField = Mid(sField, 5, Len(sField));
		}
	if (Mid(sField, 1, 4) == "opt_")
		{
		sField = Mid(sField, 5, Len(sField));
		}
	if (Mid(sField, 1, 5) == "date_")
		{
		sField = Mid(sField, 6, Len(sField));
		}

	for (i = 0; i < msgliste.length; i++)
		{
		if (msgliste[i] == null) break;
		sText = Split(msgliste[i],";");
		// window.alert ("0:" + sText[0] + " 1:" + sText[1] + " 2:" + sText[2]);
		if (sText[0] == sField)
			{
			bFound = true;
			break;
			}
		}

	if (bFound)
		{
		sErrorMessage = sText[2];
		if (sErrorMessage.length < 1) sErrorMessage = sText[1];
		}
	else
		{
		StrConv(sField, 3);
		sErrorMessage = "Keine Meldung f&uuml;r " + sField;
		}
	// alert(sErrorMessgae);
	return (sErrorMessage);
	}

function addMessage(item, form)
	{
	var sMessage;
	sMessage = sGetErrorMessage(item.name);
	sAlertMessage = sAlertMessage + sMessage + '\n';
	}


function swapImage(item, sSRC) {
	/* replace one image with another.  Generally a neutral or clear dot expanded to size with some sort of alerting or
	   attention grabbing image. Expects to find the image named the same thing as the base portion of the form.element.name
	   (no keys) which generated the error in the first place.  There can only be ONE image with each name on a page.
	   (??? maybe user name.length??? like in checkCheckbox, if that really works ....???)
	*/
	
	// check to see that the image is defined (not sure this will work - trying to avoid any error messages popping up)
	if (document[stripKeys(item.name)].src) {
		// swap the image
		document[stripKeys(item.name)].src = sSRC;
	}
}


// Default Weekday Names
var Wochentag = new Array ("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");

// Default static variables
var DisableOnBlur = false;

// Default format strings
var DefaultDateFormat = "%D1.%M1.%Y2";
var DefaultTimeFormat = "%H1:%U2";
var DefaultFloatFormat = "%T.%D,%F02";
var DefaultIntFormat = "%T.";


// This is the constructor if the class 'DataClassDate'

function DataClassDate ()

	{
	// Get current date via internal date class
	Heute = new Date ();

	// Preset members of class with current date
	this.Year = (Heute.getYear () < 1500) ? Heute.getYear () + 1900 : Heute.getYear ();
	this.Month = Heute.getMonth () + 1;
	this.Day = Heute.getDate ();
	}


// Method will be added to class 'DataClassDate'
// This routine evaluates the weekday of the date (Sunday = 0 ... Saturday = 6)

function DataClassDate_GetWeekday ()

	{
	Temp = new Date ();
	Temp.setYear (this.Year);
	Temp.setMonth (this.Month - 1);
	Temp.setDate (this.Day);
	return Temp.getDay ();
	}


// Method will be added to class 'DataClassDate'
// Creates a formatted date string using the format string.

function DataClassDate_Format (Format)

	{
	Result = (Format == null || Format == "") ? DefaultDateFormat : Format;

	Result = Result.replace (/%Y0/, "");
	Result = Result.replace (/%Y1/, FormatNumber (this.Year % 100, 2));
	Result = Result.replace (/%Y2/, this.Year);

	Result = Result.replace (/%M0/, "");
	Result = Result.replace (/%M1/, this.Month);
	Result = Result.replace (/%M./, FormatNumber (this.Month, 2));

	Result = Result.replace (/%D0/, "");
	Result = Result.replace (/%D1/, this.Day);
	Result = Result.replace (/%D2/, FormatNumber (this.Day, 2));

	Result = Result.replace (/%W0/, "");
	Result = Result.replace (/%W1/, Wochentag [this.GetWeekday ()].substr (0,2));
	Result = Result.replace (/%W2/, Wochentag [this.GetWeekday ()]);

	return Result;
	}


// Method will be added to class 'DataClassDate'
// Scans day, month and year from a given string based on format.
// Presets the associated properties.

// Return true : The string represents a valid date. The classes properties have been changed.
// Return false: The string does not represent a valid date. The classes properties remain unchanged.

function DataClassDate_Scan (Text, Format)

	{
	// Preset components
	NewDay = 0;
	NewMonth = 0;
	NewYear = 1900;

	// If format is null, use default format
	if (Format == null || Format == "")
		Format = DefaultDateFormat;

	// If the input is an 8-digit-string, interpret it as DDMMYYYY
	if (Text.length >= 6 && Text.length <= 8 && Text.search (/\D/) < 0)
		{
		NewDay = parseInt (Text.substr (0,2), 10);
		NewMonth = parseInt (Text.substr (2,2), 10);
		NewYear = parseInt (Text.substr (4,4), 10);
		Text = "";
		}

	// Scan numbers from text as long as %-sequences are found in format
	while (1)
		{
		FormatItem = Format.match (/%[DMY]\d/);
		TextItem = Text.match (/\d+/);
		if (FormatItem == null || TextItem == null)
			break;

		Format = Format.replace (/%[DMY]\d/, "");
		Text = Text.replace (/\d+/, "");

		switch (FormatItem [0].substr (1,1))
			{
			case "D":	NewDay = parseInt (TextItem [0], 10); break;
			case "M":	NewMonth = parseInt (TextItem [0], 10); break;
			case "Y":	NewYear = parseInt (TextItem [0], 10); break;
			}
		}

	// If year is less than 20, expand to 20xx else to 19xx
	if (NewYear < 20)
		NewYear += 2000;
	if (NewYear < 100)
		NewYear += 1900;

	// On bad date result 'false'
	if (NewYear < 1600)
		return false;
	if (NewMonth < 1 || NewMonth > 12)
		return false;
	if (NewDay < 1 || NewDay > GetMonthLng (NewYear, NewMonth))
		return false;

	// Assign the new date to properties
	this.Year = NewYear;
	this.Month = NewMonth;
	this.Day = NewDay;

	return true;
	}


// Method will be added to class 'DataClassDate'
// Compares the classes date (year month day) itself with a given reference class.
// Hour, minute and second are not evaluated.

// Results -1 if the class is less than the reference class.
//          0 if the class is equal the reference class
//          1 if the class is greater then the reference class.

function DataClassDate_Compare (Ref)

	{
	if (this.Year < Ref.Year)
		return -1;
	if (this.Year > Ref.Year)
		return 1;
	if (this.Month < Ref.Month)
		return -1;
	if (this.Month > Ref.Month)
		return 1;
	if (this.Day < Ref.Day)
		return -1;
	if (this.Day > Ref.Day)
		return 1;
	return 0;
	}


// This routine returns the length of the date's year in days

function GetYearLng (Year)

	{
	if ((Year %   4) != 0) return 365;
	if ((Year % 400) == 0) return 366;
	if ((Year % 100) == 0) return 365;
	return 366;
	}


// This routine returns the length of the date's month in days

function GetMonthLng (Year, Month)

	{
	var MonthLengths = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if (Month < 1)
		return 0;
	if (Month > 12)
		return 0;
	if (Month == 2)
		return (GetYearLng (Year) == 365) ? 28 : 29;

	return MonthLengths [Month - 1];
	}

// Thus routine converts a positive integer into a 2-digit-string

function FormatNumber (Value, Digits)

	{
	// Convert number to string
	Result = Value + "";

	// Add leading zeroes as long as result is too short
	while (Result.length < Digits)
		Result = "0" + Result;

	return Result;
	}

// Assign methods to classes

DataClassDate.prototype.Format = DataClassDate_Format;
DataClassDate.prototype.Scan = DataClassDate_Scan;
DataClassDate.prototype.Compare = DataClassDate_Compare;
DataClassDate.prototype.GetWeekday = DataClassDate_GetWeekday;

/**************************************************************
 IsDate: Returns a Boolean (true) if the date is true, false
         is not

 Parameters:
	- Element: String date

 Returns: Boolean
***************************************************************/
function IsDate (Element)
	{
	// Preset visible format
	VisiFormat = "%D2.%M2.%Y2";

	// If the input is empty and not required field, do not check or format
	if (Element.value.length <= 0 && Element.name.indexOf("opt_") >= 0)
		return true;
	// If the input is 00.00.0000 do not check or format
	if (Element.value == "00.00.0000")
		return true;

	// Check for valid date
	Data = new DataClassDate ();
	if (Data.Scan (Element.value, VisiFormat) != true)
		{
		return false;
		}

	// Format the input
	Element.value = Data.Format (VisiFormat);

	return true;
	}


/**************************************************************
 IsDate: Returns a Boolean (true) if the date is true, false
         is not

 Parameters:
	- DateStr: String date in format (MM/DD/YYYY)

 Returns: Boolean
***************************************************************/
function xIsDate(dateStr)
{
	// Checks for the following valid date formats:
	// MM/DD/YYYY   MM-DD-YYYY  DD.MM.YYYY

	var datePat = /^(\d{1,2})(\/|-|.)(\d{1,2})\2(\d{4})$/;

	var matchArray = dateStr.match(datePat)
	if (matchArray == null)
		return false

	month = matchArray[1]
	day = matchArray[3]
	year = matchArray[4]
	if (month < 1 || month > 12)
		return false

	if (day < 1 || day > 31)
		return false

	if ((month==4 || month==6 || month==9 || month==11) && day==31)
		return false

	if (month == 2)
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
		if (day>29 || (day==29 && !isleap))
			return false;
	}
	return true;
}

/**************************************************************
 Mask: Returns a Boolean if the specified Expression match
       the specified Mask.

 Parameters:
      Expression = String to validate
      Mask       = String that can contain the following
                   options:
                   9 = only numbers (0..9)
                   X = only letters (a..z or A..Z)
                   * = Anything...
 Example: alert(Mask("(954) 572-4419", "(999) 999-9999")); => TRUE
          alert(Mask("33351-820", "99999-9999"));          => FALSE
          alert(Mask("This is a test", "XXXXXX"));         => FALSE
          alert(Mask("This 34 a test", "**************")); => TRUE

 Returns: Boolean
***************************************************************/
function Mask(Expression, Mask)
{
	Mask = Mask.toUpperCase();
	LenStr = Expression.length;
	LenMsk = Mask.length;
	if ((LenStr == 0) || (LenMsk == 0))
		return (false);
	if (LenStr != LenMsk)
		return (false);
	TempString = '';
	for (Count = 0; Count <= Expression.length; Count++)
	{
		StrChar = Expression.substring(Count, Count + 1);
		MskChar = Mask.substring(Count, Count + 1);
		if (MskChar == '9')
		{
			if(!IsNumber(StrChar))
				return (false);
		}
		else if (MskChar == 'X')
		{
			if(!IsChar(StrChar))
				return (false);
		}
		else if (MskChar == '*')
		{
			if(!IsAlphanumeric(StrChar))
				return (false);
		}
		else
		{
			if (MskChar != StrChar) 
				return (false);
		}
	}
	return (true);
}

function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
// alert("SetCookie: Name=" + name + ", Value=" + value);
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}

function vSetLogonID (sOnlineID, sLogonID, sDescription, sLogonUser, iTimeout)
   {
	if (debuglevel > 10) 
		{
		window.alert (">>vSetLogonID");
		window.alert (sLogonID);
		}
	var expMinutes = iTimeout;
	var expDate = new Date();
	expDate.setTime(expDate.getTime() +  (60 * 1000 * expMinutes)); 
	SetCookie('extonlineid', sOnlineID, expDate, "/");
	SetCookie('extlogonid', sLogonID, expDate, "/");
	SetCookie('extbezeichnung', sDescription, expDate, "/");
	SetCookie('extlogonuser', sLogonUser, expDate, "/");
   }

function sGetLogonStatus()
	{
	var status = "";
	var id = GetCookie('extlogonid');
	if (id != null && id.length > 0)
		{
		var desc = GetCookie('extbezeichnung');
		if (desc != null && desc.length > 0)
			{
			status = desc + "<br>"
			}
		var user = GetCookie('extlogonuser');
		if (user != null && user.length > 0)
			{
			LogonUser = user;
			status = status + LogonUser + "<br>ist angemeldet"
			}
		}
	return (status);
	}

function sGetLogonID()
   {
   var id = GetCookie('extlogonid');
   if (id != null)
      {
	  return(id);
	  }
   else
      {
	  return("");
      }
   }
   
function vGetLogonID(formOBJ)
	{
	var id = GetCookie('extlogonid');
	if (id != null)
		{
        formOBJ.extlogonid.value = id;
		formOBJ.extbezeichnung.value = GetCookie('extbezeichnung');
		formOBJ.extlogonuser.value = GetCookie('extlogonuser');
		}
	}

var int_milliSec = 0;
var intInterval  = 1000 * 10;
var handlerInterval = null;

function startTimer(iSekunden)
	{
	// alert("startTimer: " + iSekunden + " (" + intInterval/1000 + ")");
	int_milliSec = iSekunden * 1000;
	handlerInterval = window.setInterval("clockTimer()", intInterval);
	}

function stopTimer()
	{
	// alert("stopTimer");
	if (handlerInterval != null) window.clearInterval(handlerInterval);
	}

function clockTimer()
	{
	if(int_milliSec > 0)
		{
    	int_milliSec = (int_milliSec -= intInterval);
  		}
	else
		{
    	timeIsUp();
    	stopTimer();
		}
	}

function timeIsUp()
	{
	// alert("timeIsUp");
	vSetLogonStatus();
	}

function bChkFile(fieldObj, iMode)
	{
	var szFileTyp = '';
	var szFileAllowed = '';
	var szFileAllowed1 = 'DXF,DWG,DWF,PDF,JPG,JPEG';
	var szFileAllowed2 = 'JPG,JPEG,PNG,TIF,GIF,BMP,PCX,TGA,PSD,PCD,WMF,EMF';
	if (fieldObj.value.length > 0)
		{
        for (var i = (fieldObj.value.length - 1); i >= 0; i--)
		   {
		   if (fieldObj.value.charAt(i) == '.') break;
		   }
		 
		 if (i > 0) szFileType = Mid(fieldObj.value, i+2, fieldObj.value.length - i)
		 if (iMode == 1) szFileAllowed = szFileAllowed1;
		 if (iMode == 2) szFileAllowed = szFileAllowed2;
		 if (InStr(szFileAllowed, szFileType) == 0)
			 {
			 window.alert('Ung&uuml;ltiger Dateityp "' + szFileType + '".\n Nur folgende Dateitypen sind erlaubt: ' + szFileAllowed);
			 fieldObj.focus();
			 return (1);
			 }
		}
	return (0);
	}

// last line

