function check_email(e) 
{
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++)
	{
		if(ok.indexOf(e.charAt(i))<0)
		{ 
			return (false);
		}	
	} 

	if (document.images)
	{
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) 
		{
		return (-1);		
		} 
	}
}


function check_form(f) // f is the form (passed using the this keyword)
{
	if(f.fields_fname.value.length < 1)
	{
		alert("You entered less than one character in the First Name field.");
		f.fields_fname.focus(); // put the prompt in the name field 

		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID)
		{
			// change the color of text field
			f.fields_fname.style.background = "yellow";
		}
		// make sure the form is not submitted
		return false;
	}

	if(f.fields_lname.value.length < 1)
	{
		alert("You entered less than one character in the Last Name field.");
		f.fields_lname.focus(); // put the prompt in the name field 

		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID)
		{
			// change the color of text field
			f.fields_lname.style.background = "yellow";
		}
		// make sure the form is not submitted
		return false;
	}

	// check the first email address ( the exclamation means "not" )
	if(!check_email(f.fields_email.value))
	{
		alert("Invalid email detected.");
		f.fields_email.focus(); 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID)
		{
			// change the color of text field
			f.fields_email.style.background = "yellow";
		}
		// make sure the form is not submitted
		return false;
	}

	// check the second email address
	if(f.email2.value != f.fields_email.value)
	{
		alert("Emails do not match.");
		f.email2.focus(); 
		if(document.all || document.getElementByID)
		{
			f.email2.style.background = "yellow";
		}
		return false;
	}

	if(f.fields_country.selectedIndex == 0 || f.fields_country.selectedIndex == 5)
	{
		alert("Please Select Your Country");
		f.fields_country.focus(); // put the prompt in the country field 

		// make sure the form is not submitted
		return false;
	}


}
