// JavaScript Document


//Copy information from the general contact form to the payment info form if it all validates correctly
function copy_info(){
	
	var name_f = document.getElementById('firstname');
	var name_l = document.getElementById('lastname');
	var address1 = document.getElementById('address');
	var address2 = document.getElementById('address2');
	var city = document.getElementById('city');
	var state = document.getElementById('state');
	var zip = document.getElementById('zip');
	var new_name_f = document.getElementById('b_firstname');
	var new_name_l = document.getElementById('b_lastname');
	var new_address1 = document.getElementById('b_address');
	var new_address2 = document.getElementById('b_address2');
	var new_city = document.getElementById('b_city');
	var new_state = document.getElementById('b_state');
	var new_zip = document.getElementById('b_zip');
	
			if(!reStr.test(name_f.value)){
				alert('Please enter your name');
				name_f.select();
				name_f.focus();
				return false;
			}
			
			if(!reStr.test(name_l.value)){
				alert('Please enter your name');
				name_l.select();
				name_l.focus();
				return false;
			}
			
			if(!reStrAlpha.test(address1.value)){
				alert('Please enter a valid address');
				address1.select();
				address1.focus();
				return false;
				
			}
			
			if(!reStr.test(city.value)){
				
				alert('Please enter a valid city');
				city.select();
				city.focus();
				return false;
				
			}
			
			if(!reStr.test(state.value)){
				alert('Please enter a valid two letter sate code');
				state.select();
				state.focus();
				return false;
			}
			
			if(!reNumber.test(zip.value)){
				alert('Please enter a valid zip code');
				zip.select();
				zip.focus();
				return false;
				
			}
			
			if(new_name_f.value =='') new_name_f.value = name_f.value; else new_name_f.value = '';
			if(new_name_l.value =='') new_name_l.value = name_l.value; else new_name_l.value = '';
			if(new_address1.value=='') new_address1.value = address1.value; else new_address1.value = '';
			if(new_address2.value=='') new_address2.value = address2.value; else new_address2.value = '';
			if(new_city.value =='') new_city.value = city.value; else new_city.value='';
			if(new_state.value =='') new_state.value = state.value; else new_state.value='';
			if(new_zip.value =='') new_zip.value = zip.value; else new_zip.value ='';
	
}


