// Beschreibung siehe ganz unten 

// Email-Adresse verstecken
function email(name, domain, tld, link) 
{
	var link = "<a href='mailto:" + name + "@" + domain + "." + tld + "'>" + link + "</a>";
	document.write(link);
}

// Init beim onLoad einer HTML-Seite (Body-Tag)
function fctInitWindow()
{
	fctShowListOfMandatoryFields ( slMussFelder );

	// Buttons durchgehen und die Sprachtexte draufschreiben
	fctRewriteButtons(); 
}

// Wird von JEDEM submit aufgerufen!
function fctCheckFelder()
{
	if ( ! fctCheckListOfFieldsFilled ( slMussFelder, "", true  ) )
	{
		return;
	}

	document.forms[0].submit();
	//alert('submit');
}



// ======================================================================
function fctGetFieldValue ( fieldInfo )
// ======================================================================
{
	// Read the first value of one field
	var fv = new FieldValues ();
	fctGetMultiValueFieldValues ( fieldInfo, fv );
	return fv.getValueOrText ();
	
}	// --------- fctGetFieldValue ---------------



// ======================================================================
function fctGetMultiValueFieldValues ( fieldInfo, pfv, pfw )
// ======================================================================
{
	// This function reads the content of one field depending on its type
	var iLen;
	var m;
	var focusObject;
	var fv;
	var field	= fctGetField ( fieldInfo );
	
	// allocates field values object
	if ( pfv )
		fv = pfv;
	else
		fv = new FieldValues ();
	fv.reset ();
		
	if ( field )	// Process only if field exists
	{
		if ( field [0] && field [0].type )	// text on field [0] doesn't fit for dialog list
		{
			// Several fields with the same name (eg Radiobuttons, checkboxes)
			focusObject		= field [0];
			var iErrorCnt	= 0;
			for ( m = 0; m < field.length; m ++ )
			{
				// Read value for one occurence of the field
				if ( ! fctGmvfv_getValueFromFieldObject ( field [m], fv ) )
					iErrorCnt ++;
			}
			if ( iErrorCnt > 0 )
				alert ( "Programm error occured on a field array" );	// may be helpfull for debug
		}
		else
		{
			// Only one field with this name (normal case)
			focusObject	= field;
			fctGmvfv_getValueFromFieldObject ( field, fv );
		}
	}		// End if field exists
	
	// Returns focus object for plaus
	if ( pfw )
		pfw.setObject ( focusObject );

	// Prepares values list 
	return fv.getList ( "valueOrText" );
	
}	// --------- fctGetMultiValueFieldValues ---------------

// -------------------------------------------------------------------------------------------------------------------------------------------
function fctGmvfv_getValueFromFieldObject ( field, fv )
// called from fctGetMultiValueFieldValues
// Fills the field value fv for one occurence of a field object
// returns false if the field type is unknown
// -------------------------------------------------------------------------------------------------------------------------------------------
{
	// This function reads the content of one field depending on its type
	var iLen;
	var m;
	var focusObject;
	var boolReturn = true;
	
		// Do Read
		switch ( field.type )
		{ 
			case "hidden" : 
			case "text" : 
			case "textarea" : 
				// Text, Textarea, same processing.
				// Value of field can be read from property "value".
				fv.addValue ( field.value, "" );
				break;
		
			case "select-one" :
				// Dialog list, one possible choice. 
				// Field contains both value and text
				fv.addValue ( field.options [ field.selectedIndex ].value, field.options [ field.selectedIndex ].text );
				break;
		
			case "select-multiple":
				// Listbox, multiple choice
				// Field contains both value and text
				if ( field.selectedIndex != -1 )
				{
					iLen = field.length;
					for ( m = 0; m < iLen; m ++ )
					{
						if ( field.options [m].selected && field.options [ m ].text != "" )
							fv.addValue ( field.options [ m ].value, field.options [ m ].text );
					}
				}
				break;
		
			case "radio" :
			case "checkbox" :
				// radiobutton, checkbox, same processing.
				// Value of field can be read from property "value". Text has to be read from the next sibling text node in DOM
				if ( field.checked )
				{
					fv.addValue ( field.value, field.nextSibling.nodeValue, field.checked );
				}
				break;
				
			default :
				alert ( "Programm error. Field '" + field.name + "' : unknown type '" + field.type + "'" );
				boolReturn = false;
				break;
		}   // End outer-switch
		
	return boolReturn;
	
}	// --------- fctGmvfv_getValueFromFieldObject ---------------
// ============= End of fctGetMultiValueFieldValues and relatives ============================


