';
}
$('#publication_title').show();
$('#publication_title1').show();
$('#publications').show();
$('#publication_list').show();
var pubselectiont = "Based on the delivery address you can subscribe to:";
$('#publication_title').html(pubselectiont);
$('#publication_title1').html(pubselectiont);
$('#publication_list').html(pubselection);
$('#publication_continue').show();
$('#inputdiv').hide();
$('#searchdiv').hide();
$('#displaydiv').show();
$("#submitbutton").removeAttr("disabled");
}
else
{
$('#wait').hide();
$('#sorry').show();
$('#publication').hide();
$('#publication_title').hide();
$('#entry').hide();
$('#sorry').html('' + objResponse.ERROR.replace("\/","/") + '');
$('#searchboxer').val('');
}
},
error: function( objRequest, strError ){}
}
);
}
}
function infotoggle(id)
{
$("#image_" + id).toggle();
$("#info_" + id).toggle();
}
function selectpublication(pub, hos)
{
progressbar(2);
$('#wait').show();
$('#publication').hide();
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "getPublicationPromotionsForAddress",
pub: pub,
promo: 'SUBNOW',
hos : hos,
_vt: $('#_vt').val(),
_vts: $('#_vts').val()
},
dataType: "json",
success: function( objResponse ){
if(objResponse.SUCCESS)
{
$('#sorry').hide();
$('#sorry').html('');
$('#wait').hide();
$('#publication').show();
var pubselection = "";
var data = objResponse.getPromotions.DATA;
///console.log(data);
$('#publication_title').html('Please select from one of the following subscription packages');
$('#pleaseselect').hide();
for (var i in data) {
var id = data[i][0];
var header = data[i][3];
var text = data[i][4];
var name = data[i][2];
var publication = data[i][5];
var cost = data[i][6];
var cost_detail = data[i][7];
var summary_detail = data[i][8];
var delivery_detail = data[i][9];
///pubselection+= "
";
/*
pubselection+= "
";
pubselection+= '
';
pubselection+= '
'+ text + "
"
pubselection+= "
"
pubselection+= "
";
*/
pubselection+= '
';/* */
}
///pubselection+= '
';
$('#publication_title').show();
$('#publication_title1').show();
$('#publication_list').html(pubselection);
$('#publication_list').show();
$('#publication_continue').show();
$('#searchdiv').hide();
$('#displaydiv').show();
$("#submitbutton").removeAttr("disabled");
$('#address').hide();
}
else
{
$('#wait').hide();
$('#sorry').show();
$('#publication').show();
$('#publication_title').hide();
$('#publication_title1').hide();
$('#entry').hide();
$('#sorry').html('
' + objResponse.ERROR.replace("\/","/") + ' ');
$('#searchboxer').val('');
}
},
error: function( objRequest, strError ){}
}
);
}
function backto_selectAddress()
{
$('#address').show();
$('#publications').show();
$('#publication').show();
selectAddress( $('#dpid').val(), $('#selected_address').val());
}
function selectAddress(dpid,label)
{
progressbar(1);
///set hidden form variables
///console.log(label);
$('#dpid').val(dpid);
$('#selected_address').val(label);
$('#selected_address').prop("readonly", true);
///selectbAddress(dpid,label);
$('#gift_address').val(label);
$('#sorry').hide();
$('#entry').hide();
$('#wait').show();
$('#publication').hide();
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "selectAddress",
dpid: dpid,
promo: 'SUBNOW',
_vt: $('#_vt').val(),
_vts: $('#_vts').val()
},
dataType: "json",
success: function( objResponse ){
////console.log(objResponse);
if(objResponse.SUCCESS)
{
$('#wait').hide();
$('#publication').show();
///$('#publication').toggle();
var pubselection = "Based on the delivery address you can subscribe to:";
var autoSelect ='';
$('#publication_title').html(pubselection);
pubselection = "";
for (var i in objResponse.ARRAYPUBS) {
var pub = objResponse.ARRAYPUBS[i];
pubselection+= '
';
pubselection+= '
';
pubselection+= '';
}
$('#publication_title').show();
$('#publication_title1').show();
$('#publications').show();
$('#publication_list').html(pubselection);
$('#publication_continue').show();
$('#searchdiv').hide();
$('#displaydiv').show();
$("#submitbutton").removeAttr("disabled");
}
else
{
$('#wait').hide();
$('#sorry').show();
$('#publication').hide();
$('#publications').hide();
$('#publication_title').hide();
$('#publication_title1').hide();
$('#entry').hide();
$('#sorry').html('' + objResponse.ERROR.replace("\/","/") + '');
$('#searchboxer').val('');
}
},
error: function( objRequest, strError ){}
}
);
}
function validatecode()
{
$('#promocoderesponse').html();
var promocode = document.getElementById('promocode').value;
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "ValidateCode",
code: promocode,
d: 'aws_NZH'
},
dataType: "json",
success: function( objResponse ){
if(objResponse.ISVALID)
{
window.location = "index.cfm?code=" + promocode;
}
else
{
$('#promocoderesponse').html(objResponse.MSG);
}
},
error: function( objRequest, strError ){
return false;
}
}
);
}
function change_address()
{
progressbar(1);
$('#publication_list').html('Enter an address above before you can select a publication');
$('#selected_address').val('');
$('#selected_address').prop("readonly", false);
$('#dpid').val('');
$('#searchdiv').show();
$('#entry').hide();
$('#displaydiv').hide();
$('#searchboxer').val('');
$('#paymentcheck').hide();
$('#require_payment_confirmation').val('false');
}
function change_baddress()
{
///$('#selected_address').html('');
///$('#dpid').val('');
if($('#bdpid').val() == '0')
{
$('#binputdiv').show();
}
else
{
$('#bsearchdiv').show();
}
$('#bdpid').val('');
$('#bdisplaydiv').hide();
$('#bsearchboxer').val('');
$('#bselected_address').prop("readonly", false);
}
function use_manual_baddress()
{
$('#bdpid').val('0');
var unit = $('#bunit').val();
var streetno = $('#bstreetno').val();
var street = $('#bstreet').val();
var suburb = $('#bsuburb').val();
var city = $('#bcity').val();
var postcode = $('#bpostcode').val();
var rdno = $('#brdno').val();
var pobox = $('#bpobox').val().toUpperCase();
if(pobox.lastIndexOf("PO"))
{
if(pobox != '')
{
pobox = "PO BOX " + pobox;
}
}
var validationfailure = false;
var reason = "";
if(pobox != '')
{
if(city == '')
{
validationfailure = true;
reason += "Please enter your city, ";
}
if(postcode == '')
{
validationfailure = true;
reason += "Please enter your postcode, ";
}
}
else
{
if(streetno == '')
{
validationfailure = true;
reason += "Please enter your street number, ";
}
if(street == '')
{
validationfailure = true;
reason += "Please enter your street address, ";
}
if(city == '')
{
validationfailure = true;
reason += "Please enter your city, ";
}
if(postcode == '')
{
validationfailure = true;
reason += "Please enter your postcode, ";
}
}
if(validationfailure)
{
$('#manual_baddress_validation').html(reason + '
');
}
else
{
var addressobj = {
"unit": unit,
"streetno": streetno,
"street" : street,
"suburb" : suburb,
"city" : city,
"postcode" : postcode,
"rdno" : rdno,
"pobox" : pobox
}
$('#bselected_address').val(formatAddress(addressobj));
$('#bentry').hide();
$('#binputdiv').hide();
$('#bdisplaydiv').show();
}
}
function selectbAddress(dpid,label)
{
///set hidden form variables
$('#bdpid').val(dpid);
$('#bselected_address').val(label);
$('#bselected_address').prop("readonly", true);
$('#bsearchdiv').hide();
$('#bdisplaydiv').show();
}
function getPublications_depreciated(dpid,address)
{
$('#dpid').val(dpid);
////console.log(dpid);
$('#selected_address').val(address);
$('#sorry').hide();
///console.log("go for" + dpid);
///$('#address').toggle();
$('#wait').show();
$('#publication').hide();
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "getPublications",
dpid: dpid,
promocode: 'SUBNOW'
},
dataType: "json",
success: function( objResponse ){
///console.log(objResponse);
if(objResponse.SUCCESS)
{
$('#wait').hide();
$('#publication').show();
$('#entry').show();
///$('#publication').toggle();
var pubselection = "";
var autoSelect ='';
if(objResponse.ARRAYPROMOTIONS.length == 1)
{
pubselection = 'Based on your delivery address you can receive';
}
else
{
pubselection = 'Please select one of the following papers:';
}
$('#publication_title').html(pubselection);
pubselection = "";
for (var i in objResponse.ARRAYPROMOTIONS) {
pubselection+= '
';
pubselection+= ' ';
pubselection+= '' + objResponse.ARRAYNAMES[i] + '
';
}
$('#publication_title').show();
$('#publication_list').html(pubselection);
$('#publication_continue').show();
$('#searchdiv').toggle();
$('#displaydiv').toggle();
$("#submitbutton").removeAttr("disabled");
}
else
{
/*
$('#modelContent').html(objResponse.ERROR.replace("\/","/"));
$('#validationModal').modal({
show: 'true'
});
*/
$('#wait').hide();
$('#sorry').show();
$('#publication').hide();
$('#publication_title').hide();
$('#entry').hide();
$('#sorry').html('' + objResponse.ERROR.replace("\/","/") + '');
$('#searchboxer').val('');
///$('#address').toggle();
}
},
error: function( objRequest, strError ){}
}
);
}
function showterms()
{
$.ajax({
url:'https://subscriptions.nzherald.co.nz/termsandconditions/',
type:'GET',
success: function(data){
var terms = $(data).find('#fullterms').html();
///console.log("terms are" + terms);
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "getTerms"
},
dataType: "json",
success: function( objResponse ){
$('#modelContent').html(terms);
$('#modalTitle').html(objResponse.TITLE);
$('#validationModal').modal({
show: 'true'
});
},
error: function( objRequest, strError ){
}
}
);
}
});
}
function selectpromo(promo)
{
progressbar(3);
$('.promobox').each(function(i, obj) {
$('#'+ this.id).removeClass("ghosted");
if(this.id != "promobox_" + promo)
{
$('#'+ this.id).addClass("ghosted");
}
});
$('#p').val(promo);
$('#promoboxes').children('div').each(function () {
alert(this.value); // "this" is the current element in the loop
});
///console.log(promo);
$('#paymentcheck').hide();//resets
$('#require_payment_confirmation').val('false');//resets
$('#entry').show();///show the entry form.
$.ajax(
{
type: "get",
url: "functions.cfc",
data: {
method: "getPublication",
promotion: promo,
l: "/export/www/wwwroot/live/subscriptions/images/uploaded/",
_vt: $('#_vt').val(),
_vts: $('#_vts').val()
},
dataType: "json",
success: function( objResponse ){
sortPaymentModeDisplay(objResponse.PAYMENT);
$('#publications').hide();
},
error: function( objRequest, strError ){
}
}
);
}
function sortPaymentModeDisplay(payment)
{
if(payment > 0)
{
///means it requires payment, so show the checkbox.
if(payment == "1")
{
$('#contine_explain').html("and continue to credit card authorisation");
///show authorisation accept text and checkbox, and require the input
$('#paymentcheck').show();
$('#require_payment_confirmation').val('true');
}
else
{
$('#contine_explain').html("and continue to credit card payment");
}
}
else
{
///free so hide/reset the text
$('#contine_explain').html("");
}
}
function validateForm() {
$('#wait').hide();
$('#validationresponse').hide();
$('#validationresponse').html('');
var success = true;
var address = $('#dpid').val();
if (address == "" ) {
addvalidationfailure("Please select your address");
success = false;
}
var promo = $('#p').val();
if (promo == "") {
addvalidationfailure("Please select a promotion");
success = false;
}
var v = $('#aaMemberNum').val();
if(typeof(v) === "undefined")
{
}
else
{
aasuccess =validate_aa(v);
if(aasuccess == false)
{
success = aasuccess;
}
}
var v = $('#firstname').val();
if (v == "" ) {
addvalidationfailure("Please enter your first name");
success = false;
}
var v = $('#lastname').val();
if (v == "" ) {
addvalidationfailure("Please enter your surname");
success = false;
}
var v = $('#phone').val();
var vp = $('#phone_prefix').val();
///var vm = $('#mobile').val();
///var vmp = $('#mobile_prefix').val();
if (vp == "") {
addvalidationfailure("Please enter your phone number (phone or mobile, you choose)");
success = false;
}
if (v == "") {
addvalidationfailure("Please enter your phone number (phone or mobile, you choose)");
success = false;
}
else
{
/*
if(vp == '' && v != '')
{
addvalidationfailure("Please enter your phone number (phone or mobile, you choose)");
success = false;
}
if (vmp == "" && vm != "")
{
addvalidationfailure("Please enter your phone number");
success = false;
}
else
{
if(vmp != '' && vm == '')
{
addvalidationfailure("Please enter your alternative phone number");
success = false;
}
}*/
}
/*
var valphone = validatePhone(v + vp);
if(valphone!=true)
{
addvalidationfailure("Please enter your phone number (phone or mobile, you choose) - it should be numbers only");
success = false;
}
var valmobphone = validatePhone(vm + vmp);
if(valmobphone!=true)
{
addvalidationfailure("Please enter your phone number (phone or mobile, you choose) - it should be numbers only");
success = false;
}
*/
var v = $('#email').val();
if (v == "" ) {
addvalidationfailure("Please enter your email address");
success = false;
}
var ex = ValidateEmail(v);
if(ex == false)
{
addvalidationfailure("Invalid email address, please check your entry");
success = false;
}
/*
var inve = $('#invoiceemail').val();
if(inve != '')
{
var ex = ValidateEmail(inve);
if(ex == false)
{
addvalidationfailure("Invalid invoice email address, please check your entry");
success = false;
}
}
*/
///console.log(typeof($('#cbTerms').attr('checked')));
var baddress = $('#bdpid').val();
if($('#cbTerms').prop('checked')) {
// something when checked
} else {
addvalidationfailure("You must agree to our terms and conditions to continue");
success = false;
}
if($('#require_payment_confirmation').val() == 'true')
{
if($('#paymentYES').prop('checked')) {
// something when checked
} else {
addvalidationfailure("You must agree to our credit card policy to continue");
success = false;
}
}
if(!success)
{
$(window).scrollTop(100);
}
return success;
}