// JavaScript Document

function validate_form(thisForm)
{
	with(thisForm)
	{
		if(txtName.value == "" || txtEmail.value == "" || txtNationality.value == "" || txtPhone.value == "" )
		{
			alert("Name, Email, Nationality and Phone cannot be left empty. Please check.");
			return false;
		}
		
		if(txtEmail.value != "")
		{
			if(validateEmail(txtEmail, "Not a valid e-mail address!") == false)
			{
				txtEmail.focus();
				return false;
			}
		}				
	}
}

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;
	}
}

/*
	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;
	}
}
*/