// ======================================================================
function fctPerformFieldCheck ( sFunctionname, sFieldname, psOtherParms, psMessage, pboolMessage )
// ======================================================================
{
	var sOtherParms;
	var sFctCallPrefix;
	var sFctCall;
	var sMessage;
	
	if ( ! psOtherParms )
		// No other parms for the function.
		sOtherParms = "";
	else
		sOtherParms = psOtherParms;
		
	// Build function call, first without focus and message
	sFctCallPrefix	= sFunctionname + "( '" + sFieldname + "'" + sOtherParms;
	sFctCall			= sFctCallPrefix + ", '', false );";

	// Perform plaus
	if ( ! eval ( sFctCall ) )
	{
			// Plaus is not successful
			
			// We check what pboolMessage contains. 
			// If parameter missing, we define it here. Default = true.
			if ( pboolMessage == true || pboolMessage == false )
				boolMessage = pboolMessage;
			else
				boolMessage = true;

			if ( boolMessage )
			{
				// Field may be on a hidden register. 
				// We look for the next hidden <div>-Tag, and make it visible, before displaying the error message
				var fld				= fctGetField ( sFieldname );
				var htmlContainer	= fld.parentNode;
				if ( ! htmlContainer )
				{
					// No container found (Bug ?). Field could be a radiobutton or a checkbox.
					// We try this way
					if ( fld[0] && fld[0].name )
						htmlContainer	= fld[0].parentNode;
				}
				
				// Loop up through the container (container of the container of the container...) to find the next hidden div
				while ( htmlContainer )
				{
					if ( htmlContainer.nodeName.toLowerCase () == "div" && htmlContainer.style.visibility == "hidden" )
					{
						// Div-Tag found. We show the division.
						htmlContainer.style.visibility = "visible";
						// We try to handle also the proper display of the register
						if ( document.fctShowRegister )
						{
							document.fctShowRegister ( htmlContainer.id, htmlContainer );
						}
						break;
					}
					else if ( htmlContainer.nodeName.toLowerCase () == "body" )
					{
						// Body found => no hidden div tag exists for this field
						break;
					}
					
					// Read container of the actual container
					htmlContainer	= htmlContainer.parentNode;
				}
				
				// Field should now for sure be visible. We give the error msg
				// first check which error message to show
				if ( ! psMessage)
					// No text => Default text
					sMessage = "";
				else
					sMessage = psMessage;
				
				// perform the plaus again, to show the correct message and set focus on the right place
				sFctCall			= sFctCallPrefix + ", '" + sMessage + "', true );";
				eval ( sFctCall );
			}	
			return false;
	}
	return true;
	
}	// --------- fctPerformFieldCheck ---------------


