/*
03/04 changes
Published new JS file with Captcha changes .
Basic captcha changed to advance captcha
Fix for autopopulation
Job role and industry
*/
/* jshint eqnull:true */
var contactFormConfig = {
'postToUrl': '/forms/submit.form',
'proxyUrl': 'http://52.24.146.215/webforms/',
'urlMapping': {
'now.experian.com': 'https://www.experian.com',
'go.experian.com': 'https://www.experian.com'
},
'security': {
'protocol': 'https://',
},
'securityDomains': [
'stg1.experian.com',
'www.experian.com',
'stg1.experian.co.jp',
'www.experian.co.uk'
],
"edqEnabled": [
"www.experian.com",
"stg1.experian.com"
],
"preference": [
"www.experian.com/innovation/subscription"
],
'enableTracking': [
'www.experian.com',
'stg1.experian.com'
],
'hostLocation': [
'www.experian.com',
'stg1.experian.com'
],
'ukLinks': [
'www.experian.co.uk',
'stg1.experian.co.uk',
'stg1-britain.experian.com'
],
'eloqua': [
'go.experian.com',
'now.experian.com',
'us-now.experian.com',
'us-go.experian.com',
'fr-go.experian.com',
'uk-go.experian.com',
'ie-go.experian.com',
'emea-go.experian.com',
'at-go.experian.com',
'be-go.experian.com',
'bg-go.experian.com',
'cz-go.experian.com',
'dk-go.experian.com',
'de-go.experian.com',
'gr-go.experian.com',
'it-go.experian.com',
'nl-go.experian.com',
'no-go.experian.com',
'pl-go.experian.com',
'pt-go.experian.com',
'ro-go.experian.com',
'ru-go.experian.com',
'za-go.experian.com',
'es-go.experian.com',
'se-go.experian.com',
'tr-go.experian.com',
'ae-go.experian.com',
'apac-go.experian.com',
'au-go.experian.com',
'cn-go.experian.com',
'hk-go.experian.com',
'in-go.experian.com',
'id-go.experian.com',
'jp-go.experian.com',
'my-go.experian.com',
'nz-go.experian.com',
'sg-go.experian.com',
'kr-go.experian.com',
'tw-go.experian.com',
'th-go.experian.com',
'vn-go.experian.com',
'images.go.experian.com',
'app.go.experian.com',
'metrics-go.experian.com'
],
'formErrorMessage': 'Oops. Something went wrong. Please try again later.',
'captchaLabel': 'Please verify you are human:*', //label override
'captchaLabelNL': 'Verificatie dat u een persoon bent:*',
'captchaMessage': 'Invalid answer. Please try again.',
//'captchaMessage': 'The text you entered was incorrect. Please try again. Can\'t read the words below? Click the refresh button or try the audio icon. ',
'qasUrl': 'https://api.experianmarketingservices.com/sync/queryresult/EmailValidate/1.0/',
'qasToken': '91fadd7c-c914-6334-3bd2-e9bb4c8beffc',
'qasTimeout': '5',
'qasDisallow': [],
'qasshowCorrections': true,
'qasMessages': {
"default": "Your email does not appear to be a valid email address. Verify the address and try again."
},
'qasLink': 'Validated by Experian Data Quality',
"proxyIP": "52.24.146.215", //For IE9
'devExperianEmail': 'qCmGsR3KeKEx6eAV0k2ZGaW5CKP7eyr7'
};
var contactFormApp = {
//Setup global variables
currentURL: '',
currentDomain: '',
allowedDomain: '',
eloquaDomain: '',
submitUrl: '',
pageUrl: '',
wtsrchUrl: '',
jCurrentForm: '',
instance_dir: '',
container: '',
leadData: {},
hostname: '',
successID: '',
edqEnabled: false,
//Initialize Contact Form
init: function() {
//Add global functions and initialize current Url
this.addGlobalFunctions();
this.currentDomain = window.location.hostname;
this.currentURL = window.location.href;
//Enable tracking
if (arrayContains(this.currentDomain, this.getConfigValue('enableTracking'))) {
this.allowedDomain = true;
}
if (arrayContains(window.location.hostname, this.getConfigValue('eloqua'))) {
this.eloquaDomain = true;
}
//Allow override to enable tracking as well
if (typeof enableTracking !== 'undefined') {
if (enableTracking) {
this.allowedDomain = true;
}
}
//create pageUrl instance
this.pageUrl = new this.urlObj();
this.wtsrchUrl = this.getParameterByName('wt.srch');
//Enable eloqua for experian domain
if (this.allowedDomain) {
this.trackExternalCampaigns();
this.trackInternalCampaigns();
}
//Set EDQ status
if (arrayContains(window.location.hostname, this.getConfigValue('edqEnabled'))) {
this.edqEnabled = true;
}
//Allow to override edq
if (typeof edqEnabled != "undefined") {
this.edqEnabled = edqEnabled;
}
//Read hostname form config
if (this.getConfigValue('urlMapping').hasOwnProperty(window.location.hostname)) {
this.hostname = this.getConfigValue('urlMapping')[window.location.hostname];
} else {
this.hostname = window.location.protocol + '//' + window.location.host;
}
//Security updates https
/* if (arrayContains(window.location.hostname, this.getConfigValue('securityDomains'))) {
this.submitUrl = this.getConfigValue('security')['protocol'] + location.hostname + this.getConfigValue('postToUrl');
} else {
this.submitUrl = this.hostname + this.getConfigValue('postToUrl');
};*/
//var current_url = window.location.hostname;
// var staging = current_url.includes("stg1");
if (window.location.href.indexOf("stg1") > -1) {
this.submitUrl = this.getConfigValue('security')['protocol'] + 'stg1.experian.com' + this.getConfigValue('postToUrl');
} else {
this.submitUrl = this.getConfigValue('security')['protocol'] + 'www.experian.com' + this.getConfigValue('postToUrl'); //11-15-16
}
//Support Legacy forms
//this.addLegacySupport();
//Create URL with hostname
// if(document.location.hostname == 'stg1.experian.com'){
// this.submitUrl = 'https://stg1.experian.com' + this.getConfigValue('postToUrl');}
// else if(document.location.hostname == 'stg1.experian.co.jp'){
// this.submitUrl = 'https://stg1.experian.co.jp' + this.getConfigValue('postToUrl');}
// else{
// this.submitUrl = this.hostname + this.getConfigValue('postToUrl');
// }
//Initialize EloquaCookie
if (arrayContains(this.currentDomain, this.getConfigValue('hostLocation'))) {
this.initEloqua();
}
//Initialize contact form
if ($('#contactForm form').exists()) {
$('#contactForm form').each(function() {
contactFormApp.container = $(this);
contactFormApp.initAjaxForm($(this));
});
}
},
/**
* Reads ContactFormConfig object and returns value
* @param {string} key - returns value of key
*/
getConfigValue: function(key) {
if (contactFormConfig.hasOwnProperty(key)) {
return contactFormConfig[key];
}
},
/**
* Appends input field to the form
* @param {string} title - Form where input fields will be appended
* @param {object} fieldObject - New input fields.
*/
addInputField: function(form, fieldObject) {
for (var property in fieldObject) {
if (fieldObject.hasOwnProperty(property)) {
if (form.find('input[name="' + property + '"]')) { //Remove if field already exist
form.find('input[name="' + property + '"]').remove();
}
if (!fieldObject[property]) fieldObject[property] = '';
form.append('');
}
}
},
/**
* Makes ajax request and returns promises
* @param {string} url - Rest API
* @param {object} data - Data to send
*/
makeAjaxRequest: function(url, data) {
var ajaxPromise =
$.ajax({
type: 'POST',
url: url,
data: data
});
var dff = $.Deferred();
ajaxPromise.then(function(data) {
dff.resolve(data);
}, function(data) {
dff.reject(data);
});
return dff.promise();
},
/**
* Search for string in URL
* @param {string} string - String to search
*/
urlSearch: function(string) {
if (this.currentURL.indexOf(string) > -1)
return true;
return false;
},
/**
* Initialize Contact Form
* @param {string} jCurrentForm - Contact form to initialize
*/
initAjaxForm: function(jCurrentForm) {
//Set current form to global object
this.jCurrentForm = jCurrentForm;
//capcha override label
if (this.jCurrentForm.find(".captcha_label").length) {
if(this.currentDomain == 'stg1-netherlands.experian.com' || this.currentDomain == 'www.experian.nl' ){
this.jCurrentForm.find(".captcha_label")
.text(contactFormConfig.captchaLabelNL); //override label
}
else{
this.jCurrentForm.find(".captcha_label")
.text(contactFormConfig.captchaLabel); //override label
}
}
//If no email field, disable EDQ
if (this.jCurrentForm.find("input[name=email]").length < 1) {
this.edqEnabled = false;
}
//Add placeholder in phone field
this.jCurrentForm.find('#phone_input').attr('placeholder', '(123) 123-1234');
if (arrayContains(this.currentDomain, this.getConfigValue('ukLinks'))) {
this.jCurrentForm.find('#phone_input').attr('placeholder', 'Telephone');
}
//Remove class 'floatl' for checkboxes and radio buttons
if (this.jCurrentForm.find("input[type=checkbox]").length) {
$("input:checkbox").parent('li').parent('ul.formRow').removeClass('floatl');
var x = $('input:checkbox').parent('li.productInputGroup').siblings('li');
$(x).children('label').removeClass('floatl__label');
}
/*
if (this.jCurrentForm.find(".productSelectField").length) {
$(".productSelectField").parent('li').parent('ul.formRow').removeClass('floatl');
var x= $('.productSelectField').parent('li.productInputGroup').siblings('li');
$(x).children('label').removeClass('floatl__label');
}
*/
var elqParts = location.hostname.split('.'),
elqSubdomain = elqParts.shift(),
paths = location.pathname,
firstDir = paths.split('/')[1];
//select dropdown fix floatl
if (this.jCurrentForm.find(".productSelectField").length > 0 && elqSubdomain != "go" && firstDir != "innovation" && elqSubdomain != "now") {
$('select.productSelectField').each(function(index, val) {
var x = $(this).parent('li.productInputGroup').siblings('li'),
label = $(x).children('label').text(),
firstOption = $(this).find('option:first').text(),
result = firstOption.search(new RegExp('select', "i"));
//* for required option
if($(x).children('label').hasClass('productFormLabelRequired') && label.search(/\*$/) < 0){
label = label + " *";
}
$(this).addClass("floatl__input").attr('placeholder', label);
$(this).wrap('
');
if (result > 0) {
$(this).find('option:first').text(label).attr('disabled', true);
} else {
$(this).prepend("");
}
});
}
//Append * to placeholder if field is required
this.jCurrentForm.find('.productFormLabel').each(function() {
if($(this).hasClass('productFormLabelRequired')){
var fieldPlaceHolder= $('[name=' + $(this).attr('for') + ']').attr('placeholder');
if (fieldPlaceHolder && fieldPlaceHolder!=''){
if(fieldPlaceHolder.search(/\*$/) < 0) {
$('[name=' + $(this).attr('for') + ']').attr('placeholder', fieldPlaceHolder + " *");
}
}
}
});
if (this.jCurrentForm.find("input[type=radio]").length) {
$("input:radio").parent('li').parent('ul.formRow').removeClass('floatl');
var x = $('input:radio').parent('li.productInputGroup').siblings('li');
$(x).children('label').removeClass('floatl__label');
}
var _this = this; //Set context
if (this.allowedDomain) {
this.jCurrentForm.append('');
this.jCurrentForm.append('');
_this.addEloquaEvents();
}
if (this.jCurrentForm.hasClass('enableValidation')) {
if (this.allowedDomain) {
this.jCurrentForm.find('.submitButton, #submitButton').bind('click', function() {
$(jCurrentForm).find(".captcha_label").addClass("productFormLabelRequired");
_this.submitAjaxForm();
});
if (this.jCurrentForm.find("input[name=form-captcha-required]").val() == "Y") {
$(jCurrentForm).find(".captcha_label").addClass("productFormLabelRequired");
_this.startValidation(_this.jCurrentForm);
} else {
_this.startValidation(_this.jCurrentForm); // starts form validation
}
} else {
this.jCurrentForm.find('.submitButton, #submitButton').bind('click', function() {
$(jCurrentForm).find(".captcha_label").addClass("productFormLabelRequired");
_this.submitAjaxForm();
});
if (this.jCurrentForm.find("input[name=form-captcha-required]").val() == "Y") {
$(jCurrentForm).find(".captcha_label").addClass("productFormLabelRequired");
_this.startValidation(_this.jCurrentForm);
} else {
_this.startValidation(_this.jCurrentForm); // starts form validation
}
//2/14/17
/*this.jCurrentForm.find('.submitButton').bind('click', function() {
$('#contactForm input[name=form-captcha-required]').each(function() {
if ($(this).val() == "Y") {
// if(jcap(_this.jCurrentForm)){
_this.submitAjaxForm();
// }
} else {
_this.submitAjaxForm();
}
});
});
*/
//2/14/17
/* if(this.jCurrentForm.find("input[name=form-captcha-required]").val() == "Y"){
$.getScript("/global-scripts/jcap.js",function(){
sjcap(_this.jCurrentForm);
_this.startValidation(_this.jCurrentForm); // starts form validation after sjcap()
});
}*/
}
}
var form_activity = "";
this.jCurrentForm.find('.form_confirm_asset').bind('click', function() {
form_activity += $(this).attr('href') + ' ';
_this.jCurrentForm.find('.form_activity').val(form_activity);
});
this.jCurrentForm.find('input.form_page').val(document.URL); // Sets #form_page input value
var urlParams = new _this.urlObj();
var pageUrl = new _this.urlObj();
var wtsrchUrl = this.getParameterByName('wt.srch');
if (wtsrchUrl) {
this.jCurrentForm.find('input.form_s_data').val('CAMPAIGN_' + wtsrchUrl);
}
if (urlParams.intcmp) {
this.jCurrentForm.find('input.form_s_data').val(urlParams.intcmp);
}
if (urlParams.cmpid) {
this.jCurrentForm.find('input.form_s_data').val('CAMPAIGN_' + urlParams.cmpid);
}
if (urlParams.elqcampaignid) {
this.addInputField(this.jCurrentForm, {
"elqCampaignId": urlParams.elqcampaignid
});
}
//added experian marketing channel variable on 05/29/14
if (urlParams.emc) {
this.addInputField(this.jCurrentForm, {
"emc": urlParams.emc
});
}
if (urlParams.sfls) {
this.addInputField(this.jCurrentForm, {
"crm_lead_source": urlParams.sfls
});
}
if (urlParams.sfcmp) {
this.addInputField(this.jCurrentForm, {
"crm_od_campaign_code": urlParams.sfcmp
});
}
if (!$('li.loadingwheel').length) $('').appendTo(this.jCurrentForm.find(".submitButton").parent("ul")); // append loading wheel to page
populateForm = function() {
_this.jCurrentForm.find("#first_name_input").val(_this.pageUrl.fname);
_this.jCurrentForm.find("#last_name_input").val(_this.pageUrl.lname);
_this.jCurrentForm.find("#company_input").val(_this.pageUrl.company);
_this.jCurrentForm.find("#email_input").val(_this.pageUrl.email);
};
populateForm();
},
/**
* Add Eloqua events to lookup data by email
*/
addEloquaEvents: function() {
/*var _this = this;
$("#email_input").blur(function() {
var email = $('input[name=email]').val();
if (email != null && email != '') {
if (_this.instance_dir != null && _this.instance_dir == 'CSDA') {
window._elqQ.push(['elqDataLookup', escape('0eb306957d604777bbfd5e258f176e8a'), '' + email + '']);
}
else if (_this.instance_dir != null && _this.instance_dir == 'PRES'){
window._elqQ.push(['elqDataLookup', escape('fed177acf4d44f239c71227163166388'), '' + email + '']);
}
else {
window._elqQ.push(['elqDataLookup', escape('9f7f4d648ec54d5e8f978a32c25f9641'), '' + email + '']);
}
}
});*/
},
// check for BIS on experian.com
checkHubspot: function($form){
var hname = window.location.hostname,
pname = window.location.pathname;
if (hname.indexOf("experian.com") > -1 && pname.split("/")[1]=='business-information') {
return true;
}else if (hname.indexOf("experian.com") > -1 && pname.split("/")[1]=='partner-solutions') {
return true;
}else{
return false;
}
},
// Submit form to HubSpot
submitHubspotForm: function(form) {
// Map page slugs to the corresponding form in Hubspot
var hsFormMap = {
'business-information-c': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'main-street-report':'ade136ca-5883-41bd-9b66-c9ed8de42290',
'credit-management': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'credit-risk-management': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'data-contribution': 'e111f0fb-4b5f-4660-a1ab-451c54b4336a',
'businessiq-offer': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'credit-management-businessiq-demo': 'cf4f87b4-0e7b-42ca-b4b7-e08078a536fe',
'bis-inquiry': 'cf4f87b4-0e7b-42ca-b4b7-e08078a536fe',
'businessiq-premier-profile': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'international-business-credit-reports': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'business-owner-background-reports': '1223d04b-32b1-437c-a75e-7b1c7ec13177',
'business-marketing': '9458a64d-3443-4aba-a7ae-2f619bb5f684',
'sip-and-solve': 'e258e420-bec5-4f67-9d54-4c5247e530fd',
};
var hsFormMapECS = {
'creditlock': '08816de5-7f4c-4654-ae6f-3c89904ab221',
'white-label-identity-protection': '356c2344-cf9e-4f37-a9af-0292c3749d61'
};
// Map field names to their equivalent properties in Hubspot
var hsPropertiesMap = {
'first_name': 'firstname',
'last_name': 'lastname',
'title': 'jobtitle',
'company': 'company',
'street_address': 'address',
'city': 'city',
'state': 'state_exp',
'zip': 'zip',
'country': 'country',
'email': 'email',
'phone': 'phone',
'other2': 'to_help_us_respond_to_your_request_please_tell_us_about_yourself_',
'other1': 'please_explain_your_questions_as_completely_as_possible_',
'comments': 'comments',
'number_of_employees': 'customer_base',
'other50':'leadsource'
};
// Get the Hubspot form submission URL
var hsAction = false;
// Select the correct page
var page = document.location.pathname.split('/');
page = page[page.length - 1].replace('.html', '');
if (typeof hsFormMap[page] !== 'undefined') {
hsAction = 'https://forms.hubspot.com/uploads/form/v2/464374/' + hsFormMap[page];
}
if (typeof hsFormMapECS[page] !== 'undefined') {
hsAction = 'https://forms.hubspot.com/uploads/form/v2/3219183/' + hsFormMapECS[page];
}
if (hsAction) {
// other1 is a different field on this page
if (page === 'data-contribution') {
hsPropertiesMap.other1 = 'i_understand_that_this_is_for_business_data_and_not_consumer_data';
}
// Iterate through the fields, get their values, and put them into the Hubspot form fields
var hsFields = {};
Object.keys(hsPropertiesMap).forEach(function(fieldName, index) {
var value = '';
var field = form.find('[name="' + fieldName + '"]');
if (field.is('select')) {
value = field.find('option:selected').val();
} else if (field.attr('type') === 'radio' || field.attr('type') === 'checkbox') {
if (field.length > 1) {
field.filter(':checked').each(function () {
value += $(this).val() + ', ';
});
value.substring(0, value.length - 3);
} else {
value = field.is(':checked') ? 'Yes' : 'No';
}
} else {
value = field.val();
}
if (value) {
hsFields[hsPropertiesMap[fieldName]] = value;
}
});
// Add in some HS metadata
hsFields.hs_context = JSON.stringify({
'hutk': document.cookie.replace(/(?:(?:^|.*;\s*)hubspotutk\s*\=\s*([^;]*).*$)|^.*$/, "$1"),
'pageUrl': document.location.href,
'pageName': $('title').text()
});
// Finally, send it off!
this.makeAjaxRequest(hsAction, hsFields).done(function (response) {
}).fail(function(jqXHR, textStatus) {
});
}
},
//Submit AjaxForm
submitAjaxForm: function() {
var _this = this;
if(this.jCurrentForm.find(".submitButton").hasClass('disabled')){
return false;
}
var currentPage = window.location.href;
var clean_url = currentPage.replace(/(^\w+:|^)\/\//, '');
if (_this.jCurrentForm.find('input[name="page_clean"]').length == 0) {
this.jCurrentForm.append(''); }
if (_this.jCurrentForm.find('input[name="marketing_channel"]').length == 0) {
if(typeof s !== "undefined"){
//Marketing Attribution
var str = document.referrer;
if(!s.c_r('mark_attr') && str.indexOf('https://www.experian.com/') == 0){
var cvalue = ['internal referrer', 'www.experian.com', 'n/a', 'n/a'];
var ma_cookie = cvalue[0] + "|" + cvalue[1] + "|" + cvalue[2] + "|" + cvalue[3];
s.c_w('mark_attr', ma_cookie);
}
if(s.c_r('mark_attr')){
var ma_exp = s.c_r('mark_attr');
var ma_exp = ma_exp.split("|");
var ma_channel = ma_exp[0];
var ma_refDomain = ma_exp[1];
var ma_campaign = ma_exp[2];
var ma_campaignID = ma_exp[3];
}
_this.jCurrentForm.append('');
_this.jCurrentForm.append('');
_this.jCurrentForm.append('');
_this.jCurrentForm.append('');
}
}
//if (_this.allowedDomain) {
if (arrayContains(this.currentDomain, this.getConfigValue('enableTracking'))) {
this.successID = s.marketingCloudVisitorID +':'+$.now();
if (_this.jCurrentForm.find('input[name="visitorId"]').length == 0) {
_this.jCurrentForm.append('');
_this.jCurrentForm.append('');
}
}
this.resetFormStatus();
this.finalValidation(this.jCurrentForm);
var redirecturl = document.URL.split("#")[0];
redirecturl = redirecturl.replace(/(\&|\?)?(fname|lname|company|email)=[^\&]*/gi, ''); // strip out populateform params from redirect
postform = function() {
_this.jCurrentForm.find(".submitButton").addClass('disabled');
_this.jCurrentForm.find(".loadingwheel").show();
var firstNameValue = _this.jCurrentForm.find('input[name="first_name"]').val(); // Get first name
var lastNameValue = _this.jCurrentForm.find('input[name="last_name"]').val(); // Get last name
_this.jCurrentForm.find('input[name="realname"]').val(firstNameValue + " " + lastNameValue); // Set realname value
_this.jCurrentForm.find('input[name="redirect"]').val(redirecturl); // sets required redirect param
_this.jCurrentForm.find('#StreetAddress__label').attr('for', 'street_address'); // correct for legacy form
_this.jCurrentForm.find('#StreetAddress_input').attr('name', 'street_address'); // correct for legacy form
_this.addInputField(_this.jCurrentForm, {
"enc": ''
});
// Append campaign values for experian.com
if (_this.allowedDomain) {
var externalcampaigns = _this.readCampaignsFromCookies('extrnl_cmpcd_');
var internalcampaigns = _this.readCampaignsFromCookies('intrnl_cmpcd_');
_this.addInputField(_this.jCurrentForm, {
"extrnl_campaign": externalcampaigns
});
_this.addInputField(_this.jCurrentForm, {
"intrnl_campaign": internalcampaigns
});
var referrer_type = _this.extractAnalyticsValues();
_this.addInputField(_this.jCurrentForm, {
"referrer_type": referrer_type
});
}
// appending sitecat tags as a hidden fields to the form when it gets submitted
if (typeof expProductGrp != "undefined") {
_this.addInputField(_this.jCurrentForm, {
"product_group": expProductGrp
});
} else if (typeof expProductGrp == null) {
return false;
}
if (typeof expBUSegment != "undefined") {
_this.addInputField(_this.jCurrentForm, {
"business_segment": expBUSegment
});
} else if (typeof expBUSegment == null) {
return false;
}
if (typeof expBUPartner != "undefined") {
_this.addInputField(_this.jCurrentForm, {
"business_unit": expBUPartner
});
} else if (typeof expBUPartner == null) {
return false;
}
if (typeof expChannel != "undefined") {
_this.addInputField(_this.jCurrentForm, {
"channel": expChannel
});
} else if (typeof expChannel == null) {
return false;
}
//construct leadData object
_this.leadData = {
"firstName": firstNameValue,
"lastName": lastNameValue,
"email": _this.jCurrentForm.find('input[name="email"]').val(),
"phone": _this.jCurrentForm.find('input[name="phone"]').val()
};
adjustObjectProperty = function (obj, propertyToChange, newValue) {
for(var i = 0; i < obj.length; i++) {
if (obj[i].name == propertyToChange) {
obj[i].value = newValue;
}
}
},
sanitizeSubmitForm = function(obj){
var moreInfoProductForm = document.forms['more_info_product'],
//selectedFormValue = document.querySelector("select[name='contact_reason']").value,
selectedFormValue = _this.jCurrentForm.find('select[name="contact_reason"]').val(),
defaultEmail = document.querySelector("input[name='recipient_email']").value;
// Logic 1 - only execute on particular form : "more_info_product"
if (moreInfoProductForm && selectedFormValue == 'Technical Support') {
adjustObjectProperty(obj, 'recipient_email', _this.getConfigValue('devExperianEmail'))
} else {
adjustObjectProperty(obj, 'recipient_email', defaultEmail)
};
return jQuery.param(obj);
},
submitForm = function() {
//If doing ajax add a field for backend
_this.addInputField(_this.jCurrentForm, {
"suppressRedirect": true
});
var submitForm = _this.makeAjaxRequest(_this.submitUrl, this.sanitizeSubmitForm(_this.jCurrentForm.serializeArray()));
if(_this.checkHubspot(_this.jCurrentForm)){
//if BIS on experian.com run submitHubspotForm
_this.submitHubspotForm(_this.jCurrentForm);
}
submitForm.done(function(data) {
_this.formSubmitSucess(data);
}).fail(function(data) {
_this.formSubmitError(data);
});
}
//Make call to QAS and verify email
if (_this.edqEnabled) {
var verifyEmail = _this.verifyEmail(_this.jCurrentForm.find('input[name="email"]').val());
//Submit form on QAS response
verifyEmail.done(function(qasResponse) {
//Create edq payload from qasResponse
var edqStatus = {};
if (qasResponse.hasOwnProperty('Message')) edqStatus.Message = qasResponse.Message;
if (qasResponse.hasOwnProperty('Certainty')) edqStatus.Certainty = qasResponse.Certainty;
if (qasResponse.hasOwnProperty('Corrections')) edqStatus.Corrections = qasResponse.Corrections;
_this.addInputField(_this.jCurrentForm, edqStatus);
submitForm();
});
verifyEmail.fail(function(qasResponse) {
_this.addInputField(_this.jCurrentForm, qasResponse);
});
} else {
submitForm();
}
};
if (_this.jCurrentForm.find(".notvalid").length < 1) {
if (_this.jCurrentForm.find(".formsummary").length > 0) {
_this.displayFormSummary(this.jCurrentForm);
} else {
postform();
}
}
},
/**
* Verifies email via edq
* @param {string} email - Email to verify
*/
verifyEmail: function(email) {
var _this = this;
var emailPayload = {
"Email": email,
"Timeout": _this.getConfigValue('qasTimeout')
};
var qasPromise =
$.ajax({
type: 'POST',
url: _this.getConfigValue('qasUrl'),
data: JSON.stringify(emailPayload),
processData: false,
contentType: 'application/json',
beforeSend: function(request) {
request.setRequestHeader("Auth-Token", _this.getConfigValue('qasToken'));
}
});
var qasDeffered = $.Deferred();
qasPromise.then(function(data) {
if (((_this.getConfigValue('qasDisallow').length) && (data.hasOwnProperty('Certainty')) &&
(arrayContains(data['Certainty'], _this.getConfigValue('qasDisallow')))) ||
(_this.getConfigValue('qasshowCorrections') && data.hasOwnProperty('Corrections') && data.Corrections.length > 0)) {
var errorMessage = _this.getConfigValue('qasMessages')['default'];
if (_this.getConfigValue('qasMessages').hasOwnProperty(data.Certainty)) {
errorMessage = _this.getConfigValue('qasMessages')[data.Certainty];
}
if (data.hasOwnProperty('Corrections') && data.Corrections.length > 0) {
errorMessage = "";
for (var i = 0; i < data.Corrections.length; i++) {
errorMessage += "Did you mean " + data.Corrections[i] + "" + "? Yes | No";
if (i > 0) errorMessage += ", ";
}
}
_this.addNotValidClass('email');
_this.showErrorMessage(errorMessage);
if (data.hasOwnProperty('Corrections')) _this.addEmailEvents(data.Corrections.join(", "));
return;
} else {
qasDeffered.resolve(data);
}
}, function(jqXHR) {
var edqErrorMessage = jqXHR.getResponseHeader('Message') ? jqXHR.getResponseHeader('Message') : "Failed to connect to EDQ";
var errorObject = '{"Message": "' + jqXHR.status + ", " + edqErrorMessage + '"}';
_this.addInputField(_this.jCurrentForm, JSON.parse(errorObject));
qasDeffered.resolve(errorObject);
});
return qasDeffered.promise();
},
/**
* Display error message
* @param {string} errormessage - Error message to display
*/
showErrorMessage: function(errormessage) {
this.resetFormStatus();
var errorMsg = "" + errormessage + "
";
$('li.submitButton').parent("ul").append(errorMsg);
$('p.errmessage').closest('div.formRow').css('width', '100%');
},
/**
* Reset contact form (Hide Spinner, remove error message and enable submit button)
*/
resetFormStatus: function() {
this.jCurrentForm.find(".loadingwheel").hide();
this.jCurrentForm.find('.errmessage').remove();
this.jCurrentForm.find(".submitButton").removeClass('disabled');
this.jCurrentForm.find("#elqMessage").html('');
},
//Contact form submission completed
formSubmitSucess: function(data) {
//Reset QAS status
if (typeof window.qasCorrect !== 'undefined') window.contactFormConfig.qasshowCorrections = window.qasCorrect;
var _this = this;
//$.modal.impl.close();
if ($('.modal').is(":visible")) $('.modal').modal('hide');
if (window.location.href.indexOf("/innovation/subscription") > -1) {} else {
if (typeof s != 'undefined') {
_satellite.track("formsuccess");
}
}
if (_this.jCurrentForm.find('input[type="hidden"][name="tt"]').val() == 'yes') {
// not implemented for consumer
} else if (_this.jCurrentForm.find('input[type="hidden"][name="tt"]').val() == 'yes-enterprise') {
try {
mboxDefineExperianBus(this.jCurrentForm.find('.formConfirmation').attr('id'), _this.pageUrl.pageId + '_modal_form-success');
mboxUpdateExperianBus(_this.pageUrl.pageId + '_modal_form-success');
} catch (e) {}
}
//If redirect
if (_this.jCurrentForm.find('input[type="hidden"][class="form_redirect"]').length > 0) {
var redirectLink = _this.jCurrentForm.find('input[type="hidden"][name="link"]').val();
if (redirectLink != '' && redirectLink != null) {
if (/^(ftp|http|https):\/\/[^ "]+$/.test(redirectLink)) {
window.location = redirectLink;
} else {
window.location.href = redirectLink;
}
}
}
try {
modalSubmitSuccess(data, _this.leadData); // Will try to call modalSubmitSuccess function. This function can be implemented somewhere else.
} catch (e) {}
//var $urlVal = this.jCurrentForm.find('input[name="link"]').length > 0;
// legacy forms end
$(':input', this.jCurrentForm).not(':button, :submit, :reset, :hidden, :radio, :checkbox').val('').removeAttr('selected');
$('input:checkbox').removeAttr('checked');
_this.jCurrentForm.find('input[name="visitorId"]').remove();
_this.jCurrentForm.find('input[name="formSuccessId"]').remove();
if (_this.jCurrentForm.find('input[name="channel"]').length > 0 && this.jCurrentForm.find('input[name="channel"]').val() != '') {
_this.jCurrentForm.find('input[name="channel"]').remove();
_this.jCurrentForm.find('input[name="business_unit"]').remove();
_this.jCurrentForm.find('input[name="business_segment"]').remove();
_this.jCurrentForm.find('input[name="product_group"]').remove();
}
if (_this.jCurrentForm.find('input[name="marketing_channel"]').length > 0 && this.jCurrentForm.find('input[name="marketing_channel"]').val() != '') {
_this.jCurrentForm.find('input[name="marketing_channel"]').remove();
_this.jCurrentForm.find('input[name="referring_domain"]').remove();
_this.jCurrentForm.find('input[name="external_campaign_tracking_code"]').remove();
_this.jCurrentForm.find('input[name="marketing_channel_full"]').remove();
_this.jCurrentForm.find('input[name="page_clean"]').remove();
}
$("#recaptcha_reload").click();
$("#recaptcha_switch_img").click();
$('#errorMsg').hide();
_this.jCurrentForm.find(".loadingwheel").hide();
_this.jCurrentForm.find(".submitButton").removeClass('disabled');
if (_this.jCurrentForm.find('input[name="link"]').length > 0 && _this.jCurrentForm.find('input[name="link"]').val() != '') {
var url = _this.jCurrentForm.find('input[name="link"]').val();
_this.currentURL = url;
} else {
if (_this.jCurrentForm.find('.formConfirmation').length > 0) { // display form confirmation modal if it exists
_this.jCurrentForm.find('.formConfirmation').modal();
}
// legacy forms with #productContactForm
else if (_this.jCurrentForm.next('#formConfirmation').length > 0) { // display form confirmation modal if it exists
_this.jCurrentForm.next('#formConfirmation').modal();
}
}
//Eloqua Integrated Marketing event listener
if (this.eloquaDomain) {
if (_this.jCurrentForm.find('input[type="hidden"][name="google_conversion_tracking"]').val() == 'Y') {
var elqPage = window.location.href;
return gtag_report_conversion(elqPage);
}
}
},
/**
* Form submit error (Reset form and show error)
*/
formSubmitError: function(data) {
/* Captcha error */
var captchaError;
if (data && data.status === 400 && data.responseText) {
captchaError = (data.responseText).indexOf("captcha error") > -1;
}
/* On failed captcha -> reload captcha, reset captcah field and display captcha error */
if (captchaError) {
$("#recaptcha_reload").click();
this.showErrorMessage(this.getConfigValue('captchaMessage'));
$('#recaptcha_response_field').val('');
$('li.AdvcaptchaBox').parent('ul.productInputGroup ').removeClass('valid').addClass('notvalid');
$('li.captchaBox').parent('ul.productInputGroup ').removeClass('valid').addClass('notvalid');
}
/* Generic error -> reset form and display generic error */
else {
this.resetFormStatus();
this.showErrorMessage(this.getConfigValue('formErrorMessage'));
}
$("#elqMessage").hide();
},
/**
* Add events for email validation (click to copy etc)
*/
addEmailEvents: function(correctemail) {
var _this = this;
this.jCurrentForm.find('a.corrected, a.correctLink').on('click', function(e) {
e.preventDefault();
$('input[name="email"]').val($(this).data('email'));
_this.finalValidation();
$('p.errmessage').html('');
});
this.jCurrentForm.find('a.notCorrectLink').on('click', function(e) {
e.preventDefault();
_this.removeNotValidClass('email');
$('p.errmessage').html('');
window.qasCorrect = window.contactFormConfig.qasshowCorrections;
window.contactFormConfig.qasshowCorrections = false;
});
},
/**
* Start Validation on key press
*/
startValidation: function() {
var _this = this;
this.jCurrentForm.find('.productFormLabel').each(function() {
var fieldName = $(this).attr('for');
var jThis;
var testType;
/* $('#phone_input').bind('keyup', function() {
if ($("#phone_input").val()) {
$("#phone_label").addClass('productFormLabelRequired');
if ($(this.jCurrentForm).hasClass('productFormLabelRequired')) {
testType = "testValue";
}
} else {
$("#phone_label").removeClass('productFormLabelRequired');
$("#phone_label").parent().removeClass("labelnotvalid");
}
});*/
if ($(this).hasClass('productFormLabelRequired')) {
var labelText = $(this).text();
if (labelText.search(/\*$/) < 0) {
$(this).text(labelText + " *");
}
testType = "testValue";
} else {
testType = "testLength";
}
if ($('.productTextField[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productTextField[name=' + fieldName + ']');
jAutoCapFrst = _this.jCurrentForm.find('.productTextField[name=first_name]');
jAutoCapLst = _this.jCurrentForm.find('.productTextField[name=last_name]');
jThis.bind('keyup', function() {
_this.setValueAsActive(jThis, fieldName); // set values at keyup
});
jThis.bind('blur', function() {
if (jThis.val()) _this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
if (jAutoCapFrst || jAutoCapLst) {
$(jAutoCapFrst).keyup(function(evt) {
var txt = $(this).val();
$(this).val(txt.replace(/^(.)|\s(.)/g, function($1) {
return $1.toUpperCase();
}));
});
$(jAutoCapLst).keyup(function(evt) {
var txt = $(this).val();
$(this).val(txt.replace(/^(.)|\s(.)/g, function($1) {
return $1.toUpperCase();
}));
});
}
} else if ($('.productTextArea[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productTextArea[name=' + fieldName + ']');
jThis.bind('keyup', function() {
_this.setValueAsActive(jThis, fieldName); // set values at keyup
});
jThis.bind('blur', function() {
_this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
} else if ($('.productRadioInput[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productRadioInput[name=' + fieldName + ']');
jThis.bind('click', function() {
_this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
} else if ($('.productCheckInput[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productCheckInput[name=' + fieldName + ']');
jThis.bind('click', function() {
_this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
} else if ($('.productSelectField[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productSelectField[name=' + fieldName + ']');
jThis.bind('click', function() {
_this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
}
/*else if ($('#recaptcha_response_field[name=recaptcha_response_field]').length > 0) {
jThis = _this.jCurrentForm.find('#recaptcha_response_field[name=recaptcha_response_field]');
jThis.bind('keyup', function() {
_this.setValueAsActive(jThis, fieldName); // set values at keyup
});
jThis.bind('blur', function() {
_this.setValues(_this.jCurrentForm, jThis, fieldName, testType); // set values at blur
});
}*/
else if ($('.captcha_label').length > 0) {
jThis = _this.jCurrentForm.find('#caps');
$('#caps').bind('click', function() {
_this.setValues(_this.jCurrentForm, jThis, 'form-captcha', 'testCaptcha'); // set values at blur
});
}
});
},
/**
* Final Validation before submit
*/
finalValidation: function() {
var _this = this;
this.jCurrentForm.find('.productFormLabel').each(function() {
if ($(this).hasClass('productFormLabelRequired')) {
var fieldName = $(this).attr('for');
var jThis;
if ($('.productTextField[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productTextField[name=' + fieldName + ']');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
} else if ($('.productTextArea[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productTextArea[name=' + fieldName + ']');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
} else if ($('.productRadioInput[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productRadioInput[name=' + fieldName + ']');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
} else if ($('.productCheckInput[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productCheckInput[name=' + fieldName + ']');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
} else if ($('.productSelectField[name=' + fieldName + ']').length > 0) {
jThis = _this.jCurrentForm.find('.productSelectField[name=' + fieldName + ']');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
}
/*else if ($('#recaptcha_response_field[name=recaptcha_response_field]').length > 0) {
jThis = _this.jCurrentForm.find('#recaptcha_response_field[name=recaptcha_response_field]');
_this.setValues(_this.jCurrentForm, jThis, fieldName, "testValue");
}*/
else if ($('.captcha_label').length > 0) {
jThis = _this.jCurrentForm.find('#caps');
_this.setValues(_this.jCurrentForm, jThis, 'form-captcha', 'testCaptcha'); // set values at blur
}
}
});
},
/**
* Add active class
*/
setValueAsActive: function(jThis, req) {
if (jThis.parents('.productInputGroup').hasClass('activeField')) {
jThis.parents('.productInputGroup').removeClass('activeField');
}
if (jThis.parents('.productInputGroup').hasClass('notvalid')) {
jThis.parents('.productInputGroup').removeClass('notvalid');
}
if (jThis.parents('.productInputGroup').hasClass('valid')) {
jThis.parents('.productInputGroup').removeClass('valid');
}
var thisLabel = $(".productLabelGroup label[for=" + req + "]").parents(".productLabelGroup");
if (thisLabel.hasClass("labelnotvalid")) {
thisLabel.removeClass("labelnotvalid");
}
jThis.parents('.productInputGroup').addClass('activeField');
return;
},
/**
* Toggle valid, invalid classes
*/
addNotValidClass: function(fieldname) {
this.jCurrentForm.find(".productLabelGroup label[for=" + fieldname + "]").parents(".productLabelGroup").addClass("labelnotvalid");
this.jCurrentForm.find("input[name=" + fieldname + "]").parents('.productInputGroup').addClass('notvalid');
},
/**
* Toggle valid, invalid classes
*/
removeNotValidClass: function(fieldname) {
this.jCurrentForm.find(".productLabelGroup label[for=" + fieldname + "]").parents(".productLabelGroup").removeClass("labelnotvalid");
this.jCurrentForm.find("input[name=" + fieldname + "]").parents('.productInputGroup').removeClass('notvalid');
},
/**
* Toggle valid, invalid classes
*/
setValues: function(jCurrentForm, jThis, req, testType) {
//If it is dropdown and vaue is null, select the first value
if (jThis.is('select') && !jThis.val()) jThis.prop('selectedIndex', 0);
var fieldValue = jThis.val();
var fieldClass = jThis.attr("class");
var testClass;
if (testType != "testCaptcha") {
testClass = this.testLength(req, fieldValue, fieldClass);
} else {
testClass = "valid";
}
if (testType == "testValue" && testClass == "valid") {
testClass = this.testValue(req, fieldValue, fieldClass);
}
//captcha
if (testType == "testCaptcha" && testClass == "valid") {
testClass = this.testCaptcha(req, fieldValue);
}
if (jThis.parents('.productInputGroup').hasClass('activeField')) {
jThis.parents('.productInputGroup').removeClass('activeField');
}
if (jThis.parents('.productInputGroup').hasClass('notvalid')) {
jThis.parents('.productInputGroup').removeClass('notvalid');
}
if (jThis.parents('.productInputGroup').hasClass('valid')) {
jThis.parents('.productInputGroup').removeClass('valid');
}
// set input validation class
jThis.parents('.productInputGroup').addClass(testClass);
// set label validation class
var thisLabel = this.jCurrentForm.find(".productLabelGroup label[for=" + req + "]").parents(".productLabelGroup");
if (thisLabel.hasClass("labelnotvalid")) {
thisLabel.removeClass("labelnotvalid");
}
if (testClass == "notvalid") {
thisLabel.addClass("labelnotvalid");
}
return;
},
/**
* Check response add class (valid or invalid)
*/
testCaptcha: function(fieldname, fieldvalue) {
var captchaResponse = grecaptcha.getResponse();
if (captchaResponse.length == 0) {
testClass = "notvalid";
} else {
testClass = "valid";
}
return testClass;
},
/**
* Check length of input field and add class (valid or invalid)
*/
testLength: function(fieldName, fieldValue, fieldClass) {
var state = "state";
var country = "country";
var phone = "phone";
var best_contact_time = "best_contact_time";
var email = 'Email';
var email2 = 'Email Address'; // covers legacy forms that use Email Address
var email3 = 'email';
var testClass;
//Support recaptcha on legacy forms (without class on recaptcha field)
if ($('#recaptcha_response_field').length > 0 && !$('#recaptcha_response_field').attr('class')) $('#recaptcha_response_field').addClass('productTextField');
if (fieldClass.indexOf("productTextArea") > -1) {
if (fieldValue.length < 2048) {
testClass = "valid";
} else {
testClass = "notvalid";
}
} else if (fieldClass.indexOf("productCheckInput") > -1) { // check input values are usually very descriptive
if (fieldValue.length < 2048) {
testClass = "valid";
} else {
testClass = "notvalid";
}
} else {
switch (fieldName) {
case state:
if (fieldValue != null && fieldValue.length < 64) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case country:
if (fieldValue != null && fieldValue.length < 100) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case phone:
if (fieldValue != null && fieldValue.length < 50 && fieldValue != "") {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case best_contact_time:
if (fieldValue.length < 100) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case email: //form v1
case email2: //form v1
case email3:
if (fieldValue != null && fieldValue.length < 128) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
default:
if (fieldValue != null && fieldValue.length < 128) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
}
}
return testClass;
},
/**
* Regex validation on input fields
*/
testValue: function(fieldName, fieldValue, fieldClass) {
var email = 'Email';
var email2 = 'Email Address'; // covers legacy forms that use Email Address
var email3 = 'email';
var phone = "phone";
var emailTest = /\b[\w._%+-]+@(?:[\w-]+\.)+[\w]{2,15}\b/;
var phoneTest1 = /^\(?([0-9]{3})\)?[- ]?([0-9]{3})[- ]?([0-9]{4})$/;
var phoneTest = /^[+0-9-() ]{3,20}$/;
//var textTest = /^[^\s](.+)?(\s+)?(.+)?(\s+)?$/;
var textTest = /^[^\s]/;
var testClass;
if (fieldClass == "productRadioInput") {
if ($("input:radio:checked[name=" + fieldName + "]").length > 0) {
testClass = "valid";
} else {
testClass = "notvalid";
}
} else if (fieldClass == "productCheckInput") {
if ($("input:checkbox:checked[name=" + fieldName + "]").length > 0) {
testClass = "valid";
} else {
testClass = "notvalid";
}
} else if (fieldClass == "productSelectField include") {
if (fieldValue.length > 0) {
testClass = "valid";
} else {
testClass = "notvalid";
}
} else {
switch (fieldName) {
case email: //form v1
if (emailTest.test(fieldValue)) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case email2: //form v1
if (emailTest.test(fieldValue)) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case email3: //form v2
if (emailTest.test(fieldValue)) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
case phone:
if (phoneTest.test(fieldValue) && fieldValue != null) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
default:
if (textTest.test(fieldValue)) {
testClass = "valid";
} else {
testClass = "notvalid";
}
break;
}
}
return testClass;
},
/**
* Show form summary in a modal
*/
displayFormSummary: function(jCurrentForm) {
var formfields = this.jCurrentForm.serializeArray();
var submitBtn = this.jCurrentForm.find('.formsummarySubmitBtn');
var clearBtn = this.jCurrentForm.find('.formsummaryClearBtn');
var formSummaryContainer = this.jCurrentForm.find(".formsummary");
var formDetailsContainer = this.jCurrentForm.find(".formsummaryDetails");
var labeltxt, formfieldindex, nextfield;
jQuery.each(formfields, function(i, field) {
if (field.value != "" && this.jCurrentForm.find("[type!=hidden][name=" + field.name + "]").length > 0) {
formfieldindex = "formfield_" + i;
if (field.name != formfields[i - 1].name) {
labeltxt = this.jCurrentForm.find("label[class^='productFormLabel'][for=" + field.name + "]").text().split("*")[0];
formDetailsContainer.append('' + '' + labeltxt + '' + '' + field.value + '' + '');
nextfield = i + 1;
while (typeof formfields[nextfield] != 'undefined' && formfields[i].name == formfields[nextfield].name) {
$("#" + formfieldindex).append('' + formfields[nextfield].value + '');
++nextfield;
}
}
}
});
formSummaryContainer.modal({
onShow: function(dialog) {
dialog.container.width(600);
$(window).trigger('resize.simplemodal'); // required for ie6 to resize modal
},
onClose: function() {
$.modal.impl.close();
this.jCurrentForm.find(".formsummaryDetails").empty();
}
});
submitBtn.hover(function() {
submitBtn.addClass('cursor');
}, function() {
submitBtn.removeClass('cursor');
});
submitBtn.bind('click', function() {
$.modal.impl.close();
postform();
});
clearBtn.hover(function() {
clearBtn.addClass('cursor');
}, function() {
clearBtn.removeClass('cursor');
});
clearBtn.bind('click', function() {
$.modal.impl.close();
this.jCurrentForm.find(".formsummaryDetails").empty();
});
},
/**
* Set Cookie
*/
setCookie: function(name, value, date) {
var today = new Date();
today.setTime(today.getTime());
var expires = 30 * 1000 * 60 * 60 * 24;
var expires_date = new Date(today.getTime() + (expires));
var path = "/";
document.cookie = name + "=" + escape(value) +
((expires) ? ";expires=" + expires_date.toGMTString() : "") +
((path) ? ";path= /" : "");
},
getCookie: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
},
checkCookie: function(cookie_val, cookie_type) {
var ext_cookie_name = 'extrnl_cmpcd_';
var int_cookie_name = 'intrnl_cmpcd_';
var prefix_cookie_name = '';
if (cookie_type == 'E') {
prefix_cookie_name = ext_cookie_name;
} else {
prefix_cookie_name = int_cookie_name;
}
var cookie_name = null;
var ext_cookie_val = null;
var current_cookie_pos = 0;
var curr_cookie_pos = 0;
//Loop Exterior cookie
for (i = 1; i < 100; i++) {
cookie_name = prefix_cookie_name + i;
ext_cookie_val = this.getCookie(cookie_name);
if (ext_cookie_val == null) {
curr_cookie_pos = i;
break;
}
}
//Strip out # if necessary
cookie_val = cookie_val.replace(/#$/, "");
cookie_name = prefix_cookie_name + curr_cookie_pos;
this.setCookie(cookie_name, cookie_val, new Date());
},
trackExternalCampaigns: function() {
if (this.pageUrl.cmpid != null) {
this.checkCookie(this.pageUrl.cmpid, 'E');
}
if (this.wtsrchUrl != null) {
this.checkCookie(this.wtsrchUrl, 'E');
}
},
trackInternalCampaigns: function() {
if (this.pageUrl.intcmp != null) {
this.checkCookie(this.pageUrl.intcmp, 'I');
}
},
readCampaignsFromCookies: function(prefix_cookie_name) {
var cookie_name;
var all_cookie_values;
var cookie_value;
for (i = 100; i > 0; i--) {
cookie_name = prefix_cookie_name + i;
cookie_value = this.getCookie(cookie_name);
if (cookie_value != null) {
if (all_cookie_values != null) {
all_cookie_values = all_cookie_values + ", " + cookie_value;
} else {
all_cookie_values = cookie_value;
}
}
}
return all_cookie_values;
},
setAutoCookie: function() {
this.setCookie("NotAutoPop", "1");
$("input[name=first_name]").val("");
$("input[name=last_name]").val("");
$("input[name=company]").val("");
$("input[name=email]").val("");
$("input[name=phone]").val("");
$("input[name=city]").val("");
$("input[name=state]").val("");
$("input[name=country]").val("");
$("input[name=zip]").val("");
$("input[name=title]").val("");
$("input[name=street_address]").val("");
$("#elqMessage").css("display", "none");
},
/**
* Initialize Eloqua
*/
initEloqua: function() {
var context = this;
var _this = this;
var checkCk = this.getCookie('NotAutoPop');
var checkCondition = checkCk != null && checkCk == 1;
// Generating Eloqua Cookie
this.instance_dir = 'CSDA';
if (!checkCondition) {
if (this.allowedDomain) {
if (this.urlSearch("/about-us/") || this.urlSearch("/test/") || this.urlSearch("/automotive/") || this.urlSearch("/consumer-information/") || this.urlSearch("/business-information/") || this.urlSearch("/rentbureau/") || this.urlSearch("/credit-unions/") || this.urlSearch("/corporate/") || this.urlSearch("/data-breach/") || this.urlSearch("/events/") || this.urlSearch("/consulting-service/") || this.urlSearch("/decision-analytics/") || this.urlSearch("/strategy-management/") || this.urlSearch("/government/") || this.urlSearch("/communications-energy/") || this.urlSearch("/business-resources/") || this.urlSearch("/marketing-resources/") || this.urlSearch("/business-services/") || this.urlSearch("/public-sector/") || this.urlSearch("/vision/") || this.urlSearch("/poc/") || this.urlSearch("/cheetahmail/") || this.urlSearch("/dataselect/") || this.urlSearch("/marketing-services/") || this.urlSearch("/simmons-research/") || this.urlSearch("/hitwise/") || document.location.hostname == 'go.experian.com') {
this.instance_dir = 'EMS';
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '2448']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
var timerId = null;
var timeout = 5;
window.WaitUntilCustomerGUIDIsRetrieved = function() {
if (!!(timerId)) {
if (timeout == 0) {
return;
}
if (typeof GetElqCustomerGUID === 'function') {
var getGUID = GetElqCustomerGUID();
getGUID = getGUID.toUpperCase().replace(/[_\W]+/g, "");
$("input[name='elqCustomerGUID']").val(getGUID);
return;
}
timeout -= 1;
}
timerId = setTimeout("WaitUntilCustomerGUIDIsRetrieved()", 500);
return;
};
window.onload = WaitUntilCustomerGUIDIsRetrieved;
window._elqQ.push(['elqGetCustomerGUID']);
window._elqQ.push(['elqDataLookup', escape('30ee8cd1c6d540d9aa67b636e12e22bc'), '']);
} else if (this.urlSearch("/small-business/") || this.urlSearch("/innovation/")) {
this.instance_dir = 'EMS';
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '2448']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
var timerId = null;
var timeout = 5;
window.WaitUntilCustomerGUIDIsRetrieved = function() {
if (!!(timerId)) {
if (timeout == 0) {
return;
}
if (typeof GetElqCustomerGUID === 'function') {
var getGUID = GetElqCustomerGUID();
getGUID = getGUID.toUpperCase().replace(/[_\W]+/g, "");
$("input[name='elqCustomerGUID']").val(getGUID);
return;
}
timeout -= 1;
}
timerId = setTimeout("WaitUntilCustomerGUIDIsRetrieved()", 500);
return;
};
window.onload = WaitUntilCustomerGUIDIsRetrieved;
window._elqQ.push(['elqGetCustomerGUID']);
window._elqQ.push(['elqDataLookup', escape('30ee8cd1c6d540d9aa67b636e12e22bc'), '']);
} else if (this.urlSearch("/healthcare/") || document.location.hostname == 'now.experian.com') {
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '476064971']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
var timerId = null,
timeout = 5;
window.WaitUntilCustomerGUIDIsRetrieved = function() {
if (!!(timerId)) {
if (timeout == 0) {
return;
}
if (typeof GetElqCustomerGUID === 'function') {
var getGUID = GetElqCustomerGUID();
getGUID = getGUID.toUpperCase().replace(/[_\W]+/g, "");
$("input[name='elqCustomerGUID']").val(getGUID);
return;
}
timeout -= 1;
}
timerId = setTimeout("WaitUntilCustomerGUIDIsRetrieved()", 500); //not global
return;
};
window.onload = WaitUntilCustomerGUIDIsRetrieved;
window._elqQ.push(['elqGetCustomerGUID']);
window._elqQ.push(['elqDataLookup', escape('4f82c1b55b93429cbff2bd27bc2c7d37'), '']);
} else if (this.urlSearch("/innovation/subscription")) {
this.instance_dir = 'PRES';
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '2448']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
var timerId = null;
var timeout = 5;
window.WaitUntilCustomerGUIDIsRetrieved = function() {
if (!!(timerId)) {
if (timeout == 0) {
return;
}
if (typeof GetElqCustomerGUID === 'function') {
var getGUID = GetElqCustomerGUID();
getGUID = getGUID.toUpperCase().replace(/[_\W]+/g, "");
$("input[name='elqCustomerGUID']").val(getGUID);
return;
}
timeout -= 1;
}
timerId = setTimeout("WaitUntilCustomerGUIDIsRetrieved()", 500);
return;
};
window.onload = WaitUntilCustomerGUIDIsRetrieved;
window._elqQ.push(['elqGetCustomerGUID']);
window._elqQ.push(['elqDataLookup', escape('30ee8cd1c6d540d9aa67b636e12e22bc'), '']);
}
window.SetElqContent = function() {
if (window.GetElqContentPersonalizationValue) {
if (_this.instance_dir != null && _this.instance_dir == 'CSDA') {
var email = GetElqContentPersonalizationValue('V_ElqEmailAddress');
//autopopulate CSDA block
if (email != null && email != '') {
//window._elqQ.push(['elqDataLookup', escape('0eb306957d604777bbfd5e258f176e8a'), '' + email + '']);
} else {
var c_email = GetElqContentPersonalizationValue('C_EmailAddress');
if (c_email != null && c_email != '') {
// contactFormApp.setFormFields();
$(".floatl").each(function(index) {
new Floatl($(this));
});
}
}
} else if (_this.instance_dir != null && _this.instance_dir == 'PRES') {
var email = GetElqContentPersonalizationValue('V_ElqEmailAddress');
//autopopulate EMS block
if (email != null && email != '') {
// window._elqQ.push(['elqDataLookup', escape('fed177acf4d44f239c71227163166388'), '' + email + '']);
} else {
var c_email_pres = GetElqContentPersonalizationValue('Email_Address1');
if (c_email_pres != null && c_email_pres != '') {
//contactFormApp.setFormFields();
$(".floatl").each(function(index) {
new Floatl($(this));
});
}
}
} else {
var email = GetElqContentPersonalizationValue('V_ElqEmailAddress');
//autopopulate EMS block
if (email != null && email != '') {
//window._elqQ.push(['elqDataLookup', escape('9f7f4d648ec54d5e8f978a32c25f9641'), '' + email + '']);
} else {
var c_email = GetElqContentPersonalizationValue('C_EmailAddress');
contactFormApp.loadTrackingDetails();
if (c_email != null && c_email != '') {
//contactFormApp.setFormFields();
$(".floatl").each(function(index) {
new Floatl($(this));
});
}
}
}
}
var elqCheckFirst = $("input[name=first_name]").val();
var elqCheckLast = $("input[name=last_name]").val();
var msgexists = $("#elqMessage").length;
if (elqCheckFirst) {
if (!msgexists) {
$('#contactForm form').prepend('If you are not
' + elqCheckFirst + ' ' + elqCheckLast + ' click here ');
$(".msg").css("cursor", "pointer");
}
}
};
}
} else {
this.setAutoCookie();
$("#elqMessage").hide();
if (this.urlSearch("/cheetahmail/") > -1 || this.urlSearch("/dataselect/") > -1 || this.urlSearch("/marketing-services/") > -1 || this.urlSearch("/simmons-research/") > -1 || this.urlSearch("/hitwise/") > -1) {
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '2448']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
} else {
window._elqQ = window._elqQ || [];
window._elqQ.push(['elqSetSiteId', '476064971']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqTrackPageView']);
window._elqQ.push(['elqGetCustomerGUID']);
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//img.en25.com/i/elqCfg.min.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
else if (window.attachEvent) window.attachEvent('onload', async_load);
})();
}
}
},
/**
* Set form fields with Eloqua stored data
*/
setFormFields: function() {
var c_email = GetElqContentPersonalizationValue('C_EmailAddress');
var firstname = GetElqContentPersonalizationValue('C_FirstName');
var lastname = GetElqContentPersonalizationValue('C_LastName');
var company = GetElqContentPersonalizationValue('C_Company');
var phone = GetElqContentPersonalizationValue('C_BusPhone');
var mobile = GetElqContentPersonalizationValue('C_MobilePhone');
var city = GetElqContentPersonalizationValue('C_City');
var state = GetElqContentPersonalizationValue('C_State_Prov');
var country = GetElqContentPersonalizationValue('C_Country');
var zip = GetElqContentPersonalizationValue('C_Zip_Postal');
var job_title = GetElqContentPersonalizationValue('C_Job_Role1');
var address1 = GetElqContentPersonalizationValue('C_Address1');
var job_role = GetElqContentPersonalizationValue('C_Job_Role1');
var industry = GetElqContentPersonalizationValue('C_Industry1');
var c_email_pres = GetElqContentPersonalizationValue('Email_Address1');
var firstname_pres = GetElqContentPersonalizationValue('First_Name1');
var lastname_pres = GetElqContentPersonalizationValue('Last_Name1');
var company_pres = GetElqContentPersonalizationValue('Company1');
var phone_pres = GetElqContentPersonalizationValue('Business_Phone1');
var mobile_pres = GetElqContentPersonalizationValue('Mobile_Phone1');
var state_pres = GetElqContentPersonalizationValue('State1');
var country_pres = GetElqContentPersonalizationValue('Country1');
var job_title_pres = GetElqContentPersonalizationValue('Job_Title1');
var rent_bureau = GetElqContentPersonalizationValue('Rent_Bureau1');
var credit_cornerstone = GetElqContentPersonalizationValue('Credit_Corenerstone1');
var experian_insights = GetElqContentPersonalizationValue('Experian_Insights1');
var public_sector = GetElqContentPersonalizationValue('Public_Sector1');
var iet_automotive = GetElqContentPersonalizationValue('IET___Automotive1');
var iet_business_information = GetElqContentPersonalizationValue('IET___Business_Information1');
var iet_credit_services = GetElqContentPersonalizationValue('IET___Consumer_Credit_Services1');
var iet_decision_analytics = GetElqContentPersonalizationValue('IET___Decision_Analytics1');
var iet_fraud_solutions = GetElqContentPersonalizationValue('IET___Fraud___Identity_Solutions1');
var pi_automotive = GetElqContentPersonalizationValue('PI___Automotive1');
var pi_business_information = GetElqContentPersonalizationValue('PI___Business_Information1');
var pi_credit_services = GetElqContentPersonalizationValue('PI___Consumer_Credit_Services1');
var pi_fraud_solutions = GetElqContentPersonalizationValue('PI___Fraud___Identity_Solutions1');
var pi_decision_analytics = GetElqContentPersonalizationValue('PI___Decision_Analytics1');
var sms_approval = GetElqContentPersonalizationValue('SMS_Approval1');
var casl_compliance = GetElqContentPersonalizationValue('CASL_Compliance1');
var first_name_val = this.container.find("input[name=first_name]").val();
var last_name_val = this.container.find("input[name=last_name]").val();
var company_val = this.container.find("input[name=company]").val();
var email_val = this.container.find("input[name=email]").val();
var phone_val = this.container.find("input[name=phone]").val();
var mobile_val = this.container.find("input[name=mobileNumber]").val();
var city_val = this.container.find("input[name=city]").val();
var state_droplist_val = this.container.find("select[name=state]").val();
var state_val = this.container.find("input[name=state]").val();
var country_val = this.container.find("input[name=country]").val();
var country_droplist_val = this.container.find("select[name=country]").val();
var zip_val = this.container.find("input[name=zip]").val();
var title_val = this.container.find("input[name=title]").val();
var title_droplist_val = this.container.find("select[name=title]").val();
var role_val = this.container.find("input[name=jobFunction]").val();
var street_address_val = this.container.find("input[name=street_address]").val();
var industry_droplist_val = this.container.find("select[name=industry]").val();
var rent_bureau_val = this.container.find("#10004").is(":checked");
var public_sector_val = this.container.find("#10006").is(":checked");
var experian_insights_val = this.container.find("#10002").is(":checked");
var credit_cornerstone_val = this.container.find("#10000").is(":checked");
var iet_automotive_val = this.container.find("#10008").is(":checked");
var iet_business_information_val = this.container.find("#10012").is(":checked");
var iet_credit_services_val = this.container.find("#10016").is(":checked");
var iet_decision_analytics_val = this.container.find("#10010").is(":checked");
var iet_fraud_solutions_val = this.container.find("#10014").is(":checked");
var pi_automotive_val = this.container.find("#10018").is(":checked");
var pi_business_information_val = this.container.find("#10022").is(":checked");
var pi_credit_services_val = this.container.find("#10026").is(":checked");
var pi_decision_analytics_val = this.container.find("#10020").is(":checked");
var pi_fraud_solutions_val = this.container.find("#10024").is(":checked");
var sms_approval_val = this.container.find("#0547").is(":checked");
var casl_compliance_val = this.container.find("#10030").is(":checked");
if (!rent_bureau_val) {
if (rent_bureau == 'Yes') {
this.container.find("input[id=10004]").prop('checked', true);
}
}
if (!credit_cornerstone_val) {
if (credit_cornerstone == 'Yes') {
this.container.find("input[id=10000]").prop('checked', true);
}
}
if (!experian_insights_val) {
if (experian_insights == 'Yes') {
this.container.find("input[id=10002]").prop('checked', true);
}
}
if (!public_sector_val) {
if (public_sector == 'Yes') {
this.container.find("input[id=10006]").prop('checked', true);
}
}
if (!iet_automotive_val) {
if (iet_automotive == 'Yes') {
this.container.find("input[id=10008]").prop('checked', true);
}
}
if (!iet_business_information_val) {
if (iet_business_information == 'Yes') {
this.container.find("input[id=10012]").prop('checked', true);
}
}
if (!iet_credit_services_val) {
if (iet_credit_services == 'Yes') {
this.container.find("input[id=10016]").prop('checked', true);
}
}
if (!iet_decision_analytics_val) {
if (iet_decision_analytics == 'Yes') {
this.container.find("input[id=10010]").prop('checked', true);
}
}
if (!iet_fraud_solutions_val) {
if (iet_fraud_solutions == 'Yes') {
this.container.find("input[id=10014]").prop('checked', true);
}
}
if (!pi_automotive_val) {
if (pi_automotive == 'Yes') {
this.container.find("input[id=10018]").prop('checked', true);
}
}
if (!pi_business_information_val) {
if (pi_business_information == 'Yes') {
this.container.find("input[id=10022]").prop('checked', true);
}
}
if (!pi_credit_services_val) {
if (pi_credit_services == 'Yes') {
this.container.find("input[id=10026]").prop('checked', true);
}
}
if (!pi_fraud_solutions_val) {
if (pi_fraud_solutions == 'Yes') {
this.container.find("input[id=10024]").prop('checked', true);
}
}
if (!pi_decision_analytics_val) {
if (pi_decision_analytics == 'Yes') {
this.container.find("input[id=10020]").prop('checked', true);
}
}
if (!sms_approval_val) {
if (sms_approval == 'Yes') {
this.container.find("input[id=0547]").prop('checked', true);
}
}
if (!casl_compliance_val) {
if (casl_compliance == 'Yes') {
this.container.find("input[id=10030]").prop('checked', true);
}
}
if (first_name_val == null || first_name_val == '') {
if (!firstname_pres) {
this.container.find("input[name=first_name]").val(firstname);
} else {
this.container.find("input[name=first_name]").val(firstname_pres);
}
}
if (last_name_val == null || last_name_val == '') {
if (!lastname_pres) {
this.container.find("input[name=last_name]").val(lastname);
} else {
this.container.find("input[name=last_name]").val(lastname_pres);
}
}
if (company_val == null || company_val == '') {
if (!company_pres) {
this.container.find("input[name=company]").val(company);
} else {
this.container.find("input[name=company]").val(company_pres);
}
}
if (email_val == null || email_val == '') {
if (!c_email_pres) {
this.container.find("input[name=email]").val(c_email);
} else {
this.container.find("input[name=email]").val(c_email_pres);
}
}
if (phone_val == null || phone_val == '') {
if (!phone_pres) {
this.container.find("input[name=phone]").val(phone);
} else {
this.container.find("input[name=phone]").val(phone_pres);
}
}
if (mobile_val == null || mobile_val == '') {
if (!mobile_pres) {
this.container.find("input[name=mobileNumber]").val(mobile);
} else {
this.container.find("input[name=mobileNumber]").val(mobile_pres);
}
}
if (city_val == null || city_val == '') {
this.container.find("input[name=city]").val(city);
}
if (state_droplist_val == null || state_droplist_val == '') {
if (!state_pres) {
this.container.find("input[name=state]").val(state);
} else {
this.container.find("input[name=state]").val(state_pres);
}
}
if (state_val == null || state_val == '') {
if (!state_pres) {
this.container.find("input[name=state]").val(state);
} else {
this.container.find("input[name=state]").val(state_pres);
}
}
if (country_droplist_val == null || country_droplist_val == '') {
if (!country_pres) {
this.container.find("select[name=country]").val(country);
} else {
this.container.find("select[name=country]").val(country_pres);
}
}
if (country_val == null || country_val == '') {
if (!country_pres) {
this.container.find("select[name=country]").val(country);
} else {
this.container.find("select[name=country]").val(country_pres);
}
}
if (zip_val == null || zip_val == '') {
this.container.find("input[name=zip]").val(zip);
}
if (title_val == null || title_val == '') {
if (!job_title_pres) {
this.container.find("select[name=title]").val(job_title);
} else {
this.container.find("select[name=title]").val(job_title_pres);
}
}
if (role_val == null || role_val == '') {
this.container.find("input[name=jobFunction]").val(job_role);
}
if (title_droplist_val == null || title_droplist_val == '') {
if (!job_title_pres) {
this.container.find("select[name=title]").val(job_title);
} else {
this.container.find("select[name=title]").val(job_title_pres);
}
}
if (industry_droplist_val == null || industry_droplist_val == '') {
this.container.find("select[name=industry]").val(industry);
}
if (street_address_val == null || street_address_val == '') {
this.container.find("input[name=street_address]").val(address1);
}
this.finalValidation($('#contactForm'));
},
/**
* Read analytics cookie and return it
*/
getAnalyticsCookie: function(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
},
/**
* Return value of analytics cookie extracted earlier (@getAnalyticsCookie)
*/
getAnalyticsCookieValue: function(cookieValue, key) {
var keyValue = cookieValue.match(key + '=([^;|]*)([|]|$)');
return keyValue ? keyValue[1] : null;
},
/**
* Read cookie extracted earlier (@getAnalyticsCookie) and process them
*/
extractAnalyticsValues: function() {
var cookieValue = this.getAnalyticsCookie('__utmz');
if (cookieValue == null || cookieValue == '') {
return '';
} else {
var s = this.getAnalyticsCookieValue(cookieValue, 'utmcsr');
var c = this.getAnalyticsCookieValue(cookieValue, 'utmccn');
var m = this.getAnalyticsCookieValue(cookieValue, 'utmcmd');
var ppc = this.getAnalyticsCookieValue(cookieValue, 'utmgclid');
var ctr = this.getAnalyticsCookieValue(cookieValue, 'utmctr');
if (ppc !== null) {
return 'PPC';
}
if ((c === '(organic)' && m === 'organic')) {
return 'Organic';
}
if ((c === '(referral)' && m === 'referral')) {
return 'Referral - ' + s; // add referral source to token
}
if (c === "(direct)" && m === "(none)") {
return 'Direct';
}
return s;
}
},
/**
* Create a global object to store query parametres
*/
urlObj: function() {
var rawpathname = location.pathname.substring(1);
rawpathname = rawpathname.split(".");
this.pageId = rawpathname[0].replace("/", "_");
if (document.URL.indexOf('?') > 0) {
this.urlArray = document.URL.split('?');
this.paramString = this.urlArray[1];
this.paramArray = this.paramString.split('&');
for (var i = 0; i < this.paramArray.length; i++) {
var pair = this.paramArray[i].split('=');
var urlkey = pair[0].toLowerCase();
this[urlkey] = pair[1];
}
}
},
/*for wt.srch*/
getParameterByName: function(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\./g, ""));
},
/**
* Add global functions (jquery exist method and arraycontains method)
*/
addGlobalFunctions: function() {
//Add indexOf function for IE <= 9
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/ ) {
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++) {
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
jQuery.fn.exists = function() {
return this.length > 0;
};
window.arrayContains = function(string, array) {
return (array.indexOf(string) > -1);
};
},
/**
* Ensure that s variables are set
*/
ensureSisSet: function() {
return new Promise(function(resolve, reject) {
(function waitForS() {
if (s.marketingCloudVisitorID && s.pageURL) return resolve();
setTimeout(waitForS, 30);
})();
});
},
/**
* Pass tracking information on a payload
*/
loadTrackingDetails: function() {
//var brokenCookie = this.getCookie("e");
this.ensureSisSet().then(function() {
var myObj = {
"visitorId": GetElqCustomerGUID(),
"maId": s.marketingCloudVisitorID,
"page": s.pageURL
};
$(function() {
$.ajax({
type: "POST",
data: JSON.stringify(myObj),
//processData: false,
url: '//www.experian.com/innovation/integration/visitor-sync', //change to prod
contentType: "application/json",
beforeSend: function(request) {
request.setRequestHeader("Accept", 'application/json');
}
});
});
});
},
/**
* Support legacy forms
*/
/*addLegacySupport: function() {
var _this = this;
//IF IE9, use EDQ Proxy
if (document.addEventListener && !window.requestAnimationFrame) {
$.getScript('http://www.experian.com/global-scripts/content/xdomainrequest.js');
contactFormConfig.qasUrl = "http://" + contactFormConfig.proxyIP;
contactFormApp.submitUrl = contactFormConfig.proxyUrl;
$('#contactForm form').append('');
}
// legacy forms require these additional hidden fields
$("#productContactForm").prepend("");
//Support legacy form built using jquery 1.3 and jquery simple modal
var legacyModal = ($('.formConfirmation').find('.modal-dialog').length < 1 && $('.formConfirmation').find('.modal-content').length < 1 && typeof($.fn.modal) === 'undefined');
if (legacyModal) {
legacyContactForm();
}
//Bad html, remove an empty 'editorcontent' div that is overlapping 'Validated by' message
if ($('#contactForm').exists()) {
$('#contactForm').find(".editorcontent").each(function() {
if (($(this).is(':empty') || $(this).val() == "") && ($(this).html().trim() === "")) {
$(this).css('width', '1px');
}
});
}
}*/
};
$(document).ready(function() {
//Inititalize Contact Form
contactFormApp.init();
});
/* Staging dont have mbox */
if (typeof mboxCreateExperianBus !== 'function') {
var mboxCreateExperianBus = {};
var mboxUpdateExperianBus = {};
var mboxDefineExperianBus = {};
}
/* Support super old forms (To be removed) */
window.initAjaxForm = function(form) {
form.parent('div').attr('id', 'contactForm')
}