

function textCounter(field, countfield, maxlimit) {

if (field.value.length > maxlimit) // if too long...trim it!

field.value = field.value.substring(0, maxlimit);

// otherwise, update 'characters left' counter

else 

countfield.value = maxlimit - field.value.length;

}

// End -->



function emailCheck (emailStr) {



var checkTLD=1;

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

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

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

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

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

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

var atom=validChars + '+';

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

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

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

var matchArray=emailStr.match(emailPat);



if (matchArray==null) {

	alert("Email address seems incorrect (check @ and .'s)");

	return false;

}



var user=matchArray[1];

var domain=matchArray[2];



for (i=0; i<user.length; i++) {

	if (user.charCodeAt(i)>127) {

		alert("Ths username contains invalid characters.");

		return false;

	   }

}

for (i=0; i<domain.length; i++) {

	if (domain.charCodeAt(i)>127) {

		alert("Ths domain name contains invalid characters.");

		return false;

	   }

}





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

	alert("The username doesn't seem to be valid.");

	return false;

}



var IPArray=domain.match(ipDomainPat);

if (IPArray!=null) {

	for (var i=1;i<=4;i++) {

		if (IPArray[i]>255) {

			alert("Destination IP address is invalid!");

			return false;

		   }

	}

	return true;

}



 

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("The domain name does not seem to be valid.");

		return false;

	   }

}



if (checkTLD && domArr[domArr.length-1].length!=2 && 

domArr[domArr.length-1].search(knownDomsPat)==-1) {

	alert("The address must end in a well-known domain or two letter " + "country.");

	return false;

}



if (len<2) {

	alert("This address is missing a hostname!");

	return false;

}



return true;

}

function junponef2(){

var val = "";

val = document.FrontPage_Form2.hp.value;

//alert(val);

if((val.length)== 3)

document.FrontPage_Form2.hp1.focus();

}



function junptwof2(){

var val = "";

val = document.FrontPage_Form2.hp1.value;

if((val.length)== 3)

document.FrontPage_Form2.hp2.focus();

}



function junpthreef2(){

	var val = "";

	val = document.FrontPage_Form2.hp2.value;

	if((val.length)== 4)

	document.FrontPage_Form2.email.focus();

}

function junpone(){

var val = "";

val = document.FrontPage_Form1.hp.value;

//alert(val);

if((val.length)== 3)

document.FrontPage_Form1.hp1.focus();

}



function junptwo(){

var val = "";

val = document.FrontPage_Form1.hp1.value;

if((val.length)== 3)

document.FrontPage_Form1.hp2.focus();

}



function junpthree(){

	var val = "";

	val = document.FrontPage_Form1.hp2.value;

	if((val.length)== 4)

	document.FrontPage_Form1.wphone.focus();

}



function junpfour(){

	var val = "";

	val = document.FrontPage_Form1.wphone.value;

	if((val.length)== 3)

	document.FrontPage_Form1.wphone1.focus();

}

function junpfive(){

	var val = "";

	val = document.FrontPage_Form1.wphone1.value;

	if((val.length)== 3)

	document.FrontPage_Form1.wphone2.focus();

}

function junpsix(){

	var val = "";

	val = document.FrontPage_Form1.wphone2.value;

	if((val.length)== 4)

	document.FrontPage_Form1.fax.focus();

}

function junpseven(){

	var val = "";

	val = document.FrontPage_Form1.fax.value;

	if((val.length)== 3)

	document.FrontPage_Form1.fax1.focus();

}

function junpeight(){

	var val = "";

	val = document.FrontPage_Form1.fax1.value;

	if((val.length)== 3)

	document.FrontPage_Form1.fax2.focus();

}

function junpnine(){

	var val = "";

	val = document.FrontPage_Form1.fax2.value;

	if((val.length)== 4)

	document.FrontPage_Form1.email.focus();

}


function FrontPage_Form2_Validator(theForm)
{
	 if (theForm.fname.value == "")

  {

    alert("Please enter a value for the \"Name\" field.");

    theForm.fname.focus();

    return (false);

  }



  if (theForm.fname.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"Name\" field.");

    theForm.fname.focus();

    return (false);

  }



  if (theForm.fname.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"Name\" field.");

    theForm.fname.focus();

    return (false);

  }
  
    if (theForm.hp.value==""){



alert ("Please enter  the value for the \"Phone \" Field");

theForm.hp.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Phone\" field.");

    theForm.hp.focus();

    return (false);

  }





  if (theForm.hp.value.length < 3)

  {

    alert("Please enter at most 3 characters in the \"Phone\" field.");

    theForm.hp.focus();

    return (false);

  }



   if (theForm.hp1.value==""){



alert ("Please enter  the value for the \"Phone \" Field");

theForm.hp1.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp1.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Phone\" field.");

    theForm.hp1.focus();

    return (false);

  }





  if (theForm.hp1.value.length < 3)

  {

    alert("Please enter at most 3 characters in the \"Phone\" field.");

    theForm.hp1.focus();

    return (false);

  }



 if (theForm.hp2.value==""){



alert ("Please enter  the value for the \"Phone \" Field");

theForm.hp2.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp2.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Phone\" field.");

    theForm.hp2.focus();

    return (false);

  }
  
    if (theForm.email.value == "")

  {

    alert("Please enter a value for the \"Email\" field.");

    theForm.email.focus();

    return (false);

  }
  
    if (theForm.website.value == "")

  {

    alert("Please enter a value for the \"Birthday\" field.");

    theForm.website.focus();

    return (false);

  }



  
  return (true);
}








function FrontPage_Form1_Validator(theForm)