// ======================================================================
function fctCheckListOfFieldsFilled ( pslFieldnames, pslMessages, pboolMessage )
// ======================================================================
{
	// This function validates the content of a list of fields fields depending on their types
	var boolReturn	= true;
	var boolArray	= false;
	var boolMessage;
	var sMessage;
	var slFieldnames;

	// We check what slFieldnames contains. 
	// If only one string, we change it to an array, to make the same processing for all cases
	if ( pslFieldnames [0] )
		slFieldnames = pslFieldnames
	else
		slFieldnames = new Array ( pslFieldnames );
	
	
	// We check what slMessages contains.
	// If only one string, the same message will be used for all the fields. 
	// If not defined, then default message will be used
	if ( pslMessages )
	{
		if ( pslMessages [0] )
			boolArray = true;
		else
			sMessage = pslMessages;
	}
	else		
		sMessage = "";

	// We check what pboolMessage contains. 
	// If parameter missing, we define it here. Default = true.
	if ( pboolMessage == true || pboolMessage == false )
		boolMessage = pboolMessage;
	else
		boolMessage = true;

	// We loop through all fields to check them
	for (var i = 0; i < slFieldnames.length ; i ++ )
	{
		// Let's prepare the error msg for this field
		// Empty = Default-Message
		if ( boolArray )
		{
			if ( i >= pslMessages.length )
				sMessage = "";
			else
				sMessage = pslMessages [i];	
		}	
		
		// Checks if field filled
		if ( ! fctCheckOneFieldFilled ( slFieldnames[i], sMessage, boolMessage ) )
		{
			boolReturn = false;
			// Field empty, we stop here
			break;
		}
	}  

	return boolReturn;	
}	// ------------ fctCheckListOfFieldsFilled ----------


// ======================================================================
function fctCheckOneFieldFilled ( fieldInfo, psMessage, pboolMessage )
// ======================================================================
{
	// This function validates the content of one field depending on its typ
	var boolUnchecked = true;
	var boolReturn = true;
	var field = fctGetField ( fieldInfo );
	if ( field ) {
		var sMessage;
		var boolMessage;
		var focusObject;
		var fw = new Wrapper();
		var fv = new FieldValues();
		var sValue;
	
		// Read field	
		sValue = fctGetMultiValueFieldValues ( field, fv, fw )
		if ( sValue == "" && ! fv.checked ) {
			// field empty
			boolReturn = false;
			
			if ( (! psMessage) || psMessage == "" )
				// No text => Default text
				sMessage = JSCheckFieldFilled;
			else
				sMessage = psMessage;
	
			// We check what pboolMessage contains. 
			// If parameter missing, we define it here. Default = true.
			if ( pboolMessage == true || pboolMessage == false )
				boolMessage = pboolMessage;
			else
				boolMessage = true;
				
			// Display error message
			if ( boolMessage ) {
				focusObject = fw.getObject ();
				if ( focusObject.type == "hidden" ) {
					// Not possible to set focus on hidden field.
					// We change the default message to display also the fieldname
					// We assume that if the message was provided, it is smart enough to inform the user correctly
					if ( sMessage == JSCheckFieldFilled )
						sMessage = focusObject.name + " : " + JSCheckFieldFilled;
				}

				fctDisplayErrorMsg ( focusObject, sMessage );
			}
		}	// Endif field empty
	}		// Endif field exists
	
	return boolReturn;
	
}	// --------- fctCheckOneFieldFilled ---------------


// ======================================================================
function fctCheckInput ( fieldInfo, sAllowedValues, iMaxCntChars, psMessage, pboolMessage )
// ======================================================================
{
	var sMessageCntChars;
	var sMessageAllowedChars;
	var sMessage = "";
	var boolMessage;
	var iPos;
	var field					= fctGetField		( fieldInfo );
	var boolReturn			= true;
	
	if ( field )	// Check only if field exists
	{
		// We check what pboolMessage contains. 
		// If parameter missing, we define it here. Default = true.
		if ( pboolMessage == true || pboolMessage == false )
			boolMessage = pboolMessage;
		else
			boolMessage = true;
	
		// Checks count chars in field. 0 = no limit
		if ( 	iMaxCntChars > 0
			&&	field.value.length > iMaxCntChars )
		{
			sMessage	= JSCheckInputMaxCountChar + iMaxCntChars;
			boolReturn	= false;
		}	
	
		// Checks field value. sAllowedValue "" = All is allowed
		if (		sMessage			== "" 
			&&	sAllowedValues	!= "" )
		{
			for ( iPos = field.value.length - 1; iPos >= 0; iPos -- )
			{
				if ( sAllowedValues.indexOf ( field.value.charAt (iPos) ) == -1)
				{
					sMessage	= JSCheckInputCharsAllowed + sAllowedValues;
					boolReturn	= false;
					break;
				}
			}
		}
		
		// Display error Message
		if ( ! boolReturn )
		{
			if ( boolMessage )
			{
				if ( psMessage && psMessage != "" )
					sMessage = psMessage;
				fctDisplayErrorMsg ( field, sMessage );
			}
		}	
	}
	
	return boolReturn ;
}	// ------- fctCheckInput --------


