report_problem Please complete your shipping address above to continue.
');
}
else
{
//alert('no zip code');
$('#contact_alert').html('
report_problem Please complete your shipping address above to continue.
');
}
}
else
{
console.log('sufficient information. show #delivery_methods');
}
//////////////now, saving the order //////////////////
//check that either a valid email or sufficiently long phone number or mobile has been entered
if( contact_name.length > 1 && contact_email.length > 6 && contact_phone_mobile.length > 5)
{
//console.log('enough details to continue');
$('#parent_shipping_container').css("display","block");
//alert('show address input');
if(contact_address_1=='')
{
contact_address_1='0';
}
if(contact_address_2=='')
{
contact_address_2='0';
}
if(contact_email=='')
{
contact_email='none';
}
if(contact_name=='')
{
contact_name='none';
}
if(contact_lastname=='')
{
contact_lastname='none';
}
//alert("/ajax_store/saveorder/"+encodeURIComponent(contact_name)+"/"+encodeURIComponent(contact_lastname)+"/"+encodeURIComponent(contact_email)+"/"+encodeURIComponent(contact_phone_mobile)+"/"+encodeURIComponent(contact_acode_home+''+contact_phone_home)+"/"+encodeURIComponent(contact_address_1)+"/"+encodeURIComponent(contact_address_2)+"/"+save_suburb_id+"-"+internation_country+'-'+contact_postcode+'/');
//alert('sending: '+save_suburb_id+' '+contact_postcode);
//check_show_delivery(hide_rest_of_form_po_box);
var aj_url="/ajax_store/saveorderca/"+encodeURIComponent(contact_name)+"|||"+encodeURIComponent(contact_lastname)+"|||"+encodeURIComponent(contact_email)+"/"+encodeURIComponent(contact_phone_mobile)+"/"+encodeURIComponent(contact_address_1)+"|||"+encodeURIComponent(contact_address_2)+"/"+contact_zip+"<=>"+encodeURIComponent(contact_city)+"<=>"+encodeURIComponent(contact_state)+"<=>"+encodeURIComponent(contact_country)+"<=>"+call_me+"/";
console.log(aj_url);
$.ajax({url: aj_url, async: false, success: function(result){
if (contact_city !== '' && contact_state !== '' && contact_country !== '' && combinedaddresses.length > 5)
{
if(result[1]['ca_tax_amount']>0)
{
$('#taxes-amount').html('$'+result[1]['ca_tax_amount']);
$('#taxes-holder').css('display', 'block');
}
else
{
$('#taxes-amount').html('N/A');
}
if(result[1]['ca_shipping_amount']>0)
{
$('#shipping-amount').html('$'+result[1]['ca_shipping_amount']);
}
else
{
$('#shipping-amount').html('FREE');
}
if(result[1]['ca_final_order_amount']>0)
{
$('#total-selector').html(result[1]['ca_final_order_amount']);
}
if(result[1]['freighter']!=='')
{
$('#freighter-holder').html(result[1]['freighter']);
}
if (contact_state === "AK" || contact_state === "AS" || contact_state === "HI" || contact_state === "PR" || contact_state === "TT" || contact_state === "VI" || contact_state === "MP")
{
console.log("State input is not allowed: "+contact_state);
console.log('hide inside australia');
$('.cannot_deliver').css("display","block");
}
else
{
$('.inside_australia').css("display","block");
$('#delivery_methods').css("display","block");
$('#address_holder').css("display","table");
$('#zip_holder').css("display","table");
$('#city_holder').css("display","table");
$('#state_holder').css("display","table");
$('#country_holder').css("display","table");
$('#lead_origin_header').css("display","block");
$('#lead_origin_options').css("display","block");
$('.mob_summary_box-1').css("display","block");
$('.mob_summary_box-2').css("display","block");
$('#zip-msg-box').css("display","none");
}
}
}});
}
else
{
//$('#contact_alert').html('
report_problem Please enter a valid name, email address and phone number above to continue.
');
}
}, 300);
}
function verify_email_address()
{
var contact_email = $('#contact_email').val();
var n = contact_email.length;
//$.ajax({url: "/ajax_store/check_address/"+encodeURIComponent(contact_address_2)+"/"+suburb_id+"/"+encodeURIComponent(contact_address_1)+"/", async: false, success: function(result){
if(n < 1)
{
// do nothing
}
else if(n > 6)
{
$.ajax({url: "/ajax_store/verify_email_address_exists/"+encodeURIComponent(contact_email)+"/", async: true, success: function(result){
$("#address_alert").html(result);
}});
}
else
{
$("#address_alert").html('
report_problem Your email address does not exist. Please double check it.
');
}
}
function verify_email_address_with_delay()
{
//there has already been a 1 second delay before this function is called
time_delay(function()
{
var contact_email = $('#contact_email').val();
var n = contact_email.length;
//$.ajax({url: "/ajax_store/check_address/"+encodeURIComponent(contact_address_2)+"/"+suburb_id+"/"+encodeURIComponent(contact_address_1)+"/", async: false, success: function(result){
if(n < 1)
{
// do nothing
}
else if(n > 6)
{
$.ajax({url: "/ajax_store/verify_email_address_exists/"+encodeURIComponent(contact_email)+"/", async: true, success: function(result){
$("#address_alert").html(result);
}});
}
else
{
$("#address_alert").html('
report_problem Your email address does not exist. Please double check it.
');
}
}, 1800);
}
function check_show_delivery(hide_rest_of_form_po_box)
{
//since user has gone back to editing their basic details
$('.inside_australia').css("display","none");
$("#next_button").css("display","block");
$("#next_button_submit").css("display","none");
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#continue_button').css("display","none");
//create 1.5 second delay, so this function is not being hit over and over agin
delay(function(){
var save_suburb_id = $('#save_suburb_id').val();
//get data entered into client feilds
var contact_name = $('#contact_name').val();
var contact_lastname = $('#contact_lastname').val();
var contact_email = $('#contact_email').val();
var contact_phone_mobile = $('#contact_phone_mobile').val();
var contact_acode_home = $('#contact_acode_home').val();
var contact_phone_home = $('#contact_phone_home').val();
var contact_address_1 = $('#contact_address_1').val();
var contact_address_2 = $('#contact_address_2').val();
var email_test = is_valid_email(contact_email);
var combinedphones = contact_phone_mobile + contact_acode_home + contact_phone_home;
var combinedaddresses = contact_address_1 + contact_address_2;
//if we have the necessary details, ensure that the shipping options are shown
if(save_suburb_id == '' || contact_email.length < 9 || combinedphones.length < 8 || contact_name.length < 2 || contact_lastname.length < 2 || combinedaddresses.length < 7 || email_test == false)
{
//alert(save_suburb_id + ' | ' + contact_email+ ' | ' + combinedphones + ' | ' + contact_name+ ' | ' + contact_lastname+ ' | ' + combinedaddresses);;
$('.inside_australia').css("display","none");
$('#delivery_methods').css("display","none");
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
if(contact_email.length < 9)
{
$('#contact_alert').html('
report_problem Please complete your email address above to continue.
');
$('#suburb_searcher').css("display","none");
$('#fake_state_holder').css("display","block");
//temporary message to states
var foundin = suburb_name.indexOf(" VIC ");
if(foundin < 2)
{
foundin = suburb_name.indexOf(" NSW ");
}
if(foundin > 1)//this order is for NSW or VIC
{
$('#delay_delivery').css("display","block");
}
else
{
$('#delay_delivery').css("display","none");
}
//$('#shs_label').css( "background-color", "#d8ffdb" );
$('#save_suburb_id').val(suburb_id);
var contact_address_1 = $('#contact_address_1').val();
var contact_address_2 = $('#contact_address_2').val();
if(contact_address_2 == '' && contact_address_1 != '') // the fields are around the wrong way
{
$('#contact_address_1').val(contact_address_2);
$('#contact_address_2').val(contact_address_1);
}
if(suburb_id > 0) // within australia
{
console.log('within australia');
//hide international shipping address
$('#international_address').css("display","none");
$(".inside_australia").css("display","block");
adopt_pickup_method_2020(); // new 2020 template
//$('#delivery_method').val('delivery');
//check address is valid
saveorder('1');
//if(suburb_id > 0) // within australia
//{
//hide delivery options
if( $('#delivery_method').val() == 'delivery') // only check this if the delivery option is selected. otherwise it is premature to check this
{
//choose_delivery_fast('delivery');
//calculate delivery fee
$.ajax({url: "/ajax_store/check_stock_levels/"+suburb_id+"/", async: true, success: function(result){
$("#stock_control_feedback").html(result);
//show delivery options
console.log('result = '+result);
if(result=='brisbane') // ex brisbane
{
$('#perth_pickup_col').css("display","none");
$('#perth_pickup_col_na').css("display","block");
}
else
{
$('#perth_pickup_col').css("display","block");
$('#perth_pickup_col_na').css("display","none");
}
// $('#delivery_methods').css("display","block");
}});
}
$.ajax({url: "/ajax_store/get_order_id/", async: true, success: function(result){
$("#saved_ord_id").val(result);
}});
//}
//scroll_to_anchor('subscribenews');
}
else // international
{
console.log('international');
$('#address_alert').html('');
//show international shipping address
$('#international_address').css("display","block");
//dont check validity of address
saveorder('0');
//show international modal
//calculate delivery fee
$.ajax({url: "/ajax_store/get_order_id/", async: false, success: function(result){
$("#int_order_id").html(result);
$("#int_order_id_onscreen").html(result);
//$('#outside_australia_modal').openModal();
$(".inside_australia").css("display","none");
$("#next_button").css("display","block");
$("#next_button_submit").css("display","none");
$("#outside_australia_onscreen").css("display","block");
$('.inside_australia').css("display","none");
$("#next_button").css("display","block");
$("#next_button_submit").css("display","none");
console.log('hide #delivery_methods');
$("#delivery_methods").css("display","none");
}});
}
}
function save_suburb_order_usa()
{
$("#outside_australia_onscreen").css("display","none");
$('#delivery_methods').css("display","none");
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#international_address').css("display","none");
$(".inside_australia").css("display","block");
//adopt_pickup_method_2020(); // new 2020 template
//$('#delivery_method').val('delivery');
//check address is valid
//saveorder('1');
}
function proceed_stock_option(option, days)
{
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none"); //hide continue button
if(option == '1')// wait for all order
{
days=days*1;
//set minimum days can book for
set_pickdate_field('#shipping_date',days);
$('#days_to_delivery').val(days);
//create date from this day
var someDate = new Date();
someDate.setDate(someDate.getDate() + days);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();
$('#shipping_date').val(dd + '/'+ mm + '/'+ y);
$('#earliestdate_bolded').html(dd + '/'+ mm + '/'+ y);
//$('#earliestdate').html();
$('#choose_split_delivery_dates').css("display","none");
$('#choose_single_delivery_date').css("display","block");
//confirm freight and delivery fee
$.ajax({url: "/ajax_store/confirm_freighter/", async: false, success: function(result){
$("#confirm_freighter").html(result);
$('#confirm_freighter').css("display","block");
}});
}
else if(option == '2')// split the order
{
$('#choose_single_delivery_date').css("display","none");
//show splitting options
var suburb_id = $('#save_suburb_id').val();
$.ajax({url: "/ajax_store/show_splitting_options/"+suburb_id+"/", async: false, success: function(result){
$('#choose_split_delivery_dates').css("display","block");
var pieces = result.split('|||');
// pieces[0] message 1
// pieces[1] days 1
// pieces[2] message 2
// pieces[3] days 2
// pieces[4] total cost
$("#split_delivery_message_1").html(pieces[0]);
$("#split_days_to_delivery_1").val(pieces[1]);
var days=pieces[1]*1;
days++;
// alert(' days = '+days);
$('#split_shipping_date_1').val('');
//set minimum days can book for
set_pickdate_field('#split_shipping_date_1',days);
$("#split_delivery_message_2").html(pieces[2]);
$("#split_days_to_delivery_2").val(pieces[3]);
days=pieces[3]*1;
days++;
$('#split_shipping_date_2').val('');
set_pickdate_field('#split_shipping_date_2',days);
$("#split_delivery_message_price").html(pieces[4]);
}});
}
else // order needs to come from 2 seperate warehouses
{
$('#choose_single_delivery_date').css("display","none");
//show splitting options
var suburb_id = $('#save_suburb_id').val();
$.ajax({url: "/ajax_store/show_splitting_warehouse_options/"+suburb_id+"/", async: false, success: function(result){
$('#choose_split_delivery_dates').css("display","block");
var pieces = result.split('|||');
// pieces[0] message 1
// pieces[1] days 1
// pieces[2] message 2
// pieces[3] days 2
// pieces[4] total cost
$("#split_delivery_message_1").html(pieces[0]);
$("#split_days_to_delivery_1").val(pieces[1]);
var days=pieces[1]*1;
days++;
$('#split_shipping_date_1').val('');
//set minimum days can book for
set_pickdate_field('#split_shipping_date_1',days);
$("#split_delivery_message_2").html(pieces[2]);
$("#split_days_to_delivery_2").val(pieces[3]);
days=pieces[3]*1;
days++;
$('#split_shipping_date_2').val('');
set_pickdate_field('#split_shipping_date_2',days);
$("#split_delivery_message_price").html(pieces[4]);
}});
}
//scroll down a bit
scroll_to_anchor('changeorder');
}
function clearance_size_option_new(classname,size_id,name,option_price,was_price)
{
//since we are changing the size, make the "add to cart" button the default colours
$('#add_cart_'+classname).css("color","#f15a01");
$('#add_cart_'+classname).css("background-color","#fff");
$('#add_cart_'+classname).css("border-color","#f15a01");
//register the chosen size
$('#chosen-size-'+classname).html(size_id);
$('#size_name_'+classname).html(name);
//change colours
var color='f15a01';
//make all divs in that sequance standard orange and white
$('.opt-'+classname).css("color","#f15a01");
$('.opt-'+classname).css("background-color","#fff");
$('.opt-'+classname).css("border-color","#f15a01");
//select the chosen option as grey/white
$('.opt-'+classname+'-'+size_id).css("color","#fff");
$('.opt-'+classname+'-'+size_id).css("background-color","#"+color);
$('.opt-'+classname+'-'+size_id).css("border-color","#"+color);
//fade current image out and new image in
$('#opt-'+classname).fadeOut(300, function() {
$('#opt-'+classname).attr("src",'/img/sizes/'+size_id+'-web.jpg');
if(option_price!=''){$('#price'+classname).html('$'+option_price);}
if(was_price!=''){$('#wasprice'+classname).html('$'+was_price);}
});
$('#opt-'+classname).delay(300).fadeIn(400);
}
function cartadded_model_size(make_id)
{
var free_items ='';
var model_make_name = $('#model_make_name_'+make_id).html();
var chosen_size= $('#chosen-size-'+make_id).html();
var name = $('#size_name_'+chosen_size).html();
$('#size_added_name').html(name);
if( $('#free_items_'+chosen_size).length)
{
free_items = $('#free_items_'+chosen_size).html();
$('#free_item').html(free_items);
}
else
{
$('#free_item').html('');
}
////check free items
//does the free item include a shade cover?
free_items = free_items.toLowerCase();
var n = free_items.indexOf("shade");
if(n > 0)
{
//show an "already included message
$('.acc_shade-cover').html('
doneFREE - Already added
');
}
var bballincluded = free_items.indexOf("basket");
if(bballincluded > 0)
{
//show an "already included message
$('.acc_basketball-set').html('
doneFREE - Already added
');
}
$('#added_accessory_cart_contents').html(name+' '+model_make_name);
$('#added_accessory_cart').fadeIn(400);
//$('#cartadded').css("left",'inherit');
//$('#cartadded').css("right",0);
//Materialize.showStaggeredList('#cartadded');
$.ajax({url: "/ajax_store/add_cart/s"+chosen_size+"/", async: true, success: function(result){
$('#cartqty').css("display","block");
$('#cartqtymobile').css("display","block");
$('#cartqty_contents').html(result);
}});
myVar = setTimeout(hide_accessory_cart, 3000);
}
function cartadded_accessory(make_id)
{
var free_items ='';
var chosen_size= $('#chosen-item-'+make_id).html();
var name = $('#size_name_'+make_id).html();
$('#size_added_name').html(name);
//alert('make_id = ' + make_id+ ' chosen_size = ' + chosen_size + ' name = ' + name );
/*
if( $('#free_items_'+chosen_size).length)
{
free_items = $('#free_items_'+chosen_size).html();
$('#free_item').html(free_items);
}
else
{
$('#free_item').html('');
}
*/
$('#free_item').html('');
/*
////check free items
//does the free item include a shade cover?
free_items = free_items.toLowerCase();
var n = free_items.indexOf("shade");
if(n > 0)
{
//show an "already included message
$('.acc_shade-cover').html('
doneFREE - Already added
');
}
var bballincluded = free_items.indexOf("basket");
if(bballincluded > 0)
{
//show an "already included message
$('.acc_basketball-set').html('
doneFREE - Already added
');
}
*/
//$('#cartadded').css("left",'inherit');
//$('#cartadded').css("right",0);
//Materialize.showStaggeredList('#cartadded');
$('#added_accessory_cart_contents').html(name);
$('#added_accessory_cart').fadeIn(400);
$.ajax({url: "/ajax_store/add_cart/i"+chosen_size+"/", async: true, success: function(result){
$('#cartqty').css("display","block");
$('#cartqtymobile').css("display","block");
$('#cartqty_contents').html(result);
}});
//set callback to make disappear
myVar = setTimeout(hide_accessory_cart, 3000);
}
function clearance_accessory_option(classname,item_id,name,option_price,was_price)
{
//since we are changing the size, make the "add to cart" button the default colours
$('#add_cart_'+classname).css("color","#f15a01");
$('#add_cart_'+classname).css("background-color","#fff");
$('#add_cart_'+classname).css("border-color","#f15a01");
//register the chosen size
$('#chosen-item-'+classname).html(item_id);
//alert('#size_name_'+classname+ ' = '+name);
$('#size_name_'+classname).html(name);
//change colours
var color='f15a01';
//make all divs in that sequance standard orange and white
$('.opt-'+classname).css("color","#f15a01");
$('.opt-'+classname).css("background-color","#fff");
$('.opt-'+classname).css("border-color","#f15a01");
//select the chosen option as grey/white
$('.opt-'+classname+'-'+item_id).css("color","#fff");
$('.opt-'+classname+'-'+item_id).css("background-color","#"+color);
$('.opt-'+classname+'-'+item_id).css("border-color","#"+color);
//fade current image out and new image in
//alert(' faceout #acc-opt-'+classname);
$('#acc-opt-'+classname).fadeOut(300, function() {
$('#acc-opt-'+classname).attr("src",'/img/items/'+item_id+'-web.jpg');
if(option_price!=''){$('#price'+classname).html('$'+option_price);}
if(was_price!=''){$('#wasprice'+classname).html('$'+was_price);}
});
$('#acc-opt-'+classname).delay(300).fadeIn(400);
}
function clearance_size_option(classname,size_id,name,option_price)
{
//since we are changing the size, make the "add to cart" button the default colours
$('#add_cart_'+classname).css("color","#f15a01");
$('#add_cart_'+classname).css("background-color","#fff");
$('#add_cart_'+classname).css("border-color","#f15a01");
//register the chosen size
$('#chosen-size-'+classname).html(size_id);
$('#size_name_'+classname).html(name);
//change colours
var color='f15a01';
//make all divs in that sequance standard orange and white
$('.opt-'+classname).css("color","#f15a01");
$('.opt-'+classname).css("background-color","#fff");
$('.opt-'+classname).css("border-color","#f15a01");
//select the chosen option as grey/white
$('.opt-'+classname+'-'+size_id).css("color","#fff");
$('.opt-'+classname+'-'+size_id).css("background-color","#"+color);
$('.opt-'+classname+'-'+size_id).css("border-color","#"+color);
//fade current image out and new image in
$('#opt-'+classname).fadeOut(300, function() {
$('#opt-'+classname).attr("src",'/img/sizes/'+size_id+'-web.jpg');
if(option_price!=''){$('#price'+classname).html('$'+option_price);}
});
$('#opt-'+classname).delay(300).fadeIn(400);
}
//item_option('1','6','','1999.99');
function item_option(classname,item_id,override_color,option_price)
{
//since we are changing the size, make the "add to cart" button the default colours
$('#add_cart_'+classname).css("color","#f15a01");
$('#add_cart_'+classname).css("background-color","#fff");
$('#add_cart_'+classname).css("border-color","#f15a01");
//register the chosen option
$('#'+classname+'_item_id').html(item_id);
if ( $('#opt-'+classname+'-'+item_id+'-tick').length )//tick element exists
{
//hide tick options from all in sequence
$('.opt-'+classname).html("");
//dont change colours, just show a tick icon
$('#opt-'+classname+"-"+item_id+'-tick').html('check');
}
else
{
//change colours
if(override_color != '')
{
var color=override_color;
}
else
{
var color='f15a01';
}
//make all divs in that sequance standard orange and white
$('.opt-'+classname).css("color","#f15a01");
$('.opt-'+classname).css("background-color","#fff");
$('.opt-'+classname).css("border-color","#f15a01");
//select the chosen option as grey/white
$('.opt-'+classname+'-'+item_id).css("color","#fff");
$('.opt-'+classname+'-'+item_id).css("background-color","#"+color);
$('.opt-'+classname+'-'+item_id).css("border-color","#"+color);
}
//fade current image out and new image in
$('#opt-'+classname).fadeOut(300, function() {
$('#opt-'+classname).attr("src",'/img/items/'+item_id+'-web.jpg');
if(option_price!=''){$('#price'+classname).html('$'+option_price);}
});
$('#opt-'+classname).delay(300).fadeIn(400);
}
function lookup_map(warehouse)
{
var postcode = $('#contact_zip_suburb').val();
postcode = postcode.trim();
var mapkey = 'AIzaSyDWe_BJQTPHZVwBdS8KtcJ_BtspLGa0wTE';
var suburb = $('#shs_label').html();
suburb = suburb.replace("Suburb: ", ""); // remove this for NZ
suburb = suburb.replace("Suburb:", "");
suburb = suburb.replace("(town)", "");
if(warehouse == 'Auckland')
{
//if the suburb contains , only take the latter part (which is the township, not the suburb) because the suburb/town combinations for the freighter are different to that of google maps
/*
var n = suburb.includes(",");
if(n == true)
{
var res = suburb.split(",");
suburb=res[1];
//alert('suburb = '+suburb);
}
*/
var postcode = $('#contact_nz_postcode').val();
}
else
{
var postcode = $('#contact_zip_suburb').val();
}
postcode = postcode.trim();
//suburb = suburb.replace(",", "");
suburb = suburb.trim();
if(suburb == '(Outside Australia)') // outside australia
{
//alert( '(Outside Australia)');
var from = $("#internation_country option:selected").text();
}
else
{
var from = suburb+' '+postcode+' '+$("#internation_country option:selected").text();
//alert( suburb+' '+postcode );
}
if(warehouse == 'Auckland')
{
//if the suburb contains , only take the latter part (which is the township, not the suburb) because the suburb/town combinations for the freighter are different to that of google maps
$('#aucklandmap').css("display","block");
$('#brisbanemap').css("display","none");
$('#perthmap').css("display","none");
var weblink = 'https://maps.google.com.au/maps?hl=en&saddr=%20%20'+encodeURIComponent(from)+'&daddr=42+Ororke+Rd,+Penrose,+Auckland+1061,+New+Zealand';
var mapimg = 'https://maps.googleapis.com/maps/api/staticmap?key='+mapkey+'&scale=2&size=448x250&markers=color:blue|label:B|%20%20'+encodeURIComponent(from)+'&markers=color:green|label:A|%20%20Penrose%20Auckland%201061%20New%20Zealand&sensor=false&format=jpg-baseline';
}
else if(warehouse == 'Brisbane')
{
$('#aucklandmap').css("display","none");
$('#pickup_map').css("display","block");
$('#brisbanemap').css("display","block");
$('#perthmap').css("display","none");
var weblink = 'https://maps.google.com.au/maps?hl=en&saddr=%20%20'+encodeURIComponent(from)+'&daddr=Vuly+Trampolines,+95+Ingleston+Road,+Wakerley+QLD+4154';
var mapimg = 'https://maps.googleapis.com/maps/api/staticmap?key='+mapkey+'&scale=2&size=448x250&markers=color:blue|label:B|%20%20'+encodeURIComponent(from)+'&markers=color:green|label:A|%20%20Wakerley%20QLD%204154&sensor=false&format=jpg-baseline';
}
else
{
$('#aucklandmap').css("display","none");
$('#brisbanemap').css("display","none");
$('#perthmap').css("display","block");
var weblink = 'https://maps.google.com.au/maps?hl=en&saddr=%20%20'+encodeURIComponent(from)+'&daddr=Mainfreight+International+Pty+Ltd,+2,+Hugh+Edwards+Drive,+Perth+Airport+WA+6105';
var mapimg = 'https://maps.googleapis.com/maps/api/staticmap?key='+mapkey+'&scale=2&size=448x250&markers=color:blue|label:B|%20%20'+encodeURIComponent(from)+'&markers=color:green|label:A|Mainfreight+International+Pty+Ltd,+2+Hugh+Edwards+Drive,+Perth+Airport+WA+6105';
}
$("#js-map-directions_1").attr("href", weblink);
$("#js-map-directions").attr("href", weblink);
$("#js-map-image").attr("src", mapimg);
$('#pickup_map').css("display","block");
//alert("sending data ... /ajax_store/check_pickup/"+warehouse+"/");
//get pickup availability information
$.ajax({url: "/ajax_store/check_pickup/"+warehouse+"/", async: false, success: function(result)
{
//alert("result = "+result);
$("#pickup_alert").html(result);
if( result.indexOf('not stocked at our') >= 0)
{
// this is the error message saying that items are not stocked. don't show continue button
$('#continue_button').css("display","none");
if(warehouse == 'Perth')
{
$('#pickup_map').css("display","none");
$('#perthmap').css("display","none");
}
}
else
{
$('#continue_button').css("display","block");
}
}});
scroll_to_anchor('whichlocation');
}
function continue_shopping()
{
scroll_to_anchor('accessoryslider');
hide_cart();
}
function show_billing_address(show)
{
if(show == '1')
{
$('#billing_contact').css("display","block");
}
else
{
$('#billing_contact').css("display","none");
}
}
function check_zipmoney()
{
$('#zip_congrats').css("display","none");
$('#zip_rejected').css("display","none");
var yob = $('#zip_yob').val();
var approved = false;
// Return today's date and time
var currentTime = new Date()
var year = currentTime.getFullYear()
year=year*1;
yob=yob*1;
var difference = year - yob;
var selectedoption = $('#zip_employment').val();
if(selectedoption == '9' || selectedoption == '8' || selectedoption == '1' || selectedoption == '2' || selectedoption == '11' || selectedoption == '3')
{
approved = true;
}
if(difference > 18 && approved == true) // accepted
{
$('#zip_congrats').css("display","block");
$('#rest-of-form').css("display","block");
}
else // desclined
{
$('#zip_rejected').css("display","block");
$('#rest-of-form').css("display","none");
}
}
function show_payment(div,smssec)
{
var value;
//make all buttons in that sequance standard orange text and white bg
$('.payoptbtn').css("color","#f15a01");
$('.payoptbtn').css("background-color","#fffff");
$('.paym_lnk').css("background-color","#ffffff");
//select the chosen option as orange bg /white text
$('#payopt-'+div).css("color","#fff");
$('#payopt-'+div).css("background-color","#f15a01");
switch(div)
{
case "credit":
value = "Credit Card";
break;
case "afterpay":
value = "Afterpay";
break;
case "finance":
value = "Finance";
break;
case "cash":
value = "Cash";
break;
default:
value = "Direct Deposit ";
}
$('#payment_type').val(value);
$('#zip_congrats').css("display","none");
$('#zip_rejected').css("display","none");
$('#rest-of-form').css("display","none");
$('#payment-method-afterpay').css("display","none");
$('#payment-method-credit').css("display","none");
$('#payment-method-cash').css("display","none");
$('#payment-method-deposit').css("display","none");
$('#payment-method-finance').css("display","none");
$('#payment-method-'+div).css("display","block");
$('#smssec').val(smssec);
scroll_to_anchor('howpay');
if( div == 'finance')
{
// show rest of form
$('#rest-of-form').css("display","block");
}
else if(div == 'credit' )
{
//dont show rest of form
}
else
{
$('#rest-of-form').css("display","block");
}
}
function blur_suburb_2020()
{
$('#contact_zip_suburb').blur(); // un focus suburb field
}
function search_order_suburbs_2020(post_code)
{
//since user has gone back to the suburb choice, hide delivery options and continue button
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none");
post_code = post_code.trim()
var length = post_code.length;
if(length > 2)
{
delay(function()
{
//reset the address warning alert
$('#address_alert').html(" ");
//$('#shs_label').css( "background-color", "#fff" );
$('#shs_label').html('');
$.ajax({url: "/ajax_store/search_order_suburbs_2020/"+encodeURIComponent(post_code)+"/", async: true, success: function(result){
$("#shs_label").html(result);
//
}});
}, 500);
}
}
function search_order_suburbs_usa()
{
console.log('tripped');
//since user has gone back to the suburb choice, hide delivery options and continue button
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none");
$('#inside_australia').css("display","none");
$('#city_holder').css("display","none");
$('#state_holder').css("display","none");
$('#country_holder').css("display","none");
$('#lead_origin_header').css("display","none");
$('#lead_origin_options').css("display","none");
$('.mob_summary_box-1').css("display","none");
$('.mob_summary_box-2').css("display","none");
$('#zip-msg-box').css("display","block");
$('#city-input').val('');
$('#state-input').val('');
$('#country-input').val('');
saveorderusa("0");
}
function search_order_suburbs(post_code)
{
//since user has gone back to the suburb choice, hide delivery options and continue button
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none");
post_code = post_code.trim()
var length = post_code.length;
if(length > 3)
{
//reset the address warning alert
$('#address_alert').html(" ");
//$('#shs_label').css( "background-color", "#fff" );
$('#shs_label').html('');
$.ajax({url: "/ajax_store/search_order_suburbs/"+post_code+"/", async: false, success: function(result){
$("#shs_label").html(result);
$('#contact_zip_suburb').blur(); // un focus suburb field
}});
}
else if(length > 1)
{
//reset the address warning alert
$('#address_alert').html(" ");
$("#shs_label").html('Click on your suburb: Outside Australia');
}
}
function search_order_suburbs_nz(suburb)
{
delay(function()
{
//since user has gone back to the suburb choice, hide delivery options and continue button
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","none");
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none");
suburb = suburb.trim()
var length = suburb.length;
if(length > 2)
{
//reset the address warning alert
$('#address_alert').html(" ");
//$('#shs_label').css( "background-color", "#fff" );
$('#shs_label').html('');
$.ajax({url: "/ajax_store/search_order_suburbs_nz/"+encodeURIComponent(suburb)+"/", async: false, success: function(result){
$("#shs_label").html(result);
//$('#contact_zip_suburb').blur(); // un focus suburb field
}});
}
else if(length > 1)
{
//reset the address warning alert
$('#address_alert').html(" ");
$("#shs_label").html('Click on your suburb: Outside New Zealand');
}
}, 100);
}
function changed_bold_date()
{
var changed_date=$('#shipping_date').val();
$('#earliestdate_bolded').html(changed_date);
// warehouse storage charging
var end_date='';
//if warehouse charging is turned on
if($('#charging_for_storage').html() == '1')
{
//check if chosen date is more than 14 days after todays date, or after the earliest dispatch date (whatever is latter)
//check if stock option exists on page
if ( $('#stock_option_1').length )//stock options exist on page - some stock must be out of stock
{
if($('#stock_option_1').is(':checked')) //chose to wait for all order
{
//get earliest selectable date of #shipping_date
start_date = $('#shipping_date_min_date').html();
//compare with chosen date
end_date = $('#earliestdate_bolded').html(); // 23 December, 2016
}
else // chose to split into 2 deliveries
{
//start_date = $('#split_shipping_date_1').html();
//end_date = $('#earliestdate_bolded').html(); // 23 December, 2016
//start_date = $('#split_shipping_date_2').html();
//end_date = $('#earliestdate_bolded').html(); // 23 December, 2016
}
}
else // no stock options - all items must be in stock
{
//get earliest selectable date of #shipping_date
start_date = $('#shipping_date_min_date').html();
//compare with chosen date
end_date = $('#earliestdate_bolded').html(); // 23 December, 2016
}
//alert("/ajax_store/compare_holding_dates/"+encodeURIComponent(start_date)+"/"+encodeURIComponent(end_date)+"/");
$.ajax({url: "/ajax_store/compare_holding_dates/"+encodeURIComponent(start_date)+"/"+encodeURIComponent(end_date)+"/", async: false, success: function(result){
//alert(result);
$('#charging_storage').html(result);
}});
}
}
function set_pickdate_field(field_id,days) //sets the minimum selectable date for a datepicker field
{
var count=1;
var hourcount = days * 24;
var day_window;
var datcurrentDate = new Date(new Date().getTime() + hourcount * 60 * 60 * 1000);
var datday = datcurrentDate.getDate();
var datmonth = datcurrentDate.getMonth();
var datyear = datcurrentDate.getFullYear();
/*
9 // insert this code on page to test what the page would do if you were in this month. 9 = October (js does one month ahead)
if( $('#sheldyn_test_month').length) // if element exists on page for testing purposes
{
//override month for testing purposes
datmonth = $('#sheldyn_test_month').html();
datmonth = datmonth * 1;
alert('new datmonth = '+datmonth);
}
*/
/*
Rationale:
During our non-peak times of the year, allow customers to book in delivery within 2 months of their purchase date.
This seems reasonable and allows for more customer convenience than a 3 week period.
It allows customers to organise birthdays and special events well in advance, not just a few weeks in advance.
To help spreadh the warehouse burden :
during October, it drop the window to a 4 week window.
In November and December, it can drop to a 2 week window.
If we don't drop the window during these months, customers will inevitably choose to have the order delivered in the week leading up to xmas and our warehouse will have to work 24 hours a day.
*/
//the month is 1 less (eg 1 = feb, 2 = march ...)
switch(datmonth)
{
case 7: // during august
day_window = 31;//4week window
break;
case 8: // during september
day_window = 14;//4week window
break;
case 9: // during oct
day_window = 14;// 2 week window
break;
case 10: // during nov
day_window = 14; // 2 week window
break;
case 11: // during dec
day_window = 60;// 2 month window to allow next year delivery
break;
default: // all other months
day_window = 60;//4week window
break;
}
var endhourcount = 24 * day_window;
endhourcount=endhourcount+ hourcount;
var datendDate = new Date(new Date().getTime() + endhourcount * 60 * 60 * 1000);
var endday = datendDate.getDate();
var endmonth = datendDate.getMonth();
var endyear = datendDate.getFullYear();
//alert('month = '+datmonth+' | window = '+week_window+ ' | endhourcount = '+endhourcount+ ' | end date: '+endday+'/'+endmonth+'/'+endyear );
/*
if( $('#sheldyn_test_month').length) // if element exists on page
{
alert(datyear+'/'+datmonth+'/'+datday+' ... '+endyear+'/'+endmonth+'/'+endday);
}
*/
$(field_id).pickadate({selectYears: 2, min:new Date(datyear, datmonth, datday, 10, 30), max:new Date(endyear, endmonth, endday, 10, 30), disable:[1,7,[2017,11,25],[2017,11,26],[2018,0,1],[2018,11,25],[2018,11,26],[2019,0,1]]});
datmonth++;
$(field_id+'_min_date').html(datyear+'-'+datmonth+'-'+datday);
}
function set_datepick_field(field_id,days) //sets the minimum selectable date for a datepicker field but with no future limits or weekend limits
{
var count=1;
var hourcount = days * 24;
var day_window;
var datcurrentDate = new Date(new Date().getTime() + hourcount * 60 * 60 * 1000);
var datday = datcurrentDate.getDate();
var datmonth = datcurrentDate.getMonth();
var datyear = datcurrentDate.getFullYear();
/*
Rationale:
During our non-peak times of the year, allow customers to book in delivery within 2 months of their purchase date.
This seems reasonable and allows for more customer convenience than a 3 week period.
It allows customers to organise birthdays and special events well in advance, not just a few weeks in advance.
To help spreadh the warehouse burden :
during October, it drop the window to a 4 week window.
In November and December, it can drop to a 2 week window.
If we don't drop the window during these months, customers will inevitably choose to have the order delivered in the week leading up to xmas and our warehouse will have to work 24 hours a day.
*/
//the month is 1 less (eg 1 = feb, 2 = march ...)
switch(datmonth)
{
case 7: // during august
day_window = 31;//4week window
break;
case 8: // during september
day_window = 14;//4week window
break;
case 9: // during oct
day_window = 14;// 2 week window
break;
case 10: // during nov
day_window = 14; // 2 week window
break;
case 11: // during dec
day_window = 60;// 2 month window to allow next year delivery
break;
default: // all other months
day_window = 60;//4week window
break;
}
var endhourcount = 24 * day_window;
endhourcount=endhourcount+ hourcount;
var datendDate = new Date(new Date().getTime() + endhourcount * 60 * 60 * 1000);
var endday = datendDate.getDate();
var endmonth = datendDate.getMonth();
var endyear = datendDate.getFullYear();
$(field_id).pickadate({selectYears: 2, min:new Date(datyear, datmonth, datday, 10, 30), disable:[[2019,11,25],[2019,11,26],[2020,0,1]]});
datmonth++;
$(field_id+'_min_date').html(datyear+'-'+datmonth+'-'+datday);
}
function adopt_pickup_method_2020()
{
var method = $("#delivery_method").val();
var suburb_id = $("#save_suburb_id").val();
if(suburb_id == '0')
{
$(".inside_australia").css('display','none');
$("#next_button").css('display','block');
$("#next_button_submit").css('display','none');
}
else
{
if(method == 'delivery')
{
$("#next_button").css('display','block');
$("#next_button_submit").css('display','none');
choose_delivery_fast('delivery'); // recalculate shipping
}
else // pickup
{
$("#delivery_method").val('pickup');
$("#next_button").css('display','none');
$("#next_button_submit").css('display','block');
$('#shipping_rh_line').css("display","none");
var total_price = $('#cart_total_price_on_page_load').html();
console.log('11. #cart_total_price = $'+total_price);
$('#cart_total_price').html('$'+total_price);
}
}
}
function choose_delivery_fast(method)
{
//hide these sections, forcing the user to choose their warehouse again
$('#aucklandmap').css("display","none");
$('#brisbanemap').css("display","none");
$('#perthmap').css("display","none");
$('#pickup_alert').html("");
$('#pickup_map').css("display","none");
$('.indicator').css("display","inline");
//slider animation
if(method == 'delivery')
{
fadedelivery('#delivery','1');
}
else
{
fadedelivery('#pickup','2');
}
//reset pickup location to blank
$('#pickup_location').val("");
$('#delivery_method').val(method);
//scroll_to_anchor('deliveryclicker');
if(method=='pickup')
{
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","block");
$('#continue_button').css("display","none"); // temporary covid 19 measure
var afterpay_original = $("#afterpay_on_page_load").html();
$('#afterpay_4_payments').html(afterpay_original);
adopt_pickup_method_2020(); // new 2020 template
}
else // delivery
{
$('#pickup_div').css("display","none");
var suburb_id = $('#save_suburb_id').val();
$.ajax({url: "/ajax_store/fast_checkout_prep/"+suburb_id+"/", async: false, success: function(result){
$("#confirm_freighter").html(result);
$('#confirm_freighter').css("display","block");
$('#delivery_div').css("display","block");
$('#continue_button').css("display","block"); // hide continue to payment button
// new 2020 template
$("#next_button").css('display','none');
$("#next_button_submit").css('display','block');
var shipping_price = 0;
if ($('#ship_price').length > 0)
{
shipping_price=$("#ship_price").html();
shipping_price=shipping_price*1;
}
//console.log('shipping_price = '+shipping_price);
if(shipping_price > 0)
{
var final_shipping_price = (Math.round(shipping_price * 100) / 100).toFixed(2);
$('#shipping_value').html('$'+final_shipping_price);
}
else
{
$('#shipping_value').html('FREE');
}
$('#shipping_rh_line').css("display","block");
var total_price = $('#cart_total_price_on_page_load').html();
total_price = total_price*1;
console.log('total_price = '+total_price+" + "+shipping_price);
total_price = total_price + shipping_price;
//console.log(total_price+' = '+total_price+' + '+shipping_price);
var final_total_price = (Math.round(total_price * 100) / 100).toFixed(2);
console.log('22. #cart_total_price = $'+final_total_price);
$('#cart_total_price').html('$'+final_total_price);
var afterpay_original;
if(shipping_price > 0)
{
afterpay_original = total_price / 4;
afterpay_original = (Math.round(afterpay_original * 100) / 100).toFixed(2);
}
else
{
afterpay_original = $("#afterpay_on_page_load").html();
}
$('#afterpay_4_payments').html(afterpay_original);
//lookup_map('Brisbane');
}});
}
}
function choose_delivery(method)
{
//hide these sections, forcing the user to choose their warehouse again
$('#aucklandmap').css("display","none");
$('#brisbanemap').css("display","none");
$('#perthmap').css("display","none");
$('#pickup_alert').html("");
$('#pickup_map').css("display","none");
$('.indicator').css("display","inline");
//slider animation
if(method == 'delivery')
{
fadedelivery('#delivery','1');
}
else
{
fadedelivery('#pickup','2');
}
$("#earliestdate").html(''); // set to blank
$('#choose_split_delivery_dates').css("display","none");
$('#choose_single_delivery_date').css("display","none");
$('#deliverytermsandconditions').css("display","none");
$('#continue_button').css("display","none"); // hide continue to payment button
//reset pickup location to blank
$('#pickup_location').val("");
//uncheck atl options
$('#confirm_freighter_split').css("display","none");
$("#split_atl_yes").attr("checked", false);
$("#split_atl_no").attr("checked", false);
if(method=='pickup')
{
delivery_method='pickup';
$('#delivery_div').css("display","none");
$('#pickup_div').css("display","block");
}
else // delivery
{
delivery_method='delivery';
$('#delivery_div').css("display","block");
$('#pickup_div').css("display","none");
$('#deliverytermsandconditions').css("display","none");
}
$('#delivery_method').val(delivery_method);
//scroll_to_anchor('deliveryclicker');
if(method!='pickup')
{
var suburb_id = $('#save_suburb_id').val();
$.ajax({url: "/ajax_store/check_stock_levels/"+suburb_id+"/", async: false, success: function(result){
//if everything is in stock, then chose single delivery date, and enforce minimum date selection
if(result.length < 10) //return the days until arrival
{
var days = result * 1;
//create date from this day
var someDate = new Date();
someDate.setDate(someDate.getDate() + days);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();
$('#shipping_date').val(dd + '/'+ mm + '/'+ y);
set_pickdate_field('#shipping_date',days);
$("#days_to_delivery").val(days);
$('#choose_single_delivery_date').css("display","block");
$("#stock_control_feedback").html('');
//temporary xmas messages
if(dd < 24 && mm == 12)
{
$("#stock_control_feedback").html('