function e(s) {
	rex=true;
	if (window.RegExp) 
	{
		st="a";ex=new RegExp(st);
		if (st.match(ex)) {
		r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)\$");
		b=(!r1.test(s)&&r2.test(s));
		}
		else 
		{
			rex=false;
		}
	} 
	else
	{
		rex=false;
	}

	if(!rex) b=(s.indexOf("@")>0 && s.indexOf(".")>0 && s!="" && s!="enter e-mail");
	return (b);
}

function f(h) 
{
	h.focus();
	h.select();
}
function val(fld) 
{
	s=fld.value;
	if(e(s)) 
	{
		if (checkform()) 
		{
		document.Entry.datatype.value = "Todd";
		}
		else 
		{
		//f(fld);
			return false;
		}

		if (clearform()); 
	} 
	else 
	{
		alert("Please include a proper e-mail address, of the form id\@domain.zzz or id\@domain.xx.zzz.");
		document.Entry.Email.focus();
		//f(fld);
		return false;
	}
}




function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}




function gotFocusHomeAreaCode()
{

	if(trim(document.Entry.HomeAreaCode.value)=="" || trim(document.Entry.HomeAreaCode.value)=="xxx")	
	{
		document.Entry.HomeAreaCode.value="";
		document.Entry.HomeAreaCode.focus();
	}
}

function lostFocusHomeAreaCode()
{
	if(trim(document.Entry.HomeAreaCode.value)=="")
		document.Entry.HomeAreaCode.value="xxx";
}


function gotFocusHomePrefix()
{

	if(trim(document.Entry.HomePrefix.value)=="" || trim(document.Entry.HomePrefix.value)=="xxx")	
	{
		document.Entry.HomePrefix.value="";
		document.Entry.HomePrefix.focus();
	}
}

function lostFocusHomePrefix()
{
	if(trim(document.Entry.HomePrefix.value)=="")
		document.Entry.HomePrefix.value="xxx";
}


function gotFocusHomeSuffix()
{

	if(trim(document.Entry.HomeSuffix.value)=="" || trim(document.Entry.HomeSuffix.value)=="xxxx")	
	{
		document.Entry.HomeSuffix.value="";
		document.Entry.HomeSuffix.focus();
	}
}

function lostFocusHomeSuffix()
{
	if(trim(document.Entry.HomeSuffix.value)=="")
		document.Entry.HomeSuffix.value="xxxx";
}





















function isDigit(c)
{   return ((c >= "0") && (c <= "9"))
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isInteger (s)
{   
	var i,vval;
	vval="";

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);


        if (isDigit(c)) 
		{
			vval="True";
			break;
		}
		else
			vval="False";
			
    }

    // All characters are numbers.

	if(vval=="True")
		return true;
	else
		return false;
}


function isChars (s)
{   
	var i,vval;
	vval="";

    if (isEmpty(s)) 
       if (isChars.arguments.length == 1) return defaultEmptyOK;
       else return (isChars.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);


        if (!isDigit(c)) 
		{
			vval="True";
			break;
		}
		else
			vval="False";
			
    }

    // All characters are numbers.

	if(vval=="True")
		return true;
	else
		return false;
}



function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {

      var j=0, i = s.length;


      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      s = s.substring(j, i);
   }
   return s;
}


function RTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      var i = s.length - 1;      

      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;

      s = s.substring(0, i+1);
   }

   return s;
}

function trim(str)
{   
   return RTrim(LTrim(str));
}