// ======================================================================
function fctCheckNumeric ( fieldInfo, pboolWithDot, pboolSigned, psMessage, pboolMessage )
// ======================================================================
{
	// Validates a numeric field
	var boolMessage;
	var iPos;
	var cChar;
	var boolReturn = true;
	var iDotCount = 0;
	var iSignCount = 0;
	var sCorrectChars = "1234567890";
	var sMessage = "";
	var field = fctGetField( fieldInfo );
	
	if ( field )	// Check only if field exists
	{
		// We check what pboolMessage contains. 
		// If parameter missing, we define it here. Default = true.
		if ( pboolMessage == true || pboolMessage == false ) {
			boolMessage = pboolMessage;
		} else {
			boolMessage = true;
		}

		// We complete the string with dot and sign, and initialize the error msg
		if ( pboolWithDot ) {
			sCorrectChars +=  ".";
			sMessage = "Punkt hinzugefuegt";
		}	
		if ( pboolSigned ) {
			sCorrectChars += "+-";
			sMessage = "Vorzeichen hinzugefuegt";
		}
		if ( pboolWithDot && pboolSigned ) {
			sMessage = "Vorzeichen und Punkt hinzugefuegt";
		}
			
		for ( iPos = field.value.length - 1; iPos >= 0; iPos -- ) {
			cChar = field.value.charAt ( iPos );
			if ( sCorrectChars.indexOf ( cChar ) == -1) {
				boolReturn = false;
				break;
			}
	
			if ( cChar == "." ) {
				iDotCount++;
				if ( iDotCount > 1 ) {
					// max 1 dot allowed
					boolReturn = false;
					break;
				}
			} else if ( ( cChar == "+" ||  cChar == "-" ) && ( iPos > 0 ) ) {
					// sign has to be on the first place
					boolReturn = false;
					break;
			}
		}
		
		// Display error Message
		if ( ! boolReturn ) {
			if ( boolMessage ) {
				if ( psMessage && psMessage != "" )
					sMessage = psMessage;
				fctDisplayErrorMsg ( field, sMessage );
			}
		}	
	}	// End if field exists
	
	return boolReturn; 
}	// --------- fctCheckNumeric ------------


// ======================================================================
var gErrorMsgDefaultBgColor = "red";
function fctDisplayErrorMsg ( fieldInfo, sMessage, psBgColor )
// ======================================================================
{
	var field = fctGetField ( fieldInfo );
	var sColor;
	var sOldColor;
	
	if ( field )
	{
		if ( psBgColor && psBgColor != "" )
			sColor = psBgColor;
		else
			sColor = gErrorMsgDefaultBgColor;
	
		// Field will be shown red while the error message is on the screen
		if ( sColor != "none" )
		{
			sOldColor = field.style.backgroundColor;
			if ( field.type != "hidden" )
				field.style.backgroundColor = sColor;
		}
			
		alert ( sMessage );
		
		if ( field.type != "hidden" )
		{
			if ( sColor != "none" )
				field.style.backgroundColor = sOldColor;
			field.focus ();
		}	
	}			
	else
	{
		// Field unknown. We only show the error message
		alert ( sMessage );
	}	
	
}	// --------- fctDisplayErrorMsg ------------
// Allows to change the default background color to set for error messages
function fctSetErrorMsgDefaultBgColor ( sColor )
{
	gErrorMsgDefaultBgColor = sColor;
}	// --------------- fctSetErrorMsgDefaultBgColor