//Send Credit card information
function send_card(){
	
	
	
	var name_f = document.getElementById('firstname');
	var name_l = document.getElementById('lastname');
	var address1 = document.getElementById('address');
	var address2 = document.getElementById('address2');
	var city = document.getElementById('city');
	var state = document.getElementById('state');
	var zip = document.getElementById('zip');
	var email = document.getElementById('email');
	var email2 = document.getElementById('email2');
	var phone = document.getElementById('phone');
	var cnumber = document.getElementById('cardnumber');
	var ctype = document.getElementById('cardtype');
	var cvv = document.getElementById('cvv');
	var exp_mon = document.getElementById('month');
	var exp_year = document.getElementById('year');
	var billing_name_f = document.getElementById('b_firstname');
	var billing_name_l = document.getElementById('b_lastname');
	var billing_address1 = document.getElementById('b_address');
	var billing_address2 = document.getElementById('b_address2');
	var billing_city = document.getElementById('b_city');
	var billing_state = document.getElementById('b_state');
	var billing_zip = document.getElementById('b_zip');
	
	
	//Validate the card holder contact info here

		
			if(!reStr.test(name_f.value)){
				alert('Please enter your name');
				name_f.select();
				name_f.focus();
				return false;
			}
			
			if(!reStr.test(name_l.value)){
				alert('Please enter your name');
				name_l.select();
				name_l.focus();
				return false;
			}
			
			if(!reStrAlpha.test(address1.value)){
				alert('Please enter a valid address');
				address1.select();
				address1.focus();
				return false;
				
			}
			
			if(!reStr.test(city.value)){
				
				alert('Please enter a valid city');
				city.select();
				city.focus();
				return false;
				
			}
			
			if(!reStr.test(state.value)){
				alert('Please enter a valid two letter sate code');
				state.select();
				state.focus();
				return false;
			}
			
			if(!reNumber.test(zip.value)){
				alert('Please enter a valid zip code');
				zip.select();
				zip.focus();
				return false;
				
			}	
			
			if(!reEmail.test(email.value)){
				alert('Please enter a valid email address');
				email.select();
				email.focus();
				return false;
			}
			
			if(!reEmail.test(email2.value)){
				alert('Please confirm your email address');
				email2.select();
				email2.focus();
				return false;
			}
			
			if(email.value != email2.value){
				alert('Email addresses do not match');
				email2.select();
				email2.focus();
				return false;
			}
			
			if(!reStr.test(billing_name_f.value)){
				alert('All billing information is required');
				billing_name_f.select();
				billing_name_f.focus();
				return false;
			}
			
			if(!reStr.test(billing_name_l.value)){
				alert('All billing information is required');
				billing_name_l.select();
				billing_name_l.focus();
				return false;
			}
			
			if(!reStrAlpha.test(billing_address1.value)){
				alert('All billing information is required');
				billing_address1.select();
				billing_address1.focus();
				return false;
				
			}
			
			if(!reStr.test(billing_city.value)){
				
				alert('All billing informaton is required');
				billing_city.select();
				billing_city.focus();
				return false;
				
			}
			
			if(!reStr.test(billing_state.value)){
				alert('All billing information is required');
				billing_state.select();
				billing_state.focus();
				return false;
			}
			
			if(!reNumber.test(billing_zip.value)){
				alert('All billing information is required');
				billing_zip.select();
				billing_zip.focus();
				return false;
				
			}
	
	//Validate the actual card information here
	
	if(!reNumber.test(cnumber.value)){
		alert('Please enter a valid card number');
		cnumber.focus();
		cnumber.select();
		return false;
	}
	if(!reNumber.test(cvv.value)){
		alert('Please enter the cvv number for this card');
		cvv.focus();
		cvv.select();
		return false;
	}
	
	if(!reNumber.test(exp_mon.value)){
		alert('Please select the expiration date for your card');
		return false;
	}
	
	if(!reNumber.test(exp_year.value)){
		alert('Please select the expiration date for yout card');
		return false;
	}
	
	
	
	
	
	
}


//Send Credit card information
function send_mail(){
	
	
	
	var name_f = document.getElementById('firstname');
	var name_l = document.getElementById('lastname');
	var address1 = document.getElementById('address');
	var address2 = document.getElementById('address2');
	var city = document.getElementById('city');
	var state = document.getElementById('state');
	var zip = document.getElementById('zip');
	var email = document.getElementById('email');
	var email2 = document.getElementById('email2');
	var phone = document.getElementById('phone');
	
	
	//Validate the card holder contact info here

		
			if(!reStr.test(name_f.value)){
				alert('Please enter your name');
				name_f.select();
				name_f.focus();
				return false;
			}
			
			if(!reStr.test(name_l.value)){
				alert('Please enter your name');
				name_l.select();
				name_l.focus();
				return false;
			}
			
			if(!reStrAlpha.test(address1.value)){
				alert('Please enter a valid address');
				address1.select();
				address1.focus();
				return false;
				
			}
			
			if(!reStr.test(city.value)){
				
				alert('Please enter a valid city');
				city.select();
				city.focus();
				return false;
				
			}
			
			if(!reStr.test(state.value)){
				alert('Please enter a valid two letter sate code');
				state.select();
				state.focus();
				return false;
			}
			
			if(!reNumber.test(zip.value)){
				alert('Please enter a valid zip code');
				zip.select();
				zip.focus();
				return false;
				
			}	
			
			if(!reEmail.test(email.value)){
				alert('Please enter a valid email address');
				email.select();
				email.focus();
				return false;
			}
			
			if(!reEmail.test(email2.value)){
				alert('Please confirm your email address');
				email2.select();
				email2.focus();
				return false;
			}
			
			if(email.value != email2.value){
				alert('Email addresses do not match');
				email2.select();
				email2.focus();
				return false;
			}
			
			
	
	
	
	
	
}
