var SessionID = "a5j3db43sp1brln0x2rx4orx";
var KeepSession = true, MaxHardValidationFailures = 3, MaxSteps = 8, LastStringToRecover = "", RecoveryMode = false, SliderMode = false, HardValidationFailure = 0, LastDupeScanPhone1 = "", LastDupeScanPhone2 = "", LastDupeScanEmail = "", LastValidated = {}, LastCount = {}, StepsWidth = new Array(), currentStep = 1, postingPage = "/schoolselection.aspx", LastAskUserShowAdditionalSchools = "", isIE7 = (($.browser.msie && parseInt($.browser.version) < 8 && !document.documentMode) || (document.documentMode && document.documentMode == 7)); function textslider() { if (true) { var $this = jQuery(this), label = jQuery('label[for=' + this.id + ']'); if (label.size() == 0) { return; } var wrapper = jQuery('<div class="compactlabel-wrapper"></div>'); $this.wrap(wrapper); $this.before(label); var backing = jQuery('<div class="compactlabel-label-backing"></div>').insertBefore($this).height(label.height() + 5).width(label.width() + 6), labelOffset = label.position(), inputOffset = $this.position(), labelHeight = label.outerHeight(), isHover = false, isFocus = false, animatedElements = jQuery(backing.get()).add(label.get()), on = function (event) { $this.parent().addClass('compactlabel-wrapper-on'); animatedElements.stop().animate({ "top": '-' + (labelHeight - inputOffset.top) + 'px' }); }; var off = function (event) { if (isHover || isFocus) { return; } if (inputEmpty) { label.removeClass('compactlabel-hide'); } else { label.addClass('compactlabel-hide'); } if (!inputEmptyChange) { animatedElements.stop(); } animatedElements.animate({ "top": labelOffset.top + 'px' }, function () { $this.parent().removeClass('compactlabel-wrapper-on'); }); }; var onHover = function (event) { isHover = true; on(event); }; var offHover = function (event) { isHover = false; off(event); }; var onFocus = function (event) { isFocus = true; on(event); }; var offFocus = function (event) { isFocus = false; off(event); }; var inputEmpty = false, inputEmptyStart = false, inputEmptyChange = false, checkInputEmpty = function () { inputEmpty = $this.val() == ''; }; checkInputEmpty(); var checkInputEmptyFnID = null; if (!inputEmpty) { label.addClass('compactlabel-hide'); } $this.focus(function () { inputEmptyStart = inputEmpty; inputEmptyChange = false; checkInputEmptyFnID = setInterval(checkInputEmpty, 50); }); $this.blur(function () { clearInterval(checkInputEmptyFnID); checkInputEmpty(); inputEmptyChange = inputEmptyStart != inputEmpty; }); $this.focus(onFocus); $this.blur(offFocus); $this.hover(onHover, offHover); label.hover(onHover, offHover); } } function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(emailAddress); } function SaveSession() { if (KeepSession) { var save = $('#formDF').find('input,textarea,text,select,hidden').serialize() + "&currentStep=" + currentStep; $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/SaveFormState", data: "{ 'sessionid': '" + SessionID + "','serialized': '" + save + "'}", contentType: "application/json; charset=utf-8", dataType: "json" }); } } function showLoader() { $('#divloader').removeClass('loaderHide').addClass('loader'); $('#divcontent').addClass('formFade'); } function hideLoader() { $('#divloader').addClass('loaderHide').removeClass('loader'); $('#divcontent').removeClass('formFade'); } function UpdateMatchCount() { return; } function OtherSchools() { $('input[name=AllowNonChristian]').val('true'); SwitchStep(1); } function NoOtherSchools() { $('input[name=AllowNonChristian]').val('false'); SwitchStep(1); } function validStepServer(step, idx) { var result = LastValidated['currentStep' + currentStep] == undefined ? true : LastValidated['currentStep' + currentStep], items = []; if (HardValidationFailure >= MaxHardValidationFailures) { showLoader(); window.location.href = "/nothankyou.aspx?FirstName=" + $('#FirstName').val(); return; } if (currentStep == 5 && (LastValidated['FirstName'] != $('#FirstName').val() || LastValidated['LastName'] != $('#LastName').val() || LastValidated['Email'] != $('#Email').val())) { result = false; LastValidated['FirstName'] = $('#FirstName').val(); items.push('{"Key":"FirstName","Value":"' + $('#FirstName').val() + '"}'); LastValidated['LastName'] = $('#LastName').val(); items.push('{"Key":"LastName","Value":"' + $('#LastName').val() + '"}'); LastValidated['Email'] = $('#Email').val(); items.push('{"Key":"Email","Value":"' + $('#Email').val() + '"}'); } else if (currentStep == 6 && (LastValidated['StreetAddress'] != $('#StreetAddress').val() || LastValidated['Address2'] != $('#Address2').val() || LastValidated['City'] != $('#City').val() || LastValidated['State'] != $('#State').val() || LastValidated['Country'] != $('#Country').val() || LastValidated['ZipCode'] != $('#ZipCode').val())) { result = false; LastValidated['StreetAddress'] = $('#StreetAddress').val(); items.push('{"Key":"StreetAddress","Value":"' + $('#StreetAddress').val() + '"}'); LastValidated['Address2'] = $('#Address2').val(); items.push('{"Key":"Address2","Value":"' + $('#Address2').val() + '"}'); LastValidated['City'] = $('#City').val(); items.push('{"Key":"City","Value":"' + $('#City').val() + '"}'); LastValidated['State'] = $('#State').val(); items.push('{"Key":"State","Value":"' + $('select[id$=State]').val() + '"}'); LastValidated['Country'] = $('#Country').val(); items.push('{"Key":"Country","Value":"' + $('select[id$=Country]').val() + '"}'); LastValidated['ZipCode'] = $('#ZipCode').val(); items.push('{"Key":"ZipCode","Value":"' + $('#ZipCode').val() + '"}'); } else if (currentStep == 7 && (LastValidated['PhoneNumber'] != $('input[name=PhoneNumber]').val() || LastValidated['AlternatePhoneNumber'] != $('input[name=AlternatePhoneNumber]').val())) { result = false; LastValidated['PhoneNumber'] = $('input[name=PhoneNumber]').val(); items.push('{"Key":"PhoneNumber","Value":"' + $('input[name=PhoneNumber]').val() + '"}'); LastValidated['AlternatePhoneNumber'] = $('input[name=AlternatePhoneNumber]').val(); items.push('{"Key":"AlternatePhoneNumber","Value":"' + $('input[name=AlternatePhoneNumber]').val() + '"}'); items.push('{"Key":"StreetAddress","Value":"' + $('#StreetAddress').val() + '"}'); items.push('{"Key":"City","Value":"' + $('#City').val() + '"}'); items.push('{"Key":"State","Value":"' + $('select[id$=State]').val() + '"}'); items.push('{"Key":"ZipCode","Value":"' + $('#ZipCode').val() + '"}'); items.push('{"Key":"FirstName","Value":"' + $('#FirstName').val() + '"}'); items.push('{"Key":"LastName","Value":"' + $('#LastName').val() + '"}'); } if (items.length > 0) { LastValidated['currentStep' + currentStep] = false; if (currentStep == 7 || currentStep == 6) { showLoader(); } $.ajax({ type: "POST", traditional: true, url: "/ec-dForm/jsonformhelper.asmx/Validate", data: '{"fields":[' + items.join(',') + ']}', contentType: 'application/json; charset=utf-8', dataType: "json", success: function (msg) { var res = msg.d, anyfailed = false, invalidItems = [], validItems = []; for (var item in res) { result = result && res[item].Passed; if (res[item].Passed == false) { anyfailed = true; $("#valText_" + res[item].FormFieldName).html(res[item].SingleFriendlyErrorMessage); invalidItems.push(res[item].FormFieldName); if (res[item].FormFieldName == "PhoneNumber") { invalidItems.push("areacode1", "prefix1", "suffix1"); } else if (res[item].FormFieldName == "AlternatePhoneNumber") { invalidItems.push("areacode2", "prefix2", "suffix2"); } } else { validItems.push(res[item].FormFieldName); if (res[item].FormFieldName == "PhoneNumber") { validItems.push("areacode1", "prefix1", "suffix1"); } else if (res[item].FormFieldName == "AlternatePhoneNumber") { validItems.push("areacode2", "prefix2", "suffix2"); } } } LastValidated['InvalidItems'] = invalidItems; LastValidated['ValidItems'] = validItems; $(invalidItems).each(function () { $('#val_' + this).removeClass('valid').addClass('invalid'); $('#valText_' + this).removeClass('ghostText').addClass('valErrorText'); $('#' + this).addClass('error').removeClass('validBorder'); }); $(validItems).each(function () { $('#val_' + this).removeClass('invalid').addClass('valid'); $('#valText_' + this).removeClass('valErrorText').addClass('ghostText'); $('#' + this).removeClass('error').addClass('validBorder'); }); if (anyfailed) { HardValidationFailure++; } else { LastValidated['currentStep' + currentStep] = true; result = true; } var invalidItems = LastValidated['InvalidItems'], validItems = LastValidated['ValidItems']; $(invalidItems).each(function () { $('#val_' + this).removeClass('valid').addClass('invalid'); $('#valText_' + this).removeClass('ghostText').addClass('valErrorText'); $('#' + this).addClass('error').removeClass('validBorder'); }); $(validItems).each(function () { $('#val_' + this).removeClass('invalid').addClass('valid'); $('#valText_' + this).removeClass('valErrorText').addClass('ghostText'); $('#' + this).removeClass('error').addClass('validBorder'); }); hideLoader(); if (result) { SwitchStepAsync(idx); } }, error: function () { hideLoader(); result = false; }, async: true }); } else if (currentStep == 5 || currentStep == 6 || currentStep == 7) { var invalidItems = LastValidated['InvalidItems'], validItems = LastValidated['ValidItems']; $(invalidItems).each(function () { $('#val_' + this).removeClass('valid').addClass('invalid'); $('#valText_' + this).removeClass('ghostText').addClass('valErrorText'); $('#' + this).addClass('error').removeClass('validBorder'); }); $(validItems).each(function () { $('#val_' + this).removeClass('invalid').addClass('valid'); $('#valText_' + this).removeClass('valErrorText').addClass('ghostText'); $('#' + this).removeClass('error').addClass('validBorder'); }); } if (result) { SwitchStepAsync(idx); } } function validStep(step) { var invalidItems = [], validItems = [], postvalItems = [], selects = $(step).find('select[required=""],select[required="required"]'); $(selects).each(function () { var val = $(this).find('option:selected').val(); if (val == '' || val == 0) { invalidItems.push($(this).attr('id')); $('#' + $(this).attr('id') + '-button').addClass('invalidBorder'); } else { validItems.push($(this).attr('id')); $('#' + $(this).attr('id') + '-button').removeClass('invalidBorder'); } }); var texts = $(step).find('input[type="text"][required=""]'); passedEmail = false; $(texts).each(function () { var val = $(this).val(), minlength = $(this).attr('minlength'), maxlength = $(this).attr('maxlength'); if ($(this).attr('id').toLowerCase().indexOf("email") != -1) { if (val == '' || !isValidEmailAddress(val) || val.length > maxlength || val.length < minlength) { invalidItems.push($(this).attr('id')); $(this).addClass('error').removeClass('validBorder'); } else { postvalItems.push($(this).attr('id')); passedEmail = true; } } else if (val == '' || val.length > maxlength || val.length < minlength) { invalidItems.push($(this).attr('id')); $(this).addClass('error').removeClass('validBorder'); } else if ($(this).attr("id") == "FirstName" || $(this).attr("id") == "LastName" || $(this).attr("id") == "StreetAddress" || $(this).attr("id") == "City" || $(this).attr("id") == "ZipCode" || $(this).attr("id") == "areacode1" || $(this).attr("id") == "prefix1" || $(this).attr("id") == "suffix1" || $(this).attr("id") == "areacode2" || $(this).attr("id") == "prefix2" || $(this).attr("id") == "suffix2") { postvalItems.push($(this).attr('id')); } else { validItems.push($(this).attr('id')); $(this).removeClass('error').addClass('validBorder'); } }); var passedPhone1 = false; if (jQuery.inArray('areacode1', invalidItems) >= 0 || jQuery.inArray('prefix1', invalidItems) >= 0 || jQuery.inArray('suffix1', invalidItems) >= 0) { invalidItems.push('PhoneNumber'); } else if (jQuery.inArray('areacode1', postvalItems) >= 0 || jQuery.inArray('prefix1', postvalItems) >= 0 || jQuery.inArray('suffix1', postvalItems) >= 0) { postvalItems.push('PhoneNumber'); passedPhone1 = true; $('input[name=PhoneNumber]').val($('#areacode1').val() + $('#prefix1').val() + $('#suffix1').val()); } var passedPhone2 = false; if (jQuery.inArray('areacode2', invalidItems) >= 0 || jQuery.inArray('prefix2', invalidItems) >= 0 || jQuery.inArray('suffix2', invalidItems) >= 0) { invalidItems.push('AlternatePhoneNumber'); } else if (jQuery.inArray('areacode2', postvalItems) >= 0 || jQuery.inArray('prefix2', postvalItems) >= 0 || jQuery.inArray('suffix2', postvalItems) >= 0) { postvalItems.push('AlternatePhoneNumber'); passedPhone2 = true; $('input[name=AlternatePhoneNumber]').val($('#areacode2').val() + $('#prefix2').val() + $('#suffix2').val()); } if (passedPhone1 && passedPhone2 && ($('input[name=PhoneNumber]').val() != LastDupeScanPhone1 || $('input[name=AlternatePhoneNumber]').val() != LastDupeScanPhone2)) { LastDupeScanPhone1 = $('input[name=PhoneNumber]').val(); LastDupeScanPhone2 = $('input[name=AlternatePhoneNumber]').val(); $.get('/dupescan.aspx?t1=' + LastDupeScanPhone1 + '&t2=' + LastDupeScanPhone2); } if (passedEmail && $('input[name=Email]').val() != LastDupeScanEmail) { LastDupeScanEmail = $('input[name=Email]').val(); $.get('/dupescan.aspx?e=' + LastDupeScanEmail); } if ($(step).find('#iaControl[required=""]').attr('id') != undefined) { if (getIASelections().indexOf('null') != -1) { invalidItems.push('iaControl'); $('#val_iaControl').addClass('invalidSA'); $('#val_iaControl').html('Interest Area is required.'); } else { $('#val_iaControl').html(''); $('#val_iaControl').removeClass('invalid').removeClass('invalidSA'); } } if ($(step).find('#saControl[required=""]').attr('id') != undefined) { if (getSASelections().indexOf('null') != -1) { invalidItems.push('saControl'); $('#val_saControl').addClass('invalidSA'); $('#val_saControl').html('Please select at least one subject area.'); } else { $('#val_saControl').html(''); $('#val_saControl').removeClass('invalidSA').removeClass('invalid'); } } var radios = $(step).find('input[required=""][type="radio"]'); $(radios).each(function () { if ($(step).find('input[type="radio"][name="' + $(this).attr('name') + '"]:checked').val() == undefined) { invalidItems.push($(this).attr('name')); } else { $('#val_' + $(this).attr('name')).removeClass('invalid'); } }); var checkboxes = $(step).find('input[required=""][type="checkbox"]'); $(checkboxes).each(function () { if ($(this).attr('checked') == undefined) { invalidItems.push($(this).attr('id')); } else { validItems.push($(this).attr('id')); } }); if ($(step).find('#NoOtherSchools').val() != undefined) { if ($('input[name=AllowNonChristian]').val() == "") { invalidItems.push('OtherSchools'); } else { validItems.push('OtherSchools'); } } $(invalidItems).each(function () { $('#val_' + this).removeClass('valid').addClass('invalid'); $('#valText_' + this).removeClass('ghostText').addClass('valErrorText'); }); $(validItems).each(function () { $('#val_' + this).removeClass('invalid').addClass('valid'); $('#valText_' + this).removeClass('valErrorText').addClass('ghostText'); }); $(postvalItems).each(function () { $('#' + this).removeClass('error'); $('#val_' + this).removeClass('invalid'); $('#valText_' + this).removeClass('valErrorText').addClass('ghostText'); }); return $(invalidItems).length == 0; } function TrackStep(idx) { try { if (idx > 1) { lpMTagConfig.vars.push(['ConversionStage', idx]); lpMTagConfig.vars.push(['Section', 'MatchingProcess']); lpSendData(); } } catch (e) { } try { _gaq.push(['_trackPageview', window.location.pathname + '/DripFormStep' + idx]); } catch (e) { } var iFrameDiv = $('#iframediv'), src = "/wt-chrised/DripFormStep?DripFormStep=" + idx; iFrameDiv.html("<iframe width=\"1\" height=\"1\" src=\"" + src + "\"></iframe>"); } function TryPostingServer() { var res = $('#formDF').find('input,textarea,text,select,hidden').not('[name=areacode1]').not('[name=prefix1]').not('[name=suffix1]').not('[name=areacode2]').not('[name=prefix2]').not('[name=suffix2]').not('[id^="iaci"]').not('[id^="saci"]').serialize(); showLoader(); window.location.href = postingPage + "?" + res; } function SwitchStepAsync(idx) { if (currentStep >= 8 && idx > 0) { SaveSession(); LastAskUserShowAdditionalSchools = "true"; if (LastAskUserShowAdditionalSchools == "") { showLoader(); var zipcode = $('#ZipCodeStep1').val(), elevelid = $('select[id$=EducationLevel] option:selected').val(); if (zipcode == undefined) { zipcode = ""; } if (elevelid == undefined) { elevelid = 0; } $.ajax({ type: "POST", traditional: true, url: "/ec-dForm/jsonformhelper.asmx/AskUserShowAdditionalSchools", data: "{ 'saSelected' : " + getSASelections() + ",'iaSelected' : " + getIASelections() + ",'zipcode': '" + zipcode + "','elevelID': '" + elevelid + "','city': '" + $('#City').val() + "','streetaddress': '" + $('#StreetAddress').val() + "','graduationyear': '" + $('select[id$=GraduationYear] option:selected').val() + "','state': '" + $('select[id$=State] option:selected').val() + "'}", contentType: 'application/json; charset=utf-8', dataType: "json", success: function (msg) { if (msg.d.toString() == "true") { LastAskUserShowAdditionalSchools = "true"; hideLoader(); SwitchStepChristian(idx); } else { LastAskUserShowAdditionalSchools = "false"; $('input[name=AllowNonChristian]').val('false'); TryPostingServer(); } } }); } else if (LastAskUserShowAdditionalSchools == "false" || $('input[name=AllowNonChristian]').val() != "") { TryPostingServer(); } else { SwitchStepChristian(idx); } return; } else { SwitchStepChristian(idx); } } function UpdateProgress(idx) { $("#progressbar").progressbar({ value: (idx * 100) / ($('input[name=AllowNonChristian]').val() == "" ? MaxSteps - 1 : MaxSteps) }); } function SwitchStepChristian(idx) { var startidx = idx; UpdateMatchCount(); idx = currentStep + idx; var CStep = $('fieldset[id="stepContent' + idx + '"]'); if (idx < 1 || idx > MaxSteps) { return; } $('#dripStepwrap').removeClass('dripStep' + currentStep).addClass('dripStep' + idx); SliderMode = true; if (isIE7) { $('fieldset:not([id="stepContent' + idx + '"])').each(function () { $(this).attr('style', 'display:none;'); }); CStep.attr('style', 'display:block'); CStep.find("input[type='text']:enabled:first").blur(); SliderMode = false; } if (!isIE7) { $('#stepSlider').stop().animate({ marginLeft: '-' + StepsWidth[idx] + 'px' }, { duration: 500, complete: function () { SliderMode = false; } }); } if (!isIE7) { CStep.find('select').selectmenu(); } CStep.find('input:text').each(textslider); UpdateProgress(idx); currentStep = idx; if (currentStep > 1 && $('#btnPrev').attr("style") && $('#btnPrev').attr("style").length > 0) { $('#btnPrev').fadeIn(550, function () { $(this).attr('style', ''); }); } else if (currentStep == 1 && (!$('#btnPrev').attr("style") || $('#btnPrev').attr("style").length == 0)) { $('#btnPrev').fadeOut(550, function () { $(this).attr("style", "display:none"); }); } TrackStep(currentStep); } function SwitchStep(idx) { if (idx > 0) { if (!validStep($('fieldset[id="stepContent' + currentStep + '"]'))) { return; } else { validStepServer($('fieldset[id="stepContent' + currentStep + '"]'), idx); } } else { SwitchStepAsync(idx); } } function getIASelections() { var items = [], iaSelected = $('input[id^="iaci"]:checked'); $(iaSelected).each(function () { items.push(this.id.replace('iaci_', '')); }); if (items.length > 0) { return "[" + items.join(',') + "]"; } else { return 'null'; } } function getSASelections() { var items = [], iaSelected = $('input[id^="saci"]:checked'); $(iaSelected).each(function () { items.push(this.id.replace('saci_', '')); }); if (items.length > 0) { return "[" + items.join(',') + "]"; } else { return 'null'; } } $(document).ready(function () { var stpwidth = 0, stpi = 1; $('fieldset[id^="stepContent"]').each(function () { StepsWidth[stpi] = stpwidth; stpwidth += $('#divcontent').width(); stpi++; }); var lBoxEducationLevel = $('select[id$=EducationLevel]'); $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchEducationLevel", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var elevel = msg.d; if (elevel.length > 0) { lBoxEducationLevel.empty(); var listItems = []; listItems.push('<option value="0" selected="selected">--SELECT--</option>'); for (var item in elevel) { listItems.push('<option value="' + elevel[item].Key + '">' + elevel[item].Value + '</option>'); } $(lBoxEducationLevel).append(listItems.join('')); if (!isIE7) { $(lBoxEducationLevel).selectmenu(); } } } }); var lBoxYear = $('select[id$=GraduationYear]'), listItemsYear = [], year = new Date().getFullYear(); listItemsYear.push('<option value="0" selected="selected">--SELECT--</option>'); for (i = 0; i <= 40; i++) { listItemsYear.push('<option value="' + (year - i).toString() + '">' + (year - i).toString() + '</option>'); } lBoxYear.empty(); $(lBoxYear).append(listItemsYear.join('')); if (!isIE7) { $(lBoxYear).selectmenu(); } $(lBoxYear).change(function () { TryAutoNextStep1(); }); var lBoxGYear = $('select[id$=ExpectedGY]'), listItemsGYear = []; year = new Date().getFullYear(); listItemsGYear.push('<option value="0" selected="selected">--SELECT--</option>'); for (i = 0; i <= 3; i++) { listItemsGYear.push('<option value="' + (year + i).toString() + '">' + (year + i).toString() + '</option>'); } lBoxGYear.empty(); $(lBoxGYear).append(listItemsGYear.join('')); if (!isIE7) { $(lBoxGYear).selectmenu(); } $(lBoxGYear).change(function () { TryAutoNextStep1(); }); function displaygradyear() { var elevel = $('select[id$=EducationLevel] option:selected').val(); if (elevel == 0) { $('#divGraduate').attr("style", "display:none;"); $('#divExpectGraduate').attr("style", "display:none;"); $('#GraduationYear').removeAttr("required"); $('#ExpectedGY').removeAttr("required"); } else if (elevel == 1 || elevel == 2) { $('#divExpectGraduate').attr("style", ""); $('#divGraduate').attr("style", "display:none;"); $('#GraduationYear').removeAttr("required"); $('#GraduationYear').val(new Date().getFullYear()); $('#ExpectedGY').attr("required", "required").selectmenu('refresh'); } else { $('#divGraduate').attr("style", ""); $('#divExpectGraduate').attr("style", "display:none;"); $('#ExpectedGY').removeAttr("required"); $('#GraduationYear').attr("required", "required").selectmenu('refresh'); } } $(document).keypress(function (e) { if (e.keyCode == 9 || e.which == 9) { e.preventDefault(); } }); $(document).keydown(function (e) { if (e.keyCode == 9 || e.which == 9) { e.preventDefault(); } }); $("#formDF").keydown(function (e) { if (!SliderMode) { if (e.keyCode == 9 || e.which == 9) { e.preventDefault(); var focusables = $('fieldset[id="stepContent' + currentStep + '"]').find(':focusable'), current = focusables.index(e.target), next = focusables.eq(current + 1).length ? focusables.eq(current + 1) : focusables.eq(0); next.focus(); } else if (e.keyCode == 13 || e.which == 13) { SwitchStep(1); } } else { e.preventDefault(); } }); $('#Age').keyfilter(function (a) { var val = $('#Age').val(); return a >= 0 && a <= 9 && val + a > 0 && val + a < 100; }); $('#Age').keyup(function () { TryAutoNextStep2(); }); var zipcode = $('#ZipCodeStep1'), oldZipcode = zipcode.val(); if (oldZipcode != '') { var elevel = $('select[id$=EducationLevel] option:selected').val(); setInterestAreas(oldZipcode, elevel); } zipcode.keyfilter(/[0-9]/i).keyup(function () { interesAreaValidation($(this).val()); TryAutoNextStep2(); }); lBoxEducationLevel.change(function () { interesAreaValidation($(zipcode).val()); displaygradyear(); TryAutoNextStep1(); }); function TryAutoNextStep1() { if ($('select[id$=EducationLevel] option:selected').val() != 0 && ((($('#divGraduate').attr("style") == undefined || $('#divGraduate').attr("style").length == 0) && $('select[id$=GraduationYear] option:selected').val() != 0) || (($('#divExpectGraduate').attr("style") == undefined || $('#divExpectGraduate').attr("style").length == 0) && $('select[id$=ExpectedGY] option:selected').val() != 0))) { SwitchStep(1); } } function TryAutoNextStep2() { if ($('#Age').val().length == 2 && $('#ZipCodeStep1').val().length == 5 && currentStep == 2) { SwitchStep(1); } } function TryAutoNextStep7() { if ($('#areacode1').val().length == 3 && $('#prefix1').val().length == 3 && $('#suffix1').val().length == 4 && $('#areacode2').val().length == 3 && $('#prefix2').val().length == 3 && $('#suffix2').val().length == 4 && $('select[id$=BestTimeToContact] option:selected').val() != 0 && $('select[id$=StartDate] option:selected').val() != 0 && $('select[id$=EmploymentStatus] option:selected').val() != 0) { SwitchStep(1); } } function setCountryStateByZipcode(zipcode) { $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchCountryStateByZipCode", data: "{ 'zipcode': '" + zipcode + "'}", contentType: 'application/json; charset=utf-8', dataType: "json", success: function (msg) { var cs = msg.d; try { if ($('select[id$=Country]').val() != cs.CountryID) { $('select[id$=Country]').val(cs.CountryID); } if ($('select[id$=State]').val() != cs.StateID) { $('select[id$=State]').val(cs.StateID); } if (cs.CityName != '') { $('#City').val(cs.CityName); $('#City').blur(); } } catch (e) { } } }); } $('#FirstName').keyfilter(/[a-z]/i); $('#LastName').keyfilter(/[a-z]/i); $('#Email').keyfilter(/[a-z0-9\.\-\_@]/i); $('#areacode1, #areacode2, #prefix1, #prefix2, #suffix1, #suffix2').keyfilter(/[\d\-\.]/); $('#areacode1, #areacode2, #prefix1, #prefix2, #suffix1, #suffix2').autotab_magic(); $('#areacode1, #areacode2, #prefix1, #prefix2, #suffix1, #suffix2').keyup(function () { TryAutoNextStep7(); }); $("#samePhone").click(function (event) { if ($("#samePhone").is(":checked") && $('#areacode1').val().length == 3 && $('#prefix1').val().length == 3 && $('#suffix1').val().length == 4) { $('#areacode2').val($('#areacode1').val()); $('#prefix2').val($('#prefix1').val()); $('#suffix2').val($('#suffix1').val()); $('input[name=AlternatePhoneNumber]').val($('#areacode2').val() + $('#prefix2').val() + $('#suffix2').val()); } TryAutoNextStep7(); }); $("#checkboxallIA").click(function (event) { $('input[id^="iaci_"]').each(function () { $(this).checked = true; $(this).attr({ "checked": "checked" }); $(this).trigger('change'); }); setSubjectAreas(); $('input[id^="iaci_"]').click(setSubjectAreas); SwitchStep(1); }); $("#uncheckboxallIA").click(function (event) { $('input[id^="iaci_"]').each(function () { $(this).checked = false; $(this).removeAttr('checked'); $(this).trigger('change'); }); setSubjectAreas(); $('input[id^="iaci_"]').click(setSubjectAreas); }); function interesAreaValidation(zipcode) { var elevel = $('select[id$=EducationLevel] option:selected').val(); if (zipcode.length == 5) { $('#ZipCode').val(zipcode); $('#ZipCode').blur(); setInterestAreas(zipcode, elevel); if (oldZipcode != zipcode) { setCountryStateByZipcode(zipcode); } oldZipcode = zipcode; } } function recoverIA() { $("[id^=iaci_]").each(function () { var check = LastStringToRecover.search($(this).attr("name")) > -1; $(this).checked = check; if (check) { $(this).attr({ "checked": "checked" }); } else { $(this).removeAttr('checked'); } $(this).trigger('change'); }); } function recoverSA() { $("[id^=saci_]").each(function () { var check = LastStringToRecover.search($(this).attr("name")) > -1; $(this).checked = check; if (check) { $(this).attr({ "checked": "checked" }); } else { $(this).removeAttr('checked'); } $(this).trigger('change'); }); saChange(); } function setInterestAreas(zipcode, educationlevel) { var iaControl = $('#iaControl'); if (!(educationlevel > 0)) { educationlevel = 0; } $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchInterestAreas", data: "{ 'zipcode': '" + zipcode + "','elevelID': '" + educationlevel + "'}", contentType: 'application/json; charset=utf-8', dataType: "json", success: function (msg) { var ias = msg.d; if (ias.length > 0) { var listItemsIACol1 = [], listItemsIACol2 = [], switchCol = false; for (var item in ias) { if (!switchCol) { listItemsIACol1.push('<li><input type="checkbox" name="iaci_' + ias[item].Key + '" id="iaci_' + ias[item].Key + '" value="' + ias[item].Key + '"><label for="iaci_' + ias[item].Key + '">' + ias[item].Value + '</label></li>'); } else { listItemsIACol2.push('<li><input type="checkbox" name="iaci_' + ias[item].Key + '" id="iaci_' + ias[item].Key + '" value="' + ias[item].Key + '"><label for="iaci_' + ias[item].Key + '">' + ias[item].Value + '</label></li>'); } switchCol = !switchCol; } $(iaControl).html('<div class="subjectScroll"><ul class="interestItem col1" id="IAcol1">' + listItemsIACol1.join('') + '</ul><ul class="interestItem col1" id="IAcol2">' + listItemsIACol2.join('') + '</ul></div>'); $('.subjectScroll').jScrollPane(); if (RecoveryMode) { recoverIA(); } setSubjectAreas(); $('input[id^="iaci_"]').each(function () { }).click(setSubjectAreas); $('input[id^="iaci_"]:checkbox').ezMark({ checkboxCls: 'ez-checkbox', checkedCls: 'ez-checked' }); } } }); } function setSubjectAreas() { $('input[name=AreaOfInterest]').val(getIASelections().replace(/[-[\]{}+\s]/g, '').replace(/[,\s]/g, ';')); var zipcode = $('#ZipCodeStep1').val(), educationlevel = $('select[id$=EducationLevel] option:selected').val(); educationlevel = educationlevel == undefined ? 0 : educationlevel; var saControl = $('#saControl'); $.ajax({ type: "POST", traditional: true, url: "/ec-dForm/jsonformhelper.asmx/FetchSubjectAreas", data: "{ 'iaSelected' : " + getIASelections() + ",'zipcode': '" + zipcode + "','elevelID': '" + educationlevel + "'}", contentType: 'application/json; charset=utf-8', dataType: "json", success: function (msg) { var sas = msg.d; if (sas.length > 0) { var listItemsSACol1 = [], listItemsSACol2 = [], switchCol = false; for (var item in sas) { if (!switchCol) { listItemsSACol1.push('<li><input type="checkbox" name="saci_' + sas[item].Key + '" id="saci_' + sas[item].Key + '" value="' + sas[item].Key + '"><label for="saci_' + sas[item].Key + '">' + sas[item].Value + '</label></li>'); } else { listItemsSACol2.push('<li><input type="checkbox" name="saci_' + sas[item].Key + '" id="saci_' + sas[item].Key + '" value="' + sas[item].Key + '"><label for="saci_' + sas[item].Key + '">' + sas[item].Value + '</label></li>'); } switchCol = !switchCol; } $(saControl).html('<div class="subjectScroll" id="subjectScrollBar"><ul class="subjectItem col1">' + listItemsSACol1.join('') + '</ul><ul class="subjectItem col2">' + listItemsSACol2.join('') + '</ul></div>'); $('.subjectScroll').jScrollPane(); if (RecoveryMode) { recoverSA(); RecoveryMode = false; } $('input[id^="saci_"]').each(function () { }).click(saChange); $('input[id^="saci_"]:checkbox').ezMark({ checkboxCls: 'ez-checkbox', checkedCls: 'ez-checked' }); } } }); } function saChange() { $('input[name=SubjectArea]').val(getSASelections().replace(/[-[\]{}+\s]/g, '').replace(/[,\s]/g, ';')); } $("#checkboxallSA").click(function (event) { $('input[id^="saci_"]').each(function () { $(this).checked = true; $(this).attr({ "checked": "checked" }); $(this).trigger('change'); }); saChange(); $('input[id^="saci"]').click(saChange); SwitchStep(1); }); $("#uncheckboxallSA").click(function (event) { $('input[id^="saci"]').each(function () { $(this).checked = false; $(this).removeAttr('checked'); $(this).trigger('change'); }); saChange(); $('input[id^="saci"]').click(saChange); }); var lBoxCountry = $('select[id$=Country]'); $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchCountryList", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var country = msg.d; if (country.length > 0) { lBoxCountry.empty(); var listItems = []; listItems.push('<option value="0">--SELECT COUNTRY--</option>'); for (var item in country) { if (country[item].Key == "US") { listItems.push('<option value="' + country[item].Key + '" selected="selected">' + country[item].Value + '</option>'); } else { listItems.push('<option value="' + country[item].Key + '">' + country[item].Value + '</option>'); } } $(lBoxCountry).append(listItems.join('')); getStates(); } } }); lBoxCountry.change(function () { getStates(); }); function getStates() { var countryid = $('select[id$=Country] option:selected').val(); if (countryid == "0") { countryid = "US"; } var lBoxStates = $('select[id$=State]'); $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchStateList", data: "{ 'countryID' : '" + countryid + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { var state = msg.d; if (state.length > 0) { lBoxStates.empty(); var listItems = []; listItems.push('<option value="0">--SELECT STATE--</option>'); for (var item in state) { listItems.push('<option value="' + state[item].Key + '">' + state[item].Value + '</option>'); } $(lBoxStates).append(listItems.join('')); } } }); } var lBoxStartDate = $('select[id$="StartDate"]'), StartDate = new Date(), listItemsStartDate = []; listItemsStartDate.push('<option value="0" selected="selected">--SELECT--</option>'); listItemsStartDate.push('<option value="01/' + (StartDate.getMonth() + 1 > 9 ? StartDate.getMonth() + 1 : '0' + (StartDate.getMonth() + 1)) + '/' + StartDate.getFullYear() + '">Immediately</option>'); StartDate.setMonth(StartDate.getMonth() + 1); listItemsStartDate.push('<option value="01/' + (StartDate.getMonth() + 1 > 9 ? StartDate.getMonth() + 1 : '0' + (StartDate.getMonth() + 1)) + '/' + StartDate.getFullYear() + '">1-3 months</option>'); StartDate.setMonth(StartDate.getMonth() + 3); listItemsStartDate.push('<option value="01/' + (StartDate.getMonth() + 1 > 9 ? StartDate.getMonth() + 1 : '0' + (StartDate.getMonth() + 1)) + '/' + StartDate.getFullYear() + '">4-6 months</option>'); lBoxStartDate.empty(); $(lBoxStartDate).append(listItemsStartDate.join('')); lBoxStartDate.change(function () { TryAutoNextStep7(); }); var lBoxBestTimeToContact = $('select[id$="BestTimeToContact"]'); lBoxBestTimeToContact.change(function () { TryAutoNextStep7(); }); var lBoxEmployment = $('select[id$="EmploymentStatus"]'); lBoxEmployment.change(function () { TryAutoNextStep7(); }); function displaymilitary() { if ($(this).attr('id') == "MilitaryAffiliationY") { $('#MilitarySelection').attr("style", ""); } else { $('#MilitarySelection').attr("style", "position: fixed; left: -99999px;"); } } $('#MilitaryAffiliationY').click(displaymilitary); $('#MilitaryAffiliationN').click(displaymilitary); $("#progressbar").progressbar({ value: 100 / ($('input[name=AllowNonChristian]').val() == "" ? MaxSteps - 1 : MaxSteps) }); function LoadSession() { if (KeepSession) { $.ajax({ type: "POST", url: "/ec-dForm/jsonformhelper.asmx/FetchFormState", data: "{ 'sessionid': '" + SessionID + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { if (msg.d != undefined && msg.d != "") { showLoader(); LastStringToRecover = msg.d; RecoveryMode = true; $("#formDF").deserialize(msg.d); setInterestAreas($('#ZipCodeStep1').val(), $('select[id$=EducationLevel] option:selected').val()); displaygradyear(); $('input[type="radio"]:checked').each(function () { $(this).trigger('change'); }); $('input[id="NewsletterOptIn"]:checkbox').trigger('change'); $('input[id="OptinSchoolContact"]:checkbox').trigger('change'); $('input[id="samePhone"]:checkbox').trigger('change'); currentStep = 0; SwitchStep(1); hideLoader(); MaxSteps = $('input[name=AllowNonChristian]').val() == "" ? MaxSteps + 1 : MaxSteps; LastAskUserShowAdditionalSchools = $('input[name=AllowNonChristian]').val(); } else { TrackStep(1); } } }); } } if (KeepSession) { $(window).load(LoadSession); } else { TrackStep(1); } UpdateMatchCount(); MaxSteps = $('input[name=AllowNonChristian]').val() == "" ? MaxSteps + 1 : MaxSteps; LastAskUserShowAdditionalSchools = $('input[name=AllowNonChristian]').val(); $('input[id="NewsletterOptIn"]:checkbox').ezMark({ radioCls: 'ez-checkbox', selectedCls: 'ez-checked' }); $('input[id="OptinSchoolContact"]:checkbox').ezMark({ radioCls: 'ez-checkbox', selectedCls: 'ez-checked' }); $('input[id="samePhone"]:checkbox').ezMark({ radioCls: 'ez-checkbox', selectedCls: 'ez-checked' }); $('input[type="radio"]').ezMark({ radioCls: 'ez-radio', selectedCls: 'ez-checked-big' }); $("p.cta-button a").css({ 'backgroundPosition': '0 0' }).hover(function () { $(this).stop().animate({ 'opacity': 0 }, 650); }, function () { $(this).stop().animate({ 'opacity': 1 }, 650); }); $("p.cta-button-prev a").css({ 'backgroundPosition': '0 0' }).hover(function () { $(this).stop().animate({ 'opacity': 0 }, 650); }, function () { $(this).stop().animate({ 'opacity': 1 }, 650); }); });
