function submitForm()
{
	
	var formElements = document.forms["newsletterForm"].elements;
//alert ("submit(6) " + formElements);
	//Get country
	var i;
	var aCheckBox;
	var checkBoxChecked = false;
	var myCheckBoxValue;
	
	
	for (i=0; i<=7; i++)
	{
		//alert("i = " + i);
		//aCheckBox = document.forms["newsletterForm"].["countryRadioBtn" + i];
		aCheckBox = formElements["countryRadioBtn" + i.toString()];
		//aCheckBox = document.getElementById("countryRadioBtn" + i.toString())
		//alert("aCheckBox=" + aCheckBox);
		if (aCheckBox.checked)
		{
			checkBoxChecked = true;
			myCheckBoxValue = aCheckBox.value;
			break;
		}
	}
	if (checkBoxChecked)
	{
		if (formElements["countryRadioBtn7"].checked)
		{
			if (formElements["userCountryText"].value.length > 0)
			{
				formElements["countryText"].value = formElements["userCountryText"].value;
			}
			else
			{
				alert("Please type in a country");
				return false;
			}
		}
		else
		{
			formElements["countryText"].value = myCheckBoxValue;
		}
	}
	else
	{
		alert("You must select a country");
		return false;
	}
	
	checkBoxChecked = false;
	for (i=0; i <=4; i++)
	{
		//aCheckBox = eval("newsletterForm.employerDescriptionRadioBtn" + i);
		//alert("i = " + i);
		aCheckBox = formElements["employerDescriptionRadioBtn" + i.toString()];
		//alert("aCheckBox = " + aCheckBox);
		if (aCheckBox.checked)
		{
			checkBoxChecked = true;
			myCheckBoxValue = aCheckBox.value;
			break;
		}
	}
	if (checkBoxChecked)
	{
		if (formElements["employerDescriptionRadioBtn4"].checked)
		{
			if (formElements["userDescriptionText"].value.length  > 0)
			{
				formElements["employerDescriptionText"].value = formElements["userDescriptionText"].value;
			}
			else
			{
				alert("Please type in a description");
				return false;
			}
		}
		else
		{
			formElements["employerDescriptionText"].value = myCheckBoxValue;
		}
	}
	else
	{
		alert("You must select a description");
		return false;
	}
	
	if (!validate_required(formElements["emailText"], "Please enter an email address"))
	{
		return false;
	}
	if (!echeck(formElements["emailText"].value))
	{
		alert("Please enter a valid email")
		return false;
	}
	
	
	return true;
}

function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return 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("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


