function update_edit_billing()
{
	var error_str = '';
	var first_name = document.getElementById('EDIT_BILLING_FIRST_NAME');
	var last_name = document.getElementById('EDIT_BILLING_LAST_NAME');
	var company_name = document.getElementById('EDIT_BILLING_COMPANY_NAME');
	var address_1 = document.getElementById('EDIT_BILLING_ADDRESS_1');
	var address_2 = document.getElementById('EDIT_BILLING_ADDRESS_2');
	var city = document.getElementById('EDIT_BILLING_CITY');
	var state = document.getElementById('EDIT_BILLING_STATE');
	var zip = document.getElementById('EDIT_BILLING_ZIP');
	var phone = document.getElementById('EDIT_BILLING_PHONE');
	var extension = document.getElementById('EDIT_BILLING_EXTENSION');
	
	first_name.value = trim(first_name.value);
	last_name.value = trim(last_name.value);
	company_name.value = trim(company_name.value);
	address_1.value = trim(address_1.value);
	address_2.value = trim(address_2.value);
	city.value = trim(city.value);
	zip.value = trim(zip.value);
	phone.value = trim(phone.value);
	extension.value = trim(extension.value);	
	
	if (first_name.value.length < 1) { error_str += 'First Name - blank \n'; }
	else if (!is_alpha(first_name.value)) { error_str += 'First Name - Invalid characters used \n'; }
	if (last_name.value.length < 1) { error_str += 'Last Name - blank \n'; last_name_text = 'red_text'; }
	else if (!is_alpha(last_name.value)) { error_str += 'Last Name - Invalid characters used \n'; }
	if (company_name.value.length && !is_alpha(company_name.value)) { error_str += 'Company Name - Invalid characters used \n'; }
	if (city.value.length < 1) { error_str += 'City - blank \n'; }
	else if (!is_alpha(city.value)) { error_str += 'City - Invalid characters used \n'; }
	if (address_1.value.length < 1) { error_str += 'Address Line 1 - blank \n'; }
	else if (!is_alpha(address_1.value)) { error_str += 'Address Line 1 - Invalid characters used \n'; }
	if (address_2.value.length && !is_alpha(address_2.value)) { error_str += 'Address Line 2 - Invalid characters used \n'; }
	
	if (state.value < 1) { error_str += 'State - Please make selection \n'; }
	if (zip.value.length < 1) { error_str += 'Zip - blank \n'; }
	else if (!is_zip(zip.value)) { error_str += 'Zip - invalid (please check) \n'; }
	if (phone.value.length < 1) { error_str += 'Phone - blank \n'; }
	else if (!check_phone(phone.value)) { error_str += 'Phone - invalid (please check) \n'; }
	if (extension.value.length && !is_extension(extension.value)) { error_str += 'Phone Extension - Invalid characters used \n'; }
	
	if (error_str.length) 
	{ 
		alert('Please correct the following: \n \n' + error_str); 
	}
	else
	{
		var url = "library/functions/update_edit_billing.php";
		url = url + "?q=";
		url = url + "&ajax=1";
		url = url + "&first_name=" + first_name.value;
		url = url + "&last_name=" + last_name.value;
		url = url + "&company_name=" + company_name.value;
		url = url + "&address_1=" + address_1.value;
		url = url + "&address_2=" + address_2.value;
		url = url + "&city=" + city.value;
		url = url + "&state=" + state.value;
		url = url + "&zip=" + zip.value;
		url = url + "&phone=" + phone.value;
		url = url + "&extension=" + extension.value;
		url = url + "&sid=" + Math.random();		
		
		xmlreqGET(url);	
	}
}

