/*
	--
	jslib.js
	(c) www.edv-service-tb.de
*/

function IsCharofList(sText,ValidChars)
{
   var isOk=true;
   var Char;
   for (i = 0; i < sText.length && isOk == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         	isOk = false;
         }
      }
   return isOk;
   }
/*
	--
*/
function IsNumeric(sText) {
	return IsCharofList(sText,"0123456789.")
}
/*
	--
*/

// isStringofFormat(this,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.',5,10,'Länge falsch','Nicht erlaubte Zeichen!',errormess') {
function isStringofFormat(pFieldObj,pFormatString,pMinLength,pMaxLenght,pErrorMessLenght,pErrorMessFormat,pMessField) {

	document.getElementById(pMessField).innerHTML = "&nbsp;";

	var isOk		= true;
	var ErrorMess   = '';

	with (pFieldObj)
	{
		if (value.length<pMinLength || value.length>pMaxLenght) {
			ErrorMess = pErrorMessLenght;
		}
		if (!IsCharofList(value,pFormatString)) {
			ErrorMess = ErrorMess +'\n'+pErrorMessFormat;
		}
		
	}

	if (ErrorMess) {
		isOk = false;
	  	alert(ErrorMess);
		document.getElementById(pMessField).innerHTML = ErrorMess;
	}
	return true;
}

/*
	--
*/

function isSameString(pFieldObj,pSecondFieldValue,pErrorMess,pMessField) {

	document.getElementById(pMessField).innerHTML = "&nbsp;";

	var isOk		= true;
	var ErrorMess   = '';

	with (pFieldObj)
	{
		if (value!=pSecondFieldValue)
		{
			ErrorMess = pErrorMess;
		}
	}

	if (ErrorMess) {
		isOk = false;
	  	alert(ErrorMess);
		document.getElementById(pMessField).innerHTML = ErrorMess;
	}
	return isOk;
}


function Check_if_empty(pField,pMess,pMessField) {

	document.getElementById(pMessField).innerHTML = "&nbsp;";
	
	with (pField)
	{
		if (value==null||value=="") {
			alert(pMess);
		  	document.getElementById(pMessField).innerHTML = pMess;
			return false;
		} else {
			return true;
		}
	}
}



/*
	--
*/
function validate_email(pField,pMess,pMessField) {

	document.getElementById(pMessField).innerHTML = "&nbsp;";

	with (pField)		
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2||!(value.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/))) 
		  {
		  	alert(pMess);
		  	document.getElementById(pMessField).innerHTML = pMess;
		  	return false;
		  }
		else {return true}
	}
}

function isEmailAddr(str) 
{
    return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
}


/*
 	ende jslib.js
*/

