// ********** BEGIN VALIDATION FUNCTIONS ***********



function runValidation() {

		// Add the error messages, if any
	var obj_Error	= new ErrorMsg();
	obj_Error.AddCategory();
	for ( var i = 1; i < ( numChecks + 1 ); i++ )  {
		if ( checkFields[i] != "" ) obj_Error.AddMessage( checkFields[i] );
	}

		// Display errors
	if( obj_Error.errors == false ) {
		// document.forms[0].submit();
		// alert("alles OK");
		submitFlag = true;
		return true;
	} else {
		obj_Error.DisplayMessage();
		submitFlag = false;
		return false;
	}
}



function runPartValidation() {

		// Add the error messages, if any
	var obj_Error	= new ErrorMsg();
	var errControl  = 0;
	obj_Error.AddCategory();
	varNumChecks = numChecks + 1;
	
	for ( var i = 1; i < varNumChecks; i++ )  {
		cmdError = checkFields[i];
		if ( cmdError != "" ) {
			obj_Error.AddMessage( checkFields[i] );
			errControl = 0;
		}
		else {
			errControl = 1;
		}	
	}

		// Display errors
	if( obj_Error.errors == false ) {
		// document.forms[0].submit();
		alert("alles OK");
		submitFlag = true;
	} else {
		obj_Error.DisplayMessage();
		submitFlag = false;
		return false;
	}
}





	// ===== Check if field is required =====
	//  field = document.forms[sender.name].elements[myarray[i][0]];

function isNewRequired ( sendername, fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	// fieldValue	= document.forms[0][fieldName].value;
	 fieldValue = document.forms[sendername].elements[fieldName].value;
	 curfield = document.forms[sendername].elements[fieldName];
	
	if(( fieldValue == "" ) || ( fieldValue == " " )) {
		errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel + "";
	}

	varname = document.forms[sendername].elements[fieldName].name;
	alert(varname);
	curfield.focus();
	return errorMsg ;
}


function chgErrMessage(errorLabel) {

	errorMsg	= "";
	errorMsg = errorLabel;
	return errorMsg ;
	
}


	// ===== Check if field is required =====
function isRequired ( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	if(( fieldValue == "" ) || ( fieldValue == " " )) {
		errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel + "";
	}
	return errorMsg ;
}

	// ===== Validate field minimum and maximum length =====
function validateMinMax ( fieldName, fieldDescription, minLength, maxLength ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;
	if ( fieldLength < minLength ) {
		errorMsg = "\"" + fieldDescription +  "\"  - Minimal " + minLength + " Ziffern.";
	} else if (( fieldLength > maxLength ) && ( maxLength > 0 )) {
		errorMsg = "\"" + fieldDescription +  "\"  - Maximal " + maxLength + " Ziffern.";
	}
	return errorMsg ;
}

	// ===== Validate field minimum and maximum length =====
function validateIfExistMinMax ( fieldName, fieldDescription, minLength, maxLength ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	if ( fieldLength > 0 ) {
		if ( fieldLength < minLength ) {
			errorMsg = "\"" + fieldDescription +  "\"  - Minimal " + minLength + " Ziffern.";
		} else if (( fieldLength > maxLength ) && ( maxLength > 0 )) {
			errorMsg = "\"" + fieldDescription +  "\"  - Maximal " + maxLength + " Ziffern.";
		}
	}
	return errorMsg ;
}

	// ===== Check if netry contains only valid characters =====
function checkValidChars( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;
	for( var i=0; i<fieldLength; i++ ) {
		if ( validChars.indexOf( fieldValue.charAt( i )) == -1 ) {
			// alert (fieldValue);
			// alert (fieldValue.charAt(i));
			// alert (validChars.indexOf( fieldValue.charAt( i )) );
			errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		}
	}
	return errorMsg ;
}


	// ===== Check if netry contains only valid characters =====