function update_edit_shipping()
{
	var error_str = '';
	var first_name = document.getElementById('EDIT_SHIPPING_FIRST_NAME');
	var last_name = document.getElementById('EDIT_SHIPPING_LAST_NAME');
	var company_name = document.getElementById('EDIT_SHIPPING_COMPANY_NAME');
	var address_1 = document.getElementById('EDIT_SHIPPING_ADDRESS_1');
	var address_2 = document.getElementById('EDIT_SHIPPING_ADDRESS_2');
	var city = document.getElementById('EDIT_SHIPPING_CITY');
	var state = document.getElementById('EDIT_SHIPPING_STATE');
	var zip = document.getElementById('EDIT_SHIPPING_ZIP');
	var phone = document.getElementById('EDIT_SHIPPING_PHONE');
	var extension = document.getElementById('EDIT_SHIPPING_EXTENSION');
	
	first_name.value = trim(first_name.value);
	last_name.value = trim(last_name.value);
	company_name.value = trim(company_name.value);
	address_1.value = trim(address_1.value);
	address_2.value = trim(address_2.value);
	city.value = trim(city.value);
	zip.value = trim(zip.value);
	phone.value = trim(phone.value);
	extension.value = trim(extension.value);
	
	if (first_name.value.length < 1) { error_str += 'First Name - blank \n'; }
	else if (!is_alpha(first_name.value)) { error_str += 'First Name - Invalid characters used \n'; }
	if (last_name.value.length < 1) { error_str += 'Last Name - blank \n'; last_name_text = 'red_text'; }
	else if (!is_alpha(last_name.value)) { error_str += 'Last Name - Invalid characters used \n'; }
	if (company_name.value.length && !is_alpha(company_name.value)) { error_str += 'Company Name - Invalid characters used \n'; }
	if (city.value.length < 1) { error_str += 'City - blank \n'; }
	else if (!is_alpha(city.value)) { error_str += 'City - Invalid characters used \n'; }
	if (address_1.value.length < 1) { error_str += 'Address Line 1 - blank \n'; }
	else if (!is_alpha(address_1.value)) { error_str += 'Address Line 1 - Invalid characters used \n'; }
	if (address_2.value.length && !is_alpha(address_2.value)) { error_str += 'Address Line 2 - Invalid characters used \n'; }
	
	if (state.value < 1) { error_str += 'State - Please make selection \n'; }
	if (zip.value.length < 1) { error_str += 'Zip - blank \n'; }
	else if (!is_zip(zip.value)) { error_str += 'Zip - invalid (please check) \n'; }
	if (phone.value.length < 1) { error_str += 'Phone - blank \n'; }
	else if (!check_phone(phone.value)) { error_str += 'Phone - invalid (please check) \n'; }
	if (extension.value.length && !is_extension(extension.value)) { error_str += 'Phone Extension - Invalid characters used \n'; }

	if (error_str.length) 
	{ 
		alert('Please correct the following: \n \n' + error_str); 
	}
	else
	{
		var url = "library/functions/update_edit_shipping.php";
		url = url + "?q=";
		url = url + "&ajax=1";
		url = url + "&first_name=" + first_name.value;
		url = url + "&last_name=" + last_name.value;
		url = url + "&company_name=" + company_name.value;
		url = url + "&address_1=" + address_1.value;
		url = url + "&address_2=" + address_2.value;
		url = url + "&city=" + city.value;
		url = url + "&state=" + state.value;
		url = url + "&zip=" + zip.value;
		url = url + "&phone=" + phone.value;
		url = url + "&extension=" + extension.value;
		url = url + "&sid=" + Math.random();		
		
		xmlreqGET(url);	
	}
}

function confirm_order()
{
	document.myForm.CARD_FIRST_NAME.value = trim(document.myForm.CARD_FIRST_NAME.value);
	document.myForm.CARD_LAST_NAME.value = trim(document.myForm.CARD_LAST_NAME.value);
	document.myForm.CARD_NUM.value = trim(document.myForm.CARD_NUM.value);
	document.myForm.CARD_EXP_MONTH.value = trim(document.myForm.CARD_EXP_MONTH.value);
	document.myForm.CARD_EXP_YEAR.value = trim(document.myForm.CARD_EXP_YEAR.value);
	document.myForm.CARD_CODE.value = trim(document.myForm.CARD_CODE.value);
	
	var card_type = document.myForm.CARD_TYPE.selectedIndex;
	var first_name = document.myForm.CARD_FIRST_NAME;
	var last_name = document.myForm.CARD_LAST_NAME;
	var card_num = document.myForm.CARD_NUM;
	var card_exp_month = document.myForm.CARD_EXP_MONTH;
	var card_exp_year = document.myForm.CARD_EXP_YEAR;
	var card_code = document.myForm.CARD_CODE;
		
	var error_str = '';
	
	if (!card_type) { error_str += 'Credit Card Type - Please make selection \n'; }
	if (first_name.value.length < 1) { error_str += 'First Name - blank \n'; }
	else if (!is_alpha(first_name.value)) { error_str += 'First Name - Invalid characters used \n'; }
	if (last_name.value.length < 1) { error_str += 'Last Name - blank \n';  }
	else if (!is_alpha(last_name.value)) { error_str += 'Last Name - Invalid characters used \n'; }
	if (card_num.value.length < 1) { error_str += 'Credit Card # - blank \n';  }
	else if (!is_whole_num(card_num.value)) { error_str += 'Credit Card # - Invalid characters used (numbers only, do not use dashes or spaces) \n'; }
	if (card_exp_month.value.length < 1) { error_str += 'Exp Month - blank \n'; }
	else if (!is_whole_num(card_exp_month.value)) { error_str += 'Exp Month - Invalid characters used \n'; }
	if (card_exp_year.value.length < 1) { error_str += 'Exp Year - blank \n'; }
	else if (!is_whole_num(card_exp_year.value)) { error_str += 'Exp Year - Invalid characters used \n'; }
	if (card_code.value < 1) { error_str += 'CSC - blank \n'; }
	else if (!is_whole_num(card_code.value)) { error_str += 'CSC - Invalid characters used \n'; }
	
	if (error_str.length) 
	{ 
		alert('Please correct the following: \n \n' + error_str); 
	}
	else
	{		
		document.myForm.ACTION.value = 'PROCESS_ORDER';
		document.myForm.submit();
	}
}