// ======================================================================
// BENOETIGT Liefert das entsprechende Feld
function fctGetField ( fieldInfo )
// ======================================================================
{
	var field = null;
	if ( fieldInfo ) {
		if ( fieldInfo.type ) {		
			field = fieldInfo;			
		} else if ( fieldInfo.length ) {
			if ( fieldInfo[0] ) {
				field = fieldInfo;
			} else {
				field = document.all [ fieldInfo ];
			}
		} else {
			field = null;
		}
	}
	
	return field;
} 	// -------------- fctGetField ---------------


// ======================================================================
function fctShowListOfMandatoryFields ( pslFieldnames, pboolShowStar )
// ======================================================================
{
	fctHandleListOfFieldsWithFunction ( pslFieldnames, fctShowMandatoryField, pboolShowStar );
}	// ------------ fctShowListOfMandatoryFields ----------


// ======================================================================
function fctShowMandatoryField ( fieldInfo, pboolShowStar )
// ======================================================================
{
	var field			= fctGetField ( fieldInfo );
	var boolReturn	= false;

	if ( field && field.length && field[0].type )	// Special handling for radiobuttons and checkboxes
		field = field [0];

	if ( field && ! ( field.type == "hidden" || field.readOnly) )
	{
		var nodeWithStar;
		var sNodeId		= "Star" + field.name;
		var boolShowStar;
		
		// Test input parm
		if ( pboolShowStar == true || pboolShowStar == false )
			boolShowStar = pboolShowStar;
		else
			boolShowStar = true;

		if ( boolShowStar )	// The field is must new be filled
		{
			var nodeParent	= field.parentNode;
			var nodeParent;
			var nodeForStar;
				
			// We search the <td>-tag in wich the field is included
			while ( nodeParent && nodeParent.tagName.toLowerCase () != "td" )
				nodeParent	= nodeParent.parentNode;

			if ( nodeParent )
				// Field is actually held in a table. We look for a previous cell where to write the star
				nodeForStar	= nodeParent.previousSibling;

			if ( ! nodeForStar )
				// field is not held in a table, or is in the first cell of the row. We set the star in the current HTML container
				nodeForStar	= field.parentNode;
			
			if ( nodeForStar )
			{
				// We look in the node if there is already a star, to avoid writing a second one
				if ( fctSmfTestNodeForStar ( field, nodeForStar ) )
				{
					// No star exists. We create one
					var nodeStar				= document.createTextNode	( "*" );		// Create text node
					nodeWithStar				= document.createElement		( "span" );	// Create container (to set color and Id)
					nodeWithStar.style.color	= "red";
					nodeWithStar.id			= sNodeId;				// Set an Id to the node (to retrieve it easily for removal)
					nodeWithStar.appendChild ( nodeStar );			// include text in container

					// Insert the star in the node.
					// If the field and the star are to be in the same node, inserts the star before the field
					// else appends the star as last child node in the node
					if ( nodeForStar.contains ( field ) )
						nodeForStar.insertBefore ( nodeWithStar, field );
					else
						nodeForStar.appendChild ( nodeWithStar );
					boolReturn = true;
				}
			}
		}		// end if star has to be shown
		else	
		{	// This field is no longer mandatory. Removes the star. Works only if the star was set by this function (Id must be OK)
			nodeWithStar = document.getElementById ( sNodeId );
			if ( nodeWithStar )
			{
				nodeWithStar.removeNode ( true );
				boolReturn = true;
			}
		}
	}	// Endif field exists
	
	return boolReturn;
} 	// -------------- fctShowMandatoryField ---------------