function checkSetValidChars( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";

	varokstr    = "";
	varerrstr   = "";
	
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	for( var i=0; i<fieldLength; i++ ) {
		if ( validChars.indexOf( fieldValue.charAt( i )) == -1 ) {
			varfield = fieldValue.charAt(i);
			varerrstr = "" + varerrstr + "" + varfield + "";
			// errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		}
		else {
			varfield = fieldValue.charAt(i);
			varokstr = "" + varokstr + "" + varfield + "";
		}
	}
	
	if ( varerrstr != "" ) {
		document.forms[0][fieldName].value = varokstr;
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + " " + varerrstr + "";
	}
	
	return errorMsg ;
}

	// ===== Check if entry contains entirely identical characters =====
function checkIdentical( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	if (( fieldLength > 1 ) && ( isComposedOfChars( fieldValue.charAt( 0 ), fieldValue ))) {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	return errorMsg ;
}

function isComposedOfChars( curChar, inString ) {
	return ( indexOfFirstNotIn( curChar, inString ) == -1 );
}

function indexOfFirstNotIn( okayChars, inString ) {
	for ( var i=0; i<inString.length; i++ ) {
		if ( okayChars.indexOf( inString.charAt( i )) == -1 ) {
			return i;
		}
	}
	return -1;
}

	// ===== Check if entry contains entirely sequential characters =====
function checkSequential( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	if ( fieldLength > 1 ) {
		for ( var i = 1; i < ( numSeqStr + 1 ); i++ )  {
			if ( strSeq[i].indexOf( fieldValue ) != -1 ) {
				errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
			}
		}
	}
	return errorMsg ;
}

	// ===== Check if an option has been selected =====
function validateTextAndSelBox( fieldName, fieldName2, fieldDescription, errorLabel, checkWhat ) {
	errorMsg	= "";

	optSelected	= document.forms[0][fieldName2].selectedIndex;
	// alert(optSelected);
	// if (optSelected == 1) {
	if (optSelected == checkWhat) {
		fieldValue	= document.forms[0][fieldName].value;
		// alert(fieldValue);
		if(( fieldValue == "" ) || ( fieldValue == " " )) {
			errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		}
	}

	return errorMsg ;

}



	// ===== Check if an option has been selected =====
function validateSelectBox( fieldName, fieldDescription, errorLabel, checkWhat ) {
	errorMsg	= "";
	optSelected	= document.forms[0][fieldName].selectedIndex;
	fieldValue	= document.forms[0][fieldName].options[optSelected].value;
	// alert(fieldValue);
	if( fieldValue == checkWhat ) {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	return errorMsg ;
}

	// ===== Check if a checkbox or radio button has been selected =====
function validateRadioBox( fieldName, fieldDescription, errorLabel, checkWhat ) {
	errorMsg	= "";
	selection = null;
	thisButton		= document.forms[0][fieldName];
	for( var i=0; i<thisButton.length; i++ ) {
		if( thisButton[i].checked ) {
		   selection = thisButton[i].value;
		}
	}
	if( selection == checkWhat ) {
		// errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	else {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	
	if( selection == null ) {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	return errorMsg;
}

function initRadio ( fieldName, fieldDescription, errorLabel) {

	// alert("initRadio");
	errorMsg	= "";
    // selection  = null; 
    thisButton = document.forms[0][fieldName]; 
   	thisButton[0].checked = true;
   	// alert(msgstr);
	// thisButton[0].focus();
   return errorMsg;
}


function setFocusTest ( fieldName, fieldDescription, errorLabel) {

	errorMsg	= "";
    // selection  = null; 
    thisButton = document.forms[0][fieldName]; 
    for( var i=0; i < thisButton.length; i++ ) {
    	// alert (i); 
 		if (( i == 1) && ( strexist == 0)) {
        	thisButton[1].checked = false;
        	thisButton[0].checked = true;
        	alert(msgstr);
        } 
    } 

   return errorMsg;
}

	// ===== Check if a checkbox or radio button has been selected =====
function validateBtnsBox( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	selection = null;
	thisButton		= document.forms[0][fieldName];
	for( var i=0; i<thisButton.length; i++ ) {
		if( thisButton[i].checked ) {
		   selection = thisButton[i].value;
		}
	}
	if( selection == null ) {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	return errorMsg;
}


	// ===== Check if entry contains only numbers =====
function validateNumBox( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	for( var i = 0; i < fieldLength; i++ ) {
		var ch = fieldValue.substring( i, i + 1 );
		if (( ch < "0" ) || ( ch > "9" )) {
			errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		}
	}
	return errorMsg ;
}

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

function validateNumRangeBox( fieldName, fieldDescription, intMin, intMax ) {
	errorMsg	= "";
	errorMsg1	= "";
	errorMsg2	= "";
	errorMsg3	= "";

	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	// Eingabe vorhanden
	if(( fieldValue == "" ) || ( fieldValue == " " )) {
		errorMsg1 = 'Eingabe fehlt! ';
	}

	// Integer ueberpruefung
	for( var i = 0; i < fieldLength; i++ ) {
		var ch = fieldValue.substring( i, i + 1 );
		if (( ch < "0" ) || ( ch > "9" )) {
			errorMsg2 = 'Nur Zahlen! ';
		}
	}
	
	// 
	var minimum = parseInt(intMin);
	var maximum = parseInt(intMax);
	var curval = parseInt(fieldValue);
	 
	if (( curval < minimum ) || ( curval > maximum) ) {
			errorMsg3 = 'Min='+intMin+' Max='+intMax+' ! ';
	}

	errorLabel = ''+errorMsg1+''+errorMsg2+''+errorMsg3+'';

	if(( errorLabel == "" ) || ( errorLabel == " " )) {
		errorMsg = '';
	}
	else {
		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
	}
	
	
	return errorMsg ;
}



	// ===== Validate an email address =====
function validateEmailBox ( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	if ( fieldLength > 0 ) {

		if (( errorLabel == "" ) || ( errorLabel == null )) {

			errorLabel1	= "Keine gueltige Mailadresse.";			// Not valid
			errorLabel2	= "Fehlendes [ @ ] Zeichen.";						// Missing "@"
			errorLabel3	= "Fehlender [ . ].";								// Missing "."
			errorLabel4	= "Kann nicht mit einem Leerzeichen beginnen.";					// Starts with " "
			errorLabel5	= "Kann nicht mit einem [ @ ] beginnen.";				// Starts with "@"
			errorLabel6	= "Kann nicht mit einem [ . ] beginnen.";					// Starts with "."

			if ( fieldValue.indexOf( "@" ) == -1 ) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel2 + "";
			} else if ( fieldValue.indexOf( "." ) == -1 ) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel3 + "";
			} else if ( fieldValue.charAt( 0 ) == " " ) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel4 + "";
			} else if ( fieldValue.charAt( 0 ) == "@" ) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel5 + "";
			} else if ( fieldValue.charAt( 0 ) == "." ) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel6 + "";
			}

		} else {

			if (( fieldValue.indexOf( "@" ) == -1 ) || 					// Missing "@"
				( fieldValue.indexOf( "." ) == -1 ) || 					// Missing "."
				( fieldValue.charAt( 0 ) == "@" ) || 					// Starts with "@"
				( fieldValue.charAt( 0 ) == "." ) 						// Starts with "."
				) {
				errorMsg = "\"" + fieldDescription +  "\"  - " + errorLabel + "";
			}
		}
	}
	return errorMsg ;
}



function checkExtBoxInput( checkname, fieldDescription, errorLabel ) {
	var retval;
	var errorMsg = '';
	
	// alert("hallo: "+checkname);
	var retval		= new Array();

	count = 0;

	for (x = 0; x < document.forms[0].elements.length; x++) {
		varname = 	document.forms[0].elements[x].name;
		vartype = 	document.forms[0].elements[x].type;
		varstatus = document.forms[0].elements[x].checked;
		varvalue = 	document.forms[0].elements[x].value;
		varvallen = document.forms[0].elements[x].value.length;

		// msgstr = "ELEMENTS: NAME="+varname+"\nTYPE="+vartype+"\nSTATUS="+varstatus+"\nVALUE="+varvalue+"\nLENGE="+varvallen+"\n"; 
		
		switch(vartype) {
 			case "checkbox":
				separator = '_';
				retval = varname.split( separator ); 
				 				
 				if (retval.length > 1) {
						elemstr = ''+retval[0]+'_'+retval[1]+'';
						
						 // alert(elemstr);
						
						if (elemstr == checkname) {
							if (varstatus == true) {
								count = count + 1;
								elemnum = retval[1];
								elemval = varvalue;
		 						// alert(msgstr);
								// alert(varstatus);
							}
							// alert(retval[i]);
						}
				} 
 				break;
			default:
 				// alert(vartype);
 				break;
		}
		


	}

	if (count == 0) {
		// errorLabel = 'Hotel';
		// fieldDescription = 'Bitte Hotel selektieren !';

		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		// alert(errorMsg);
		return errorMsg;
	}

	return errorMsg;


}


function checkCookExtBoxInput( checkname, fieldDescription, errorLabel ) {
	var retval;
	var errorMsg = '';
	
	// alert("hallo: "+checkname);

	count = 0;

	for (x = 0; x < document.forms[0].elements.length; x++) {
		varname = 	document.forms[0].elements[x].name;
		vartype = 	document.forms[0].elements[x].type;
		varstatus = document.forms[0].elements[x].checked;
		varvalue = 	document.forms[0].elements[x].value;
		varvallen = document.forms[0].elements[x].value.length;

		// msgstr = "ELEMENTS: NAME="+varname+"\nTYPE="+vartype+"\nSTATUS="+varstatus+"\nVALUE="+varvalue+"\nLENGE="+varvallen+"\n"; 
		// alert(msgstr);
		
		switch(vartype) {
 			case "checkbox":
				separator = '_';
				retval = varname.split( separator ); 
				 				
 				if (retval.length == 2) {
						elemstr = retval[0]
						if (elemstr == checkname) {
							if (varstatus == true) {
								count = count + 1;
								elemnum = retval[1];
								elemval = varvalue;
								// alert(varstatus);
							}
							// alert(retval[i]);
						}
				} 
 				break;
			default:
 				// alert(vartype);
 				break;
		}
		


	}

	// ----------------------------------------------------------
	// Checkbox-ausgewaehlt
	// ----------------------------------------------------------


	if (count == 0) {
		errorLabel = 'Platz';
		fieldDescription = 'Bitte buchen Sie !';

		errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
		// alert(errorMsg);
		return errorMsg;
	}

	// ----------------------------------------------------------
	// Formulartyp ermitteln aus dem hiddenfeld-classtyp
	// ----------------------------------------------------------

	// curfield = 'classtyp';
	 var classTyp = '';
	curfield = 'CLASSIFICATION';
	className   = document.forms[0][curfield]; 
    classValue  = className.value; 



	
	if ( classValue == '001120040002') classTyp = 'LC' ;
	if ( classValue == '001120040003') classTyp = 'KK' ;
	if ( classValue == '001120040004') classTyp = 'WT' ;

	if ( classValue == '001040002') classTyp = 'LC' ;
	if ( classValue == '001060002') classTyp = 'KK' ;

    classLength = classValue.length; 
	
	var restwert;
	var	seatName = 'pa_platzanzahl';
	
	if (classTyp == 'LC') {
		document.forms[0][seatName].value = count;
		// Minimal 1 Reservierung
	}
	else if (classTyp == 'KK') {
		// Gerade Anzahl
		document.forms[0][seatName].value = count;
		restwert = (count % 2);
		if (restwert == 0 ) {
			// alert ('Anzahl OK');
		}
		else {
			errorLabel = 'Platz';
			fieldDescription = 'Kann nur paarweise gebucht werden!';
			errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
			// alert(errorMsg);
			return errorMsg;
			// alert ('NOTOK: Bitte gerade Anzahl von Plätzen!');
		}
	
	}
	else if (classTyp == 'WT') {
	
	}
	else {
			errorLabel = 'FORMULAR';
			fieldDescription = 'Bitte informieren Sie die Administration!';
			errorMsg = "\"" + fieldDescription +  "\" - " + errorLabel + "";
			// alert(errorMsg);
			return errorMsg;
		
	}

	// alert(count);

	return errorMsg;
}


//NEUER EMAILCHECKER


function validateEmailCheck ( fieldName, fieldDescription, errorLabel ) {
	errorMsg	= "";
	fieldValue	= document.forms[0][fieldName].value;
	fieldLength	= document.forms[0][fieldName].value.length;

	emailStr = fieldValue;

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var submitFlag=false;
var errortext = "Eingabeüberprüfung der relevanten Daten";
/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

//alert("Die Emailadresse fehlt oder ist nicht korrekt. Bitte ergänzen Sie die Eingaben für '@' oder die Domainendungen .123)");
//return false;

errorMsg = " Email - die Emailadresse fehlt oder ist nicht korrekt. Bitte ergaenzen Sie die Eingaben für '@' oder die Domainendungen .123.";
errorMsg = " Email - die Emailadresse fehlt oder ist nicht korrekt. z.B.: username@domainname.de";
return errorMsg;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
// alert("Benutzen Sie bitte keine Sonderzeichen");
// return false;

errorMsg = " Email - benutzen Sie bitte keine Sonderzeichen.";
return errorMsg;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
// alert("Der Domainname enthält Sonderzeichen.");
// return false;

errorMsg = " Email - der Domainname enthaelt Sonderzeichen.";
return errorMsg;

   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

// alert("Der Benutzername ist nicht vorhanden oder ungueltig!");
// return false;

errorMsg = " Email - Der Benutzername ist nicht vorhanden oder ungueltig!";
return errorMsg;

}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
// alert("Die angegebene IP Adresse ist ungültig!");
// return false;

errorMsg = " Email - die angegebene IP Adresse ist ungueltig!";
return errorMsg;
   }
}
// return true;
return errorMsg;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
// alert("Der Domainname ist nicht vorhanden oder ungueltig!!");
// return false;