function update_billing_shipping()
{
	var billing_error_str = '';
	var billing_first_name = $('BILLING_FIRST_NAME');
	var billing_last_name = $('BILLING_LAST_NAME');
	var billing_company_name = $('BILLING_COMPANY_NAME');
	var billing_address_1 = $('BILLING_ADDRESS_1');
	var billing_address_2 = $('BILLING_ADDRESS_2');
	var billing_city = $('BILLING_CITY');
	var billing_state = $('BILLING_STATE');
	var billing_zip = $('BILLING_ZIP');
	var billing_phone = $('BILLING_PHONE');
	var billing_extension = $('BILLING_EXTENSION');
	
	billing_first_name.value = trim(billing_first_name.value);
	billing_last_name.value = trim(billing_last_name.value);
	billing_company_name.value = trim(billing_company_name.value);
	billing_address_1.value = trim(billing_address_1.value);
	billing_address_2.value = trim(billing_address_2.value);
	billing_city.value = trim(billing_city.value);
	billing_zip.value = trim(billing_zip.value);
	billing_phone.value = trim(billing_phone.value);
	billing_extension.value = trim(billing_extension.value);
	
	var shipping_error_str = '';
	var shipping_first_name = $('SHIPPING_FIRST_NAME');
	var shipping_last_name = $('SHIPPING_LAST_NAME');
	var shipping_company_name = $('SHIPPING_COMPANY_NAME');
	var shipping_address_1 = $('SHIPPING_ADDRESS_1');
	var shipping_address_2 = $('SHIPPING_ADDRESS_2');
	var shipping_city = $('SHIPPING_CITY');
	var shipping_state = $('SHIPPING_STATE');
	var shipping_zip = $('SHIPPING_ZIP');
	var shipping_phone = $('SHIPPING_PHONE');
	var shipping_extension = $('SHIPPING_EXTENSION');
		
	shipping_first_name.value = trim(shipping_first_name.value);
	shipping_last_name.value = trim(shipping_last_name.value);
	shipping_company_name.value = trim(shipping_company_name.value);
	shipping_address_1.value = trim(shipping_address_1.value);
	shipping_address_2.value = trim(shipping_address_2.value);
	shipping_city.value = trim(shipping_city.value);
	shipping_zip.value = trim(shipping_zip.value);
	shipping_phone.value = trim(shipping_phone.value);
	shipping_extension.value = trim(shipping_extension.value);
	
	if (billing_first_name.value.length < 1) { billing_error_str += 'First Name - blank \n'; }
	else if (!is_alpha(billing_first_name.value)) { billing_error_str += 'First Name - Invalid characters used \n'; }
	if (billing_last_name.value.length < 1) { billing_error_str += 'Last Name - blank \n'; }
	else if (!is_alpha(billing_last_name.value)) { billing_error_str += 'Last Name - Invalid characters used \n'; }
	if (billing_company_name.value.length && !is_alpha(billing_company_name.value)) { billing_error_str += 'Company Name - Invalid characters used \n'; }
	if (billing_city.value.length < 1) { billing_error_str += 'City - blank \n'; }
	else if (!is_alpha(billing_city.value)) { billing_error_str += 'City - Invalid characters used \n'; }
	if (billing_address_1.value.length < 1) { billing_error_str += 'Address Line 1 - blank \n'; }
	else if (!is_alpha(billing_address_1.value)) { billing_error_str += 'Address Line 1 - Invalid characters used \n'; }
	if (billing_address_2.value.length && !is_alpha(billing_address_2.value)) { billing_error_str += 'Address Line 2 - Invalid characters used \n'; }
	
	if (billing_state.value < 1) { billing_error_str += 'State - Please make selection \n'; }
	if (billing_zip.value.length < 1) { billing_error_str += 'Zip - blank \n'; }
	else if (!is_zip(billing_zip.value)) { billing_error_str += 'Zip - invalid (please check) \n'; }
	if (billing_phone.value.length < 1) { billing_error_str += 'Phone - blank \n'; }
	else if (!check_phone(billing_phone.value)) { billing_error_str += 'Phone - invalid (please check) \n'; }
	if (billing_extension.value.length && !is_extension(billing_extension.value)) { billing_error_str += 'Phone Extension - Invalid characters used \n'; }
	
	if (shipping_first_name.value.length < 1) { shipping_error_str += 'First Name - blank \n'; }
	else if (!is_alpha(shipping_first_name.value)) { shipping_error_str += 'First Name - Invalid characters used \n'; }
	if (shipping_last_name.value.length < 1) { shipping_error_str += 'Last Name - blank \n'; }
	else if (!is_alpha(shipping_last_name.value)) { shipping_error_str += 'Last Name - Invalid characters used \n'; }
	if (shipping_company_name.value.length && !is_alpha(shipping_company_name.value)) { shipping_error_str += 'Company Name - Invalid characters used \n'; }
	if (shipping_city.value.length < 1) { shipping_error_str += 'City - blank \n'; }
	else if (!is_alpha(shipping_city.value)) { shipping_error_str += 'City - Invalid characters used \n'; }
	if (shipping_address_1.value.length < 1) { shipping_error_str += 'Address Line 1 - blank \n'; }
	else if (!is_alpha(shipping_address_1.value)) { shipping_error_str += 'Address Line 1 - Invalid characters used \n'; }
	if (!is_alpha(shipping_address_2.value)) { shipping_error_str += 'Address Line 2 - Invalid characters used \n'; }
	if (shipping_state.value < 1) { shipping_error_str += 'State - Please make selection \n'; }
	if (shipping_zip.value.length < 1) { shipping_error_str += 'Zip - blank \n'; }
	else if (!is_zip(shipping_zip.value)) { shipping_error_str += 'Zip - invalid (please check) \n'; }
	if (!check_phone(shipping_phone.value)) { shipping_error_str += 'Phone - invalid (please check) \n'; }	
	if (shipping_extension.value.length && !is_extension(shipping_extension.value)) { shipping_error_str += 'Phone Extension - Invalid characters used \n'; }
		
	if (billing_error_str.length || shipping_error_str.length) 
	{ 
		var error_str = '';
		if (billing_error_str.length) { error_str += '\n' + 'Billing: \n' + '--------' + '\n' + billing_error_str; }
		if (shipping_error_str.length) { error_str += '\n' + 'Shipping: \n' + '---------' + '\n' + shipping_error_str; }
		
		alert('Please correct the following: \n' + error_str); 
	}
	else
	{
		var url = "library/functions/update_billing_shipping.php";
		url = url + "?q=";
		url = url + "&ajax=1";
		url = url + "&sid=" + Math.random();	
		
		url = url + "&billing_first_name=" + billing_first_name.value;
		url = url + "&billing_last_name=" + billing_last_name.value;
		url = url + "&billing_company_name=" + billing_company_name.value;
		url = url + "&billing_address_1=" + billing_address_1.value;
		url = url + "&billing_address_2=" + billing_address_2.value;
		url = url + "&billing_city=" + billing_city.value;
		url = url + "&billing_state=" + billing_state.value;
		url = url + "&billing_zip=" + billing_zip.value;
		url = url + "&billing_phone=" + billing_phone.value;
		url = url + "&billing_extension=" + billing_extension.value;
		
		url = url + "&shipping_first_name=" + shipping_first_name.value;
		url = url + "&shipping_last_name=" + shipping_last_name.value;
		url = url + "&shipping_company_name=" + shipping_company_name.value;
		url = url + "&shipping_address_1=" + shipping_address_1.value;
		url = url + "&shipping_address_2=" + shipping_address_2.value;
		url = url + "&shipping_city=" + shipping_city.value;
		url = url + "&shipping_state=" + shipping_state.value;
		url = url + "&shipping_zip=" + shipping_zip.value;
		url = url + "&shipping_phone=" + shipping_phone.value;
		url = url + "&shipping_extension=" + shipping_extension.value;		
		
		xmlreqGET(url);	
	}
}