// -------------------------------------------------------------------------------------------------------------------------------------------
function fctSmfTestNodeForStar ( field, node )
// called from fctShowMandatoryField, and recursive from itself
// Looks for a subnode containing a star as last character.
// return true (= Star has to be set) if a corresponding node is found
// -------------------------------------------------------------------------------------------------------------------------------------------
{
	if ( node.tagName && node.tagName.toLowerCase () == "form" )
	{
		// Is the field direct on the form, we test only the text right before the field (and childrens)
		node = field.previousSibling;
		if ( fctSmfTestNodeValueForStar ( field.previousSibling ) )
			// star found at the end of the string (ignore trailing spaces) => no star has to be set
			return false;
	}

	// Test all node's childrens
	for ( var i = 0; i < node.childNodes.length; i ++ )
	{
		if ( fctSmfTestNodeValueForStar ( node.childNodes [i] ) )
			// star found at the end of the string (ignore trailing spaces) => no star has to be set
			return false;

		// If this child node has children, test its childrens also (recursive call)
		if ( node.childNodes [i].hasChildNodes () )
		{
			if ( ! fctSmfTestNodeForStar ( field, node.childNodes [i] ) )
				return false;
		}	
	}

	return true;
} 	// -------------- fctSmfTestNodeForStar ---------------

// -------------------------------------------------------------------------------------------------------------------------------------------
function fctSmfTestNodeValueForStar ( node )
// called from fctSmfTestNodeForStar
// Test if the given node contains a star as last character.
// return true if found
// -------------------------------------------------------------------------------------------------------------------------------------------
{
	if (	node.nodeValue && node.nodeValue.indexOf ( "*" ) >= 0 )
	{
		// star found in string
		if ( node.nodeValue.search ( /\*\s*$/ ) >= 0 )
			// star found at the end of the string (ignore trailing spaces) => no star has to be set
			return true;
	}
	return false;
} 	// -------------- fctSmfTestNodeValueForStar ---------------
// ============= End of fctShowMandatoryField and relatives ============================


// ======================================================================
function fctSetListOfReadOnlyFields ( pslFieldnames )
// ======================================================================
{
	fctHandleListOfFieldsWithFunction ( pslFieldnames, fctSetReadOnlyField );
}	// ------------ fctSetListOfReadOnlyFields ----------


// ======================================================================
function fctSetReadOnlyField ( fieldInfo )
// ======================================================================
{
	var sFieldDef;
	var fieldNew;
	var field = fctGetField ( fieldInfo );
	var nodeCell;
	var nodeSpan;
	var nodeText;
	var fv;
	
	if ( field )
	{
		switch ( field.type )
		{
			case "hidden":
				// a hidden field is for the user already read only
				break;
				
			case "text":
			case "textarea":
				// For these field types, we can handle with setting the readOnly attribute on
				field.readOnly = true;
				break;
				
			default :
				// readOnly-Attribute is only supported for field of type text and textarea
				// we delete the field generated from domino, 
				// and replace it with
				// -	a text containing the texts corresponding to the choosen values
				// -	a new read only hidden text field with same name and value ( value = alias ). 
				//		This field avoids domino to loose the seized values on submit
				fv				= new FieldValues ();
				// Create a span-object as container for the new text and field
				nodeSpan	= document.createElement ( "span" );
				if ( field.type )
				{
					// Read texts and values
					fctGetMultiValueFieldValues ( field, fv );

					// Replaces the actual field with the new span container
					field.replaceNode ( nodeSpan );
				}
				else if ( field[0].type )
				{
					// multi choice radio buttons and check boxes 
					// Read texts and values
					fctGetMultiValueFieldValues ( field, fv );
					
					// We don't replace the field, as there are more than one, but the whole containing cell with the new span container
					// (in the hope that the field is actually contained in a table cell. Else, whoops...)
					var fldlFields			= field;		// Process the list using a tmp-variable
					field						= field[0];	// We need the reference to the field (field.name) to build the new field
					nodeCell					= field.parentNode;
//					nodeCell.innerHTML	= "";
// Line above replaced by the loop below. Less dangerous : only the text and <br>-Tags near the element are removed.
// Avoids deleting the whole form if the tag is outside a table cell
					for ( var i = fldlFields.length - 1; i >= 0; i -- )
					{
						// Removes the text corresponding to one choice of the checkbox or radiobutton
						if ( 	fldlFields [i].nextSibling
							&&	fldlFields [i].nextSibling.nodeType == 3 )
								fldlFields [i].nextSibling.removeNode (true);
						// Removes the <br>-tag corresponding to this choice of the checkbox or radiobutton
						if (		fldlFields [i].nextSibling
							&&	fldlFields [i].nextSibling.nodeType == 1
							&&	fldlFields [i].nextSibling.tagName.toLowerCase () == "br" )
								fldlFields [i].nextSibling.removeNode (true);
						// Removes the element of the choice itself
						fldlFields [i].removeNode ( true );
					}
					nodeCell.appendChild ( nodeSpan );
				}	// End if Field array
				
				// Create the text
				nodeText	= document.createTextNode ( fv.getList ( "textOrValue" ) );
				
				// Create the hidden field
				sFieldDef	=	"<input "
								+	"name=" + field.name
								+ " type=hidden "
								+ "value=\"" + fv.getList ( "valueOrText", "," ) + "\"" // Comma as list separator, to avoid domino loosing the values
								+ "readOnly>";
				fieldNew		= document.createElement ( sFieldDef );
					
				// inserts text and field in the new span
				nodeSpan.appendChild ( nodeText );
				nodeSpan.appendChild ( fieldNew );
				break;
		}	// endswitch
	}		// endif field exists
}	// ------------------------------ fctSetReadOnlyField


