var currentField='';
var currentAlert='';
var currentPass='';
var currentEmail='';
var complete=true;
var target='';
var temp1='';
var temp2='';
	
function toForm()
{
username.focus();
}
	
function validate_field(field,alerttxt)
{
if (currentField!=''&&currentField!=field)
	{
	if (currentField.value==null||currentField.value=='')
		{
		target=currentField;
		window.alert(currentAlert);
		currentField='';
		currentAlert='';
		target.focus();
		}
	else if (currentField.name=='password2'||currentField.name=='email2')
		{
		if (currentField.name=='password2')
			{
			temp1=currentPassword;
			}
		else
			{
			temp1=currentEmail;
			}
		temp2=currentField.value;
		if (temp2!=temp1)
			{
			if (currentField.name=='password2')
				{
				window.alert("The password fields do not match!");
				currentField='';
				currentAlert='';
				password.focus();
				}
			else
				{
				window.alert("The email fields do not match!");
				currentField='';
				currentAlert='';
				email2.focus();
				}
			}
		else if (alerttxt!='')
			{
			currentField=field;
			currentAlert=alerttxt;
			}
		}
	else if (currentField.name=='email')
		{
		apos=currentField.value.indexOf("@");
		dotpos=currentField.value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2)
			{
			target=currentField;
			window.alert("Invalid e-mail address!");
			currentField='';
			currentAlert='';
			target.focus();
			}
		else
			{
			currentEmail=currentField.value;
			if (alerttxt!='')
				{
				currentField=field;
				currentAlert=alerttxt;
				}
			}
		}
	else if (currentField.name=='password')
		{
		currentPassword=currentField.value;
		if (alerttxt!='')
			{
			currentField=field;
			currentAlert=alerttxt;
			}
		}
	else if (alerttxt!='')
		{
		currentField=field;
		currentAlert=alerttxt;
		}
	}
else if (alerttxt!='')
	{
	currentField=field;
	currentAlert=alerttxt;
	}
}
	
function validate_form()
{
	complete=true;
	if (username.value==null||username.value=='')
		{
		window.alert("You must enter a user name!");
		username.focus();
		complete=false;
		}
	else if (password.value==null||password.value=='')
		{
		window.alert("You must enter a password!");
		password.focus();
		complete=false;
		}
	else if (password2.value!=password.value)
		{
		window.alert("The password fields do not match!");
		currentField='';
		currentAlert='';
		password.focus();
		complete=false;
		}
	else if (email.value==null||email.value=='')
		{
		window.alert("You must enter an email address!");
		email.focus();
		complete=false;
		}
	else if (email2.value!=email.value)
		{
		window.alert("The email fields do not match!");
		email2.focus();
		complete=false;
		}
	else if (first.value==null||first.value=='')
		{
		window.alert("You must enter a first name!");
		first.focus();
		complete=false;
		}
	else if (last.value==null||last.value=='')
		{
		window.alert("You must enter a last name!");
		last.focus();
		complete=false;
		}
	else if (address.value==null||address.value=='')
		{
		window.alert("You must enter an address!");
		address.focus();
		complete=false;
		}
	else if (city.value==null||city.value=='')
		{
		window.alert("You must enter a city!");
		city.focus();
		complete=false;
		}
	else if (state.value==null||state.value=='')
		{
		window.alert("You must enter a state or province!");
		state.focus();
		complete=false;
		}
	else if (zip.value==null||zip.value=='')
		{
		window.alert("You must enter a zip/postal code!");
		zip.focus();
		complete=false;
		}
	else if (country.value==null||country.value=='')
		{
		window.alert("You must enter a country!");
		country.focus();
		complete=false;
		}
	else if (phone.value==null||phone.value=='')
		{
		window.alert("You must enter a phone number!");
		phone.focus();
		complete=false;
		}
	return complete;
}
