var textInserted = false;
function formatCheckoutLayout(){
var node_br0 = document.createElement('BR');
node_br0.style.clear = 'both';
var node_br1 = document.createElement('BR');
node_br1.style.clear = 'both';
var node_div1 = document.createElement('DIV');
node_div1.style.marginBottom = '20px';
node_div1.style.paddingLeft = '60px';
node_div1.style.fontStyle = 'italic';
node_div1.innerHTML = 'Campaign finance law requires us to obtain your occupation and employer, and to verify the following statements are true.';
var node_br2 = document.createElement('BR');
node_br2.style.clear = 'both';
var node_div2 = document.createElement('DIV');
node_div2.style.maxWidth = '500px';
node_div2.style.marginLeft = 'auto';
node_div2.style.marginRight = 'auto';
node_div2.style.lineHeight = '2';
node_div2.innerHTML = '
- I am over 18 years old.
- I am a U.S. citizen or lawfully admitted permanent resident (i.e., green card holder).
- This contribution is made from my own funds, not those of another
- This contribution is not made from the funds of a corporation or labor organization
- This contribution is made on a personal credit card or debit card for which I have legal obligation to pay, and is not made either on a corporate or business entity credit card or the card of another person.
- This contribution is not made from the funds of an entity or person who is a federal contractor.
';
document.getElementById('FormField_31').parentNode.style.display = 'none';
/**************************************************/
document.getElementById('FormField_6').style.display = 'none';
var theDTs = '';
var billingBlock = (document.getElementById('FormField_13').parentNode).parentNode;
theDTs = billingBlock.getElementsByTagName('DT');
if (!textInserted) {
for(i=0; i -1){
theDTs[i].parentNode.insertBefore(node_br0,theDTs[i+1]);
}
if(theDTs[i].innerHTML.indexOf('Employer') > -1){
theDTs[i].parentNode.insertBefore(node_br1,theDTs[i]);
theDTs[i].parentNode.insertBefore(node_div1,theDTs[i]);
}
if(theDTs[i].innerHTML.indexOf('Certify') > -1){
theDTs[i].parentNode.insertBefore(node_br2,theDTs[i]);
theDTs[i].parentNode.insertBefore(node_div2,theDTs[i]);
}
/*
if(theDTs[i].innerHTML.indexOf('Get Mobile Alerts') > -1){
theDTs[i].parentNode.insertBefore(node_br3,theDTs[i]);
theDTs[i].parentNode.insertBefore(node_div3,theDTs[i]);
theDTs[i].style.display = 'none';
document.getElementById('FormField_37').parentNode.style.display = 'none';
}
*/
}
textInserted = true;
}
/**************************************************/
document.getElementById('FormField_16').style.display = 'none';
var shippingBlock = (document.getElementById('FormField_23').parentNode).parentNode;
var node_div3 = document.createElement('DIV');
var empInput = document.getElementById('FormField_26');
empInput.value = 'n/a';
empInput.style.display = 'none';
var occInput = document.getElementById('FormField_28');
occInput.value = 'n/a';
occInput.style.display = 'none';
var certInput = document.getElementById('FormField_30');
certInput.value = 'n/a';
var optionList = certInput.getElementsByTagName('option')[1].selected = 'true';
certInput.style.display = 'none';
theDTs = shippingBlock.getElementsByTagName('DT');
for(i=0; i -1){
theDTs[i].parentNode.insertBefore(node_div3,theDTs[i]);
theDTs[i].style.display = 'none';
}
if(theDTs[i].innerHTML.indexOf('Occupation') > -1){
theDTs[i].style.display = 'none';
}
if(theDTs[i].innerHTML.indexOf('Certify') > -1){
theDTs[i].style.display = 'none';
}
/*
if(theDTs[i].innerHTML.indexOf('Mobile') > -1){
theDTs[i].style.display = 'none';
}
*/
}
}
var ExpressCheckout = {
completedSteps: new Array(),
currentStep: 'AccountDetails',
signedIn: 0,
digitalOrder: 0,
createAccount: 0,
anonymousCheckout: 0,
checkoutLogin: 0,
usingMultipleAddresses: false,
init: function()
{
if($('#CheckoutStepAccountDetails').css('display') === 'none') {
ExpressCheckout.currentStep = 'BillingAddress';
}
else {
$('#BillingDetailsLabel').html(lang.ExpressCheckoutStepBillingAccountDetails);
}
$('.ExpressCheckoutBlock').hover(function() {
if($(this).hasClass('ExpressCheckoutBlockCompleted')) {
$(this).css('cursor', 'pointer');
}
},
function() {
$(this).css('cursor', 'default');
});
$('.ExpressCheckoutTitle').click(function() {
if($(this).hasClass('ExpressCheckoutBlockCompleted')) {
$(this).find('.ChangeLink').click();
}
});
// Capture any loading errors
$(document).ajaxError(function(event, request, settings) {
ExpressCheckout.HideLoadingIndicators();
alert(lang.ExpressCheckoutLoadError);
});
},
Login: function()
{
$('#CheckoutLoginError').hide();
ExpressCheckout.anonymousCheckout = 0;
ExpressCheckout.createAccount = 0;
if(ExpressCheckout.validateEmailAddress($('#login_email').val()) === false) {
alert(lang.LoginEnterValidEmail);
$('#login_email').focus();
$('#login_email').select();
return false;
}
if($('#login_pass').val() === '') {
alert(lang.LoginEnterPassword);
$('#login_pass').focus();
return false;
}
ExpressCheckout.ShowLoadingIndicator('#LoginForm');
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: 'w=expressCheckoutLogin&'+$('#LoginForm').serialize(),
success: ExpressCheckout.HandleResponse
});
return false;
},
HandleResponse: function(response)
{
ExpressCheckout.HideLoadingIndicators();
if(response.completedSteps !== undefined) {
$.each(response.completedSteps, function() {
var value = document.createTextNode(this.message);
$('#CheckoutStep'+this.id+' .ExpressCheckoutCompletedContent').html(value);
$('#CheckoutStep'+this.id).addClass('ExpressCheckoutBlockCompleted');
ExpressCheckout.completedSteps[ExpressCheckout.completedSteps.length] = this.id;
});
}
if(response.stepContent !== undefined) {
$.each(response.stepContent, function() {
$('#CheckoutStep'+this.id+' .ExpressCheckoutContent').html(this.content);
$('#CheckoutStep'+this.id+' .ExpressCheckoutContent .FormField.JSHidden').show();
});
}
formatCheckoutLayout();
ExpressCheckout.HandleResponseStatus(response);
},
HandleResponseStatus: function(response)
{
if(response.status === 0) {
if(response.errorContainer) {
$(response.errorContainer).html(response.errorMessage).show();
}
else {
alert(response.errorMessage);
}
}
if(response.changeStep) {
ExpressCheckout.ChangeStep(response.changeStep);
ExpressCheckout.ResetNextSteps();
}
// Set focus to a particular field
if(response.focus) {
try {
$(response.focus).focus().select();
}
catch(e) { }
}
},
GuestCheckout: function()
{
var type;
$('#CreateAccountForm').show();
$('#CheckoutLoginError').hide();
if($('#CheckoutGuestForm').css('display') !== 'none' && !$('#checkout_type_register:checked').val()) {
type = 'guest';
ExpressCheckout.anonymousCheckout = 1;
ExpressCheckout.createAccount = 0;
}
else {
type = 'account';
ExpressCheckout.anonymousCheckout = 0;
ExpressCheckout.createAccount = 1;
}
ExpressCheckout.ShowLoadingIndicator('#CheckoutGuestForm');
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: {
w: 'expressCheckoutGetAddressFields',
type: type
},
success: ExpressCheckout.HandleResponse
});
},
ResetNextSteps:function()
{
var steps = ExpressCheckout.GetSteps();
var beginReset = false;
var newCompleted = new Array();
$.each(steps, function(i, step) {
if(step === ExpressCheckout.currentStep) {
newCompleted[newCompleted.length] = step;
beginReset = true;
}
else if(beginReset === true) {
$('#CheckoutStep'+step).removeClass('ExpressCheckoutBlockCompleted');
$('#CheckoutStep'+step+' .ExpressCheckoutCompletedContent').html('');
}
});
ExpressCheckout.completedSteps = newCompleted;
},
ChangeStep: function(step)
{
var topAcc2;
// Re-enable the submit button if previously disabled (ChangeStep is called by the response handler so this is
// a safe place to do so).
$('#bottom_payment_button').removeAttr('disabled');
if(typeof(step) == 'undefined') {
step = ExpressCheckout.CalculateNextStep(ExpressCheckout.currentStep);
}
if(step === ExpressCheckout.currentStep) {
return false;
}
if (step === 'BillingAddress' && this.usingMultipleAddresses) {
$('.SelectMultipleAddresses').hide();
}
if (step === 'ShippingAddress' && this.usingMultipleAddresses) {
$('.SelectMultipleAddresses').show();
}
if (step === 'AccountDetails') {
textInserted == false;
}
$('#CheckoutStep'+ExpressCheckout.currentStep+' .ExpressCheckoutContent').slideUp('slow');
$('#CheckoutStep'+ExpressCheckout.currentStep).addClass('ExpressCheckoutBlockCollapsed');
if($.inArray(ExpressCheckout.currentStep, ExpressCheckout.completedSteps) !== -1) {
$('#CheckoutStep'+ExpressCheckout.currentStep).addClass('ExpressCheckoutBlockCompleted');
}
$('#CheckoutStep'+step+' .ExpressCheckoutContent').slideDown('slow',function() {
//check weather the theme support the view port functions
if( $.inviewport !== undefined ) {
var checkoutInViewport = $(this).find('.ExpressCheckoutTitle').is(":in-viewport");
if (!checkoutInViewport) {
topAcc2 = $(this).offset().top;
$('html, body').animate({ scrollTop: topAcc2 - 90}, 600);
}
}
});
$('#CheckoutStep'+step).removeClass('ExpressCheckoutBlockCollapsed');
ExpressCheckout.currentStep = step;
return false;
},
GetSteps: function()
{
var steps = new Array();
if(ExpressCheckout.signedIn === 0) {
steps[steps.length] = 'AccountDetails';
}
steps[steps.length] = 'BillingAddress';
if(!ExpressCheckout.digitalOrder) {
steps[steps.length] = 'ShippingAddress';
steps[steps.length] = 'ShippingProvider';
}
steps[steps.length] = 'Confirmation';
steps[steps.length] = 'PaymentDetails';
return steps;
},
CalculateNextStep: function(currentStep) {
var steps = ExpressCheckout.GetSteps();
var nextStep = '';
$.each(steps, function(i, step) {
if(step === currentStep) {
nextStep = steps[i + 1];
}
});
if(nextStep) {
return nextStep;
}
},
// This function is overwritten by address_validation.js if Avalara's address validation feature is turned on
ChooseBillingAddress: function()
{
var addressType;
// Chosen to use a new address?
if(!$('#BillingAddressTypeExisting:checked').val() || $('#ChooseBillingAddress').css('display') === 'none') {
// If creating a new account, validate the account fields as well
if((ExpressCheckout.anonymousCheckout || ExpressCheckout.createAccount) &&
!ExpressCheckout.ValidateNewAccount(true)) {
return false;
}
if(!ExpressCheckout.ValidateNewAddress('billing')) {
return false;
}
addressType = 'new';
}
// An address wasn't selected
else if($('.SelectBillingAddress select option:selected').val() === -1) {
alert(lang.ExpressCheckoutChooseBilling);
$('.SelectBillingAddress select').focus();
return false;
}
else {
addressType = 'existing';
}
var createAppend = '';
if(ExpressCheckout.createAccount) {
createAppend = '&createAccount=1';
}
// ISC-1214: no script issue in webkit browser, with serialized form submission
$('noscript').remove();
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: 'w=saveExpressCheckoutBillingAddress&'
+ $('#NewBillingAddress').serialize()
+ '&BillingAddressType=' + addressType
+ createAppend,
success: ExpressCheckout.HandleResponse
});
return false;
},
// This function is overwritten by address_validation.js if Avalara's address validation feature is turned on
ChooseShippingAddress: function(copyBilling)
{
var addressType;
// Chosen to use a new address?
if(!$('#ShippingAddressTypeExisting:checked').val() || $('#ChooseShippingAddress').css('display') === 'none') {
if(!ExpressCheckout.ValidateNewAddress('shipping')) {
return false;
}
addressType = 'new';
}
// An address wasn't selected
else if($('.SelectShippingAddress select option:selected').val() === -1) {
alert(lang.ExpressCheckoutChooseShipping);
$('.SelectShippingAddress select').focus();
return false;
}
else {
addressType = 'existing';
}
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: 'w=saveExpressCheckoutShippingAddress&'
+$('#NewShippingAddress').serialize()
+'&ShippingAddressType='+addressType,
success: ExpressCheckout.HandleResponse
});
return false;
},
SetBillingAndShippingAddress: function()
{
if ($('.SelectBillingAddress select option:selected').html() === null) {
return;
}
// billing address is pre-selected so update the HTML block content from selected index
billingAddress = $('.SelectBillingAddress select option:selected').html().substring(0, 58);
$('#CheckoutStepBillingAddress .ExpressCheckoutCompletedContent').html(billingAddress + '...');
$('#CheckoutStepBillingAddress').addClass('ExpressCheckoutBlockCompleted');
// select given shipping address and reset the cart step to ShippingProvider
ExpressCheckout.ChooseShippingAddress();
return false;
},
ChooseShippingProvider: function()
{
// A shipping provider hasn't been selected
var shippingValid = true;
if(!$('#CheckoutStepShippingProvider .ShippingProviderList input[type=radio]:checked').val()) {
alert(lang.ExpressCheckoutChooseShipper);
$('#CheckoutStepShippingProvider .ShippingProviderList input[type=radio]').get(0).focus();
shippingValid = false;
return false;
}
if(shippingValid === false) {
return false;
}
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: 'w=saveExpressCheckoutShippingProvider&'+$('#CheckoutStepShippingProvider form').serialize(),
success: ExpressCheckout.HandleResponse
});
return false;
},
ShowLoadingIndicator: function(step) {
if(typeof(step) == 'undefined') {
step = 'body';
}
$(step).find('.ExpressCheckoutBlock input[type=submit]').each(function() {
$(this).attr('oldValue', $(this).val());
$(this).val(lang.ExpressCheckoutLoading);
$(this).attr('disabled', true);
});
$(step).find('.LoadingIndicator').show();
$('body').css('cursor', 'wait');
},
HideLoadingIndicators: function()
{
HideLoadingIndicator();
$('.ExpressCheckoutBlock input[type=submit]').each(function() {
if($(this).attr('oldValue') && $(this).attr('disabled') === true) {
$(this).val($(this).attr('oldValue'));
$(this).attr('disabled', false);
}
});
$('.LoadingIndicator').hide();
$('body').css('cursor', 'default');
},
LoadOrderConfirmation: function()
{
postVars.w = 'expressCheckoutShowConfirmation';
$.ajax({
url: 'remote.php',
type: 'post',
dataType: 'json',
data: postVars,
success: ExpressCheckout.HandleResponse
});
},
HidePaymentForm: function()
{
$('#CheckoutStepPaymentDetails').hide();
$('#CheckoutStepPaymentDetails .ExpressCheckoutContent').html('');
},
LoadPaymentForm: function(provider)
{
$.ajax({
url: 'remote.php',
data: 'w=expressCheckoutLoadPaymentForm&'+$('#CheckoutStepConfirmation form').serialize(),
dataType: 'json',
type: 'post',
success: ExpressCheckout.HandleResponse
});
},
ShowSingleMethodPaymentForm: function()
{
$('#CheckoutStepPaymentDetails').show();
ShowContinueButton();
},
ValidateNewAccount: function()
{
var password, confirmPassword, formfield = FormField.GetValues(CustomCheckoutFormNewAccount);
for (var i=0; i