// ======================================================================
function fctSetListOfFieldsBgColor ( pslFieldnames, psColor )
// ======================================================================
{
	fctHandleListOfFieldsWithFunction ( pslFieldnames, fctSetFieldBgColor, psColor );
}	// ------------ fctShowListOfMandatoryFields ----------


// ======================================================================
var gSetFieldDefaultBgColor = "#ffeebb";
function fctSetFieldBgColor ( fieldInfo, psColor )
// ======================================================================
{
	var sColor;
	var objStyle;
	var field			 = fctGetField ( fieldInfo );
	var doc			= document.all;
	
	// Check input parm
	if ( psColor && psColor != "" )
		sColor = psColor;
	else
		sColor = gSetFieldDefaultBgColor;

	// Handle field	
	if ( field )
	{
		if ( ! field.style && field[0].style )
			// Radio buttons and checkboxes are handled specially. We set the style of the parent element.
			objStyle		= field[0].parentNode.style;
		else
			objStyle		= field.style;
		
		// Sets the background color on the field
		objStyle.backgroundColor = sColor;
	
	}	// Endif field found
}	// --------------- fctSetFieldBgColor	
// Allows to change the default Background color to set
function fctSetFieldDefaultBgColor ( sColor )
{
	gSetFieldDefaultBgColor = sColor;
}	// --------------- fctSetFieldDefaultBgColor


// ======================================================================
function fctHandleListOfFieldsWithFunction ( pslFieldnames, pfnFunction, pParameter1 )
// ======================================================================
{
	var slFieldnames;

	// We check what slFieldnames contains. 
	// If only one string, we change it to an array, to make the same processing for all cases
	if ( pslFieldnames [0] )
		slFieldnames = pslFieldnames
	else
		slFieldnames = new Array ( pslFieldnames );
	
	if ( pParameter1 == null )
	{
		// We loop through all fields
		for (var i = 0; i < slFieldnames.length ; i ++ )
		{
			// Call function for one field
			pfnFunction ( slFieldnames[i] );
		}	
	}
	else
	{
		// We loop through all fields
		for (var i = 0; i < slFieldnames.length ; i ++ )
		{
			// Call function for one field
			pfnFunction ( slFieldnames[i], pParameter1 );
		}  
	}
} 	// -------------- fctHandleListOfFieldsWithFunction ---------------