function checkform()
{

	if (document.Entry.programs.value == null || document.Entry.programs.value.length == 0 || trim(document.Entry.programs.value) == "") 
	{
		alert("\nPlease select the Program of your Interest.");
		document.Entry.programs.value="";
		document.Entry.programs.focus();
		return false;
	}

	if (document.Entry.FirstName.value == null || document.Entry.FirstName.value.length == 0 || trim(document.Entry.FirstName.value) == "") 
	{
		alert("\nPlease Enter your First Name.");
		document.Entry.FirstName.value="";
		document.Entry.FirstName.focus();
		return false;
	}

	if (isInteger(trim(document.Entry.FirstName.value)) == true)
	{
			alert("\nNo numbers allowed in your First Name.");
			document.Entry.FirstName.value="";
			document.Entry.FirstName.focus();
			return false;		
	}

	if (document.Entry.LastName.value == null || document.Entry.LastName.value.length == 0 || trim(document.Entry.LastName.value) == "") 
	{
		alert("\nPlease Enter your Last Name.");
		document.Entry.LastName.value="";
		document.Entry.LastName.focus();
		return false;
	}

	if (isInteger(trim(document.Entry.LastName.value)) == true)
	{
			alert("\nNo numbers allowed in your Last Name.");
			document.Entry.LastName.value="";
			document.Entry.LastName.focus();
			return false;		
	}



	if (document.Entry.Address.value == null || document.Entry.Address.value.length == 0 || trim(document.Entry.Address.value) == "") 
	{
		alert("\nPlease Enter your Address.");
		document.Entry.Address.focus();
		return false;
	}




	if (document.Entry.City.value == null || document.Entry.City.value.length == 0 || trim(document.Entry.City.value) == "") 
	{
		alert("\nPlease Enter your City Name.");
		document.Entry.City.focus();
		return false;
	}


	if (isInteger(trim(document.Entry.City.value)) == true)
	{
			alert("\nNo numbers allowed in City Name.");
			document.Entry.City.focus();
			return false;		
	}


	if (document.Entry.State.value == "") 
	{
		alert("\nPlease select Your State.");
		document.Entry.State.focus();
		return false;
	}


	if (document.Entry.Zip.value == null || document.Entry.Zip.value.length == 0 || trim(document.Entry.Zip.value) == "") 
	{
		alert("\nPlease Enter your ZipCode.");
		document.Entry.Zip.focus();
		return false;
	}


	if (isChars(document.Entry.Zip.value) == true)
	{
			alert("\nNo Alphabets allowed in Zip Code.");
			document.Entry.Zip.focus();
			return false;		
	}


	if (trim(document.Entry.HomeAreaCode.value) == "xxx") 
	{
		alert("\nPlease Enter your Home Phone Area Code.");
		document.Entry.HomeAreaCode.focus();
		return false;
	}

	if (isChars(document.Entry.HomeAreaCode.value) == true)
	{
			alert("\nNo Alphabets allowed in Home Phone Area Code");
			document.Entry.HomeAreaCode.focus();
			return false;		
	}

	if (document.Entry.HomeAreaCode.value.length < 3) 
	{
		alert("\nHome Phone Area Code must contain 3 digits.");
		document.Entry.HomePhone.focus();
		return false;
	}




	if (trim(document.Entry.HomePrefix.value) == "xxx") 
	{
		alert("\nPlease Enter your Home Phone Prefix.");
		document.Entry.HomePrefix.focus();
		return false;
	}

	if (isChars(document.Entry.HomePrefix.value) == true)
	{
			alert("\nNo Alphabets allowed in Home Phone Preifx");
			document.Entry.HomePrefix.focus();
			return false;		
	}

	if (document.Entry.HomePrefix.value.length < 3) 
	{
		alert("\nHome Phone Prefix must contain 3 digits.");
		document.Entry.HomePrefix.focus();
		return false;
	}



	if (trim(document.Entry.HomeSuffix.value) == "xxxx") 
	{
		alert("\nPlease Enter your Home Phone Suffix.");
		document.Entry.HomeSuffix.focus();
		return false;
	}

	if (isChars(document.Entry.HomeSuffix.value) == true)
	{
			alert("\nNo Alphabets allowed in Home Phone Suffix");
			document.Entry.HomeSuffix.focus();
			return false;		
	}

	if (document.Entry.HomeSuffix.value.length < 4) 
	{
		alert("\nHome Phone Suffix must contain 4 digits.");
		document.Entry.HomeSuffix.focus();
		return false;
	}


	if (document.Entry.Email.value == null || document.Entry.Email.value.length == 0 || trim(document.Entry.Email.value) == "") 
	{
		alert("\nPlease Enter your Email.");
		document.Entry.Email.focus();
		return false;
	}

	if (!e(document.Entry.Email.value))
	{

		alert("Please include a proper e-mail address, of the form id\@domain.zzz or id\@domain.xx.zzz.");
		document.Entry.Email.focus();
		//f(fld);
		return false;
	}


	if (document.Entry.Age.value == null || document.Entry.Age.value.length == 0 || trim(document.Entry.Age.value) == "") 
	{
		alert("\nPlease Enter your Age.");
		document.Entry.Age.focus();
		return false;
	}


	if (isChars(document.Entry.Age.value) == true)
	{
			alert("\nNo Alphabets allowed in your Age.");
			document.Entry.Age.focus();
			return false;		
	}


	if (document.Entry.Gender.value == "") 
	{
		alert("\nPlease select Your Gender.");
		document.Entry.Gender.focus();
		return false;
	}

}