// JavaScript Document

// Function to check null values
function isBlank(val, errtxt)
{
	if(val==null)
	{
		return true;
	}
	for(var i=0;i<val.length;i++)
	{
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r"))
		{
			return false;
		}
	}
	if(errtxt != null)
	{
		alert(errtxt);
	}
	return true;
}

// Function to determine whether the email address entered is a valid email
function checkemail(curfield)
{ 
    fieldValue  = curfield;
    fieldLength = curfield.length; 

    var err = "Indtast korrekt e-mail adresse";

    if (fieldLength < 8)
	{
		alert(err);
		return false;
    }
	else
	{
        if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(fieldValue))
		{
			return true;
        }
		else
		{
            alert(err);
			return false;
        }
    }
}

// Function to check whether the string entered has valid characters
function inString(sText, ValidChars, errtxt)
{
   var IsValid=true;
   var Char;

   for (i = 0; i < sText.length && IsValid == true; i++) 
	  { 
	  Char = sText.charAt(i); 
	  if (ValidChars.indexOf(Char) == -1) 
		 {
			 if(errtxt != null)
			 {
				 alert(errtxt);
			 }
			 IsValid = false;
		 }
	  }
   return IsValid;
}