// ======================================================================
// BENOTIGT
// Definition of the FieldValues object
// ======================================================================
function FieldValues ()
{
	// Properties
	this.checked = false;
	this.slValues = new Array ();
	this.slTexts = new Array ();
	this.length = 0;
	// Methods
	this.addValue = fctFV_addValue;
	this.getList = fctFV_getList;
	this.getValidIndex = fctFV_getValidIndex;
	this.getValue = fctFV_getValue;
	this.getValueOrText = fctFV_getValueOrText;
	this.getText = fctFV_getText;
	this.getTextOrValue = fctFV_getTextOrValue;
	this.reset = fctFV_reset;
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_addValue ( sValue, sText, boolChecked )
{
	var i	= this.slValues.length;
	this.slValues.length	++;
	this.slTexts.length		++;
	if ( sValue )
		this.slValues	[i]	= sValue;
	else	
		this.slValues	[i]	= "";
	if ( sText )		
		this.slTexts		[i]	= sText;
	else	
		this.slTexts		[i]	= "";
	this.length				= this.slValues.length;
	if ( boolChecked )
		this.checked		= true;
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_reset ()
{
	this.checked			= false;
	this.slValues.length	= 0;
	this.slTexts.length		= 0;
	this.length				= 0;
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getValue ( iIndex )
{
	if ( this.length > 0 )
	{
		var i = this.getValidIndex ( iIndex );
		return this.slValues [i];
	}
	else
		return "";	
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getText ( iIndex )
{
	if ( this.length > 0 )
	{
		var i = this.getValidIndex ( iIndex );
		return this.slTexts [i];	
	}
	else
		return "";	
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getValueOrText ( iIndex )
{
	if ( this.length > 0 )
	{
		var i = this.getValidIndex ( iIndex );
		if ( this.slValues [i] == "" )
			return this.slTexts [i];
		else
			return this.slValues [i];	
	}
	else
		return "";	
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getTextOrValue ( iIndex )
{
	if ( this.length > 0 )
	{
		var i = this.getValidIndex ( iIndex );
		if ( this.slTexts [i] == "" )
			return this.slValues [i];	
		else
			return this.slTexts [i];
	}
	else
		return "";	
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getList ( sListname, psSeparator )
{
	var sList					= "";
	var sSeparator;
	var sSeparatorTmp	= "";
	var sFunctionname;
	
	switch ( sListname )
	{
		case "value" :
			sFunctionname = "getValue";
			break;
		case "text" :
			sFunctionname = "getText";
			break;
		case "textOrValue" :
			sFunctionname = "getTextOrValue";
			break;
		case "valueOrText" :
		default :
			sFunctionname = "getValueOrText";
			break;
	}
	
	if ( psSeparator )
		sSeparator = psSeparator;
	else	
		sSeparator = ";";
			
	for ( var i = 0; i < this.length; i++ )
	{
		sList = sList + sSeparatorTmp + this [ sFunctionname ] ( i );
		sSeparatorTmp	= sSeparator;
	}
	return sList;

}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFV_getValidIndex ( iIndex )
{
	var i = 0;
	if ( ! isNaN ( iIndex ) )
	{
		if ( i < this.slValues.length )
			i = iIndex;
	}	
	return i;
}
// ----------------------------------------------------------- FieldValues -------------------------------------------------------------



// ======================================================================
// Definition of the Wrapper object
// Allows passing parameter by references (instead of by value)
// ======================================================================
function Wrapper ( object )
{
	this.object	= object;
	this.setObject	= fctFW_setObject;
	this.getObject	= fctFW_getObject;
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFW_setObject ( object )
{
	this.object = object;
}
// --------------------------------------------------------------------------------------------------------------------------------------------
function fctFW_getObject ()
{
	return this.object;
}
// ---------------------------------------------------------- Wrapper ------------------------------------------------------------------

