		var ajaxObj = new XMLHTTP("includes/ajax/mybic_server.php");
		// Turn debugger on or off
		//ajaxObj.debug=0;

		ajaxObj.net_down_func = yourFuncName;
		function yourFuncName(status) {}

					var curButton;

					function addCreditCard() {
						if (document.getElementById('cc_num').value.length === 0 || !ccMod10(document.getElementById('cc_num').value)) { alert("Please enter a valid card number."); document.getElementById('cc_num').focus(); return; }
						if (ccExpired(document.getElementById('cc_exp_month').value,document.getElementById('cc_exp_year').value)) { alert("Your expiration date is in the past. Please choose a date in the future."); document.getElementById('cc_num').focus(); return; }
						if (document.getElementById('fname').value.length === 0) { alert("Please enter the first name for this card."); document.getElementById('fname').focus(); return; }
						if (document.getElementById('lname').value.length === 0) { alert("Please enter the last name for this card."); document.getElementById('lname').focus(); return; }
						if (document.getElementById('address').value.length === 0) { alert("Please enter the address for this card."); document.getElementById('address').focus(); return; }
						if (document.getElementById('city').value.length === 0) { alert("Please enter the city for this card."); document.getElementById('city').focus(); return; }
						if (document.getElementById('zip').value.length != 5 || !isNumeric(document.getElementById('zip').value)) { alert("Please enter  a valid zip code for this card."); document.getElementById('zip').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = curButton == '' ? curButton : document.getElementById('addCreditCardReply').innerHTML;
						// error checking
						document.getElementById('addCreditCardReply').innerHTML = '<p>Updating...<img border="0" src="images/loading.gif"></p>';
						// get the form data
						var formVars = ajaxObj.getForm('addCreditCardForm');
						// ajax call
       					ajaxObj.call("action=ajaxFunctions&do=addCreditCard"+formVars, addCreditCard2);
					}

					function addCreditCard2(resp) {
						if (resp.doSQL) {
							window.location.href='account/credit_cards/';
						} else {
							document.getElementById('addCreditCardReply').innerHTML = '<p>Sorry. There was an error and your registry was not updated. <a href="account/registries/">Back to registry list.</a></p>'+curButton;
						}
					}
					function addRegistry() {
						// validate fields
						if (document.getElementById('wedding_city').value.length === 0) { alert("Please enter the wedding city."); document.getElementById('wedding_city').focus(); return; }
						if (document.getElementById('bride_fname').value.length === 0) { alert("Please enter the first name of registrant #1."); document.getElementById('bride_fname').focus(); return; }
						if (document.getElementById('bride_lname').value.length === 0) { alert("Please enter the last name of registrant #1."); document.getElementById('bride_lname').focus(); return; }
						if (document.getElementById('bride_address').value.length === 0) { alert("Please enter the address for registrant #1."); document.getElementById('bride_address').focus(); return; }
						if (document.getElementById('bride_city').value.length === 0) { alert("Please enter the city of registrant #1."); document.getElementById('bride_city').focus(); return; }
						if (document.getElementById('bride_zip').value.length != 5 || !isNumeric(document.getElementById('bride_zip').value)) { alert("Please enter  a valid zip code for registrant #1."); document.getElementById('bride_zip').focus(); return; }
						if (document.getElementById('groom_fname').value.length === 0) { alert("Please enter first name of registrant #2."); document.getElementById('groom_fname').focus(); return; }
						if (document.getElementById('groom_lname').value.length === 0) { alert("Please enter last name of registrant #2."); document.getElementById('groom_lname').focus(); return; }
						if (document.getElementById('groom_address').value.length === 0) { alert("Please enter the address for registrant #2."); document.getElementById('groom_address').focus(); return; }
						if (document.getElementById('groom_city').value.length === 0) { alert("Please enter the city of registrant #2."); document.getElementById('groom_city').focus(); return; }
						if (document.getElementById('groom_zip').value.length != 5 || !isNumeric(document.getElementById('groom_zip').value)) { alert("Please enter  a valid zip code for registrant #2."); document.getElementById('groom_zip').focus(); return; }
						if (document.getElementById('ship_fname').value.length === 0) { alert("Please enter the first name for the shipping address."); document.getElementById('ship_fname').focus(); return; }
						if (document.getElementById('ship_lname').value.length === 0) { alert("Please enter the last name for the shipping address."); document.getElementById('ship_lname').focus(); return; }
						if (document.getElementById('ship_address').value.length === 0) { alert("Please enter the address for the shipping address."); document.getElementById('ship_address').focus(); return; }
						if (document.getElementById('ship_city').value.length === 0) { alert("Please enter the city for the shipping address."); document.getElementById('ship_city').focus(); return; }
						if (document.getElementById('ship_zip').value.length != 5 || !isNumeric(document.getElementById('ship_zip').value)) { alert("Please enter  a valid zip code for the shipping information."); document.getElementById('ship_zip').focus(); return; }
						/*
						shipTo = getRadioValue(document.AddRegistryForm.r_ship_to);
						if (shipTo == 'Ship Address') {
							if (document.getElementById('r_ship_address').value.length === 0) { alert("Please enter the shipping address."); document.getElementById('r_ship_address').focus(); return; }
							if (document.getElementById('r_ship_city').value.length === 0) { alert("Please enter the shipping city."); document.getElementById('r_ship_city').focus(); return; }
							if (document.getElementById('r_ship_zip').value.length != 5 || !isNumeric(document.getElementById('r_ship_zip').value)) { alert("Please enter  a valid zip code for shipping."); document.getElementById('r_ship_zip').focus(); return; }
						}
						*/
        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('addregistryreply').innerHTML;
        				// show loading gif
        				document.getElementById('addregistryreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

        				// call the function
       					//var str = document.getElementById('r_date').value;
        				//ajaxObj.call("action=ajaxFunctions&do=isDate&str="+str, addRegistry2);
        				var formVars = ajaxObj.getForm('AddRegistryForm');
						ajaxObj.call("action=ajaxFunctions&do=addRegistry"+formVars, addRegistry3);
					}

					// THIS FUNCTION IS DEPRECATED
					function addRegistry2(resp) {
						if (resp) {
        					var formVars = ajaxObj.getForm('AddRegistryForm');
							ajaxObj.call("action=ajaxFunctions&do=addRegistry"+formVars, addRegistry3);
						} else {
							document.getElementById('addregistryreply').innerHTML = curButton;
							alert("Please enter a valid date.");
							document.getElementById('r_date').focus();
						}
					}

					function addRegistry3(resp) {
						if (resp.doSQL) {
							location.replace('registry/?rid='+resp.rid);
						} else {
							document.getElementById('addregistryreply').innerHTML = curButton;
							alert("We're sorry. There was a server issue and your registry was not added.");
						}
					}

					function addShippingAddress() {
						// validate fields
						if (document.getElementById('fname').value.length === 0) { alert("Please enter the first name."); document.getElementById('fname').focus(); return; }
						if (document.getElementById('lname').value.length === 0) { alert("Please enter the last name."); document.getElementById('lname').focus(); return; }
						if (document.getElementById('address').value.length === 0) { alert("Please enter the address."); document.getElementById('address').focus(); return; }
						if (document.getElementById('city').value.length === 0) { alert("Please enter the city."); document.getElementById('city').focus(); return; }
						if (document.getElementById('zip').value.length != 5) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!isNumeric(document.getElementById('zip').value)) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('addShippingReply').innerHTML;
        				// show loading gif
        				document.getElementById('addShippingReply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

        				// call the function
       					var formVars = ajaxObj.getForm('addShippingAddressForm');
        				ajaxObj.call("action=ajaxFunctions&do=addShippingAddress"+formVars, addShippingAddress2);
					}

					function addShippingAddress2(resp) {
						if (resp) {
							location.replace('account/shipping_addresses/');
						} else {
							document.getElementById('addShippingReply').innerHTML = curButton;
							alert("We're sorry. There was a server issue and your shipping address was not added.");
						}
					}

					function changePassword() {
						// make sure new passwords match
						if (document.getElementById('cp_newpass').value != document.getElementById('cp_newpass2').value) {
							alert("Your new passwords do not match.");
							document.getElementById('cp_newpass').focus();
							return;
						}

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('changepasswordreply').innerHTML;
        				// show loading gif
        				document.getElementById('changepasswordreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

						// get the current password
						curPass = document.getElementById('cp_curpass').value;
						// check to see if it matches the current password
        				ajaxObj.call("action=ajaxFunctions&do=checkCurrentPassword&curPass="+curPass, changePassword2);
					}

					function changePassword2(resp) {
						if (resp) {
         					var formVars = ajaxObj.getForm('ChangePasswordForm');
							ajaxObj.call("action=ajaxFunctions&do=changePassword"+formVars, changePassword3);
						} else {
							document.getElementById('changepasswordreply').innerHTML = curButton;
							alert("Your current password does not match what we have on file. Please try again.");
							document.getElementById('cp_curpass').focus();
						}
					}

					function changePassword3(resp) {
						if (resp) {
							// location.replace('?p=my_account&msg=Your password was successfully changed.');
							alert("Thank you. Your password was successfully changed.");
							document.getElementById('cp_curpass').value = '';
							document.getElementById('cp_newpass').value = '';
							document.getElementById('cp_newpass2').value = '';
						} else {
							alert("We're sorry. There was a server issue and your password was not changed.");
						}
						document.getElementById('changepasswordreply').innerHTML = curButton;
					}

					function createAccount() {
						// validate fields
						if (document.getElementById('fname').value.length === 0) { alert("Please enter your first name."); document.getElementById('fname').focus(); return; }
						if (document.getElementById('lname').value.length === 0) { alert("Please enter your last name."); document.getElementById('lname').focus(); return; }
						if (document.getElementById('address').value.length === 0) { alert("Please enter your address."); document.getElementById('address').focus(); return; }
						if (document.getElementById('city').value.length === 0) { alert("Please enter your city."); document.getElementById('city').focus(); return; }
						if (document.getElementById('zip').value.length != 5) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!isNumeric(document.getElementById('zip').value)) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!validEmail(document.getElementById('email').value)) { alert("Please enter a valid email address."); document.getElementById('email').focus(); return; }
						if (document.getElementById('password').value.length === 0) { alert("Please enter a password for your account."); document.getElementById('password').focus(); return; }
						if (document.getElementById('password').value != document.getElementById('password2').value) { alert("Your passwords do not match."); document.getElementById('password').focus(); return; }
						if (document.getElementById('phonearea').value.length != 3) { alert("Please enter a valid area code."); document.getElementById('phonearea').focus(); return; }
						if (document.getElementById('phone3').value.length != 3) { alert("Please enter a valid phone number."); document.getElementById('phone3').focus(); return; }
						if (document.getElementById('phone4').value.length != 4) { alert("Please enter a valid phone number."); document.getElementById('phone4').focus(); return; }
						if (!isNumeric(document.getElementById('phonearea').value.length)) { alert("Please enter a valid area code."); document.getElementById('phonearea').focus(); return; }
						if (!isNumeric(document.getElementById('phone3').value.length)) { alert("Please enter a valid phone number."); document.getElementById('phone3').focus(); return; }
						if (!isNumeric(document.getElementById('phone4').value.length)) { alert("Please enter a valid phone number."); document.getElementById('phone4').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('createreply').innerHTML;

						// show loading gif
        				document.getElementById('createreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

        				// check for duplicate email
						var email = document.getElementById('email').value;
        				ajaxObj.call("action=ajaxFunctions&do=duplicateEmail&email="+email, createAccount2);
					}

					function createAccount2(resp) {
						if (resp) {
							alert("This email address is already on file. Please log in or retrieve your password.");
        					document.getElementById('createreply').innerHTML = curButton;
						} else {
        					var formVars = ajaxObj.getForm('CreateAccountForm');
        					ajaxObj.call("action=ajaxFunctions&do=createAccount"+formVars, createAccount3);
						}
					}

					function createAccount3(resp) {
						if (resp) {
							location.replace('?p=account');
						} else {
							document.getElementById('createreply').innerHTML = curButton;
							alert("We're sorry. There was a server issue and your account was not created.");
						}
					}

					function delRegistry(rid) {
						if (confirm("Are you sure you want to delete this registry? It will no longer be available through our website.")) {
							ajaxObj.call("action=ajaxFunctions&do=ma_delRegistry&rid="+rid, delRegistry2);
						}
					}
					function delRegistry2(resp) {
						if (resp.doSQL) {
							location.replace('account/registries/?msg=The registry has been deleted.');
						} else {
							alert("We're sorry. There was a server issue and the registry was not deleted.");
						}
					}

					function delShippingAddress(id) {
						if (confirm("Are you sure you want to delete this shipping address from your list? You will not be able to get it back.")) {
							ajaxObj.call("action=ajaxFunctions&do=delShippingAddress&id="+id, delShippingAddress2);
						}
					}

					function delShippingAddress2(resp) {
						if (resp) {
							location.replace('account/shipping_addresses/?msg=The shipping address has been deleted from your account.');
						} else {
							alert("We're sorry. There was a server issue and your shipping address was not deleted.");
						}
					}

					function getOrderHistory() {
						if (document.getElementById('orderhistorydiv').innerHTML == "") {
  							document.getElementById('orderhistorydiv').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";
  							ajaxObj.call("action=ajaxFunctions&do=ma_getOrderHistory", "orderhistorydiv");
						} else {
							document.getElementById('orderhistorydiv').innerHTML = "";
						}
					}

					function getRegistries() {
						if (document.getElementById('registriesdiv').innerHTML == "") {
  							document.getElementById('registriesdiv').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";
  							ajaxObj.call("action=ajaxFunctions&do=ma_getRegistries", "registriesdiv");
						} else {
							document.getElementById('registriesdiv').innerHTML = "";
						}
					}

					function getShippingAddresses() {
						if (document.getElementById('shippingaddressesdiv').innerHTML == "") {
  							document.getElementById('shippingaddressesdiv').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";
  							ajaxObj.call("action=ajaxFunctions&do=ma_getShippingAddresses", "shippingaddressesdiv");
						} else {
							document.getElementById('shippingaddressesdiv').innerHTML = "";
						}
					}

					function logIn() {
						// field validation
						if (!validEmail(document.getElementById('li_email').value)) { alert("Please enter a valid email address."); document.getElementById('li_email').focus(); return; }
						if (document.getElementById('li_password').value.length === 0) { alert("Please enter the password for this account."); document.getElementById('li_password').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('loginreply').innerHTML;
        				// show loading gif
        				document.getElementById('loginreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

       					var formVars = ajaxObj.getForm('LogInForm');
       					ajaxObj.call("action=ajaxFunctions&do=logIn"+formVars, logIn2);
					}

					function logIn2(resp) {
						if (resp) {
							location.replace('account/account_summary');
						} else {
							document.getElementById('loginreply').innerHTML = curButton;
							alert("We're sorry. Log in not successful.");
						}
					}

					function removeCreditCard(cid) {
						// ajax call
       					ajaxObj.call("action=ajaxFunctions&do=removeCreditCard&cid="+cid, removeCreditCard2);
					}

					function removeCreditCard2(resp) {
						if (resp.doSQL) {
							window.location.href='account/credit_cards/';
						} else {
							alert("Sorry. There was a server error and your credit card was not removed.");
						}
					}
					function resetPassword() {
						// field validation
						if (!validEmail(document.getElementById('rp_email').value)) { alert("Please enter a valid email address."); document.getElementById('rp_email').focus(); return; }
						if (document.getElementById('rp_password').value.length === 0) { alert("Please enter a password for your account."); document.getElementById('rp_password').focus(); return; }
						if (document.getElementById('rp_password').value != document.getElementById('rp_password2').value) { alert("Your passwords do not match."); document.getElementById('rp_password').focus(); return; }

						// record the current value of createreply (the submit button)
						curButton = document.getElementById('rpreply').innerHTML;
        				// show loading gif
        				document.getElementById('rpreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

						// get field values
						email = document.getElementById('rp_email').value;
						password = document.getElementById('rp_password').value;

						// call function
						ajaxObj.call("action=ajaxFunctions&do=resetPassword&email="+email+"&c="+document.getElementById('c').value+"&password="+password, resetPassword2);
					}

					function resetPassword2(resp) {
        				document.getElementById('rpreply').innerHTML = curButton;
						if (resp) {
							alert("Your password has been reset successfully.");
						} else {
							alert("We're sorry. Your password could not be reset.");
						}
					}

					function resetPasswordRequest() {
						// field validation
						if (!validEmail(document.getElementById('fp_email').value)) { alert("Please enter a valid email address."); document.getElementById('fp_email').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('fpreply').innerHTML;
        				// show loading gif
        				document.getElementById('fpreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

						var email = document.getElementById('fp_email').value;
       					ajaxObj.call("action=ajaxFunctions&do=duplicateEmail&email="+email, resetPasswordRequest2);
					}

					function resetPasswordRequest2(resp) {
						if (resp) {
							var email = document.getElementById('fp_email').value;
							ajaxObj.call("action=ajaxFunctions&do=resetPasswordRequest&email="+email, resetPasswordRequest3);
						} else {
							alert("We do not have this email address in our records.");
        					document.getElementById('fpreply').innerHTML = curButton;
						}
					}

					function resetPasswordRequest3(resp) {
						document.getElementById('fpreply').innerHTML = curButton;
						if (resp) {
							alert("We have emailed you a link to reset your password. This link will be available for 24 hours.");
						} else {
							alert("We're sorry. There was a server error and we were unable to send a password reset email.");
						}
					}
					function updateAccount() {
						// validate fields
						if (document.getElementById('fname').value.length === 0) { alert("Please enter your first name."); document.getElementById('fname').focus(); return; }
						if (document.getElementById('lname').value.length === 0) { alert("Please enter your last name."); document.getElementById('lname').focus(); return; }
						if (document.getElementById('address').value.length === 0) { alert("Please enter your address."); document.getElementById('address').focus(); return; }
						if (document.getElementById('city').value.length === 0) { alert("Please enter your city."); document.getElementById('city').focus(); return; }
						if (document.getElementById('zip').value.length != 5) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!isNumeric(document.getElementById('zip').value)) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!validEmail(document.getElementById('email').value)) { alert("Please enter a valid email address."); document.getElementById('email').focus(); return; }
						if (document.getElementById('phonearea').value.length != 3) { alert("Please enter a valid area code."); document.getElementById('phonearea').focus(); return; }
						if (document.getElementById('phone3').value.length != 3) { alert("Please enter a valid phone number."); document.getElementById('phone3').focus(); return; }
						if (document.getElementById('phone4').value.length != 4) { alert("Please enter a valid phone number."); document.getElementById('phone4').focus(); return; }
						if (!isNumeric(document.getElementById('phonearea').value.length)) { alert("Please enter a valid area code."); document.getElementById('phonearea').focus(); return; }
						if (!isNumeric(document.getElementById('phone3').value.length)) { alert("Please enter a valid phone number."); document.getElementById('phone3').focus(); return; }
						if (!isNumeric(document.getElementById('phone4').value.length)) { alert("Please enter a valid phone number."); document.getElementById('phone4').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('updateaccountreply').innerHTML;
        				// show loading gif
        				document.getElementById('updateaccountreply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

        				// check for duplicate email (that's not their own)
						var email = document.getElementById('email').value;
        				ajaxObj.call("action=ajaxFunctions&do=duplicateEmailNotMyOwn&email="+email, updateAccount2);
					}

					function updateAccount2(resp) {
						if (resp) {
							alert("This email address is already in use for another account. Please choose another.");
        					document.getElementById('updateaccountreply').innerHTML = curButton;
						} else {
							var formVars = ajaxObj.getForm('UpdateAccountForm');
        					ajaxObj.call("action=ajaxFunctions&do=updateAccount"+formVars, updateAccount3);
						}
					}

					function updateAccount3(resp) {
						if (resp) {
							document.getElementById('updateaccountreply').innerHTML = '<p>Your account has been updated. <a href="account/">Back to account menu.</a></p>'+curButton;
							//location.replace('account/my_account/?msg=Your account has been updated.');
						} else {
        					document.getElementById('updateaccountreply').innerHTML = curButton;
							alert("We're sorry. There was a server issue and your account was not updated.");
						}
					}

					function updateRegistry() {
						// error checking
						document.getElementById('updateregistryreply').innerHTML = '<p>Updating...<img border="0" src="images/loading.gif"></p>';
						// get the form data
						var formVars = ajaxObj.getForm('updateRegistryForm');
						// ajax call
       					ajaxObj.call("action=ajaxFunctions&do=ma_updateRegistry"+formVars, updateRegistry2);
					}

					function updateRegistry2(resp) {
						if (resp.doSQL) {
							document.getElementById('updateregistryreply').innerHTML = '<p>The registry has been updated. <a href="account/registries/">Back to registry list.</a></p>';
						} else {
							document.getElementById('updateregistryreply').innerHTML = '<p>Sorry. There was an error and your registry was not updated. <a href="account/registries/">Back to registry list.</a></p>';
						}
					}
					function updateShippingAddress() {
						// validate fields
						if (document.getElementById('fname').value.length === 0) { alert("Please enter the first name."); document.getElementById('fname').focus(); return; }
						if (document.getElementById('lname').value.length === 0) { alert("Please enter the last name."); document.getElementById('lname').focus(); return; }
						if (document.getElementById('address').value.length === 0) { alert("Please enter the address."); document.getElementById('address').focus(); return; }
						if (document.getElementById('city').value.length === 0) { alert("Please enter the city."); document.getElementById('city').focus(); return; }
						if (document.getElementById('zip').value.length != 5) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }
						if (!isNumeric(document.getElementById('zip').value)) { alert("Please enter a valid zip code."); document.getElementById('zip').focus(); return; }

        				// record the current value of createreply (the submit button)
						curButton = document.getElementById('updateShippingReply').innerHTML;
        				// show loading gif
        				document.getElementById('updateShippingReply').innerHTML = "<img border=\"0\" src=\"images/loading.gif\">";

        				// call the function
       					var formVars = ajaxObj.getForm('updateShippingAddressForm');
        				ajaxObj.call("action=ajaxFunctions&do=updateShippingAddress"+formVars, updateShippingAddress2);
					}

					function updateShippingAddress2(resp) {
						if (resp.doSQL) {
							location.replace('account/shipping_addresses/');
						} else {
							document.getElementById('updateShippingReply').innerHTML = curButton;
							alert("We're sorry. There was a server issue and your shipping address was not updated.");
						}
					}