{



  if (theForm.fname.value == "")

  {

    alert("Please enter a value for the \"First Name\" field.");

    theForm.fname.focus();

    return (false);

  }



  if (theForm.fname.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"First Name\" field.");

    theForm.fname.focus();

    return (false);

  }



  if (theForm.fname.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"First Name\" field.");

    theForm.fname.focus();

    return (false);

  }





 if (theForm.lname.value == "")

  {

    alert("Please enter a value for the \"Last Name\" field.");

    theForm.lname.focus();

    return (false);

  }



  if (theForm.lname.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"Last Name\" field.");

    theForm.lname.focus();

    return (false);

  }



  if (theForm.lname.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"Last Name\" field.");

    theForm.lname.focus();

    return (false);

  }

  

  

  if (theForm.add1.value == "")

  {

    alert("Please enter a value for the \"Address \" field.");

    theForm.add1.focus();

    return (false);

  }



  if (theForm.add1.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"Address\" field.");

    theForm.add1.focus();

    return (false);

  }



  if (theForm.add1.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"Address \" field.");

    theForm.add1.focus();

    return (false);

  }

  



  if (theForm.city.value == "")

  {

    alert("Please enter a value for the \"City \" field.");

    theForm.city.focus();

    return (false);

  }



  if (theForm.city.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"City\" field.");

    theForm.city.focus();

    return (false);

  }



  if (theForm.city.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"City\" field.");

    theForm.city.focus();

    return (false);

  }

 

 

  if (theForm.Province.value == "")

  {

    alert("Please enter a value for the \"State \" field.");

    theForm.Province.focus();

    return (false);

  }



  if (theForm.Province.value.length < 1)

  {

    alert("Please enter at least 1 characters in the \"State\" field.");

    theForm.Province.focus();

    return (false);

  }



  if (theForm.Province.value.length > 50)

  {

    alert("Please enter at most 50 characters in the \"State\" field.");

    theForm.Province.focus();

    return (false);

  }







 if (theForm.zip.value == "")

  {

    alert("Please enter a value for the \"zip\" field.");

    theForm.zip.focus();

    return (false);

  }



  var checkOK = "0123456789-.";

  var checkStr = theForm.zip.value;

  var allValid = true;

  var validGroups = true;

  var decPoints = 0;

  var allNum = "";

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

    if (ch == ".")

    {

      allNum += ".";

      decPoints++;

    }

    else

      allNum += ch;

  }

  if (!allValid)

  {

    alert("Please enter only digit characters in the \"zip\" field.");

    theForm.zip.focus();

    return (false);

  }



  if (decPoints > 1 || !validGroups)

  {

    alert("Please enter a valid number in the \"zip\" field.");

    theForm.zip.focus();

    return (false);

  }



  if (theForm.hp.value==""){



alert ("Please enter  the value for the \" Home Phone \" Field");

theForm.hp.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Home Phone\" field.");

    theForm.hp.focus();

    return (false);

  }





  if (theForm.hp.value.length < 3)

  {

    alert("Please enter at most 3 characters in the \"Home Phone\" field.");

    theForm.hp.focus();

    return (false);

  }



   if (theForm.hp1.value==""){



alert ("Please enter  the value for the \" Home Phone \" Field");

theForm.hp1.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp1.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Home Phone\" field.");

    theForm.hp1.focus();

    return (false);

  }





  if (theForm.hp1.value.length < 3)

  {

    alert("Please enter at most 3 characters in the \"Home Phone\" field.");

    theForm.hp1.focus();

    return (false);

  }



 if (theForm.hp2.value==""){



alert ("Please enter  the value for the \" Home Phone \" Field");

theForm.hp2.focus();

return false;

}





 var checkOK = "0123456789";

  var checkStr = theForm.hp2.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Home Phone\" field.");

    theForm.hp2.focus();

    return (false);

  }



  





 

 var checkOK = "0123456789";

  var checkStr = theForm.wphone.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Work Phone\" field.");

    theForm.wphone.focus();

    return (false);

  }



 



 



   var checkOK = "0123456789";

  var checkStr = theForm.wphone1.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Work Phone\" field.");

    theForm.wphone1.focus();

    return (false);

  }







 var checkOK = "0123456789";

  var checkStr = theForm.wphone2.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Work Phone\" field.");

    theForm.wphone2.focus();

    return (false);

  }









 



var checkOK = "0123456789";

  var checkStr = theForm.fax.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Fax\" field.");

    theForm.fax.focus();

    return (false);

  }





  

 

 

 var checkOK = "0123456789";

  var checkStr = theForm.fax1.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Fax\" field.");

    theForm.fax1.focus();

    return (false);

  }









var checkOK = "0123456789";

  var checkStr = theForm.fax2.value;

  var allValid = true;

  var validGroups = true;

  for (i = 0;  i < checkStr.length;  i++)

  {

    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)

      if (ch == checkOK.charAt(j))

        break;

    if (j == checkOK.length)

    {

      allValid = false;

      break;

    }

  }

  if (!allValid)

  {

    alert("Please enter only Digit characters in the \"Fax\" field.");

    theForm.fax2.focus();

    return (false);

  }







  if (theForm.email.value == "")

  {

    alert("Please enter a value for the \"Email\" field.");

    theForm.email.focus();

    return (false);

  }



  if (theForm.comments.value == "")

  {

    alert("Please enter a value for the \"comments\" field.");

    theForm.comments.focus();

    return (false);

  }



  if (theForm.comments.value.length > 400)

  {

    alert("Please enter at most 400 characters in the \"comments\" field.");

    theForm.comments.focus();

    return (false);

  }

  return (true);

}

