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 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 validatefields()
{


	if (document.Entry.name.value == null || document.Entry.name.value.length == 0 || trim(document.Entry.name.value) == "") 
	{
		alert("\nPlease Enter your Full Name.");
		document.Entry.name.value="";
		document.Entry.name.focus();
		return false;
	}

	if (isInteger(document.Entry.name.value) == true)
	{
			alert("\nNo numbers allowed in your Name.");
			document.Entry.name.value="";
			document.Entry.name.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 (trim(document.Entry.phone.value) == "") 
	{
		alert("\nPlease Enter your Phone Number.");
		document.Entry.phone.focus();
		return false;
	}

	if (isChars(document.Entry.phone.value) == true)
	{
			alert("\nNo Alphabets allowed in Phone number.");
			document.Entry.phone.focus();
			return false;		
	}


	if (document.Entry.website.value == null || document.Entry.website.value.length == 0 || trim(document.Entry.website.value) == "") 
	{
		alert("\nPlease Enter your Web Site.");
		document.Entry.website.value="";
		document.Entry.website.focus();
		return false;
	}

	if (trim(document.Entry.service.value) == "") 
	{
		alert("\nPlease select the Service that you are looking for.");
		document.Entry.service.value="";
		document.Entry.service.focus();
		return false;
	}


	if (trim(document.Entry.mcode.value) == "") 
	{
		alert("\nPlease Enter the numbers shown.");
		document.Entry.mcode.focus();
		return false;
	}

	if (isChars(document.Entry.mcode.value) == true)
	{
			alert("\nNo Alphabets allowed.");
			document.Entry.mcode.focus();
			return false;		
	}

}
