// JavaScript Document
function validate_form(thisForm)
{
	with(thisForm)
	{
		if(txtName.value == "" || txtEmail.value == "")
		{
			alert("Name and Email cannot be left empty");
			return false;
		}		
	}

	var i;
	var count = 0;	
	for(i=1; i<6; ++i)
	{
		if(document.getElementById("txtEmail"+i).value == "") 
		{
			count++;
		}
		
		if(document.getElementById("txtEmail"+i).value != "")
		{			
			if (validateEmail(document.getElementById("txtEmail"+i), "Not a valid e-mail address!") == false)
			{
				document.getElementById("txtEmail"+i).focus();
				alert(document.getElementById("txtEmail"+i).value.selected); // = true;
				return false;
			}			
		}
	}
	
	if(count==5)
	{
		alert("At least one Email address has to entered");
			return false;
	}
				
	return true;
}

function validateEmail(field, alertTxt)
{
	with(field)
	{
		var at = value.indexOf("@");
		var dot = value.lastIndexOf(".");
		
		if (at<3 || dot-at<3)
		{
			alert(alertTxt);
			return false;
		}
		
		else
			return true;
	}
}

