<!--  

// The previous line hides the script from old browsers that cant interpret it


function emailvalidation(entered, alertbox)
{
// E-mail-Validation (c) Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove the this line and the two lines above.
with (entered)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{

checkvalue=parseFloat(value);

if (datatype)

  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};

  }
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
  {smalldatatype=datatype.toLowerCase();
   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
  }
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function selectvalidation(entered, alertbox)
{
with (entered)
{
if (selectedIndex==null || selectedIndex=="" || selectedIndex==0)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}

}



// Example uses of the functions

//function formvalidation(thisform)
//{
//with (thisform)

//{
//if (emailvalidation(TxtEmail,"Illegal E-mail")==false) {TxtEmail.focus(); return false;};
//if (valuevalidation(TxtPostCode,0,5,"Value MUST be in the range 0-5")==false) {TxtPostCode.focus(); return false;};
//if (digitvalidation(TxtMobile,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {TxtMobile.focus(); return false;};
//if (emptyvalidation(TxtFirstname,"The textfield is empty")==false) {TxtFirstname.focus(); return false;};
//}
//}

// The next line causes oldfashion browsers to start interpreting the code again.
//-->
