
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function check_and_submit()
{

// alert('I am here');
var error=0;
var good=0;
if(document.data.Telephone.value == "" ) { error = 1; }
// Just check the first three numbers
if(error==0)
	{
		var s = document.data.Telephone.value;
		var c = s.charAt(0);
        if (((c < "0") || (c > "9"))) { error = 1; }
		c = s.charAt(1);
        if (((c < "0") || (c > "9"))) { error = 1; }
		c = s.charAt(2);
        if (((c < "0") || (c > "9"))) { error = 1; }
		}


good = isEmail(document.data.Email.value);


var error_string = "";
if(error==1) { error_string ="Your telephone number is missing or incorrect." }

if(error==1 && good == 0 ) { error_string ="Your telephone number is missing or incorrect.  It also appears that either your email address has been incorrectly entered or has not been enter at all. This field is also required." }
if(error==0 && good == 0 ) { error_string ="It appears that your email address has been incorrectly entered or has not been enter at all. This field is required." }
if(error_string > "" ) { alert(error_string); document.data.error.value=1;}

if(error==0 && good==true) { document.data.submit(); }
}


function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

