
function submitonce(form){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" 
for (i=0;i<form.length;i++){
var tempobj=form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
//disable em
tempobj.disabled=true
}
}

}
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){
		   alert("You have entered an invalid email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("You have entered an invalid email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("You have entered an invalid email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("You have entered an invalid email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("You have entered an invalid email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("You have entered an invalid email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("You have entered an invalid email address")
		    return false;
		 }

	}
	

function validateFrm(form) {
var themessage = "You are required to complete the following fields: \n";
var radio_choice1 = false;

 
for (counter = 0; counter < form.q1.length; counter++)
	{
		if (form.q1[counter].checked)
		radio_choice1 = true; 
	}
	if (!radio_choice1)
	{
		themessage = themessage + "Question 1\n";		
	}


if (form.email.value != "") {
	var emailchk = form.email.value;
	return echeck(emailchk);
}

if (themessage == "You are required to complete the following fields: \n") {
	submitonce(form);
 	} else {
	alert(themessage);
	return false
	}

}