errorMsg = " Email - der Domainname ist nicht vorhanden oder ungueltig!";
return errorMsg;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
// alert("Der Domainname muß mit bekannten Domainendungen [.de, .com, .net,....]" + " abschließen.");
// return false;

errorMsg = " Email - der Domainname muß mit bekannten Domainendungen [.de, .com, .net,....]" + " abschließen.";
return errorMsg;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
// alert("Der Adresse fehlt ein Hostname!");
// return false;

errorMsg = " Email - der Adresse fehlt ein Hostname!";
return errorMsg;
}

// If we've gotten this far, everything's valid!
// return true;
 return errorMsg;
}




// *********** END VALIDATION FUNCTIONS ************


// ************ BEGIN OBJECT FUNCTIONS *************
function AddCategory( str_Name ) {
		// Creates a new category object at the next space in the array
	this.obj_Errors[this.obj_Errors.length] = new NewCategory( str_Name );
	this.NewCategory = NewCategory;
}

function NewCategory( str_Name) {
		//  Initializes the category values
	this.str_Name		= str_Name;
	this.str_Error		= "";
}

function AddMessage( str_Msg ) {
	for ( var i = 0; i < this.obj_Errors.length; i++ )  {
		this.obj_Errors[i].str_Error += errorBullet;
		this.obj_Errors[i].str_Error += str_Msg + "\n";
		this.errors = true;
		return true;
	}
}

function ErrorMsg() {
		//  This is the object you create to keep track of errors in the document
	this.obj_Errors		= new Array();
	this.errors		= false;
	this.AddCategory	= AddCategory;
	this.AddMessage		= AddMessage;
	this.DisplayMessage	= DisplayMessage;
}
// ************* END OBJECT FUNCTIONS **************


function DisplayMessage() {
		// Displays the error messages.
		// If none, false is returned and no message is displayed.
	if ( this.errors == false ) {
		return false;
	} else {
		var str_msg = "";
		str_msg += errorLine1 + "\n";
		str_msg += errorLine2 + "\n";
		for ( var i = 0; i < this.obj_Errors.length; i++ ) {			// Go through all of the objects
			if ( this.obj_Errors[i].str_Error != '' ) {			// If errors, write the errors
				str_msg += "\n" + errorLine3 + "\n";
				str_msg += this.obj_Errors[i].str_Error + "\n";
			}
		}
		alert( str_msg );							// Display the error message
		return true;
	}
}
