

function testResults(formData) {
    
    var goodBackground = '#FEE3AD';
    var badBackground = '#FEC0C0';

    var emailGood = true;
    var verifyGood = true;

    //Decoder ring for info
    var f_name = formData.entry_0.value;
    var f_email = alltrim(formData.entry_7.value);
    var f_verify = alltrim(formData.entry_8.value);
    var f_update = formData.group_11_1.checked;
    var f_volun = formData.group_11_2.checked;
    

    if(!(echeck(f_email))) {
        emailGood = false;
        alert("The entered email address is not valid.\nPlease correct and re-submit.");
        document.getElementById("entry_7").style.background = badBackground;
        return false;
    }
    else if(!(f_email == f_verify)){
        verifyGood = false;
        emailGood = false;
        alert("The entered email addresses do not match.\nPlease correct and re-submit.");
        document.getElementById("entry_8").style.background = badBackground;
        document.getElementById("entry_7").style.background = badBackground;
        return false;
    }
    
    document.getElementById("entry_7").style.background = goodBackground;        
    document.getElementById("entry_8").style.background = goodBackground;        
  
//    var http = new XMLHttpRequest();
  
//    var params = 'name='+f_name+'&email='+f_email+'&updates='+f_update+'&volun='+f_volun;
//    var url = "/cgi-bin/new.cgi";
//    http.open("GET", url+"?"+params, true);
//    http.onreadystatechange = function() {//Call a function when the state changes.
//	if(http.readyState == 4 && http.status == 200) {
//		//alert(http.responseText);
//	}
//   }
//    http.send(null);

  return true;

}


function alltrim(str) {
    return str.replace(/^\s+|\s+$/g, '');
}


function echeck(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
        return false
     }
    
     if (str.indexOf(" ")!=-1){
        return false
     }

     return true					
}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }