// JavaScript Document
function validate_new_member(){
   //first_name
   if ( trim( document.new_member.first_name.value ) == '' ) {
		document.new_member.first_name.focus();
		alert("Please enter a first name.");
		return false;} 
   //last_name
   if ( trim( document.new_member.last_name.value ) == '' ) {
		document.new_member.last_name.focus();
		alert("Please enter a last name.");
		return false;}
	//tax id	
	if ( trim( document.new_member.tax_id.value ) == '' ) {
		document.new_member.tax_id.focus();
		alert("Please enter an tax id.");
		return false;}
	//username
	if ( trim( document.new_member.user_name.value ) == '' ) {
		document.new_member.user_name.focus();
		alert("Please enter an email address.");
		return false;}
	//password
	if ( trim( document.new_member.password.value ) == '' ) {
		document.new_member.password.focus();
		alert("Please enter an password.");
		return false;}
	//password check
	if ( document.new_member.password.value != document.new_member.password_re.value ) {
		document.new_member.password.focus();
		alert("Your passwords do not match.");
		return false;}
	//valid e-mail address		
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.new_member.user_name.value))){
		alert("Please enter a valid email address")
		return false;}
	//company
	if ( trim( document.new_member.company.value ) == '' ) {
		document.new_member.company.focus();
		alert("Please enter a company name.");
		return false;}
	//address_1
	if ( trim( document.new_member.address_1.value ) == '' ) {
		document.new_member.address_1.focus();
		alert("Please enter an address.");
		return false;}
	//city
	if ( trim( document.new_member.city.value ) == '' ) {
		document.new_member.city.focus();
		alert("Please enter a city.");
		return false;}	
	//zip
	if ( trim( document.new_member.zip.value ) == '' ) {
		document.new_member.zip.focus();
		alert("Please enter a zip code.");
		return false;}	
	//phone
	if ( trim( document.new_member.phone.value ) == '' ) {
		document.new_member.phone.focus();
		alert("Please enter a phone number.");
		return false;}	
	//Terms
	if  (document.new_member.agree.checked == false ){
		document.new_member.agree.focus();
		alert('You must agree to the terms before continuing.');
		return false;}
		
}

function validate_checkout(){
	//shipto_name
	if ( trim( document.CHECKOUT.shipto_name.value ) == '' ) {
		document.CHECKOUT.shipto_name.focus();
		alert("Please enter a shipping name.");
		return false;}
	//shipto_address_1	
	if ( trim( document.CHECKOUT.shipto_address_1.value ) == '' ) {
		document.CHECKOUT.shipto_address_1.focus();
		alert("Please enter a shipping address.");
		return false;} 
	//shipto_city	
	if ( trim( document.CHECKOUT.shipto_city.value ) == '' ) {
		document.CHECKOUT.shipto_city.focus();
		alert("Please enter a shipping city");
		return false;}
	//shipto_zip	
	if ( !isValidZip( document.CHECKOUT.shipto_zip.value )) 
	{
		document.CHECKOUT.shipto_zip.focus();
		alert("Please enter a valid shipping zipcode.");
		return false;
	}
	//shipto_phone	
	if ( trim( document.CHECKOUT.shipto_phone.value ) == '' ) {
		document.CHECKOUT.shipto_phone.focus();
		alert("Please enter a shipping phone number");
		return false;}
	//cc_fname	
	if ( trim( document.CHECKOUT.cc_fname.value ) == '' ) {
		document.CHECKOUT.cc_fname.focus();
		alert("Please enter your first name");
		return false;} 
	//cc_lname	
	if ( trim( document.CHECKOUT.cc_lname.value ) == '' ) {
		document.CHECKOUT.cc_lname.focus();
		alert("Please enter your last name");
		return false;} 
	//cc_add1	
	if ( trim( document.CHECKOUT.cc_add1.value ) == '' ) {
		document.CHECKOUT.cc_add1.focus();
		alert("Please enter a credit card address");
		return false;} 
	//cc_city	
	if ( trim( document.CHECKOUT.cc_city.value ) == '' ) {
		document.CHECKOUT.cc_city.focus();
		alert("Please enter a credit card city");
		return false;} 
	//cc_zip	
	if ( !isValidZip( document.CHECKOUT.cc_zip.value )) 
	{
		document.CHECKOUT.cc_zip.focus();
		alert("Please enter a valid credit card zipcode.");
		return false;
	} 		
	//cc_num	
	if ( !isDigits( document.CHECKOUT.cc_num.value )) 
	{
		document.CHECKOUT.cc_num.focus();
		alert("Please enter a valid credit card number.\nNumbers only please. No dashes.");
		return false;
	}
	if ( !isDigits( document.CHECKOUT.cc_cvv.value )) 
	{
		document.CHECKOUT.cc_cvv.focus();
		alert("Please enter a valid CVV Code. \nFor VISA, MC and Discover cards, it is the last 3 digits printed on the signature strip.\nFor American Express, it is the 4 digits on the front of the card above the credit number.");
		return false;
	}
		
  return true;
}
