function isEmpty(aTextField) {
	if ( (aTextField.value.length==0 ) || (aTextField.value==null) ) 
		return true;
	else
		return false;
}

function isEmail ( emailField ) {
 emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
 if( !emailpat.test( emailField.value ) ) {
  return false;
 }
 return true;
}

function check_shipping_form() {
	var msg="";
	if ( isEmpty(document.shipping_form.first) )
		msg += "- Please fill out your first name\n";
		
	if ( isEmpty(document.shipping_form.last) )
		msg += "- Please fill out your last name\n";
		
	if ( isEmpty(document.shipping_form.addr1) )
		msg += "- Please fill out address line 1\n";
		
	if ( document.shipping_form.country.value == 0 )
		msg += "- Please select a country\n";
	else if ( document.shipping_form.country.value == 'US' && ( document.shipping_form.state.value == 0 || document.shipping_form.state.value == '--' ))
		msg += "- Please select a state\n";
		
	if ( isEmpty(document.shipping_form.city) )
		msg += "- Please fill out the city\n";
	
	if ( msg.length > 1 ) {
		alert ( msg );
		return false;
	}
	return true;
}

function check_register_form() {
	var msg="";
	if ( isEmpty(document.register_form.name) ) 	msg += "- please fill out the your name.\n";
	if ( isEmpty(document.register_form.email) ) 	msg += "- please fill out the email address.\n";
		else if ( !isEmail(document.register_form.email) )	msg += "- please enter a valid email address.\n";
	if ( isEmpty(document.register_form.pass1) ) 	msg += "- please fill out the password.\n";
	if ( isEmpty(document.register_form.pass2) ) 	msg += "- please fill out the retype password.\n";
	if ( !isEmpty(document.register_form.pass1) && !isEmpty(document.register_form.pass2) )
		if ( document.register_form.pass1.value != document.register_form.pass2.value )
			msg += "- password and retype password do not match.\n";
	
	if ( msg.length > 1 ) {
		alert ( msg );
		return false;
	}
	return true;
}

function check_login_form()
{
	var msg="";
	if ( isEmpty(document.login_form.email) ) 	msg += "- please fill out the email address.\n";
		else if ( !isEmail(document.login_form.email) )	msg += "- please enter a valid email address.\n";
	if ( isEmpty(document.login_form.pass1) ) 	msg += "- please fill out the password.\n";
	
	if ( msg.length > 1 )
	{
		alert ( msg );
		return false;
	}
	return true;
}