CINXE.COM
Home Page - RSA - CVRT
<!doctype html> <html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8 ie7" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9 ie8" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Home Page - RSA - CVRT</title> <meta name="description" content="Request a test"> <meta name="author" content="IQ Content"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="/Content/css/style.css"> <!--[if IE]> <link rel="stylesheet" href="~/Content/css/ie.css"> <!--<![endif]--> <link rel="stylesheet" href="/Content/css/general.css" /> <link rel="stylesheet" href="/Content/css/print.css" media="print" /> <script>window.jQuery || document.write('<script src="/Content/js/libs/jquery-1.7.2.min.js"><\/script>')</script> <script src="/Content/js/jquery.min.js"></script> <script src="/Content/js/libs/jquery-1.7.2.min.js"></script> <script src="/Scripts/jquery.searchabledropdown-1.0.8.min.js" type="text/javascript"></script> <script src="/Scripts/jquery-ui.js" type="text/javascript"></script> <script type="text/javascript" src="/Content/js/jquery.validate.min.js"></script> <script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script src="/Content/js/jquery.colorbox-min.js" type="text/javascript"></script> <script src="/Scripts/jquery.ui.datepicker.js" type="text/javascript"></script> <!-- CookiePro Cookies Consent Notice start for operator-int2.cvrt.ie --> <script src="https://cookie-cdn.cookiepro.com/scripttemplates/otSDKStub.js" type="text/javascript" charset="UTF-8" data-domain-script="be0ef0f6-cc2e-4771-bf3a-851e47591a69-test"></script> <script type="text/javascript"> function OptanonWrapper() { } </script> <!-- CookiePro Cookies Consent Notice end for operator-int2.cvrt.ie --> <script src="/Scripts/jquery.datepick.js" type="text/javascript"></script> <link href="/Content/css/redmond.datepick.css" rel="stylesheet" /> <script src="/Scripts/covis_rag.js"></script> <link rel="stylesheet" href="/Content/font-awesome.css"> <script type="text/javascript" src="/Scripts/Vehicle_ReCaptcha/formvalidation.js"></script> <script> /* Author: IQ Content */ //-------✂--------------------------------------------- // JSLint info - can remove for production // /*jslint browser: true*/ /*global $, jQuery, navigator, alert, google, colorbox*/ "use strict"; //-------✂---------------------------------------------hidestep //-------?---------------------------------------------------- // Common Function - PHS //-------?----------------------------------------------------show /*RegistrationNumber * Parses the ISO 8601 formated date into a date object, ISO 8601 is YYYY-MM-DD * returns Date object representing the date of the supplied string */ function parseISO8601(dateStringInRange) { var isoExp = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/, date = new Date(NaN), month, parts = isoExp.exec(dateStringInRange); if (parts) { month = +parts[2]; date.setFullYear(parts[1], month - 1, parts[3]); if (month != date.getMonth() + 1) { date.setTime(NaN); } } return date; } //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Encodes and Decodes HTML strings function htmlEncode(value) { //create a in-memory div, set it's inner text(which jQuery automatically encodes) //then grab the encoded contents back out. The div never exists on the page. return $('<div/>').text(value).html(); } function htmlDecode(value) { return $('<div/>').html(value).text(); } //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Adds loader gif to loading pages $("body").bind({ submit: function () { $(this).addClass("loading"); }, onload: function () { $(this).removeClass("loading"); } }); //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Override jQuery's existing '.contains' filter so we can filter dropdown lists using case insensitive filters jQuery.expr[':'].contains = function (a, i, m) { return jQuery(a).text().toUpperCase() .indexOf(m[3].toUpperCase()) >= 0; }; //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Handles a datetime by putting together separate parts of the date (dd, mm, yyyy) function UpdateDateTimeHiddenField(dayValue, monthValue, yearValue, hiddenDatetimeInputId) { $("#" + hiddenDatetimeInputId).val(yearValue + "-" + monthValue + "-" + dayValue + "T00:00:00"); } function SetDateTimeHandlers(dayInputId, monthInputId, yearInputId, hiddenDatetimeInputId) { var dayInput = $("#" + dayInputId); var monthInput = $("#" + monthInputId); var yearInput = $("#" + yearInputId); var handlerFunction = function () { UpdateDateTimeHiddenField(dayInput.val(), monthInput.val(), yearInput.val(), hiddenDatetimeInputId); }; dayInput.change(handlerFunction); monthInput.change(handlerFunction); yearInput.change(handlerFunction); } function UpdateAddressHiddenField(addressValue, hiddenAddressField) { $("#" + hiddenAddressField).val(addressValue); } function SetAddressHandlers(hiddenAddressField, inputAddressField) { var input = $("#" + inputAddressField); var handlerFunction = function () { UpdateAddressHiddenField(hiddenAddressField, inputAddressField); }; input.change(handlerFunction); } function ValidateSelectedDate(day, month, year) { // Convert to numbers with "+" prefix var m = +month - 1; // Months in Javascript start at 0 and go through 11 var d = +day; var y = +year; var date = new Date(y, m, d); // Use the proper constructor return date.getFullYear() == y && date.getMonth() == m && date.getDate() == d; } function IsSelectedDateInThePast(day, month, year) { // Convert to numbers with "+" prefix var m = +month - 1; // Months in Javascript start at 0 and go through 11 var d = +day; var y = +year; var date = new Date(y, m, d); // Use the proper constructor var now = new Date(); return date <= now; } function formatJSONDate(jsonDate, format) { //Valid date var expiryDate = new Date(parseInt(jsonDate.substr(6))); var formattedDate = ($.datepicker.formatDate(format, expiryDate)); //empty date returned by action var emptydate = new Date(parseInt('-62135596800000')); var formattedEmpty = ($.datepicker.formatDate(format, emptydate)); if (formattedDate === formattedEmpty) { return ""; } return formattedDate; } //-------?---------------------------------------------------- // Function - Adds method for date validation //-------?---------------------------------------------------- jQuery.validator.addMethod("greaterThan", function (value, element, params) { if (!/Invalid|NaN/.test(new Date(value))) { return new Date(value) > new Date($(params).val()); } return isNaN(value) && isNaN($(params).val()) || (Number(value) > Number($(params).val())); }, 'Must be greater than {0}.'); jQuery.validator.addMethod("regDateGreaterThan", function (value, element, params) { if ($('#txtYear_0').length === 0) { if ($("#VIN").val() !== '') { return true; } if (isNaN($('#txtYear').val()) && $('#txtYear').val() != 'YYYY') { return false; } if ($('#txtYear').length > 4) { return false; } if ($('#txtYear').val() !== 'YYYY' && $('#selectDay').val() !== '' && $('#selectMonth').val() !== '') { var myDate = $.datepicker.formatDate('dd/mm/yy', new Date($('#selectMonth').val() + "/" + $('#selectDay').val() + "/" + $('#txtYear').val())); var currentDate = $.datepicker.formatDate('dd/mm/yy', new Date()); if ($.datepicker.parseDate('dd/mm/yy', myDate) < $.datepicker.parseDate('dd/mm/yy', currentDate)) { return true; } //return new Date(value) > new Date($(params).val()); } else if ($('#txtYear').val() == 'YYYY') { return true; } } else { if ($('[name="TestBooking[' + params[1] + '].VIN"]').val() !== '') { return true; } if (isNaN($('#txtYear_' + params[1]).val()) && $('#txtYear_' + params[1]).val() !== 'YYYY') { return false; } if ($('#txtYear_' + params[1]).length > 4) { return false; } if ($('#txtYear_' + params[1]).val() !== 'YYYY' && $('#selectDay_' + params[1]).val() !== '' && $('#selectMonth_' + params[1]).val() !== '') { var myDate = $.datepicker.formatDate('dd/mm/yy', new Date($('#selectMonth_' + params[1]).val() + "/" + $('#selectDay_' + params[1]).val() + "/" + $('#txtYear_' + params[1]).val())); var currentDate = $.datepicker.formatDate('dd/mm/yy', new Date()); if ($.datepicker.parseDate('dd/mm/yy', myDate) < $.datepicker.parseDate('dd/mm/yy', currentDate)) { return true; } //return new Date(value) > new Date($(params).val()); } else if ($('#txtYear_' + params[1]).val() === 'YYYY') { return true; } } return false; }, 'Must be greater than {0}.'); //-------?---------------------------------------------------- // Function - Adds method for year validation //-------?---------------------------------------------------- jQuery.validator.addMethod("enterValidYear", function (value, element, params) { if (value === 'YYYY') { return true; } if (isNaN(value)) { return false; } return true; }, 'Must be enter a number {0}.'); jQuery.validator.addMethod("enterYear", function (value, element, params) { if (((value === 'YYYY') || (value.length < 4)) && $('[name="TestBooking[' + params[1] + '].VIN"]').val() === '') { return false; } if (value === 'YYYY' && $('[name="TestBooking[' + params[1] + '].VIN"]').val() !== '') { return true; } if (isNaN(value) && value !== 'YYYY') { return false; } return true; }, 'Must be enter a year {0}.'); jQuery.validator.addMethod("enterYearSingleBooking", function (value, element, params) { if (((value === 'YYYY') || (value.length < 4)) && $("#VIN").val() === '') { return false; } if (value === 'YYYY' && $("#VIN").val() !== '') { return true; } if (isNaN(value)) { return false; } return true; }, 'Must be enter a year {0}.'); //-------?---------------------------------------------------- // Function - Get Vehicle Details //-------?---------------------------------------------------- //Gets Vehicle details using either VIN or RegDate function GetVehicleDetails(registration, registrationDate, vin, challengeField, responseField, reloadButton, checkCaptcha, callBack) { $("#processing").show(); if (registration == "USE_SESSION") { var url = "/test/GetVehicleDetailsForLastCaptcha"; var data = {}; } else{ // Requires Logon var url = "/test/GetVehicleDetails"; var data = { 'registration': registration, 'registrationDate': registrationDate, 'vin': vin }; // Anonyous or not on fleet if (checkCaptcha) { var url = "/test/GetVehicleDetailsCaptcha"; var data = { 'registration': registration, 'registrationDate': registrationDate, 'vin': vin, 'recaptcha_challenge_field': challengeField, 'recaptcha_response_field': responseField }; } } $.ajax({ url: url, type: "POST", data: data, success: function (result) { if (callBack) { callBack(result, registration, reloadButton, checkCaptcha); } else { processVehicleResults(result, registration, reloadButton, checkCaptcha); } } }); return false; } function processVehicleResults(result, registration, reloadButton, checkCaptcha) { var globalVehIndex = 0; var index = $(".vehicleItem").length; var currentVeh = -1; var formattedDate = formatJSONDate(result.CRWExpiryDate, 'dd M yy'); var testCategory; if (index > 0 || ($('#RegistrationNumber_0').length)) { if (vehicle_index == -1) { //TODO: fix details once VS works on model. currentVeh = $('input').filter(function () { return this.value.toUpperCase() == result["RegistrationNumber"] }).attr("id"); currentVeh = currentVeh.substr(currentVeh.length - 1); } else { currentVeh = vehicle_index; // Set in validation } } if (result !== "") { var isObject = false; var response = null; try { response = jQuery.parseJSON(result); isObject = (typeof response == 'object'); } catch (ex) { } if (isObject == true) { SetVehilceDetails(result); if (registration == "USE_SESSION") { $("#RegistrationNumber").val(result.RegistrationNumber); } if ($("#recaptchaHidden").length > 0) { $("#recaptchaHidden").val("true"); $("#recaptchaInitial").addClass("hidden") } // Display a warning if the vehicle is already registered to an operator if (parent.location.toString().indexOf("Vehicle/CRWExpiryTestReminder", 0) == -1 && (result.OnAnotherFleet || result.OnMyFleet)) { DuplicateVehicleWarning(result.OnAnotherFleet, result.OnMyFleet); } else { $('#warningBoxDuplicateVehicle').fadeOut(); } } else { //get current vehicle var currentVeh = $(".expanded").attr("id"); if (currentVeh != null) { currentVeh = currentVeh.substr(currentVeh.length - 1); } ClearVehilceDetails(); if ($("#recaptchaHidden").val() == "false" || $("#recaptchaHidden").val() == "") { $('.vehicleDetailBox').hide(); } if (currentVeh == null) { if ($("#recaptchaHidden").length > 0 && checkCaptcha == true) { $("#recaptchaHidden").val("false"); } } var error = "<li>" + result + "</li>"; $('#validationBox').removeClass('hidden'); $("#validationBox ul").html(error); $('html, body').animate({ scrollTop: 0 }, 'slow'); if ($(reloadButton) != null) { $("#processing").hide(); } } if (currentVeh == -1) { InitialiseFormControlsVehCat($("#VehicleTypeID")); InitialiseFormControlsVehCat($("#Email")); InitialiseFormControlsVehCat($("#Phone")); if (validateMandatory( $("#Email"), "Email address is required for vehicle" )) { validateEmail( $("#Email"), "The email address provided is not in a valid format for vehicle" ); } var areacode = $("#SMSArea").val(); if (validateMandatory( $("#Phone"), "Mobile Number is required for vehicle" )) { validateMobileNumber($("#SMSArea"), $("#Phone"), "Mobile number is invalid"); } if ($.trim($("#VehicleTypeID").val()) == "") { var control = $("#VehicleTypeID"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else if (currentVeh == 1) { index = index - 1; InitialiseFormControlsVehCat($("#VehicleTypeID_1")); if ($.trim($("#VehicleTypeID_1").val()) == "") { var control = $("#VehicleTypeID_1"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID_1"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID_1"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else if (currentVeh == 2) { index = index - 1; InitialiseFormControlsVehCat($("#VehicleTypeID_2")); if ($.trim($("#VehicleTypeID_2").val()) == "") { var control = $("#VehicleTypeID_2"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID_2"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID_2"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else if (currentVeh == 3) { index = index - 1; InitialiseFormControlsVehCat($("#VehicleTypeID_3")); if ($.trim($("#VehicleTypeID_3").val()) == "") { var control = $("#VehicleTypeID_3"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID_3"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID_3"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else if (currentVeh == 4) { index = index - 1; InitialiseFormControlsVehCat($("#VehicleTypeID_4")); if ($.trim($("#VehicleTypeID_4").val()) == "") { var control = $("#VehicleTypeID_4"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID_4"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID_4"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else if (currentVeh == 0) { index = index - 1; InitialiseFormControlsVehCat($("#VehicleTypeID_0")); if ($.trim($("#VehicleTypeID_0").val()) == "") { var control = $("#VehicleTypeID_0"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).hide(); $(errorIcon).hide(); var control = $("#VehicleTypeID_0"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var inputValue = control.val(); var customNotification = control.attr("id") + "-custom-notification"; $(successIcon).hide(); $(errorIcon).show(); control.parent().addClass("has-error"); control .parent() .append( '<span id="' + control.attr("id") + '-custom-notification" class="customerrornotify"> ' + "Type of vehicle category is required for vehicle" + "</span>" ); } else { var control = $("#VehicleTypeID_0"); var successIcon = "#" + control.attr("id") + "-success-icon"; var errorIcon = "#" + control.attr("id") + "-error-icon"; var customNotification = control.attr("id") + "-custom-notification"; control.parent().removeClass("has-error"); $('span[id="' + customNotification + '"]').remove(); $("#" + control.attr("id") + "-custom-notification").remove(); $("." + control.attr("id") + "-custom-notification").remove(); $(successIcon).show(); $(errorIcon).hide(); } } else { ClearVehilceDetails(); if ($("#recaptchaHidden").length > 0 && checkCaptcha == true) { $("#recaptchaHidden").val("false"); } $("#recaptchaInitial").removeClass("hidden") $("#processing").hide(); } var path = window.location.pathname; var page = path.split("/").pop(); if (page.toUpperCase() == "LGVPREBOOKEDLOGIN") { if ($('#errorLGVPreBookingHidden').val() == "true") { $("#recaptchaInitial").removeClass("hidden") $("#recaptchaHidden").val("false") //$('#recaptcha_response_field').rules('add', 'required'); grecaptcha.reset(); } } if (page.toUpperCase() == "BOOKPUBLICLGVTEST") { if (isObject == false) { $('.vehicleDetailBox').hide(); } if ($('#errorBOOKPUBLICLGVTESTHidden').val() == "true") { $(".vehicleTypeSection").addClass("hidden") $('.vehicleDetailBox').hide(); } } $("#processing").hide(); } } function clearSedlDec(index) { $('#hgcnocerterror_' + index).hide(); $('#selfdecoptions_' + index).hide(); $('#selfdecreasons_' + index).hide(); $('#selfdecreasonsother_' + index).hide(); $('#ReasonExcludedFromSelfDecCode_' + index).val(''); $('#ReasonExcludedFromSelfDecDesc_' + index).val(''); $('#rbASDYes_' + index).prop('checked', true) } function StripRegistrationNumber(registration, registrationNumberId) { $.ajax({ url: "/test/StripRegistrationNumber", type: "POST", data: { 'registration': registration }, success: function (result) { if (result !== "") { $("#" + registrationNumberId).text(result) $("#" + registrationNumberId).val(result) } } }); } var QueryString = function () { // This function is anonymous, is executed immediately and // the return value is assigned to QueryString! var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = decodeURIComponent(pair[1]); // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [query_string[pair[0]], decodeURIComponent(pair[1])]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(decodeURIComponent(pair[1])); } } return query_string; }(); function displayCVRTestcenterDetails(cvrtCentreId, index) { var type = QueryString["type"]; $.ajax({ type: "POST", url: '/Test/GetCVRTestCenter', data: { 'cvrtCenterId': cvrtCentreId, 'testTypeCategory': type }, success: function (jsonObj) { var address = jsonObj.Address1 + ", "; //+ + jsonObj.Address3 + "," + jsonObj.CountyName; if (jsonObj.Address2.length > 0) { address += jsonObj.Address2 + ", "; } if (jsonObj.Address3.length > 0) { address += jsonObj.Address3 + ", "; } //RD 01NOV - IPC192313 - Town missing from address if (jsonObj.Town.length > 0) { address += jsonObj.Town + ", "; } address += jsonObj.CountyName; var URL = "<a href=javascript:window.open(\"" + jsonObj.URL + "\") >" + jsonObj.URL + "</a>"; var Email = "<a href=\"mailto:" + jsonObj.EMailAddress + "\" >" + jsonObj.EMailAddress + "</a>"; var categories = ""; // Creating an InfoWindow object if (jsonObj.HGVAuthorisationStatusID == 1) { categories += "HCV"; } if (jsonObj.LGVAuthorisationStatusID == 1) { if (categories == "") { categories += "LCV"; } else { categories += "/LCV"; } } if (jsonObj.ADRAuthorisationStatusID == 1) { if (categories == "") { categories += "ADR"; } else { categories += "/ADR"; } } var isMultiple = $(".vehicleItem").length; if (isMultiple >= 1) { var currentVeh = index; var warning = '<li>'; var message = ''; $("#CVRTID_" + currentVeh).val(jsonObj.CVRTID); $("#CountyID_" + currentVeh).val(jsonObj.CountyID); $("#cvrtCentreName_" + currentVeh).text(jsonObj.CVRTName); $("#cvrtCentreAddress_" + currentVeh).text(address); $("#cvrtCentrePhone_" + currentVeh).text(jsonObj.Telephone); $("#cvrtCentreFax_" + currentVeh).text(jsonObj.FaxNumber); $("#cvrtCentreEmail_" + currentVeh).html(Email); $("#cvrtCentreWeb_" + currentVeh).html(URL); $("#cvrtCentreCategories_" + currentVeh).text(categories); if (jsonObj.AllowWebBookings) { $("#noOnlineBookingsBox_" + currentVeh).hide(); } else { $("#noOnlineBookingsBox_" + currentVeh).show(); } if (jsonObj.OnlinePaymentsAllowed) { $("#AcceptsOnlinePaymentsBox_" + currentVeh).show(); } else { $("#AcceptsOnlinePaymentsBox_" + currentVeh).hide(); } for (var x = 0; x < index; x++) { if ($("#CVRTID_" + currentVeh).val() !== $("#CVRTID_" + x).val()) { message += "Selecting different <a href='#vehicleItem_" + currentVeh + "'>testing centers</a> will not allow online payment"; } } if (message !== '') { warning += message + '</li>'; $(".warningBoxCVRT ul").html(warning); $('.warningBoxCVRT').fadeIn(); } else { $('.warningBoxCVRT').hide(); } } else { $("#CVRTID").val(cvrtCentreId); $("#CountyID").val(jsonObj.CountyID); $("#cvrtCentreName").text(jsonObj.CVRTName); $("#cvrtCentreAddress").text(address); $("#cvrtCentrePhone").text(jsonObj.Telephone); $("#cvrtCentreFax").text(jsonObj.FaxNumber); $("#cvrtCentreEmail").html(Email); $("#cvrtCentreWeb").html(URL); $("#cvrtCentreCategories").text(categories); if (jsonObj.AllowWebBookings) { $("#noOnlineBookingsBox").hide(); } else { $("#noOnlineBookingsBox").show(); } if (jsonObj.OnlinePaymentsAllowed) { $("#AcceptsOnlinePaymentsBox").show(); } else { $("#AcceptsOnlinePaymentsBox").hide(); } } } }); }; //-------?---------------------------------------------------- // Function - Get Vehicle Details //-------?---------------------------------------------------- //Gets Vehicle details using either VIN or RegDate function GetTestTypeCategory() { var type; var index = parent.$(".vehicleItem").index(); if (index >= 0) { var currentVeh = parent.$(".expanded")[0].id.substr(parent.$(".expanded")[0].id.length - 1) type = parent.$("#lblVehicleType_" + currentVeh).text(); } else { type = parent.$("#lblVehicleType").text(); } return type; } //-------?---------------------------------------------------- // Function - Set Vehicle Details //-------?---------------------------------------------------- //Sets the current Vehicle details function SetVehilceDetails(result) { //check if page is multiple vehicles. var index = $(".vehicleItem").length; var currentVeh = -1; var formattedDate = formatJSONDate(result.CRWExpiryDate, 'dd M yy'); var testCategory; if (index > 0 || ($('#RegistrationNumber_0').length)) { if(vehicle_index ==-1){ //TODO: fix details once VS works on model. currentVeh = $('input').filter(function () { return this.value.toUpperCase() == result["RegistrationNumber"] }).attr("id"); currentVeh = currentVeh.substr(currentVeh.length - 1); } else{ currentVeh = vehicle_index; // Set in validation } HideStepOneDiscount(currentVeh); clearSedlDec(currentVeh); $("#vehicleMake_" + currentVeh).text(result.VehicleMake); $("#VehicleModel_" + currentVeh).text(result.VehicleModel); $("#CRWExpiry_" + currentVeh).text(formattedDate); $("#VIN_" + currentVeh).val(result.VIN.substr(result.VIN.length - 4)); $("[id^=vehicleItem]").find('.vehicleDetailBox').fadeIn(); if ($("#VehicleTypeID_" + currentVeh).val() == '' || $("#VehicleTypeID_" + currentVeh).val == null) { $("#VehicleTypeID_" + currentVeh).val(result.TestCategoryID); } $("#VehicleID_" + currentVeh).val(result.VehicleId); $("#TestCategoryID_" + currentVeh).val(result.TestCategoryID); testCategory =GetTestTypeCategory(); if (result.LaneType != null) { if (testCategory.replace("LCV", "LGV").replace("HCV", "HGV") != result.LaneType && result.TestCategoryCode != 'CARAVAN_3_AXLES_HGV' && result.TestCategoryCode != 'CARAVAN_HGV' && result.TestCategoryCode != 'AMBULANCE') { SetErrorLaneTypeMessages(testCategory, currentVeh); } else { RemoveTestTypeError(); } } // Only show when vehicle is not on operator fleet $("#ShowNoSelfDecMessage").val(result.ShowNoSelfDecMessage); if (!result.OnMyFleet) { if (result.ShowNoSelfDecMessage) { $("#hgcnocerterror_" + currentVeh).show(); } else if (result.LaneType == 'HGV') { $("#selfdecoptions_" + currentVeh).show(); } } if (result.PortalTestType != null) { //this must be a motor caravan restriction so empty the dropdown and repopulate $("#selectTestType_" + currentVeh).empty(); $.each(result.PortalTestType, function (i, item) {; if (item.Selected == true) { $("#selectTestType_" + currentVeh).append("<option selected='selected' value='" + item.Value + "'>" + item.Text + "</option>"); $("#selectTestTypeDesc_" + currentVeh).text(item.Text); } else $("#selectTestType_" + currentVeh).append("<option value='" + item.Value + "'>" + item.Text + "</option>"); }); } var formattedRegDate = formatJSONDate(result.DateFirstRegistration, 'yy/mm/dd'); if (formattedRegDate != '') { var pieces = formattedRegDate.split('/'); $('#selectDay_' + currentVeh).val((pieces[2])); $('#selectMonth_' + currentVeh).val((pieces[1])); $('#txtYear_' + currentVeh).val(pieces[0]); // Trigger a blur so that the vehicle box is displayed $('#DateFirstRegistration_' + currentVeh).val(pieces[0] + "-" + pieces[1] + "-" + pieces[2] + "T00:00:00"); } //clear down any potential error highlighting that may be on these fields from a prior validation attempt $('#selectDay_' + currentVeh + ', #selectMonth_' + currentVeh + ', #txtYear_' + currentVeh).removeClass("error"); } else { HideStepOneDiscount(currentVeh); clearSedlDec(0); $("#vehicleMake").text(result.VehicleMake); $("#VehicleModel").text(result.VehicleModel); $("#CRWExpiry").text(formattedDate); if (result.TestCategoryID != null) $("#VehicleTypeID").val(result.TestCategoryID); $("#vehicleTypeDesc").text(result.TestCategory); // $("#VehicleID").text(result.VehicleId); $("#VehicleID").val(result.VehicleId); $("#TestCategoryID").val(result.TestCategoryID).trigger('change'); $("#VIN").val(result.VIN.substr(result.VIN.length - 4)); $("[id^=vehicleItem]").find('.vehicleDetailBox').fadeIn(); $("#CRWIssueStatus").text(result.CRWIssuesStatus || ""); $("#BlokingReason").text(result.BlockingReason || ""); $("#btnContinue").css("display", "none") $("#btnSubmit").css("display", "inline") $("#btnCancelDetails").css("display", "none") $("#btnCancelContinue").css("display", "inline") $(".vehicleTypeSection").removeClass("hidden") $("#ApplicationNumberBox").css("display", "inline") $("#ApplicationNumber").css("display", "inline"); $("#continueButtons").addClass("hidden") $("#proccedButtons").removeClass("hidden") $("#contactDetails").removeClass("hidden") $("#sendConfirmation").removeClass("hidden") $("#selectTestCentre").removeClass("hidden") $("#pnlChangeOfOwnership").removeClass("hidden") $("#addAnotherVehicle").removeClass("hidden") $('.testTypeRequired').fadeIn(); if (parent.location.toString().indexOf("Vehicle/CRWExpiryTestReminder", 0) == -1) { testCategory = GetTestTypeCategory(); if (result.LaneType != null) { if (testCategory.replace("LCV", "LGV").replace("HCV", "HGV") != result.LaneType && result.TestCategoryCode != 'CARAVAN_3_AXLES_HGV' && result.TestCategoryCode != 'CARAVAN_HGV' && result.TestCategoryCode != 'AMBULANCE') { SetErrorLaneTypeMessages(testCategory, currentVeh); } else { RemoveTestTypeError(); } } $("#ShowNoSelfDecMessage").val(result.ShowNoSelfDecMessage); // Only show when vehicle is not on operator fleet if (!result.OnMyFleet) { if (result.ShowNoSelfDecMessage) { $("#hgcnocerterror_0").show(); $("#ShowNoSelfDecMessage").val(true); } else if (result.LaneType == 'HGV') { $("#selfdecoptions_0").show(); } } } else { RemoveTestTypeError(); $("#VehicleColour").text(result.VehicleColour); $("#VehicleYear").text(result.VehicleYear); } if (result.PortalTestType != null) { //this must be a motor caravan restriction so empty the dropdown and repopulate $("#selectTestType").empty(); $.each(result.PortalTestType, function (i, item) {; if (item.Selected == true) { $("#selectTestType").append("<option selected='selected' value='" + item.Value + "'>" + item.Text + "</option>"); $("#selectTestTypeDesc").text(item.Text); } else $("#selectTestType").append("<option value='" + item.Value + "'>" + item.Text + "</option>"); }); } var formattedRegDate = formatJSONDate(result.DateFirstRegistration, 'yy/mm/dd'); if (formattedRegDate != '') { var pieces = formattedRegDate.split('/'); $('#selectDay').val(pieces[2]); $('#selectMonth').val(pieces[1]); $('#txtYear').val(pieces[0]); // Trigger a blur so that the vehicle box is displayed $('#DateFirstRegistration').val(pieces[0] + "-" + pieces[1] + "-" + pieces[2] + "T00:00:00"); } //clear down any potential error highlighting that may be on these fields from a prior validation attempt $('#selectDay, #selectMonth, #txtYear').removeClass("error"); } $("#continueButtons").addClass("hidden") $("#proccedButtons").removeClass("hidden") UpdateAccordionHeaders($('#vehicleAccordion')); ShowStepOneDiscount(currentVeh, result.FeeDiscountViewModel); } function ShowStepOneDiscount(i, vm) { // Do we have fee Discounts to apply if (vm != null && (vm != null || vm != '')) { // Multi Vehicle Entry if (i >= 0 || ($('#RegistrationNumber_0').length)) { if (vm.LevyDiscountsAvailableTitle != null) { $("#levyDiscountAvailable_" + i).show(); $("#levyStep1AvailTitle_" + i).html(vm.LevyDiscountsAvailableTitle); $("#levyStep1AvailMsg_" + i).html(vm.LevyDiscountsAvailableMessage); } if (vm.DisplayTestDues) { $("#lblCRWExpiry_" + i).hide(); $("#lblTestDue_" + i).show(); } if (vm.DisplayCRWIcon) { var src = vm.ValidCRWIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $("#CRWExpiryWrapImg_" + i).show(); $("#CRWExpiryImg_" + i).attr("src", src); } if (vm.DisplaySelfDeclareIcon) { var formattedDate = vm.SelfDeclareDate != null ? formatJSONDate(vm.SelfDeclareDate, 'dd M yy') : 'Not Declared'; $("#lstBlockSelfDec_" + i).show(); var src = vm.ValidSelfDeclareIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $("#SDExpiryWrapImg_" + i).show(); $("#SDExpiryImg_" + i).attr("src", src); $("#SDExpiry_" + i).text(formattedDate); } } else { if (vm.LevyDiscountsAvailableTitle != null) { // Single vehicle entry $("#levyDiscountAvailable").show(); $("#levyStep1AvailTitle").html(vm.LevyDiscountsAvailableTitle); $("#levyStep1AvailMsg").html(vm.LevyDiscountsAvailableMessage); } if (vm.DisplayTestDues) { $("#lblCRWExpiry").hide(); $("#lblTestDue").show(); } if (vm.DisplayCRWIcon) { var src = vm.ValidCRWIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $("#CRWExpiryWrapImg").show(); $('#CRWExpiryImg').attr("src", src); } if (vm.DisplaySelfDeclareIcon) { var formattedDate = vm.SelfDeclareDate != null ? formatJSONDate(vm.SelfDeclareDate, 'dd M yy') : 'Not Declared'; $("#lstBlockSelfDec").show(); var src = vm.ValidSelfDeclareIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $("#SDExpiryWrapImg").show(); $('#SDExpiryImg').attr("src", src); $("#SDExpiry").text(formattedDate); } } } } function HideStepOneDiscount(i) { if( i >= 0 || ($('#RegistrationNumber_0').length)) { $("#levyDiscountAvailable_" + i).hide(); $("#lblTestDue_" + i).hide(); $("#CRWExpiryWrapImg_" + i).hide(); $("#lstBlockSelfDec_" + i).hide(); $("#SDExpiryWrapImg_" + i).hide(); } else { $("#lstBlockSelfDec").hide(); $("#levyDiscountAvailable").hide(); $("#lblTestDue").hide(); $("#CRWExpiryWrapImg").hide(); $("#SDExpiryWrapImg").hide(); } } function ShowStepTwoDiscount(vm, class_id) { // Do we have fee Discounts to apply if (vm != null && (vm != null || vm != '') && $('#VehicleTestType' + class_id).val() != "ADR") { if (class_id >= 0) { if (vm.LevyDiscountsAvailableMessage != null) { $("#levydiscountbubble").show(); $("#levydiscountbubblemessage").html(vm.LevyDiscountsAvailableMessage); } if (vm.LevyDiscountsAvailableTitle != null) { $(".vehicleDetailBox_" + class_id).show(); $(".vehicleDetailBox_" + class_id + " #levyDiscountAvailable").show(); $(".vehicleDetailBox_" + class_id + " #levyStep2AvailTitle").html(vm.LevyDiscountsAvailableTitle); $(".vehicleDetailBox_" + class_id + " #levyStep2AvailMsgText").html(vm.Message) } if (vm.DisplayLevyDiscountIcon) { var src = vm.ValidLevyDiscountIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $(".vehicleDetailBox_" + class_id + " #LDAvailWrapImg").show(); $(".vehicleDetailBox_" + class_id + " #LDAvailImg").attr("src", src); } } else { if (vm.LevyDiscountsAvailableMessage != null) { $("#levydiscountbubble").show(); $("#levydiscountbubblemessage").html(vm.LevyDiscountsAvailableMessage); } if (vm.LevyDiscountsAvailableTitle != null) { $("#vehicleDetailBox_" + class_id).show(); $("#levyDiscountAvailable").show(); $("#levyStep2AvailTitle").html(vm.LevyDiscountsAvailableTitle); $("#levyStep2AvailMsgText").html(vm.Message); } if (vm.DisplayLevyDiscountIcon) { var src = vm.ValidLevyDiscountIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $("#LDAvailWrapImg").show(); $('#LDAvailImg').attr("src", src); } } } } function HideStepTwoDiscount() { var index = $(".selectedTestCentreBox.expanded").attr('id'); if (index > 0 && $('#VehicleTestType' + index).val() == "ADR") { // Nothing }else{ $("#levydiscountbubble").hide(); // Multi Vehicle Entry if (index > 0 || ($('#RegistrationNumber_0').length)) { var currentVeh = $(".expanded").attr("id"); currentVeh = currentVeh.substr(currentVeh.length - 1); $(".vehicleDetailBox_" + currentVeh + " #levyDiscountAvailable").hide(); } else { $("#levyStep2AvailMsg_").hide(); $("#levyDiscountAvailable").hide(); //$("#lblTestDue").hide(); $("#LDAvailWrapImg").hide(); } } } function SetADRDiscount(vm) { // Do we have fee Discounts to apply if (vm != null && (vm != null || vm != '')) { // Single vehicle entry $("#levyStep1AvailTitle_fee").html(vm.LevyDiscountsAvailableTitle); $("#levyStep1AvailMsg_fee").html(vm.LevyDiscountsAvailableMessage); if (vm.DisplayCRWIcon) { $("#CRWExpiryImg_fee_ignore").prop('id', 'CRWExpiryImg_fee'); var src = vm.ValidCRWIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $('#CRWExpiryImg_fee').attr("src", src); } else { $("#CRWExpiryImg_fee").prop('id', 'CRWExpiryImg_fee_ignore'); $("#CRWExpiryImg_fee_ignore").hide(); } if (vm.DisplayTestDues) { $("#lblCRWExpiry_fee").prop('id', 'lblCRWExpiry_fee_ignore'); $("#lblCRWExpiry_fee_ignore").hide(); $("#lblTestDue_fee_ignore").prop('id', 'lblTestDue_fee'); $("#lblTestDue_fee").show(); } else { $("#lblCRWExpiry_fee_ignore").prop('id', 'lblCRWExpiry_fee'); $("#lblCRWExpiry_fee").hide(); $("#lblTestDue_fee").prop('id', 'lblTestDue_fee_ignore'); $("#lblTestDue_fee_ignore").show(); } if (vm.DisplaySelfDeclareIcon) { $("#lstBlockSelfDec_fee_ignore").prop('id', 'lstBlockSelfDec_fee'); var formattedDate = vm.SelfDeclareDate != null ? formatJSONDate(vm.SelfDeclareDate, 'dd M yy') : 'Not Declared'; var src = vm.ValidSelfDeclareIcon ? "/Content/img/pass.png" : "/Content/img/fail.png"; $('#SDExpiryImg_fee').attr("src", src); $("#SDExpiry_fee").text(formattedDate); } else { $("#lstBlockSelfDec_fee").prop('id', 'lstBlockSelfDec_fee_ignore'); } } } function ShowADRDiscount() { if ($.trim($('#levyStep1AvailTitle_fee').html()).length) { $("#levyDiscountAvailable_fee").show(); $("#CRWExpiryWrapImg_fee").show(); $("#lstBlockSelfDec_fee").show(); $("#SDExpiryWrapImg_fee").show(); $("#vehicleFeeDetailBox").show(); } } function HideADRDiscount() { $("#lstBlockSelfDec_fee").hide(); $("#levyDiscountAvailable_fee").hide(); $("#lblTestDue_fee").hide(); $("#CRWExpiryWrapImg_fee").hide(); $("#SDExpiryWrapImg_fee").hide(); $("#vehicleFeeDetailBox").hide(); } //-------?---------------------------------------------------- // Function - Clear Vehicle Details //-------?---------------------------------------------------- //Clears the current Vehicle details function ClearVehilceDetails() { //check if page is multiple vehicles. var index = $(".vehicleItem").index(); if (index > 0) { //TODO: fix details once VS works on model. var currentVeh = $(".expanded").attr("id"); currentVeh = currentVeh.substr(currentVeh.length - 1); $("[id^=vehicleItem]").find('.vehicleDetailBox').fadeIn(); $("#vehicleMake_" + currentVeh).text("No Vehicle found"); $("#VehicleModel_" + currentVeh).text(""); $("#CRWExpiry_" + currentVeh).text(""); $("#VehicleID_" + currentVeh).val(""); } else { $("[id^=vehicleItem]").find('.vehicleDetailBox').fadeIn(); $("#c").text(""); $("#VehicleID").val(""); $("#vehicleMake").text("No Vehicle found"); $("#VehicleModel").html(" "); $("#CRWExpiry").html(" "); if (parent.location.toString().indexOf("Vehicle/CRWExpiryTestReminder", 0) >= -0) { $("#VehicleColour").html(" "); $("#VehicleYear").html(" "); } if (parent.location.toString().indexOf("Vehicle/OnHoldCRWDetails", 0) >= -0) { $("#CRWIssueStatus").html(" "); $("#BlokingReason").html(" "); } } UpdateAccordionHeaders($('#vehicleAccordion')); } // Show and hide the add vehicle and remove vehicle buttons function showHideAccordionAddRemoveLinks() { var vehicleCount = $('.vehicleItem').length, removeVehicleLinks = $('a.deleteVehicleItem'), addVehicleLinks = $('a.addAnotherVehicleBtn'); if (vehicleCount === 5) { addVehicleLinks.hide(); } else { addVehicleLinks.show(); } if (vehicleCount === 1) { removeVehicleLinks.hide(); } else { removeVehicleLinks.show(); } } //-------?---------------------------------------------------- // Function - Display vehicle duplication warning //-------?---------------------------------------------------- function DuplicateVehicleWarning(onAnotherFleet, onMyFleet) { var warning = ""; var message = ""; var index = $(".vehicleItem").index(); // Check if there are Multiple Vehicles on the Page if (index > 0) { var currentVeh = $(".expanded").index(); if (onAnotherFleet) { warning = "<li style=\"margin: 7px 0 0!important; display: list-item !important\">"; message = "Our records indicate that this vehicle may already be managed by another operator. Please double-check the vehicle details before confirming that you are the current operator of this vehicle."; warning += message + '</li>'; $("#warningBoxDuplicateVehicle_" + currentVeh + " ul").html(warning); $("#warningBoxDuplicateVehicle_" + currentVeh).fadeIn(); } if (onMyFleet && $("#form_AddVehicle").length) { warning = "<li style=\"margin: 7px 0 0!important; display: list-item !important\">"; message = "The vehicle details you have provided already match a vehicle on your fleet."; warning += message + '</li>'; $("#warningBoxDuplicateVehicle_" + currentVeh + " ul").html(warning); $("#warningBoxDuplicateVehicle_" + currentVeh).fadeIn(); } } else { if (onAnotherFleet) { warning = "<li style=\"margin: 7px 0 0!important; display: list-item !important\">"; message = "Our records indicate that this vehicle may already be managed by another operator. Please double-check the vehicle details before confirming that you are the current operator of this vehicle."; warning += message + '</li>'; $("#warningBoxDuplicateVehicle ul").html(warning); $("#warningBoxDuplicateVehicle").fadeIn(); } if (onMyFleet && $("#form_AddVehicle").length) { warning = "<li style=\"margin: 7px 0 0!important; display: list-item !important\">"; message = "The vehicle details you have provided already match a vehicle on your fleet."; warning += message + '</li>'; $("#warningBoxDuplicateVehicle ul").html(warning); $("#warningBoxDuplicateVehicle").fadeIn(); } } } //-------?---------------------------------------------------- // Function - Set Test Type errors //-------?---------------------------------------------------- //Submits the form to an action for server validation function SetErrorLaneTypeMessages(laneType, vehicleItem) { var error = ''; $('#rulesErrorBox').removeClass('hidden'); error += "<li>This vehicle is not registered as a " +"" + laneType + "" + " vehicle. Please select the appropriate test type booking or contact your local motor tax office.</li>" +""; $("#rulesErrorBox ul").html(error); $('html, body').animate({ scrollTop: 0 }, 'slow'); //"TestBooking[0].VIN": "<a href='#vehicleItem_0'>Chassis number</a> is required for vehicle 1 if date of first registration is unknown.", //PreBooking $('#errorLGVPreBookingHidden').val("true") // //BookPublicLGV $('#errorBOOKPUBLICLGVTESTHidden').val("true") $("#btnContinue").css("display", "inline") $("#btnSubmit").css("display", "none") $("#btnCancelDetails").css("display", "inline") $("#btnCancelContinue").css("display", "none") $("#ApplicationNumberBox").css("display", "none") //Recaptcha.reload(); } //-------?---------------------------------------------------- // Function - Set Test Type errors //-------?---------------------------------------------------- //Submits the form to an action for server validation function RemoveTestTypeError() { var error = ''; error += "<li></li>"; $('#rulesErrorBox').addClass('hidden'); $("#rulesErrorBox ul").html(error); // $('html, body').animate({ scrollTop: 0 }, 'slow'); //"TestBooking[0].VIN": "<a href='#vehicleItem_0'>Chassis number</a> is required for vehicle 1 if date of first registration is unknown.", } //-------?---------------------------------------------------- // Function - Show business rules errors //-------?---------------------------------------------------- //Submits the form to an action for server validation function SetErrorMessages(result) { var error = ''; $.each(result, function (index) { error += "<li>" + result[index].Message + "</li>"; }); $('#rulesErrorBox').removeClass('hidden'); $("#rulesErrorBox ul").html(error); $('html, body').animate({ scrollTop: 0 }, 'slow'); } //-------?---------------------------------------------------- // Common Function //-------?---------------------------------------------------- //IPC 215277: Validates session with header value. If expired redirects to login page. $(document).ajaxSuccess(function (event, request, settings) { if (request.getResponseHeader('REQUIRES_AUTH') === '1') { window.location.href = '/Account/LogOff'; }; }); //-------?---------------------------------------------------- // Function - Submit booking form //-------?---------------------------------------------------- //Submits the form to an action for server validation $(function () { $('#form_HGVLGVStep1').submit(function (e) { e.preventDefault(); if ($(this).valid()) { $.ajax({ url: "/test/save", type: "POST", data: $(this).serialize(), success: function (result, status, request) { //IPC 215277: Validates session with header value. If expired redirects to login page. if (request.getResponseHeader('REQUIRES_AUTH') === '1') { window.location.href = '/Account/LogOff'; } else { validateResults(result); }; }, cache: false }); } }); }); function validateResults(result) { var error = ''; $.each(result, function (index) { error += "<li>" + result[index].Message + "</li>"; }); if (error == "") { result = "success"; } if (result == "success" ) { $('#form_HGVLGVStep1').unbind('submit').submit(); return true; } else { SetErrorMessages(result); } } $(function () { $('#form_SelfDecStep1').submit(function (e) { e.preventDefault(); // Show the loader if the form is valid if ($(this).valid()) { $("#loading").show(); $.ajax({ url: "/SelfDeclaration/SubmitSelfDeclareOperatorDetails", type: "POST", data: $(this).serialize(), success: function (result) { validateSelfDecResults(result); }, cache: false }); } }); }); function validateSelfDecResults(result) { if (result == "success") { submitForm(); return true; } else { SetErrorMessages(result); $("#loading").hide(); } } function submitForm() { $('#form_SelfDecStep1').unbind('submit').submit(); return true; } //-------?---------------------------------------------------- // Renumber all elements of form. //-------?---------------------------------------------------- // Re-index the vehicle items with sequential numbers for ID's Names and For's function reNumberVehicleAccordionAttributes(formWrapper) { var i, nested_i, names, ids, fors, attributeName, vehicleItem, vehicleTitle, mvc; for (i = 0; i < formWrapper.children('.vehicleItem').length; i += 1) { //Number the parent list items first vehicleItem = formWrapper.find('.vehicleItem:eq(' + i + ')'); attributeName = vehicleItem.attr('id'); if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; vehicleItem.attr('id', attributeName); //Update vehicle ID in the header of the accordion element vehicleTitle = vehicleItem.find('.vehicleID').html(); if (vehicleTitle.indexOf(' ') !== -1) { vehicleTitle = vehicleTitle.split(" ", 1); vehicleTitle = vehicleTitle[0]; } //this is now done in UpdateAccordionHeaders // vehicleItem.find('.vehicleID').html(vehicleTitle + ' ' + (i + 1) ); //Update all of the elements names, ID's and for's where they exist names = formWrapper.find('.vehicleItem:eq(' + i + ')').find('[name]'); ids = formWrapper.find('.vehicleItem:eq(' + i + ')').find('[id]'); fors = formWrapper.find('.vehicleItem:eq(' + i + ')').find('[for]'); //Loop through all elements with 'name' attributes and update 'name' with a sequential number for (nested_i = 0; nested_i < names.length; nested_i += 1) { attributeName = names[nested_i].getAttribute('name'); if (attributeName !== null && attributeName.indexOf("recaptcha") < 0) { if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } //Do not rename any test booking fields if (attributeName.indexOf(']') !== -1) { attributeName = attributeName.split("]", 2); if (attributeName[0].indexOf('TestBooking') !== -1) { mvc = attributeName[1]; } else { mvc = ''; } } if (mvc !== null) { attributeName = 'TestBooking[' + i + ']' + mvc; } else { attributeName = attributeName + '_' + i; } names[nested_i].setAttribute('name', attributeName); mvc = null; } } //Loop through all elements with 'id' attributes and update 'id' with a sequential number for (nested_i = 0; nested_i < ids.length; nested_i += 1) { attributeName = ids[nested_i].getAttribute('id'); if (attributeName !== null && attributeName.indexOf("recaptcha") < 0) { if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; ids[nested_i].setAttribute('id', attributeName); } } //Loop through all elements with 'for' attributes and update 'for' with a sequential number for (nested_i = 0; nested_i < fors.length; nested_i += 1) { attributeName = fors[nested_i].getAttribute('for'); if (attributeName !== null) { if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; fors[nested_i].setAttribute('for', attributeName); } } } } function UpdateAccordionHeaders(formWrapper) { var i, attributeName, vehicleItem, vehicleTitle; for (i = 0; i < formWrapper.children('.vehicleItem').length; i += 1) { //Number the parent list items first vehicleItem = formWrapper.find('.vehicleItem:eq(' + i + ')'); attributeName = vehicleItem.attr('id'); if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; vehicleItem.attr('id', attributeName); //Update vehicle ID in the header of the accordion element vehicleTitle = vehicleItem.find('.vehicleID').html(); if (vehicleTitle.indexOf(' ') !== -1) { vehicleTitle = vehicleTitle.split(" ", 1); vehicleTitle = vehicleTitle[0]; } vehicleItem.find('.vehicleID').html(vehicleTitle + ' ' + (i + 1)); //Append the Make Model & Registration to the accordion header. Easier to do after all renaming has been done var newTitle = vehicleItem.find('.vehicleID').html(); if ($("#VehicleModel_" + i).text() != null && $("#VehicleModel_" + i).text() != "") { //if the model field has a value we have a fully validated vehicle so display in header. failed lookup dont populate the model field so we should be ok. newTitle = newTitle + ': ' + $("#vehicleMake_" + i).text() + ' ' + $("#VehicleModel_" + i).text() + ' [' + $("#RegistrationNumber_" + i).val() + ']'; vehicleItem.find('.vehicleID').html(newTitle); } } } //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Validate a PPSNumber format function ValidatePPSNFormat(value) { var validationRegex = /^(\d{7})([A-Z]{1,2})$/i; if (!validationRegex.test(value)) return false; return true; } //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Validate a PPSNumber checksum //// Algorithm described in http://en.wikipedia.org/wiki/Personal_Public_Service_Number function ValidatePPSN(value) { var validationRegex = /^(\d{7})([A-Z]{1,2})$/i; var numericPart = RegExp.$1; var checksumCharacter = RegExp.$2; // According to PPSN algorithm, the Multiplying Factor is always 8. var multiplyingFactor = 8; var sum = 0; // Calculate the checksum for (var i = 0; i < numericPart.length; i++) { sum += numericPart[i] * multiplyingFactor--; } if (RegExp.$2[1]) { sum += (RegExp.$2[1].toUpperCase().charCodeAt(0) - 64) * 9; } var checksum = sum % 23 || 23; // || 23 for Special case of W (0) as checksum character in the 8th position /* Add 64 to the checksum to make it match the ASCII table, since it is cheaper and ASCII is a standard, hence it will be safer to check a character this way. As an example, we can say that, given the PPSN 1234567T, the checksCharacter would be T and the checksum value would be 20. If we add 64 to 20, we get 84 which represents the character 'T' in the ASCII table, making this return true. For any other checkCharacter other than T and the PPSNumber 1234567, it would return false. */ return checksum + 64 === checksumCharacter.toUpperCase().charCodeAt(0); } // Validates Password Strength $.validator.addMethod("ValidatePasswordStrength", function (value, element) { var ruleExpressions = ["[A-Z]", "[a-z]", "[\\d]", "[^A-Za-z0-9]"]; var rulesSatisfied = 0; for (var i = 0; i < ruleExpressions.length; i++) { var reg = new RegExp(".*" + ruleExpressions[i] + ".*"); if (reg.test(value)) rulesSatisfied++; } return rulesSatisfied > 2; }, "Password Not Strong"); //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Disable an element, based on the value of another function disableElement(elementToCheck, valueToCheck, targetElement) { if (elementToCheck.value != valueToCheck) { $("#" + targetElement).attr('disabled', true).removeClass('disabled'); // disable $("#" + targetElement).val(''); // clear the selection } else { $("#" + targetElement).attr('disabled', false).toggleClass('disabled'); // enable } } //// Disables the County select box if the country is not Ireland function disableCounty(country, county) { var selected = $("option:selected", country).text().toUpperCase().trim(); if (selected != "IRELAND") { $("#" + county).attr('disabled', true).removeClass('disabled'); // disable $("#" + county).val(''); // clear the selection } else { $("#" + county).attr('disabled', false).toggleClass('disabled'); // enable } } //-------?---------------------------------------------------- // Common Function - PHS //-------?---------------------------------------------------- //// Validates Password Strenght var ruleExpressions = ["[A-Z]", "[a-z]", "[\\d]", "[^A-Za-z0-9]"]; function ValidatePasswordStrenght(value) { var rulesSatisfied = 0; for (var i = 0; i < ruleExpressions.length; i++) { var reg = new RegExp(".*" + ruleExpressions[i] + ".*"); if (reg.test(value)) rulesSatisfied++; } return rulesSatisfied > 2; } var currentVehicle; //Practising safe script (function () { //-------✂---------------------------------------------------- // Helper function - Parse Querystring //-------✂---------------------------------------------------- function getQueryParamByName(name) { var match = new RegExp('[?&]' + name + '=([^&]*)') .exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); } //-------✂---------------------------------------------------- // Helper function - Clear form //-------✂---------------------------------------------------- function clearFormFields() { //$('form input:text, form select').val(''); //$('form input:checkbox').attr('checked', false); //$('form input.YYYY').val('YYYY'); } //-------✂---------------------------------------------------- // "Remove vehicle" box on vehicle management tab //-------✂---------------------------------------------------- //$(document).ready(function () { // if ($('#removeVehicleBox').length) { // $('#removeVehicleBox').hide(); // $('#removeVehicleBtn').on('click', function (e) { // e.preventDefault(); // $('#buttonWrapBox').hide(); // $('#removeVehicleBox').fadeIn(); // }); // } //}); //-------✂---------------------------------------------------- // UX helpers - clear YYYY box //-------✂---------------------------------------------------- //TODO $(document).ready(function () { //Clear YYYY box on focus if ($('input.YYYY').length) { $('body').on('focus', 'input.YYYY', function () { if ($(this).val() === 'YYYY') { $(this).val(''); } }); $('body').on('blur', 'input.YYYY', function () { if ($(this).val() === '') { $(this).val('YYYY'); } }); } }); //-------✂---------------------------------------------------- // UX helpers - Contact type selection - (contact me by email/sms/phone) //-------✂---------------------------------------------------- if ($('.contactTypeSelect').length) { // // When a text input gets focus, check the corresponding checkbox // $('body').on('focus', '.contactTypeSelect :text', function (e) { $(this).closest('li').find(':checkbox').attr('checked', true); }); // // When a text input loses focus and is empty, un-check the box // $('body').on('blur', '.contactTypeSelect :text', function (e) { if ($(this).val() === '') { $(this).closest('li').find(':checkbox').attr('checked', false); } }); } //-------✂---------------------------------------------------- // Flash IE7 - this makes IE7 put things in their proper place when page elements move around //-------✂---------------------------------------------------- function flashie7(refreshMe) { if ($.browser.msie && parseInt($.browser.version, 10) === 7) { refreshMe.css('zoom', '1'); refreshMe.hide(); refreshMe.show(); } return false; } //-------✂---------------------------------------------------- // UX helpers - add/remove director pg6.1 //-------✂---------------------------------------------------- $(document).ready(function () { //if there's an addirector button and it gets clicked //copy the last director into a doc fragment //get the intended index (previous director sections .length) //update the ID/Name/For of all elements with index //append the doc fragment function reNumberAttributes(formWrapper) { var i, nested_i, names, ids, fors, attributeName; for (i = 0; i < formWrapper.children('.formList').length; i += 1) { names = formWrapper.find('.formList:eq(' + i + ')').find('[name]'); ids = formWrapper.find('.formList:eq(' + i + ')').find('[id]'); fors = formWrapper.find('.formList:eq(' + i + ')').find('[for]'); //Loop through all elements with 'name' attributes and update 'name' with a sequential number for (nested_i = 0; nested_i < names.length; nested_i += 1) { attributeName = names[nested_i].getAttribute('name'); //Check this or we'll end up with messy names if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; names[nested_i].setAttribute('name', attributeName); } //Loop through all elements with 'id' attributes and update 'id' with a sequential number for (nested_i = 0; nested_i < ids.length; nested_i += 1) { attributeName = ids[nested_i].getAttribute('id'); if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; ids[nested_i].setAttribute('id', attributeName); } //Loop through all elements with 'for' attributes and update 'for' with a sequential number for (nested_i = 0; nested_i < fors.length; nested_i += 1) { attributeName = fors[nested_i].getAttribute('for'); if (attributeName.indexOf('_') !== -1) { attributeName = attributeName.split("_", 1); attributeName = attributeName[0]; } attributeName = attributeName + '_' + i; fors[nested_i].setAttribute('for', attributeName); } } } function showHideContactOptions() { //Always keep the "add" button on the last one and hide it on the others $('.addContactBtn').addClass('hidden'); $('.addContactBtn:last').removeClass('hidden'); //Show a "remove" button on all sections but hide on the first one, because you need at least one $('.removeContactBtn').removeClass('hidden'); $('.removeContactBtn:first').addClass('hidden'); } if ($('.addContactBtn').length) { $("body").on('click', '.addContactBtn', function (e) { e.preventDefault(); var fraggle = document.createDocumentFragment(), /*var*/ newGuy = ($('.dupliPart:eq(' + ($('.dupliPart').length - 1) + ')')); //Copy the latest one /*var*/ // newTitle = document.createElement("h3"), /*var*/ // newTitleContent = document.createTextNode("Contact"); //newTitle.appendChild(newTitleContent); fraggle = newGuy[0].cloneNode(true); //Add fragment to document $(this).closest('fieldset').append(fraggle); //Show and hide the Add Director / Remove director links showHideContactOptions(); //Send the parent wrapper to this method to update id/for/name attributes reNumberAttributes($(this).closest('fieldset')); }); } if ($('.removeContactBtn').length) { $("body").on('click', '.removeContactBtn', function (e) { e.preventDefault(); $(this).closest('.dupliPart').remove(); //Show and hide the Add Director / Remove director links showHideContactOptions(); //Send the parent wrapper to this method to update id/for/name attributes reNumberAttributes($(this).closest('fieldset')); }); } }); //-------✂---------------------------------------------------- // Accordion //-------✂---------------------------------------------------- function initAccordion() { //So they all open when no javascript $('.accordion').children('li').addClass('collapsed'); $('.accordion').children('li:eq(0)').addClass('expanded').removeClass('collapsed'); //click on header to toggle that section. $('.accordion .toggle, .accordion > li > h4').on('click', function (e) { var targetSection = $(this).closest('li'), openSections = targetSection.siblings('.expanded'); openSections.removeClass('expanded').addClass('collapsed'); //If targetsection is already open, close it if (targetSection.hasClass('expanded')) { targetSection.removeClass('expanded').addClass('collapsed'); } else {//Otherwise show it targetSection.removeClass('collapsed').addClass('expanded'); } }); } //-------✂---------------------------------------------------- // This takes in any collection of the same elements and sets them all to be the same height as the tallest one //-------✂---------------------------------------------------- function matchHeights(matchUs) { if (matchUs.length) { //Get tallest box height, set all boxes to this height var maxHeight = Math.max.apply(null, matchUs.map(function () { return $(this).height(); }).get()); matchUs.css('height', maxHeight); } } //-------✂---------------------------------------------------- // HGV Step 1 - Mulitple vehicle accordion //-------✂---------------------------------------------------- //-------✂---------------------------------------------------- // Vehicle Accordion - HGV and LGV //-------✂---------------------------------------------------- function doVehicleAccordion() { //If it's the first one then initialise the accordion and make transformer sound effects... $('#addAnotherVehicleBtn_0').on('click', function (e) { //Run this when the first add button is used - it converts the page from single vehicle to multi accordion e.preventDefault(); //get parent, remove class, add class, collapse, show next var vehicleItem = $(this).closest('li'), accordion = $(this).closest('ul'); if (accordion.hasClass('accordion-inactive')) { vehicleItem.addClass('vehicleItem'); vehicleItem.removeClass('vehicleItem-inactive'); accordion.addClass('accordion'); accordion.removeClass('accordion-inactive'); $('.vehicleItem:eq(1)').removeClass('hidden'); } // Select the Email by Default $('input[name="TestBooking[1].ContactChoice"][value="Email"]').prop('checked', true); $('[name="TestBooking[1].ContactID"]').trigger("change"); }); //Set up the accordion togglers $("body").on('click', '.toggle', function (e) { var targetSection = $(this).closest('li'), /*var*/ openSections = targetSection.siblings('.expanded'); openSections.removeClass('expanded').addClass('collapsed'); //If targetsection is already open, close it if (targetSection.hasClass('expanded')) { targetSection.removeClass('expanded').addClass('collapsed'); } else {//Otherwise show it targetSection.removeClass('collapsed').addClass('expanded'); } currentVehicle = $(".expanded").index(); //IE7 issue here, elements exists and are invisible, but show after a minute if you click around. //this seems to refresh it a little flashie7(targetSection); }); function resetNewCVRTItem(index) { var cvrtBox = $('.testCentreChoice:eq(' + index + ')'); $(this).hide(); //Reset form data on page load? cvrtBox.find('.lblResult').text(''); } //Reset the form fields in the newly created vehicle box function resetNewVehicleItem(index) { var vehicleBox = $('.vehicleItem:eq(' + index + ')'); vehicleBox.find('.chassisNo').hide(); vehicleBox.find('.vehicleDetailBox').hide(); vehicleBox.find('.testTypeRequired').hide(); vehicleBox.find('.warningBox').hide(); vehicleBox.find('.chooseTestCenter').removeClass('hidden'); vehicleBox.find('.formPart2 h2').removeClass('hidden'); //vehicleBox.find('.testCentreChoice').hide(); // vehicleBox.find('.countySelectBox').show(); vehicleBox.find('.testCentreSelector').hide(); vehicleBox.find('.selectTestType').hide(); vehicleBox.find('.lblResult').show(); //vehicleBox.find($("input[id^=countyItems]")).removeAttr('disabled'); //vehicleBox.find('.chooseTestCenter').removeClass('hidden'); // vehicleBox.find('.formPart2 h2').removeClass('hidden'); //Reset form data on page load? vehicleBox.find('input:text, form select').val(''); vehicleBox.find('input:checkbox').attr('checked', false); vehicleBox.find('input:radio').attr('checked', false); vehicleBox.find('input.YYYY').val('YYYY'); vehicleBox.find('select').val(''); vehicleBox.find('.vehicleDetails').text(''); } ///Add a vehicle if ($('.addAnotherVehicleBtn').length) { $("body").on('click', '.addAnotherVehicleBtn', function (e) { e.preventDefault(); var fraggle = document.createDocumentFragment(), targetSection, openSections, newVehicle = ($('#vehicleAccordion > li:eq(' + ($('#vehicleAccordion > li').length - 1) + ')')); //Copy the latest one fraggle = newVehicle[0].cloneNode(true); $(fraggle).find(".recaptchaChallenge").remove(); var vehicleCount = $('.vehicleItem').length; // This can cause problems if there is more than 1 radiobutton in the page var radioName = "TestBooking[" + vehicleCount + "].ContactChoice"; ($("input[type='radio'].contact", newVehicle[0]).prop("name", radioName)); radioName = "TestBooking[" + vehicleCount + "].ChangeOfOwnership"; ($("input[type='radio'].owner", newVehicle[0]).prop("name", radioName)); radioName = "TestBooking[" + vehicleCount + "].AddVehicleToSelfDeclaration"; ($("input[type='radio'].asd", newVehicle[0]).prop("name", radioName)); $('#vehicleAccordion').append(fraggle); //Reset the attribute numbering reNumberVehicleAccordionAttributes($('#vehicleAccordion')); //collapse all but the new one //Toggle accordion to open next section targetSection = $('#vehicleItem_' + vehicleCount); openSections = targetSection.siblings('.expanded'); openSections.removeClass('expanded').addClass('collapsed'); if (targetSection.hasClass('collapsed')) { targetSection.removeClass('collapsed').addClass('expanded'); } if ($.browser.msie && parseInt($.browser.version, 10) === 7) { targetSection.addClass('hidden'); setTimeout(function () { targetSection.removeClass('hidden'); }, 10); //Howdya like them apples? } showHideAccordionAddRemoveLinks(); var cvrtCentreId = $("#CVRTID_" + parseInt(vehicleCount - 1)).val(); var countyId = $("#CountyId_" + parseInt(vehicleCount - 1)).val(); //alert($('#rbPhone').val()); resetNewVehicleItem(vehicleCount); //resetNewCVRTItem($(this).closest('.testCentreChoice').index() + 1); //have to call this after the reset UpdateAccordionHeaders($('#vehicleAccordion')); $('.helpMe').betterTooltip({}); $("#CVRTID_" + vehicleCount).val(cvrtCentreId); $("#CountyId_" + vehicleCount).val(countyId); $(".triggerTestCentreMap").colorbox({ iframe: true, href: "/Test/FindCVRTestCenterMap", width: 818, height: 650, fixed: false, opacity: 1 }); $('html, body').animate({ scrollTop: 220 }, 'fast'); // Select the Email by Default $('input[name="TestBooking[' + parseInt(vehicleCount) + '].ContactChoice"][value="Email"]').prop('checked', true); $('[name="TestBooking[' + parseInt(vehicleCount) + '].ContactID"]').trigger("change"); clearSedlDec(vehicleCount); var ctlName = "TestBooking[" + vehicleCount + "].AddVehicleToSelfDeclaration"; $("input[type='radio'][name=" + ctlName + "].asd").each(function (index, element) { if (element.name == ctlName) { $(element).attr('data-index', vehicleCount); } }) $("select[name='TestBooking[" + vehicleCount + "].ReasonExcludedFromSelfDecCode']").attr('data-index', vehicleCount); onNewVehicleAddition(); ValdiateOwnershipChangeWhenVehicleAdd(); TestCategoryFieldcheckWhenVehAdd(); ValidateContactFieldsWhenVehAdd(); }); } ///Delete a vehicle // if ($('.deleteVehicleItem').length) { (function () { var boxIndex; $("#vehicleAccordion").on('click', '.deleteVehicleItem', function (e) { e.preventDefault(); boxIndex = $(this).closest('.vehicleItem').attr("id"); boxIndex = boxIndex.substr(boxIndex.length - 1); $(this).colorbox({ inline: true, href: "#confirmDelete", width: 360, height: 220, speed: 100, fixed: true, opacity: 1, overlayClose: false }); //ValidateCountyBoxIfVehicleRemoved(); ValdiateOwnershipChangeWhenVehicleAdd(); }); $('#btnContinueDelete').on('click', function (e) { e.preventDefault(); $('.vehicleItem:eq(' + boxIndex + ')').remove(); reNumberVehicleAccordionAttributes($('#vehicleAccordion')); showHideAccordionAddRemoveLinks(); UpdateAccordionHeaders($('#vehicleAccordion')); $.colorbox.close(); boxIndex = ''; return false; }); $('#btnCancelDelete').on('click', function (e) { e.preventDefault(); $.colorbox.close(); boxIndex = ''; return false; }); }()); } } function doHGVStep1() { //Hide sections $('.chassisNo').hide(); $('.vehicleDetailBox').hide(); $('.testTypeRequired').hide(); $('.testCentreChoice').hide(); $('.testCentreSelector').hide(); $('.warningBoxCVRT').hide(); $('.warningBox').hide(); $('.selectTestType').hide(); // Part 3 // Pick a test centre to show details and show contact/confirmation details - this could update other vehicle accordion items too $('body').on('change', '.testCentreSelector select', function (e) { if ($(this).val()) { //show centre detail box $(this).closest('.formPart').find('.testCentreChoice').show(); flashie7($(this).closest('#vehicleAccordion')); } }); $('input:submit').on('click', function (e) { if ($("#vehicleItem2").hasClass('hidden')) { $("#txtYear2").rules("remove"); } if ($("#vehicleItem3").hasClass('hidden')) { $("#txtYear3").rules("remove"); } if ($("#vehicleItem4").hasClass('hidden')) { $("#txtYear4").rules("remove"); } if ($("#vehicleItem5").hasClass('hidden')) { $("#txtYear5").rules("remove"); } if ($('#txtChassisNo1').val()) { $("#selectDay1").rules("remove"); $("#selectMonth1").rules("remove"); $("#txtYear1").rules("remove", "min max digits rangelength"); } if ($('#txtChassisNo2').val()) { $("#selectDay2").rules("remove"); $("#selectMonth2").rules("remove"); $("#txtYear2").rules("remove", "min max digits rangelength"); } if ($('#txtChassisNo3').val()) { $("#selectDay3").rules("remove"); $("#selectMonth3").rules("remove"); $("#txtYear3").rules("remove", "min max digits rangelength"); } if ($('#txtChassisNo4').val()) { $("#selectDay4").rules("remove"); $("#selectMonth4").rules("remove"); $("#txtYear4").rules("remove", "min max digits rangelength"); } if ($('#txtChassisNo5').val()) { $("#selectDay5").rules("remove"); $("#selectMonth5").rules("remove"); $("#txtYear5").rules("remove", "min max digits rangelength"); } }); // jQuery rule to validate the Phone Number $.validator.addMethod("validatePhoneNumber", function (value, element, params) { var a = $('[name="TestBooking[' + params[1] + '].Phone"]').val(); if (a.replace(" ", "") == "") { return true; } var filter = /^[0-9-+ ()]+$/; if (filter.test(a)) { return true; } else { return false; } }); //Rodrigo Paz 03-11-2015 // jQuery rule to validate the Mobile Number $.validator.addMethod("validateMobileNumberSMS", function (value, element, params) { var a = $('[name="TestBooking[' + params[1] + '].SMS"]').val(); if (a.replace(" ", "") == "") { return true; } var filter = /^[0-9-+ ()]+$/; if (filter.test(a)) { if (a.length >= $("#PhoneAreaCode_" + $('[name="TestBooking[' + params[1] + '].SMSArea"]').val() + "_MinLength").val() && a.length <= $("#PhoneAreaCode_" + $('[name="TestBooking[' + params[1] + '].SMSArea"]').val() + "_MaxLength").val()) { return true; } else { return false; } } else { return false; } }); // jQuery rule to validate the Email/Confirm Email Address on contact $.validator.addMethod("validateConfirmEmail0", function () { return $("#TestBooking_0__Email").val() == $("#TestBooking_0__ConfirmEmail").val(); }); $.validator.addMethod("validateConfirmEmail1", function () { return $("#TestBooking_1__Email").val() == $("#TestBooking_1__ConfirmEmail").val(); }); $.validator.addMethod("validateConfirmEmail2", function () { return $("#TestBooking_2__Email").val() == $("#TestBooking_2__ConfirmEmail").val(); }); $.validator.addMethod("validateConfirmEmail3", function () { return $("#TestBooking_3__Email").val() == $("#TestBooking_3__ConfirmEmail").val(); }); $.validator.addMethod("validateConfirmEmail4", function () { return $("#TestBooking_4__Email").val() == $("#TestBooking_4__ConfirmEmail").val(); }); // validation $("#form_HGVLGVStep1").validate({ rules: { recaptcha_response_field: { required: { depends: function (element) { return ($("#recaptchaHidden").val() == "false" || $("#recaptchaHidden").val() == ""); } } }, selectDay: { required: { depends: function (element) { return ($('[name="TestBooking[0].VIN"]').val() == ''); } } }, selectMonth: { required: { depends: function (element) { return (($('[name="TestBooking[0].VIN"]').val() === '')); } } }, txtYear: { enterYear: [$("#txtYear").val(), 0] }, //"TestBooking[0].RegistrationNumber": { required: { depends: function (element) { return !($("#vehicleItem_0").hasClass('hidden')); } } }, selectDay_0: { required: { depends: function (element) { return ($('[name="TestBooking[0].VIN"]').val() == ''); } } }, selectMonth_0: { required: { depends: function (element) { return (($('[name="TestBooking[0].VIN"]').val() === '')); } } }, txtYear_0: { enterYear: [$("#txtYear_0").val(), 0] }, "TestBooking[0].DateFirstRegistration": { regDateGreaterThan: [$('[name="TestBooking[0].DateFirstRegistration"]').val(), 0] },//, required: { depends: function (element) { return (($('[name="TestBooking[0].VIN"]').val() === '')); } } }, "TestBooking[0].VIN": { required: { depends: function (element) { return ((($("#txtYear_0").val() === 'YYYY') || ($("#txtYear_0").val() === '')) && !($("#vehicleItem_0").hasClass('hidden'))); } } }, "TestBooking[0].TestCategoryID": { required: { depends: function (element) { return ($("#recaptchaHidden").val() == "true"); } } }, "TestBooking[0].CVRTID": { required: true }, "TestBooking[0].ChangeOfOwnership": { required: { depends: function (element) { return ($("#recaptchaHidden").val() == "true"); } } }, "TestBooking[0].ContactName": { required: true }, "TestBooking[0].ContactFirstName": { required: true }, "TestBooking[0].ContactSurname": { required: true }, "TestBooking[0].ReasonExcludedFromSelfDecCode": { required: { depends: function (element) { return $('[name="TestBooking[0].AddVehicleToSelfDeclaration"].no').is(':checked'); } } }, "TestBooking[0].ReasonExcludedFromSelfDecDesc": { required: { depends: function (element) { return $('[name="TestBooking[0].ReasonExcludedFromSelfDecCode"]').val() == "Other" && $('[name="TestBooking[0].ReasonExcludedFromSelfDecDesc"]').val() == "" } } }, "TestBooking[0].ContactEmail": { required: { depends: function () { return $('[name="TestBooking[0].ContactEmail"]') !== null; } }, email: true }, "TestBooking[0].ContactChoice": { required: true }, "TestBooking[0].Email": { required: true, email: true }, "TestBooking[0].ConfirmEmail": { required: true, email: true, validateConfirmEmail0: true }, "TestBooking[0].SMS": { required: { depends: function () { return $('[name="TestBooking[0].ContactChoice"]:checked').val() === 'SMS'; } }, digits: true, validateMobileNumberSMS: [$('[name="TestBooking[0].SMS"]').val(), 0] }, "TestBooking[0].Phone": { required: { depends: function () { return ($('[name="TestBooking[0].SMS"]').val() === ''); } }, validatePhoneNumber: [$('[name="TestBooking[0].Phone"]').val(), 0] }, //"TestBooking[1].RegistrationNumber": { required: true }, selectDay_1: { required: { depends: function (element) { return ($('[name="TestBooking[1].VIN"]').val() == ''); } } }, selectMonth_1: { required: { depends: function (element) { return (($('[name="TestBooking[1].VIN"]').val() === '')); } } }, txtYear_1: { enterYear: [$("#txtYear_1").val(), 1] }, "TestBooking[1].DateFirstRegistration": { regDateGreaterThan: [$('[name="TestBooking[1].DateFirstRegistration"]').val(), 1] },// required: { depends: function (element) { return (($('[name="TestBooking[1].VIN"]').val() === '')); } } }, "TestBooking[1].VIN": { required: { depends: function (element) { return (($("#txtYear_1").val() === 'YYYY') || ($("#txtYear_1").val() === '')); } } }, "TestBooking[1].TestCategoryID": { required: { depends: function (element) { return !($("#vehicleItem_1").hasClass('hidden')); } } }, "TestBooking[1].CVRTID": { required: true }, "TestBooking[1].ChangeOfOwnership": { required: true }, "TestBooking[1].ContactName": { required: true }, "TestBooking[1].ContactFirstName": { required: true }, "TestBooking[1].ContactSurname": { required: true }, "TestBooking[1].ContactChoice": { required: true }, "TestBooking[1].ReasonExcludedFromSelfDecCode": { required: { depends: function (element) { return $('[name="TestBooking[1].AddVehicleToSelfDeclaration"].no').is(':checked'); } } }, "TestBooking[1].ReasonExcludedFromSelfDecDesc": { required: { depends: function (element) { return $('[name="TestBooking[1].ReasonExcludedFromSelfDecCode"]').val() == "Other" && $('[name="TestBooking[1].ReasonExcludedFromSelfDecDesc"]').val() == "" } } }, "TestBooking[1].Email": { required: true, email: true }, "TestBooking[1].ConfirmEmail": { required: true, email: true, validateConfirmEmail1: true }, "TestBooking[1].SMS": { required: { depends: function () { return $('[name="TestBooking[1].ContactChoice"]:checked').val() === 'SMS'; } }, digits: true, validateMobileNumberSMS: [$('[name="TestBooking[1].SMS"]').val(), 1] }, "TestBooking[1].Phone": { required: { depends: function () { return ($('[name="TestBooking[1].SMS"]').val() === ''); } }, validatePhoneNumber: [$('[name="TestBooking[1].Phone"]').val(), 1] }, //"TestBooking[2].RegistrationNumber": { required: { depends: function (element) { return !($("#vehicleItem_2").hasClass('hidden')); } } }, selectDay_2: { required: { depends: function (element) { return ($('[name="TestBooking[2].VIN"]').val() == ''); } } }, selectMonth_2: { required: { depends: function (element) { return (($('[name="TestBooking[2].VIN"]').val() === '')); } } }, txtYear_2: { enterYear: [$("#txtYear_2").val(), 2] }, "TestBooking[2].DateFirstRegistration": { regDateGreaterThan: [$('[name="TestBooking[2].DateFirstRegistration"]').val(), 2] },// required: { depends: function (element) { return (($('[name="TestBooking[2].VIN"]').val() === '')); } } }, "TestBooking[2].VIN": { required: { depends: function (element) { return ((($("#txtYear_2").val() === 'YYYY') || ($("#txtYear_2").val() === '')) && !($("#vehicleItem_2").hasClass('hidden'))); } } }, "TestBooking[2].TestCategoryID": { required: { depends: function (element) { return !($("#vehicleItem_2").hasClass('hidden')); } } }, "TestBooking[2].CVRTID": { required: { depends: function (element) { return !($("#vehicleItem_2").hasClass('hidden') || ("#CVRTID_2" !== "#CVRTID_1")); } } }, "TestBooking[2].ChangeOfOwnership": { required: true }, "TestBooking[2].ContactName": { required: true }, "TestBooking[2].ContactFirstName": { required: true }, "TestBooking[2].ContactSurname": { required: true }, "TestBooking[2].ContactChoice": { required: true }, "TestBooking[2].ReasonExcludedFromSelfDecCode": { required: { depends: function (element) { return $('[name="TestBooking[2].AddVehicleToSelfDeclaration"].no').is(':checked'); } } }, "TestBooking[2].ReasonExcludedFromSelfDecDesc": { required: { depends: function (element) { return $('[name="TestBooking[2].ReasonExcludedFromSelfDecCode"]').val() == "Other" && $('[name="TestBooking[2].ReasonExcludedFromSelfDecDesc"]').val() == "" } } }, "TestBooking[2].Email": { required: true, email: true }, "TestBooking[2].ConfirmEmail": { required: true, email: true, validateConfirmEmail2: true }, "TestBooking[2].SMS": { required: { depends: function () { return $('[name="TestBooking[2].ContactChoice"]:checked').val() === 'SMS'; } }, digits: true, validateMobileNumberSMS: [$('[name="TestBooking[2].SMS"]').val(), 2] }, "TestBooking[2].Phone": { required: { depends: function () { return ($('[name="TestBooking[2].SMS"]').val() === ''); } }, validatePhoneNumber: [$('[name="TestBooking[2].Phone"]').val(), 2] }, //"TestBooking[3].RegistrationNumber": { required: { depends: function (element) { return !($("#vehicleItem_3").hasClass('hidden')); } } }, selectDay_3: { required: { depends: function (element) { return ($('[name="TestBooking[3].VIN"]').val() == ''); } } }, selectMonth_3: { required: { depends: function (element) { return (($('[name="TestBooking[3].VIN"]').val() === '')); } } }, txtYear_3: { enterYear: [$("#txtYear_3").val(), 3] }, "TestBooking[3].DateFirstRegistration": { regDateGreaterThan: [$('[name="TestBooking[3].DateFirstRegistration"]').val(), 3] },// required: { depends: function (element) { return (($('[name="TestBooking[3].VIN"]').val() === '')); } } }, "TestBooking[3].VIN": { required: { depends: function (element) { return ((($("#txtYear_3").val() === 'YYYY') || ($("#txtYear_3").val() === '')) && !($("#vehicleItem_3").hasClass('hidden'))); } } }, "TestBooking[3].TestCategoryID": { required: { depends: function (element) { return !($("#vehicleItem_3").hasClass('hidden')); } } }, "TestBooking[3].CVRTID": { required: { depends: function (element) { return !($("#vehicleItem_3").hasClass('hidden')); } } }, "TestBooking[3].ChangeOfOwnership": { required: true }, "TestBooking[3].ContactName": { required: true }, "TestBooking[3].ContactFirstName": { required: true }, "TestBooking[3].ContactSurname": { required: true }, "TestBooking[3].ContactChoice": { required: true }, "TestBooking[3].ReasonExcludedFromSelfDecCode": { required: { depends: function (element) { return $('[name="TestBooking[3].AddVehicleToSelfDeclaration"].no').is(':checked'); } } }, "TestBooking[3].ReasonExcludedFromSelfDecDesc": { required: { depends: function (element) { return $('[name="TestBooking[3].ReasonExcludedFromSelfDecCode"]').val() == "Other" && $('[name="TestBooking[3].ReasonExcludedFromSelfDecDesc"]').val() == "" } } }, "TestBooking[3].Email": { required: true, email: true }, "TestBooking[3].ConfirmEmail": { required: true, email: true, validateConfirmEmail3: true }, "TestBooking[3].SMS": { required: { depends: function () { return $('[name="TestBooking[3].ContactChoice"]:checked').val() === 'SMS'; } }, digits: true, validateMobileNumberSMS: [$('[name="TestBooking[3].SMS"]').val(), 3] }, "TestBooking[3].Phone": { required: { depends: function () { return ($('[name="TestBooking[3].SMS"]').val() === ''); } }, validatePhoneNumber: [$('[name="TestBooking[3].Phone"]').val(), 3] }, //"TestBooking[4].RegistrationNumber": { required: { depends: function (element) { return !($("#vehicleItem_4").hasClass('hidden')); } } }, selectDay_4: { required: { depends: function (element) { return ($('[name="TestBooking[4].VIN"]').val() == ''); } } }, selectMonth_4: { required: { depends: function (element) { return (($('[name="TestBooking[4].VIN"]').val() === '')); } } }, txtYear_4: { enterYear: [$("#txtYear_4").val(), 4] }, "TestBooking[4].DateFirstRegistration": { regDateGreaterThan: [$('[name="TestBooking[4].DateFirstRegistration"]').val(), 4] },// required: { depends: function (element) { return (($('[name="TestBooking[4].VIN"]').val() === '')); } } }, "TestBooking[4].VIN": { required: { depends: function (element) { return ((($("#txtYear_4").val() === 'YYYY') || ($("#txtYear_4").val() === '')) && !($("#vehicleItem_4").hasClass('hidden'))); } } }, "TestBooking[4].TestCategoryID": { required: { depends: function (element) { return !($("#vehicleItem_4").hasClass('hidden')); } } }, "TestBooking[4].CVRTID": { required: { depends: function (element) { return !($("#vehicleItem_4").hasClass('hidden')); } } }, "TestBooking[4].ChangeOfOwnership": { required: true }, "TestBooking[4].ContactName": { required: true }, "TestBooking[4].ContactFirstName": { required: true }, "TestBooking[4].ContactSurname": { required: true }, "TestBooking[4].ContactChoice": { required: true }, "TestBooking[4].ReasonExcludedFromSelfDecCode": { required: { depends: function (element) { return $('[name="TestBooking[4].AddVehicleToSelfDeclaration"].no').is(':checked'); } } }, "TestBooking[4].ReasonExcludedFromSelfDecDesc": { required: { depends: function (element) { return $('[name="TestBooking[4].ReasonExcludedFromSelfDecCode"]').val() == "Other" && $('[name="TestBooking[4].ReasonExcludedFromSelfDecDesc"]').val() == "" } } }, "TestBooking[4].Email": { required: true, email: true }, "TestBooking[4].ConfirmEmail": { required: true, email: true, validateConfirmEmail4: true }, "TestBooking[4].SMS": { required: { depends: function () { return $('[name="TestBooking[4].ContactChoice"]:checked').val() === 'SMS'; } }, digits: true, validateMobileNumberSMS: [$('[name="TestBooking[4].SMS"]').val(), 4] }, "TestBooking[4].Phone": { required: { depends: function () { return ($('[name="TestBooking[4].SMS"]').val() === ''); } }, validatePhoneNumber: [$('[name="TestBooking[4].Phone"]').val(), 4] }, chkTerms: { required: { depends: function (element) { return ($('[name="TestBooking[0].VIN"]').val() == ''); } } }, }, messages: { recaptcha_response_field: { required: "<a href='#recaptcha_response_field'>Recaptcha</a> is required." }, selectDay: "<a href='#vehicleItem_0'>" + "Day</a> is required for vehicle" + " 1" + " if chassis number is unknown." +"", selectMonth: "<a href='#vehicleItem_0'>" + "Month</a> is required for vehicle" +" 1" + " if chassis number is unknown." +"", txtYear: { enterYear: "<a href='#vehicleItem_0'>" + "Year</a> is required for vehicle" +" 1" + " if chassis number is unknown." +"" }, selectDay_0: "<a href='#vehicleItem_0'>" + "Day</a> is required for vehicle" + " 1" + " if chassis number is unknown." +"", selectMonth_0: "<a href='#vehicleItem_0'>" + "Month</a> is required for vehicle" +" 1" + " if chassis number is unknown." +"", txtYear_0: { enterYear: "<a href='#vehicleItem_0'>" + "Year</a> is required for vehicle" +" 1" + " if chassis number is unknown." +"" }, "TestBooking[0].DateFirstRegistration": { regDateGreaterThan: "<a href='#vehicleItem_0'>" + "The date of registration</a> must be in the past for vehicle" + " 1" }, "TestBooking[0].VIN": "<a href='#vehicleItem_0'>" + "Chassis number</a> is required for vehicle" +" 1 " + "Chassis number</a> is required for vehicle" +"", "TestBooking[0].ContactName": "<a href='#vehicleItem_0'>" + "Contact name</a> must be provided for vehicle" +" 1 ", "TestBooking[0].ContactFirstName": "<a href='#vehicleItem_0'>" + "Contact First Name</a> must be provided for vehicle" +" 1 ", "TestBooking[0].ContactSurname": "<a href='#vehicleItem_0'>" + "Contact Surname</a> must be provided for vehicle" +" 1 ", "TestBooking[0].ReasonExcludedFromSelfDecCode": "<a href='#vehicleItem_0'>" + "Reasons for not adding to Self-Declaration</a> is required for vehicle" +" 1 ", "TestBooking[0].ReasonExcludedFromSelfDecDesc": "<a href='#vehicleItem_0'>" + "Please state the other reason for not adding to Self-Declaration</a>" +" 1 ", "TestBooking[0].ContactEmail": { required: "<a href='#vehicleItem_0'>" + "Contact Email address</a> is required for vehicle" +" 1", email: "<a href='#vehicleItem_0'>" + "The contact email address</a> provided is not in a valid format for vehicle" +" 1" }, "TestBooking[0].TestCategoryID": "<a href='#vehicleItem_0'>" + "Type of vehicle category</a> is required for vehicle " + " 1.", "TestBooking[0].CVRTID": "<a href='#vehicleItem_0'>" + "Test centre</a> selection is required for vehicle" +" 1.", "TestBooking[0].ChangeOfOwnership": "<a href='#TestBooking[0].ChangeOfOwnership'>" + "Change of ownership declaration required." +" 1.", "TestBooking[0].ContactChoice":"Must select one type of" +" <a href='#vehicleItem_0'>" +"confirmation</a> and fill in the required information for vehicle" +" 1", "TestBooking[0].Email": { required: "<a href='#vehicleItem_0'>" + "Email address</a> is required for vehicle" +" 1", email: "<a href='#vehicleItem_0'>" + "The email address</a> provided is not in a valid format for vehicle" +" 1" }, "TestBooking[0].ConfirmEmail": { required: "<a href='#vehicleItem_0'>" + "Confirm Email address</a> is required for vehicle" +" 1", email: "<a href='#vehicleItem_0'>" + "The Confirm email address</a> provided is not in a valid format for vehicle" +" 1", validateConfirmEmail0: "<a href='#vehicleItem_0'>" + "Email address</a> and <a href='#'>Confirm Email address</a> you have entered do not match for vehicle" + " 1" }, "TestBooking[0].SMS": { required: "<a href='#vehicleItem_0'>" +"If preferred contact method is SMS then mobile phone number is mandatory for vehicle" +" 1.", digits: "<a href='#vehicleItem_0'>" +"The SMS number</a> provided needs to be numeric, e.g. 085282517172 for vehicle" +" 1.", validateMobileNumberSMS: "<a href='#vehicleItem_0'>" +"The SMS number</a> is not in a valid format for vehicle" +" 1." }, "TestBooking[0].Phone": { required: "<a href='#vehicleItem_0'>" +"Either the Landline or mobile phone number must be entered for vehicle" +" 1.", validatePhoneNumber: "<a href='#vehicleItem_0'>" +"The Phone number </a> provided needs to be numeric, e.g. 0861234567 for vehicle" + " 1." }, selectDay_1: "<a href='#vehicleItem_1'>" + "Day</a> is required for vehicle" + " 2" + " if chassis number is unknown." +"", selectMonth_1: "<a href='#vehicleItem_1'>" + "Month</a> is required for vehicle" +" 2" + " if chassis number is unknown." +"", txtYear_1: "<a href='#vehicleItem_1'>" + "Year</a> is required for vehicle" +" 2" + " if chassis number is unknown." +"", "TestBooking[1].DateFirstRegistration": { regDateGreaterThan: "<a href='#vehicleItem_1'>" + "The date of registration</a> must be in the past for vehicle" + " 2" }, "TestBooking[1].VIN": "<a href='#vehicleItem_1'>" + "Chassis number</a> is required for vehicle" +" 2 " + "Chassis number</a> is required for vehicle" +"", "TestBooking[1].ContactName": "<a href='#vehicleItem_1'>" + "Contact name</a> must be provided for vehicle" +" 2 ", "TestBooking[1].ContactFirstName": "<a href='#vehicleItem_1'>" + "Contact First Name</a> must be provided for vehicle" +" 2 ", "TestBooking[1].ContactSurname": "<a href='#vehicleItem_1'>" + "Contact Surname</a> must be provided for vehicle" +" 2 ", "TestBooking[1].TestCategoryID": "<a href='#vehicleItem_1'>" + "Type of vehicle category</a> is required for vehicle " + " 2.", "TestBooking[1].ReasonExcludedFromSelfDecCode": "<a href='#vehicleItem_1'>" + "Reasons for not adding to Self-Declaration</a> is required for vehicle" +" 2 ", "TestBooking[1].ReasonExcludedFromSelfDecDesc": "<a href='#vehicleItem_1'>" + "Please state the other reason for not adding to Self-Declaration</a>" +" 2 ", "TestBooking[1].CVRTID": "<a href='#vehicleItem_1'>" + "Test centre</a> selection is required for vehicle" +" 2.", "TestBooking[1].ChangeOfOwnership": "<a href='#TestBooking[1].ChangeOfOwnership'>" + "Change of ownership declaration required." +" 2.", "TestBooking[1].ContactChoice":"Must select one type of" +" <a href='#vehicleItem_1'>" +"confirmation</a> and fill in the required information for vehicle" +" 2", "TestBooking[1].Email": { required: "<a href='#vehicleItem_1'>" + "Email address</a> is required for vehicle" +" 2", email: "<a href='#vehicleItem_1'>" + "The email address</a> provided is not in a valid format for vehicle" +" 2" }, "TestBooking[1].ConfirmEmail": { required: "<a href='#vehicleItem_1'>" + "Confirm Email address</a> is required for vehicle" +" 2", email: "<a href='#vehicleItem_1'>" + "The Confirm email address</a> provided is not in a valid format for vehicle" +" 2", validateConfirmEmail1: "<a href='#vehicleItem_1'>" + "Email address</a> and <a href='#'>Confirm Email address</a> you have entered do not match for vehicle" + " 2" }, "TestBooking[1].SMS": { required: "<a href='#vehicleItem_1'>" +"If preferred contact method is SMS then mobile phone number is mandatory for vehicle" +" 2.", digits: "<a href='#vehicleItem_1'>" +"The SMS number</a> provided needs to be numeric, e.g. 085282517172 for vehicle" +" 2.", validateMobileNumberSMS: "<a href='#vehicleItem_1'>" +"The SMS number</a> is not in a valid format for vehicle" +" 2." }, "TestBooking[1].Phone": { required: "<a href='#vehicleItem_1'>" +"Either the Landline or mobile phone number must be entered for vehicle" +" 2.", validatePhoneNumber: "<a href='#vehicleItem_1'>" +"The Phone number </a> provided needs to be numeric, e.g. 0861234567 for vehicle" + " 2." }, selectDay_2: "<a href='#vehicleItem_2'>" + "Day</a> is required for vehicle" + " 3" + " if chassis number is unknown." +"", selectMonth_2: "<a href='#vehicleItem_2'>" + "Month</a> is required for vehicle" +" 3" + " if chassis number is unknown." +"", txtYear_2: "<a href='#vehicleItem_2'>" + "Year</a> is required for vehicle" +" 3" + " if chassis number is unknown." +"", "TestBooking[2].DateFirstRegistration": { regDateGreaterThan: "<a href='#vehicleItem_2'>" + "The date of registration</a> must be in the past for vehicle" + " 3" }, "TestBooking[2].VIN": "<a href='#vehicleItem_2'>" + "Chassis number</a> is required for vehicle" +" 3 " + "Chassis number</a> is required for vehicle" +"", "TestBooking[2].ChangeOfOwnership": "<a href='#TestBooking[2].ChangeOfOwnership'>" + "Change of ownership declaration required." +" 3.", "TestBooking[2].ContactName": "<a href='#vehicleItem_2'>" + "Contact name</a> must be provided for vehicle" +" 3 ", "TestBooking[2].ContactFirstName": "<a href='#vehicleItem_2'>" + "Contact First Name</a> must be provided for vehicle" +" 3 ", "TestBooking[2].ContactSurname": "<a href='#vehicleItem_2'>" + "Contact Surname</a> must be provided for vehicle" +" 3 ", "TestBooking[2].ReasonExcludedFromSelfDecCode": "<a href='#vehicleItem_2'>" + "Reasons for not adding to Self-Declaration</a> is required for vehicle" +" 3 ", "TestBooking[2].ReasonExcludedFromSelfDecDesc": "<a href='#vehicleItem_2'>" + "Please state the other reason for not adding to Self-Declaration</a>" +" 3 ", "TestBooking[2].TestCategoryID": "<a href='#vehicleItem_2'>" + "Type of vehicle category</a> is required for vehicle " + " 3.", "TestBooking[2].ContactChoice": "Must select one type of" +" <a href='#vehicleItem_2'>" +"confirmation</a> and fill in the required information for vehicle" +" 3", "TestBooking[2].Email": { required: "<a href='#vehicleItem_2'>" + "Email address</a> is required for vehicle" +" 3", email: "<a href='#vehicleItem_2'>" + "The email address</a> provided is not in a valid format for vehicle" +" 3" }, "TestBooking[2].ConfirmEmail": { required: "<a href='#vehicleItem_2'>" + "Confirm Email address</a> is required for vehicle" +" 3", email: "<a href='#vehicleItem_2'>" + "The Confirm email address</a> provided is not in a valid format for vehicle" +" 3", validateConfirmEmail2: "<a href='#vehicleItem_2'>" + "Email address</a> and <a href='#'>Confirm Email address</a> you have entered do not match for vehicle" + " 3" }, "TestBooking[2].SMS": { required: "<a href='#vehicleItem_2'>" +"If preferred contact method is SMS then mobile phone number is mandatory for vehicle" +" 3.", digits: "<a href='#vehicleItem_2'>" +"The SMS number</a> provided needs to be numeric, e.g. 085282517172 for vehicle" +" 3.", validateMobileNumberSMS: "<a href='#vehicleItem_2'>" +"The SMS number</a> is not in a valid format for vehicle" +" 3." }, "TestBooking[2].Phone": { required: "<a href='#vehicleItem_2'>" +"Either the Landline or mobile phone number must be entered for vehicle" +" 3.", validatePhoneNumber: "<a href='#vehicleItem_2'>" +"The Phone number </a> provided needs to be numeric, e.g. 0861234567 for vehicle" + " 3." }, selectDay_3: "<a href='#vehicleItem_3'>" + "Day</a> is required for vehicle" + " 4" + " if chassis number is unknown." +"", selectMonth_3: "<a href='#vehicleItem_3'>" + "Month</a> is required for vehicle" +" 4" + " if chassis number is unknown." +"", txtYear_3: "<a href='#vehicleItem_3'>" + "Year</a> is required for vehicle" +" 4" + " if chassis number is unknown." +"", "TestBooking[3].DateFirstRegistration": { regDateGreaterThan: "<a href='#vehicleItem_3'>" + "The date of registration</a> must be in the past for vehicle" + " 4." }, "TestBooking[3].VIN": "<a href='#vehicleItem_3'>" + "Chassis number</a> is required for vehicle" +" 4 " + "Chassis number</a> is required for vehicle" +"", "TestBooking[3].ContactName": "<a href='#vehicleItem_3'>" + "Contact name</a> must be provided for vehicle" +" 4 " + "Contact name</a> must be provided for vehicle" +"", "TestBooking[3].ContactFirstName": "<a href='#vehicleItem_3'>" + "Contact First Name</a> must be provided for vehicle" +" 4 ", "TestBooking[3].ContactSurname": "<a href='#vehicleItem_3'>" + "Contact Surname</a> must be provided for vehicle" +" 4 ", "TestBooking[3].ReasonExcludedFromSelfDecCode": "<a href='#vehicleItem_3'>" + "Reasons for not adding to Self-Declaration</a> is required for vehicle" +" 4", "TestBooking[3].ReasonExcludedFromSelfDecDesc": "<a href='#vehicleItem_3'>" + "Please state the other reason for not adding to Self-Declaration</a>" +" 4 ", "TestBooking[3].TestCategoryID": "<a href='#vehicleItem_3'>" + "Type of vehicle category</a> is required for vehicle " + " 4.", "TestBooking[3].CVRTID": "<a href='#vehicleItem_3'>" + "Test centre</a> selection is required for vehicle" +" 4.", "TestBooking[3].ChangeOfOwnership": "<a href='#TestBooking[3].ChangeOfOwnership'>" + "Change of ownership declaration required." +" 4.", "TestBooking[3].ContactChoice": "Must select one type of" +" <a href='#vehicleItem_3'>" +"confirmation</a> and fill in the required information for vehicle" +" 4", "TestBooking[3].Email": { required: "<a href='#vehicleItem_3'>" + "Email address</a> is required for vehicle" +" 4", email: "<a href='#vehicleItem_3'>" + "The email address</a> provided is not in a valid format for vehicle" +" 4" }, "TestBooking[3].ConfirmEmail": { required: "<a href='#vehicleItem_3'>" + "Confirm Email address</a> is required for vehicle" +" 4", email: "<a href='#vehicleItem_3'>" + "The Confirm email address</a> provided is not in a valid format for vehicle" +" 4", validateConfirmEmail3: "<a href='#vehicleItem_3'>" + "Email address</a> and <a href='#'>Confirm Email address</a> you have entered do not match for vehicle" + " 4" }, "TestBooking[3].SMS": { digits: "<a href='#vehicleItem_3'>" +"The SMS number</a> provided needs to be numeric, e.g. 085282517172 for vehicle" +" 4.", validateMobileNumberSMS: "<a href='#vehicleItem_3'>" +"The SMS number</a> is not in a valid format for vehicle" +" 4." }, "TestBooking[3].Phone": "<a href='#vehicleItem_3'>" +"The Phone number </a> provided needs to be numeric, e.g. 0861234567 for vehicle" + " 4.", selectDay_4: "<a href='#vehicleItem_4'>" + "Day</a> is required for vehicle" + " 5" + " if chassis number is unknown." +"", selectMonth_4: "<a href='#vehicleItem_4'>" + "Month</a> is required for vehicle" +" 5" + " if chassis number is unknown." +"", txtYear_4: "<a href='#vehicleItem_4'>" + "Year</a> is required for vehicle" +" 5" + " if chassis number is unknown." +"", "TestBooking[4].DateFirstRegistration": { regDateGreaterThan: "<a href='#vehicleItem_4'>" + "The date of registration</a> must be in the past for vehicle" + " 5" }, "TestBooking[4].VIN": "<a href='#vehicleItem_4'>" + "Chassis number</a> is required for vehicle" +" 5 " + "Chassis number</a> is required for vehicle" +"", "TestBooking[4].ContactName": "<a href='#vehicleItem_4'>" + "Contact name</a> must be provided for vehicle" +" 5 ", "TestBooking[4].ContactFirstName": "<a href='#vehicleItem_4'>" + "Contact First Name</a> must be provided for vehicle" +" 5 ", "TestBooking[4].ContactSurname": "<a href='#vehicleItem_4'>" + "Contact Surname</a> must be provided for vehicle" +" 5 ", "TestBooking[4].ReasonExcludedFromSelfDecCode": "<a href='#vehicleItem_4'>" + "Reasons for not adding to Self-Declaration</a> is required for vehicle" +" 5 ", "TestBooking[4].ReasonExcludedFromSelfDecDesc": "<a href='#vehicleItem_4'>" + "Please state the other reason for not adding to Self-Declaration</a>" +" 5 ", "TestBooking[4].TestCategoryID": "<a href='#vehicleItem_4'>" + "Type of vehicle category</a> is required for vehicle " + " 5.", "TestBooking[4].CVRTID": "<a href='#vehicleItem_4'>" + "Test centre</a> selection is required for vehicle" +" 5.", "TestBooking[4].ChangeOfOwnership": "<a href='#TestBooking[4].ChangeOfOwnership'>" + "Change of ownership declaration required." +" 5.", "TestBooking[4].ContactChoice":"Must select one type of" +" <a href='#vehicleItem_4'>" +"confirmation</a> and fill in the required information for vehicle" +" 5", "TestBooking[4].Email": { required: "<a href='#vehicleItem_4'>" + "Email address</a> is required for vehicle" +" 5", email: "<a href='#vehicleItem_4'>" + "The email address</a> provided is not in a valid format for vehicle" +" 5" }, "TestBooking[4].ConfirmEmail": { required: "<a href='#vehicleItem_4'>" + "Confirm Email address</a> is required for vehicle" +" 5", email: "<a href='#vehicleItem_4'>" + "The Confirm email address</a> provided is not in a valid format for vehicle" +" 5", validateConfirmEmail4: "<a href='#vehicleItem_4'>" + "Email address</a> and <a href='#'>Confirm Email address</a> you have entered do not match for vehicle" + " 5" }, "TestBooking[4].SMS": { required: "<a href='#vehicleItem_4'>" +"If preferred contact method is SMS then mobile phone number is mandatory for vehicle" +" 5.", digits: "<a href='#vehicleItem_4'>" +"The SMS number</a> provided needs to be numeric, e.g. 085282517172 for vehicle" +" 5.", validateMobileNumberSMS: "<a href='#vehicleItem_4'>" +"The SMS number</a> is not in a valid format for vehicle" +" 5." }, "TestBooking[4].Phone": { required: "<a href='#vehicleItem_4'>" +"Either the Landline or mobile phone number must be entered for vehicle" +" 5.", validatePhoneNumber: "<a href='#vehicleItem_4'>" +"The Phone number </a> provided needs to be numeric, e.g. 0861234567 for vehicle" + " 5." }, chkTerms: "You must <a href='#chkTerms'>accept the terms</a> to continue." +"" }, ignore: {}, groups: {}, errorContainer: "#errorBox", errorLabelContainer: "#errorList", wrapper: 'li', focusInvalid: false, invalidHandler: function () { $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); // Select the county and send the id into the json query to get a selected number of CVRTest Centers. $('body').on('click', '.countyList input', function (e) { if ($(this).closest('[class^=countyList]').find($("input[id^=countyItems]:checked")).length >= 1) { $(this).closest('.formList').find('.testCentreSelector').show(); } else { $(this).closest('.formList').find('.testCentreSelector').hide(); } if ($(this).closest('[class^=countyList]').find($("input[id^=countyItems]:checked")).length >= 3) { $(this).closest('[class^=countyList]').find($("input[id^=countyItems]:unchecked")).attr('disabled', 'disabled'); } else { $(this).closest('[class^=countyList]').find($("input[id^=countyItems]")).removeAttr('disabled'); } var counties = []; $(this).closest('[class^=countyList]').find($("input[id^=countyItems]:checked")).each(function () { counties.push($(this).attr("countyId")); }); var testTypeCategory = GetTestTypeCategory().replace("HCV", "HGV").replace("LCV", "LGV"); // Populate dropdown with different test centers $.ajax({ type: "POST", url: 'GetRandomCVRTestCenters', data: { 'countyId': counties, 'testTypeCategory': testTypeCategory, 'testCategory': $("#VehicleTypeID").val() }, dataType: "json", traditional: true, success: function (jsonObj) { var multiOptions = '<option>Select<\/option>'; //check if page is multiple vehicles. var index = $(".vehicleItem").index(); if (index >= 0) { var currentVeh = $(".expanded").attr("id"); if (currentVeh != null) currentVeh = currentVeh.substr(currentVeh.length - 1); $.each(jsonObj, function () { var cls = ""; var style = ""; if (!this.AllowWebBookings) { cls += "allowwebbookings='false'"; style += "color: rgb(200,200,200)"; } else { cls += "allowwebbookings='true'"; } if (!this.OnlinePaymentsAllowed) { cls += " onlinepaymentsallowed='false'"; } else { cls += " onlinepaymentsallowed='true'"; } if (!this.SelfDeclarationServiceOffered) { cls += " selfdeclarationserviceoffered='false'"; } else { cls += " selfdeclarationserviceoffered='true'"; } multiOptions += '<option ' + cls + ' style="' + style + '" value="' + this.Value + '">' + this.Text + '<\/option>'; }); $("select#selectTestCentres_" + currentVeh).html(multiOptions); } else { $.each(jsonObj, function () { var cls = ""; var style = ""; if (!this.AllowWebBookings) { cls += "allowwebbookings='false'"; style += "color: rgb(200,200,200)"; } else { cls += "allowwebbookings='true'"; } if (!this.OnlinePaymentsAllowed) { cls += " onlinepaymentsallowed='false'"; } else { cls += " onlinepaymentsallowed='true'"; } if (!this.SelfDeclarationServiceOffered) { cls += " selfdeclarationserviceoffered='false'"; } else { cls += " selfdeclarationserviceoffered='true'"; } multiOptions += '<option ' + cls + ' style="' + style + '" value="' + this.Value + '">' + this.Text + '<\/option>'; }); $("select#selectTestCentres").html(multiOptions); } selectTestCentresOptions = multiOptions; } }); }); } //-------✂---------------------------------------------------- // ADR Step1 //-------✂---------------------------------------------------- //-------✂---------------------------------------------------- // ADR Step 2 //-------✂---------------------------------------------------- function doADRStep2() { // Grab some vars from the querystring //-------------------------------------------------------- var ADRType = getQueryParamByName('ADRType'), Skeletal = getQueryParamByName('Skeletal'), Sheeted = getQueryParamByName('chkSheeted'), newSubstanceCount = 0; // Hide some options if skeletal trailer //------------------------------------------------------ if (Skeletal === 'true') { $('.EXCat').hide(); } // Hide side helpboxes for certification lightbox if skeletal or sheeted //----------------------- if (Skeletal === 'true' || Sheeted === 'on') { $('#SpecProv.helpBox').hide(); $('#TankCode.helpBox').hide(); $('.tankSection').hide(); } } //-------✂---------------------------------------------------- // ADR Step 3 //-------✂---------------------------------------------------- function doADRStep3() { // Validation //-------✂---------------------------------------------------- $("#form_ADRStep3").validate({ rules: { chkBraking: { required: true }, chkCab: { required: true }, chkBody: { required: true } }, messages: { chkBraking: "You must declare your <a href='#chkBraking'>Braking compliance</a>.", chkCab: "You must declare your <a href='#chkCab'>Cab compliance</a>.", chkBody: "You must declare your <a href='#chkBody'>Body compliance</a>." }, groups: {}, errorContainer: "#errorBox", errorLabelContainer: "#errorList", wrapper: 'li', focusInvalid: false, invalidHandler: function () { $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); } //-------✂---------------------------------------------------- // Account Profile - 7.5 - Preferred test centre //-------✂---------------------------------------------------- function doAccountPreferredTestCentrePage() { //Hide sections $('.testCentreSelector').hide(); $('.testCentreChoice').hide(); $('#saveBtnArea').hide(); // Pick some countys to show dropdown - this could update other vehicle accordion items too $('.countyList input').on('click', function (e) { //Checks against list of counties to test if something is checked if ($(this).closest('[class^=countyList]').find($("input[name^=countyList]:checked")).val()) { $(this).closest('.formList').find('.testCentreSelector').fadeIn(); } else { $(this).closest('.formList').find('.testCentreSelector').hide(); } }); // Pick a test centre to show details and show contact/confirmation details - this could update other vehicle accordion items too $('.testCentreSelector select').on('change', function (e) { if ($(this).val()) { //show centre detail box $(this).closest('.formPart').find('.testCentreChoice').fadeIn(); //show confirmation section $(this).closest('.formPart').find('#saveBtnArea').fadeIn(); } }); } //-------✂---------------------------------------------------- // LGV Step 1 - Landing //-------✂---------------------------------------------------- function doLGVStep1landing() { //Reset form data on page load? clearFormFields(); //Hide sections $('.vehicleDetailBox').hide(); // Enter vehicle details to show next section $('.formPart1 input, .formPart1 select').bind('change blur keyup keydown', function (e) { var vehicleRegNo = $(this).closest('.formList').find("[id^=txtVehicleRegNo]").val(), vehicleDFR_DD = $(this).closest('.formList').find("[id^=selectDay]").val(), vehicleDFR_MM = $(this).closest('.formList').find("[id^=selectMonth]").val(), vehicleDFR_YY = $(this).closest('.formList').find("[id^=txtYear]").val(); if (vehicleRegNo !== '' && vehicleDFR_DD !== '' && vehicleDFR_MM !== '' && vehicleDFR_YY >= 1900 && vehicleDFR_YY <= 2100) { $(this).closest("[id^=vehicleItem]").find('.vehicleDetailBox').fadeIn(); } }); // validation $("#form_LGVStep1").validate({ rules: { txtVehicleRegNo1: { required: true }, selectDay1: { required: true }, selectMonth1: { required: true }, txtYear1: { required: true, rangelength: [4, 4], digits: true, min: 1900, max: 2100 } }, messages: { txtVehicleRegNo1: "<a href='#txtVehicleRegNo'>Vehicle Registration Number</a> is required.", selectDay1: "<a href='#selectDay'>Day</a> is required if chassis number is unknown.", selectMonth1: "<a href='#selectMonth'>Month</a> is required if chassis number is unknown.", txtYear1: "<a href='#selectYear'>Year</a> is required for if chassis number is unknown." }, groups: {}, errorContainer: "#errorBox", errorLabelContainer: "#errorList", wrapper: 'li', focusInvalid: false, invalidHandler: function () { $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); } //-------✂---------------------------------------------------- // LGV Pre Booked //-------✂---------------------------------------------------- //-------✂---------------------------------------------------- // Schedule page - multiple vehicles //-------✂---------------------------------------------------- // SGS function doSchedulePage() { $(document).ready(function () { showHideCancelTestLinks() }); // // Toggle the test centre selection box // $('.selectedTestCentreBox .expandLink').on('click', function (e) { e.preventDefault(); $('input:checkbox').removeAttr('checked'); $('input:checkbox').attr("disabled", false) $("input:checkbox").limit(3); }); $('.selectedTestCentreBox .changeTestCentre').on('click', function (e) { e.preventDefault(); var testCentreBox = $(this).closest('.selectedTestCentreBox').find('.changeTestCentreBox'), scheduleBox = $(this).closest('.selectedTestCentreBox').find('.preferredDateTime'); if (testCentreBox.hasClass('hidden')) { testCentreBox.removeClass('hidden'); } else { testCentreBox.addClass('hidden'); } }); // Part 2 $('.countyList input').on('click', function (e) { //Checks against list of counties to test if something is checked if ($(this).closest('.countyList').find($("input[name='countyList']:checked")).val()) { //show the select box $(this).closest('.formList').find('.testCentreSelector1').fadeIn(); } else { //hide the select box $(this).closest('.formList').find('.testCentreSelector1').hide(); } }); // Part 3 $('.testCentreSelector1 select').on('change', function (e) { //If user picks a new test centre then reset the calendar, remove the green tick, erase the datetime if ($(this).val()) { var thisTestBox = $(this).closest('.selectedTestCentreBox'); thisTestBox.find('.selected').removeClass('selected'); thisTestBox.find('.availableTimeSlots').hide(); thisTestBox.find('.successFlash').remove(); thisTestBox.find('.selectedDateTime').html(''); } }); // // Prevent continual unless a time has been selected for each box // $('input:submit').on('click', function (e) { var input = $(e.currentTarget); var which_button = e.currentTarget.name; if (which_button == "backbtn") { return true } //Count vehicles and count selected times. If they don't match tell user to select times for them all var numberOfVehicles = $('.selectedTestCentreBox').length; var emptyDivs = $(".selectedDateTime").filter(function () { return $.trim($(this).text()) === ""; }); //var numberOfTimesSelected = $(".selectedDateTime:not(:has(div.inside:empty))").length; //if (numberOfVehicles !== numberOfTimesSelected) { if (emptyDivs.length > 0) { if (numberOfVehicles > 1) { $('#errorList').html('<li>You will need to select a date and time for each vehicle to continue</li>'); } else { $('#errorList').html('<li>You will need to select a date and time this vehicle to continue</li>'); } $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); return false; } }); // Show and hide the add vehicle and remove vehicle buttons function showHideCancelTestLinks() { var vehicleCount = $('.selectedTestCentreBox').length, cancelTestLinks = $('a.deleteTestItem'), expandLink = $('.selectedTestCentreBox'); if (vehicleCount === 1) { cancelTestLinks.hide(); expandLink.find('.expandLink').remove(); } else { cancelTestLinks.show(); } } // Completely delete a scheduled test box if ($('.deleteTestItem').length) { (function () { var boxIndex; $('.deleteTestItem').on('click', function (e) { boxIndex = $(this).closest('.selectedTestCentreBox').index(); e.preventDefault(); $(this).colorbox({ inline: true, href: "#confirmDelete", width: 350, height: 200, speed: 100, fixed: true, opacity: 1, overlayClose: false }); }); $('#btnContinueDelete').on('click', function (e) { e.preventDefault(); $('.selectedTestCentreBox:eq(' + boxIndex + ')').hide(); $('.selectedTestCentreBox:eq(' + boxIndex + ')').find(".selectedDateTime").html("01/01/2012"); $('.selectedTestCentreBox:eq(' + boxIndex + ')').find('[id^=TestBookingDeleted' + boxIndex + ']').val(true); showHideCancelTestLinks(); $.colorbox.close(); boxIndex = ''; showHideCancelTestLinks(); return false; }); $('#btnCancelDelete').on('click', function (e) { e.preventDefault(); $.colorbox.close(); boxIndex = ''; return false; }); }()); } } //-------✂---------------------------------------------------- // Payment page //-------✂---------------------------------------------------- function doPaymentPage() { $('#radPayTestCentre').on('click', function (e) { $('#paymentBox').fadeOut(); }); } $(function () { $('#form_paymentForm').submit(function (e) { e.preventDefault(); $("#loading").show(); //$(this).find('.ieBtnO673').attr('disabled', true); //$('.submit').attr('disabled', true); if ($(this).valid()) { $.ajax({ url: "/test/Save", type: "POST", data: $(this).serialize(), success: function (result) { validateResultss(result); }, cache: false }); } }); $('#form_paymentForm2').submit(function (e) { e.preventDefault(); if ($(this).valid()) { $("#loading").show(); //$(this).find('.ieBtnO673').attr('disabled', true); $.ajax({ url: "/test/Save", type: "POST", data: $(this).serialize(), success: function (result) { validateResultsss(result); }, cache: false }); } }); }); function validateResultss(result) { if (result == "success") { $('#form_paymentForm').unbind('submit').submit(); return true; } else { SetErrorMessages(result); } } function validateResultsss(result) { if (result == "success") { $('#form_paymentForm2').unbind('submit').submit(); return true; } else { SetErrorMessages(result); } } //-------✂---------------------------------------------------- // Self Declaration Step 4 - Fade and disable button when checkbox isn't ticked //-------✂---------------------------------------------------- function doSelfDecStep4() { //Page load if (!$('#chkTerms').attr('checked')) { $('#subminDeclareBtn').attr('disabled', true).addClass('faded'); } else { $('#subminDeclareBtn').attr('disabled', false).removeClass('faded'); } //Click $('#chkTerms').on('click', function () { if (!$('#chkTerms').attr('checked')) { $('#subminDeclareBtn').attr('disabled', true); $('#subminDeclareBtn').attr('disabled', true).addClass('faded'); } else { $('#subminDeclareBtn').attr('disabled', false); $('#subminDeclareBtn').attr('disabled', false).removeClass('faded'); } }); } //-------✂---------------------------------------------------- // CRW Replacement Request Step1 //-------✂---------------------------------------------------- function doAddNewUserPage() { // CRW page validation $("#form_addNewUserPage").validate({ rules: { txtFirstname: { required: true }, txtSurname: { required: true }, txtEmail: { required: true } }, messages: { txtFirstname: "<a href='#txtFirstname'>First name</a> is required.", txtSurname: "<a href='#txtSurname'>Surname</a> is required.", txtEmail: "<a href='#txtEmail'>Email</a> is required." }, groups: {}, errorContainer: "#errorBox", errorLabelContainer: "#errorList", wrapper: 'li', focusInvalid: false, invalidHandler: function () { $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); } //-------✂---------------------------------------------------- // CRW Replacement Request Step1 //-------✂---------------------------------------------------- function doContactUsPage() { $("#form_contactUs").validate({ rules: { selectNature: { required: true }, txtAreaComment: { required: true }, txtName: { required: true }, txtNumber: { required: true }, txtEmail: { required: true } }, messages: { selectNature: "<a href='#selectNature'>Nature of complaint</a> is required.", txtAreaComment: "<a href='#txtAreaComment'>A comment</a> is required.", txtName: "<a href='#txtName'>Your name</a> is required.", txtNumber: "<a href='#txtNumber'>Your contact number</a> is required.", txtEmail: "<a href='#txtEmailtxtFirstname'>Your email address</a> is required." }, groups: {}, errorContainer: "#errorBox", errorLabelContainer: "#errorList", wrapper: 'li', focusInvalid: false, invalidHandler: function () { $('#errorBox').removeClass('hidden'); $('html, body').animate({ scrollTop: 0 }, 'slow'); } }); } //-------✂---------------------------------------------------- // Lightbox triggers //-------✂---------------------------------------------------- function clearVehicleDetails(vehicleItem) { vehicleItem.closest('.formList').find("[id^=vehicleType]").html('<strong>N/A</strong>'); vehicleItem.closest('.formList').find("[id^=VehicleTypeID]").val(''); vehicleItem.closest('.formList').find("[id^=selectDay]").val(''); vehicleItem.closest('.formList').find("[id^=selectMonth]").val(''); if (vehicleItem.closest("[id^=vehicleItem]").find("[id^=selectTestType]").val() == 2) { vehicleItem.closest("[id^=vehicleItem]").find('.chooseTestCenter').removeClass('hidden'); vehicleItem.closest("[id^=vehicleItem]").find("[id^=selectTestType]").val(1); vehicleItem.closest("[id^=vehicleItem]").find("[id^=CVRTID]").val(0); vehicleItem.closest("[id^=vehicleItem]").find('.testCentreChoice').fadeOut(); } vehicleItem.find('.chooseTestCenter').removeClass('hidden'); vehicleItem.closest('.formList').find("[id^=txtYear]").val('YYYY'); vehicleItem.closest('.formList').find("[id^=VIN]").val(''); $('#altInput-chassisNo').hide(); var path = window.location.pathname; var page = path.split("/").pop(); if (page.toUpperCase() != "CREATE") { vehicleItem.closest('.formList').find('.chassisNo').hide(); } vehicleItem.closest("[id^=vehicleItem]").find('.vehicleDetailBox').fadeOut(); vehicleItem.closest("[id^=vehicleItem]").find('.testTypeRequired').fadeOut(); vehicleItem.closest("[id^=vehicleItem]").find('.warningBox').fadeOut(); vehicleItem.closest('.formList').find("[id^=VehicleID]").val(0); } $(document).ready(function () { // Test centre map lightbox if (typeof $("#triggerTestCentreMap") !== 'undefined') { $("#triggerTestCentreMap").colorbox({ iframe: true, href: "/Test/FindCVRTestCenterMap", width: 818, height: 650, fixed: false, opacity: 1 }); } // Terms lightbox if (typeof $("#triggerTerms") !== 'undefined') { $("#triggerTerms").colorbox({ iframe: true, href: "/Home/TermsAndConditions", width: 970, height: 670, fixed: false, opacity: 1 }); } if (typeof $(".vehicleDocuments") !== 'undefined') { var listName = $("#VehicleYear").val(); var folderId = $("#VehicleID").val(); $(".vehicleDocuments").colorbox({ iframe: true, href: "/Lightbox/UploadFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle", width: 818, height: 650, fixed: false, opacity: 1 }); }; if (typeof $(".bookingDocuments_0") !== 'undefined') { var folderId = $("#RegistrationNumber_0").val(); var listName = $("#VehicleYear_0").val(); var bookingId = $("#BookingID_0").val(); $(".bookingDocuments_0").colorbox({ iframe: true, href: "/Test/UploadBookingFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle&bookingId=" + bookingId, width: 818, height: 650, fixed: false, opacity: 1 }); }; if (typeof $("#BookingID_1") !== 'undefined') { var folderId = $("#RegistrationNumber_1").val(); var listName = $("#VehicleYear_1").val(); var bookingId = $("#BookingID_1").val(); $(".bookingDocuments_1").colorbox({ iframe: true, href: "/Test/UploadBookingFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle&bookingId=" + bookingId, width: 818, height: 650, fixed: false, opacity: 1 }); }; if (typeof $("#BookingID_2") !== 'undefined') { var folderId = $("#RegistrationNumber_2").val(); var listName = $("#VehicleYear_2").val(); var bookingId = $("#BookingID_2").val(); $(".bookingDocuments_2").colorbox({ iframe: true, href: "/Test/UploadBookingFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle&bookingId=" + bookingId, width: 818, height: 650, fixed: false, opacity: 1 }); }; if (typeof $("#BookingID_3") !== 'undefined') { var folderId = $("#RegistrationNumber_3").val(); var listName = $("#VehicleYear_3").val(); var bookingId = $("#BookingID_3").val(); $(".bookingDocuments_3").colorbox({ iframe: true, href: "/Test/UploadBookingFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle&bookingId=" + bookingId, width: 818, height: 650, fixed: false, opacity: 1 }); }; if (typeof $("#BookingID_4") !== 'undefined') { var folderId = $("#RegistrationNumber_4").val(); var listName = $("#VehicleYear_4").val(); var bookingId = $("#BookingID_4").val(); $(".bookingDocuments_4").colorbox({ iframe: true, href: "/Test/UploadBookingFiles?folderId=" + folderId + "&entityName=core_vehicle&listName=" + listName + "&siteNameConfig=SP_Site_Vehicle&bookingId=" + bookingId, width: 818, height: 650, fixed: false, opacity: 1 }); }; //-------✂---------------------------------------------------- // Dialog boxes //-------✂---------------------------------------------------- // Test centre map lightbox if (typeof $(".triggerTestCentreMap") !== 'undefined') { $(".triggerTestCentreMap").colorbox({ iframe: true, href: "/Test/FindCVRTestCenterMap", width: 818, height: 650, fixed: false, opacity: 1 }); } if (typeof $(".triggerSingleTestCentreMap") !== 'undefined') { var cvrtID = $(".triggerSingleTestCentreMap").attr('cvrtID'); $(".triggerSingleTestCentreMap").colorbox({ iframe: true, href: "/Test/CVRTestCenterMap?cvrtid=" + cvrtID, width: 818, height: 650, fixed: true, opacity: 1 }); } $("#btnAddNew").click(function () { $.colorbox({ href: '/Test/VehicleLookup', width: 818, height: 743, fixed: false, opacity: 1 }); }); //Get the Test Center details and display them in a text box. $('body').on('change', '.testCentreSelector select', function (e) { if ($(this).val() != null && $(this).val() != 0) { var cvrtCentreId = $(this).val(); var currentVeh = $(this).attr("id"); currentVeh = currentVeh.substr(currentVeh.length - 1); displayCVRTestcenterDetails(cvrtCentreId, currentVeh); } }); $('body').on('change', '.RegistrationNumber', function (e) { clearVehicleDetails($(this)); var index = $(".vehicleItem").index(); if (index < 0) { $('.warningBox').hide(); $("#messageProcced").hide() } $('#errorBox').addClass('hidden'); RemoveTestTypeError(); var path = window.location.pathname; var page = path.split("/").pop(); if (page.toUpperCase() != "BOOKHGVLGVTEST") { //if ($("#recaptchaHidden").val() == "false" || $("#recaptchaHidden").val() == "") { // $('#recaptcha_response_field').rules('add', 'required'); //} } if (page.toUpperCase() == "BOOKPUBLICLGVTEST") { $(".vehicleTypeSection").addClass("hidden") $("#btnSubmit").css("display", "none"); $("#btnContinue").css("display", "inline"); $('#errorBOOKPUBLICLGVTESTHidden').val("false") } if (page.toUpperCase() == "CRWEXPIRYTESTREMINDER" || page.toUpperCase() == "ONHOLDCRWDETAILS") { if ($("#RegistrationNumberHidden").val() != "" && $("#RegistrationNumberHidden").val() != $("#RegistrationNumber").val()) { $("#btnSubmit").css("display", "none"); $("#btnNext").css("display", "inline-block"); } } }); $('body').on('change', function (e) { if (!$('#errorBox').hasClass('hidden')) { $('#errorBox').addClass('hidden'); } if (!$('#rulesErrorBox').hasClass('hidden')) { $('#rulesErrorBox').addClass('hidden'); } }); //Get the restest details $('body').on('change', '.testTypeSelector select', function (e) { // check if user can retest var testType = $(this); if ($(this).val() == 2) { var vehicleId = ''; var index = $(".vehicleItem").index(); if (index >= 0) { var currentVeh = $(".expanded").index(); vehicleId = $("#VehicleID_" + currentVeh).val(); } else { vehicleId = $("#VehicleID").val(); } $.ajax({ type: "POST", url: 'GetRetestDetails', data: { 'vehicleID': vehicleId }, dataType: "json", traditional: true, success: function (jsonObj) { if (jsonObj !== null) { if ($.isNumeric(jsonObj)) { displayCVRTestcenterDetails(jsonObj, $(".vehicleItem").index()); $('.testCentreChoice').fadeIn(); var myindex = $(".vehicleItem").index(); var vehicleBox; if (myindex > 0) { var currentVehicle = $(".expanded").index(); vehicleBox = $('.vehicleItem:eq(' + currentVehicle + ')'); vehicleBox.find('.chooseTestCenter').addClass('hidden'); vehicleBox.find('.formPart2 h2').addClass('hidden'); } else { $('.chooseTestCenter').addClass('hidden'); $('.formPart2 h2').addClass('hidden'); } } else { testType.val(1); SetErrorMessages(jsonObj); ShowADRDiscount(); } } getDiscount(); } //displayCVRTestcenterDetails(cvrtCentreId); }); } else { $('#rulesErrorBox').addClass('hidden'); var myindex = $(".vehicleItem").index(); var vehicleBox; if (myindex > 0) { var currentVehicle = $(".expanded").index(); vehicleBox = $('.vehicleItem:eq(' + currentVehicle + ')'); vehicleBox.find('.chooseTestCenter').removeClass('hidden'); vehicleBox.find('.formPart2 h2').removeClass('hidden'); } else { $('.chooseTestCenter').removeClass('hidden'); $('.formPart2 h2').removeClass('hidden'); } getDiscount(); } }); $('body').on('click', '.changeTestTypeLink', function (e) { e.preventDefault(); $(this).closest("[id^=vehicleItem]").find('.selectTestType').fadeIn(); $(this).closest('li').find('.lblResult').hide(); }); $('body').on('click', '.contactTypeSelect :radio', function (e) { if ($(this).siblings("input[type='text']").val() === "" || $(this).siblings("input[type='text']").val() === null) { var textBox = $(this).siblings("input[type='text']"); var prefixBox = $(this).siblings("select"); var contactType = $(this).val(); // Clear contact text boxes that haven't been selected var index = $(".vehicleItem").index(); if (index >= 0 || ($('#Email_0').length)) { var currentVeh = $(".expanded").index(); if (contactType == "Email") { $('#SMS_' + currentVeh).val(""); $('#Phone_' + currentVeh).val(""); } if (contactType == "SMS") { $('#Email_' + currentVeh).val(""); $('#Phone_' + currentVeh).val(""); } if (contactType == "Phone") { $('#Email_' + currentVeh).val(""); $('#SMS_' + currentVeh).val(""); } } else { if (contactType == "Email") { $('#SMS').val(""); $('#Phone').val(""); } if (contactType == "SMS") { $('#Email').val(""); $('#Phone').val(""); } if (contactType == "Phone") { $('#Email').val(""); $('#SMS').val(""); } } // End clear contact text boxes $.ajax({ type: "POST", url: 'GetOperatorContactDetails', data: { 'contactType': contactType }, dataType: "json", traditional: true, success: function (jsonObj) { if (contactType === "SMS") { var splietpieces = jsonObj.split('/'); prefixBox.val(splietpieces[0]); textBox.val(splietpieces[1]); } else { textBox.val(jsonObj); } } }); } }); }); //-------✂---------------------------------------------------- // Tabs (dashboard etc) //-------✂---------------------------------------------------- $(document).ready(function () { if (typeof $("ul.tabs") !== 'undefined') { $('ul.tabs').each(function () { // For each set of tabs, we want to keep track of // which tab is active and it's associated content var $active, $content, $links = $(this).find('a'); // If the location.hash matches one of the links, use that as the active tab. // If no match is found, use the first link as the initial active tab. $active = $($links.filter('[href="' + location.hash + '"]')[0] || $links[0]); $active.addClass('current'); $content = $($active.attr('href')); // Hide the remaining content $links.not($active).each(function () { $($(this).attr('href')).hide(); }); // Bind the click event handler $(this).on('click', 'a', function (e) { // Make the old tab inactive. $active.removeClass('current'); $content.hide(); // Update the variables with the new link and content $active = $(this); $content = $($(this).attr('href')); // Make the tab active. $active.addClass('current'); $content.show(); // Prevent the anchor's default click action e.preventDefault(); }); }); } }); //-------✂---------------------------------------------------- // Home rolled tooltips //-------✂---------------------------------------------------- $.fn.betterTooltip = function (options) { var tip = $('.tooltip'); /* Mouse over and out functions*/ $("body").on("click", ".tooltip-close", function () { $(this).parents('.tooltip').fadeOut(); $(this).next('.tooltip-point').remove(); $(this).remove(); return false; }); $(this).click( function () { var offset = $(this).position(), tLeft = offset.left, tTop = ((offset.top) + 20) + 'px', linkWidth = ($(this).width()) / 2, windowWidth = $('#fullWrap').width(),// Ensure tip stays within bounds of window etc tooltipRightSide = ($(this).offset().left) + $('.tooltip').width(), moveIn = 0; // if this offset plus this width is greater than pageWidth, move it in a bit if (windowWidth != null && tooltipRightSide > windowWidth) { moveIn = tooltipRightSide - windowWidth + 20; tLeft -= moveIn; } tLeft = (tLeft - 23 + linkWidth) + "px"; if ($(this).next('.tooltip').is(':visible')) { $('.tooltip').fadeOut(); $('.tooltip-point').remove(); $('.tooltip-close').remove(); } else { $('.tooltip').hide(); $(this).next('.tooltip').css({ 'top': tTop, 'left': tLeft }); //Appending assets here to keep the html clean $(this).next('.tooltip').prepend('<a class="tooltip-close" href="#"></a>'); $(this).next('.tooltip').prepend('<span class="tooltip-point"></span>'); $(this).next('.tooltip').fadeIn(); $(this).next('.tooltip').find('.tooltip-point').css('left', (10 + moveIn) + 'px'); } return false; } ); }; $(document).ready(function () { if ($('.helpMe').length) { $('.helpMe').betterTooltip({}); } }); //-------✂---------------------------------------------------- // Schedule calendar //-------✂---------------------------------------------------- function initCalendar() { //Hide times until day picked $('.availableTimeSlots').hide(); $('table.calendar td a').on('click', function () { $(this).closest('.calendar-page').find('table.calendar td').removeClass('selected'); $(this).closest('td').addClass('selected'); var offset = $(this).parent().position(); $(this).closest('.calendar-page').find('.availableTimeSlots').fadeIn(); }); $('table.calendar td a').on('click', function (e) { e.stopPropagation(); }); //Select a Time slot and show the continue button. var timeSlot = $('.calendar-page ul li a'); timeSlot.on('click', function (e) { e.preventDefault(); }); } //-------✂---------------------------------------------------- // Rating bar //-------✂---------------------------------------------------- //function initRatingBar() { // var yourRatingMarker = $('.bigMark'), // averageRatingMarker = $('.lilMark'), // ratingBarWidth = $('.ratingBar').width() - yourRatingMarker.width(),//Else 100% goes past the edge // yourBubble = $('.bigMark .ratingBubble'),//Tooltip with users details // averageBubble = $('.lilMark .ratingBubble'),//Tooltip with average text // //Replacing math.random with a decimal percentage will move the markers to that position // yourRating = Math.random() * ratingBarWidth, // averageRating = Math.random() * ratingBarWidth; // //yourRatingMarker.css('left', yourRating + 'px'); // //averageRatingMarker.css('left', averageRating + 'px'); // if (averageRating > ratingBarWidth / 2) { // averageBubble.addClass('flip'); // } // yourBubble.css('opacity', 0); // yourRatingMarker.animate({ left: yourRating }, 1000, function () { // yourBubble.animate({ opacity: 1 }, 500, function () { }); // }); // averageBubble.css('opacity', 0); // averageRatingMarker.animate({ left: averageRating }, 1000, function () { // averageBubble.animate({ opacity: 1 }, 500, function () { }); // }); //} function doCvoriRatingBar() { $(document).ready(function () { var activeTab = $('#cvoriTabs .current').attr('id'); if ($('.ratingBar').length) { initRatingBar(activeTab); }; $('#cvoriTabs ul li a').click(function () { if ($('.ratingBar').length) { activeTab = $(this).attr('id'); $('[class^="big"]').css('left', 0); initRatingBar(activeTab); } }); }); function initRatingBar(activeTab) { var yourRatingMarker = $('.bigMark'); var ratingBarWidth = $('.ratingBar').width() - yourRatingMarker.width(); // Else 100% goes past the edge var yourBubble = $('.bigMark .ratingBubble'); // Tooltip with users details var yourRating; // Check which tab is selected to choose where the marker should be positioned if (activeTab == "overallTab") { yourRating = $('#overallRatingMarker').val(); } else if (activeTab == "roadTab") { yourRating = $('#roadMarker').val(); } else if (activeTab == "driverTab") { yourRating = $('#driverHrsMarker').val(); } yourBubble.css('opacity', 0); yourRatingMarker.animate({ left: yourRating }, 1000, function () { yourBubble.animate({ opacity: 1 }, 500, function () { }); }); } } //-------✂------------doADRStep3---------------------------------------- // Page specific triggers //-------✂---------------------------------------------------- $(document).ready(function () { // 1.1.0_Registration_Step2_Individual.html if ($('#registerPageStep2').length) { doRegisterPageStep2(); } // 1.1.2_Registration_Step2_Company.html if ($('#registerPageStep2Company').length) { doRegisterPageStep2Company(); } // 1.3_Registration_SetUsername.html if ($('#registerPageSetUsername').length) { doRegisterPageSetUsername(); } // 1.4_Registration_SetNewPassword.html if ($('#setPasswordPage').length) { doRegisterPageSetPassword(); } // Test type alignment if ($('#testTypeOptions').length) { matchHeights($('#testTypeOptions li')); } // HGV Flow if ($('#HGVStep1').length) { doHGVStep1(); } // ADR Flow // if ($('#ADRStep1').length) { doADRStep1(); } if ($('#ADRStep2').length) { doADRStep2(); } if ($('#ADRStep3').length) { doADRStep3(); } // LGV Flow if ($('#LGVStep1-landing').length) { doLGVStep1landing(); } if ($('#LGVStep1').length) { doHGVStep1(); } if ($('#LGVPreBooked').length) { doHGVStep1(); } // Schedule pages if ($('#testSchedulePage').length) { doSchedulePage(); } // Payment pages if ($('#PaymentPage').length) { doPaymentPage(); } // Vehicle accordion page if ($('#vehicleAccordion').length) { doVehicleAccordion(); } // Self Declaration if ($('#SelfDecStep1').length) { doSelfDecStep1(); } if ($('#SelfDecStep3').length) { doSelfDecStep3(); } if ($('#SelfDecStep4').length) { doSelfDecStep4(); } // Request replacement CRW if ($('#CRWRequestStep1').length) { doCRWRequestStep1(); } // Add New User Page if ($('#addNewUserPage').length) { doAddNewUserPage(); } // Account admin - preferred test centre selection if ($('#accountPreferredTestCentre').length) { doAccountPreferredTestCentrePage(); } // Contact Us if ($('#contactUsPage').length) { doContactUsPage(); } // If page has accordion, init it if ($('.accordion').length) { initAccordion(); } // If page has calendar, init it // if ($('.calendar-page').length) { initCalendar(); } // If page has rating bar, init it if ($('.ratingBar').length) { doCvoriRatingBar(); } // If page has centeredInfoLists, set them the same as the height of the biggest one if ($('.centeredInfoList').length) { matchHeights($('.centeredInfoList')); } if ($('#form_CRWExpiryTextReminderStep1').length) { doCRWExpiryTextReminderStep1(); } if ($('#form_OnHoldCRWDetailsStep1').length) { doOnHoldCRWDetailsStep1(); } if ($('#form_LGVStep1').length) { doBookLgvTest(); } }); //-------✂---------------------------------------------------- // Only run this on IE8 and below //-------✂---------------------------------------------------- if ($.browser.msie && parseFloat($.browser.version) < 9) { //Tooltip Z fix if ($('.formList > li').length) { //Decrement the z-indexes backwards so that they can show tooltips properly $(function () { //IE bug fix - tooltips need js to open anyways, so it's ok to use it to fix em... var zIndexNumber = 1000; $('.formList > li').each(function () { $(this).css('zIndex', zIndexNumber); zIndexNumber -= 10; }); }); } } //-------✂---------------------------------------------------- // Only run this on IE8 and below //-------✂---------------------------------------------------- }()); //-------?------------------------------- // Disable Browser Cache Ajax.ActionLinks //-------?------------------------------- $(document).ready(function () { $.ajaxSetup({ cache: false }); }); //called when key is pressed in textbox to only allow numbers $(document).ready(function () { $(".onlyNumbers").keypress(function (e) { //if the letter is not digit then display error and don't type anything if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false; } }); }); //-------?---------------------------------------------------- // Common Functions for Easting/Northing calcs - PHS //-------?---------------------------------------------------- // ============================== LatLng ==================================== function LatLng(lat, lng) { this.lat = lat; this.lng = lng; this.distance = LatLngDistance; this.toOSRef = LatLngToOSRef; this.toUTMRef = LatLngToUTMRef; this.WGS84ToOSGB36 = WGS84ToOSGB36; this.OSGB36ToWGS84 = OSGB36ToWGS84; this.toString = LatLngToString; } // ========================== LatLngToString ================================ function LatLngToString() { return this.lat + ", " + this.lng; } // ============================== OSRef ===================================== function OSRef(easting, northing) { this.easting = easting; //this.easting = (Number(easting) - Number(48.3699)); this.northing = northing; //this.northing = (Number(northing) + Number(21.6464)); this.toLatLng = OSRefToLatLng; this.toString = OSRefToString; this.toTenFigureString = OSRefToTenFigureString; } // ============================== OSIRef ===================================== function OSIRef(easting, northing) { this.easting = (Number(easting) - Number(48.3699)); this.northing = (Number(northing) + Number(21.6464)); this.toLatLng = OSRefToLatLng; this.toString = OSRefToString; this.toTenFigureString = OSRefToTenFigureString; } // ========================= OSRefToString ==================================== function OSRefToString() { return this.easting + ", " + this.northing; } // ========================= OSRefToTenFigureString =========================== function OSRefToTenFigureString() { var hundredkmE = Math.floor(this.easting / 100000); var hundredkmN = Math.floor(this.northing / 100000); var firstLetter = ""; if (hundredkmN < 1) { if (hundredkmE < 1) { firstLetter = "V"; } else if (hundredkmE < 2) { firstLetter = "W"; } else if (hundredkmE < 3) { firstLetter = "X"; } else if (hundredkmE < 4) { firstLetter = "Y"; } else if (hundredkmE < 5) { firstLetter = "Z"; } else { firstLetter = "I"; } } else if (hundredkmN < 2) { if (hundredkmE < 1) { firstLetter = "Q"; } else if (hundredkmE < 2) { firstLetter = "R"; } else if (hundredkmE < 3) { firstLetter = "S"; } else if (hundredkmE < 4) { firstLetter = "T"; } else if (hundredkmE < 5) { firstLetter = "U"; } else { firstLetter = "I"; } } else if (hundredkmN < 3) { if (hundredkmE < 1) { firstLetter = "L"; } else if (hundredkmE < 2) { firstLetter = "M"; } else if (hundredkmE < 3) { firstLetter = "N"; } else if (hundredkmE < 4) { firstLetter = "O"; } else if (hundredkmE < 5) { firstLetter = "P"; } else { firstLetter = "I"; } } else if (hundredkmN < 4) { if (hundredkmE < 1) { firstLetter = "F"; } else if (hundredkmE < 2) { firstLetter = "G"; } else if (hundredkmE < 3) { firstLetter = "H"; } else if (hundredkmE < 4) { firstLetter = "J"; } else if (hundredkmE < 5) { firstLetter = "K"; } else { firstLetter = "I"; } } else if (hundredkmN < 5) { if (hundredkmE < 1) { firstLetter = "A"; } else if (hundredkmE < 2) { firstLetter = "B"; } else if (hundredkmE < 3) { firstLetter = "C"; } else if (hundredkmE < 4) { firstLetter = "D"; } else if (hundredkmE < 5) { firstLetter = "E"; } else { firstLetter = "I"; } } else { firstLetter = "I"; } var e = Math.floor(this.easting - (100000 * hundredkmE)); var n = Math.floor(this.northing - (100000 * hundredkmN)); var es = e; if (e < 10000) es = "0" + es; if (e < 1000) es = "0" + es; if (e < 100) es = "0" + es; if (e < 10) es = "0" + es; var ns = n; if (e < 10000) ns = "0" + ns; if (e < 1000) ns = "0" + ns; if (n < 100) ns = "0" + ns; if (n < 10) ns = "0" + ns; return firstLetter + es + ns; } // ================================ RefEll ================================== function RefEll(maj, min) { this.maj = maj; this.min = min; this.ecc = ((maj * maj) - (min * min)) / (maj * maj); } // ========================= Mathematical Functions ======================== function sinSquared(x) { return Math.sin(x) * Math.sin(x); } function cosSquared(x) { return Math.cos(x) * Math.cos(x); } function tanSquared(x) { return Math.tan(x) * Math.tan(x); } function sec(x) { return 1.0 / Math.cos(x); } function deg2rad(x) { return x * (Math.PI / 180); } function rad2deg(x) { return x * (180 / Math.PI); } function chr(x) { var h = x.toString(16); if (h.length == 1) h = "0" + h; h = "%" + h; return unescape(h); } function ord(x) { var c = x.charAt(0); var i; for (i = 0; i < 256; ++i) { var h = i.toString(16); if (h.length == 1) h = "0" + h; h = "%" + h; h = unescape(h); if (h == c) break; } return i; } // =========================== Other Functions ============================== function LatLngDistance(to) { var er = 6371.29; // 6366.707 var latFrom = deg2rad(this.lat); var latTo = deg2rad(to.lat); var lngFrom = deg2rad(this.lng); var lngTo = deg2rad(to.lng); var x1 = er * Math.cos(lngFrom) * Math.sin(latFrom); var y1 = er * Math.sin(lngFrom) * Math.sin(latFrom); var z1 = er * Math.cos(latFrom); var x2 = er * Math.cos(lngTo) * Math.sin(latTo); var y2 = er * Math.sin(lngTo) * Math.sin(latTo); var z2 = er * Math.cos(latTo); var d = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)); return d; } // ================== OSGB36ToWGS84 Conversion Functions ===================== function OSGB36ToWGS84() { var airy1830 = new RefEll(6377340.189, 6356034.447); var a = airy1830.maj; var b = airy1830.min; var eSquared = airy1830.ecc; var phi = deg2rad(this.lat); var lambda = deg2rad(this.lng); var v = a / (Math.sqrt(1 - eSquared * sinSquared(phi))); var H = 0; // height var x = (v + H) * Math.cos(phi) * Math.cos(lambda); var y = (v + H) * Math.cos(phi) * Math.sin(lambda); var z = ((1 - eSquared) * v + H) * Math.sin(phi); var tx = 446.448; // 482.530; // var ty = -124.157; //-130.596; // var tz = 542.060; // 564.557; // var s = -0.000008150; //-0.0000204894; // var rx = deg2rad(0.00004172222); //deg2rad( 0.0003894444); var ry = deg2rad(0.00006861111); //deg2rad( 0.00005944444); var rz = deg2rad(0.00023391666); //deg2rad( 0.0001752778); var xB = tx + (x * (1 + s)) + (-rx * y) + (ry * z); var yB = ty + (rz * x) + (y * (1 + s)) + (-rx * z); var zB = tz + (-ry * x) + (rx * y) + (z * (1 + s)); var wgs84 = new RefEll(6378137.000, 6356752.3141); a = wgs84.maj; b = wgs84.min; eSquared = wgs84.ecc; var lambdaB = rad2deg(Math.atan(yB / xB)); var p = Math.sqrt((xB * xB) + (yB * yB)); var phiN = Math.atan(zB / (p * (1 - eSquared))); for (var i = 1; i < 10; i++) { v = a / (Math.sqrt(1 - eSquared * sinSquared(phiN))); phiN = Math.atan((zB + (eSquared * v * Math.sin(phiN))) / p); } var phiB = rad2deg(phiN); this.lat = phiB; this.lng = lambdaB; } // ================== WGS84ToOSGB36 Conversion Functions ===================== function WGS84ToOSGB36() { var wgs84 = new RefEll(6378137.000, 6356752.3141); var a = wgs84.maj; var b = wgs84.min; var eSquared = wgs84.ecc; var phi = deg2rad(this.lat); var lambda = deg2rad(this.lng); var v = a / (Math.sqrt(1 - eSquared * sinSquared(phi))); var h = 0; // height var x = (v + h) * Math.cos(phi) * Math.cos(lambda); var y = (v + h) * Math.cos(phi) * Math.sin(lambda); var z = ((1 - eSquared) * v + h) * Math.sin(phi); var tx = -446.448; //-482.530; // var ty = 124.157; // 130.596; // var tz = -542.060; //-564.557; // var s = 0.000008150; //0.0000204894; // var rx = deg2rad(-0.00004172222); //deg2rad( -0.0003894444); var ry = deg2rad(-0.00006861111); //deg2rad( -0.00005944444); var rz = deg2rad(-0.00023391666); //deg2rad( -0.0001752778); var xB = tx + (x * (1 + s)) + (-rx * y) + (ry * z); var yB = ty + (rz * x) + (y * (1 + s)) + (-rx * z); var zB = tz + (-ry * x) + (rx * y) + (z * (1 + s)); var airy1830 = new RefEll(6377563.396, 6356256.909); a = airy1830.maj; b = airy1830.min; eSquared = airy1830.ecc; var lambdaB = rad2deg(Math.atan(yB / xB)); var p = Math.sqrt((xB * xB) + (yB * yB)); var phiN = Math.atan(zB / (p * (1 - eSquared))); for (var i = 1; i < 10; i++) { v = a / (Math.sqrt(1 - eSquared * sinSquared(phiN))); phiN = Math.atan((zB + (eSquared * v * Math.sin(phiN))) / p); } var phiB = rad2deg(phiN); this.lat = phiB; this.lng = lambdaB; } // ================== OSRrefToLatLng Conversion Functions ===================== function OSRefToLatLng() { var airy1830 = new RefEll(6377340.189, 6356034.447); var OSGB_F0 = 1.000035; var N0 = 250000.0; var E0 = 200000.0; var phi0 = deg2rad(53.5); var lambda0 = deg2rad(-8.0); var a = airy1830.maj; var b = airy1830.min; var eSquared = airy1830.ecc; var phi = 0.0; var lambda = 0.0; var E = this.easting; var N = this.northing; var n = (a - b) / (a + b); var M = 0.0; var phiPrime = ((N - N0) / (a * OSGB_F0)) + phi0; do { M = (b * OSGB_F0) * (((1 + n + ((5.0 / 4.0) * n * n) + ((5.0 / 4.0) * n * n * n)) * (phiPrime - phi0)) - (((3 * n) + (3 * n * n) + ((21.0 / 8.0) * n * n * n)) * Math.sin(phiPrime - phi0) * Math.cos(phiPrime + phi0)) + ((((15.0 / 8.0) * n * n) + ((15.0 / 8.0) * n * n * n)) * Math.sin(2.0 * (phiPrime - phi0)) * Math.cos(2.0 * (phiPrime + phi0))) - (((35.0 / 24.0) * n * n * n) * Math.sin(3.0 * (phiPrime - phi0)) * Math.cos(3.0 * (phiPrime + phi0)))); phiPrime += (N - N0 - M) / (a * OSGB_F0); } while ((N - N0 - M) >= 0.001); var v = a * OSGB_F0 * Math.pow(1.0 - eSquared * sinSquared(phiPrime), -0.5); var rho = a * OSGB_F0 * (1.0 - eSquared) * Math.pow(1.0 - eSquared * sinSquared(phiPrime), -1.5); var etaSquared = (v / rho) - 1.0; var VII = Math.tan(phiPrime) / (2 * rho * v); var VIII = (Math.tan(phiPrime) / (24.0 * rho * Math.pow(v, 3.0))) * (5.0 + (3.0 * tanSquared(phiPrime)) + etaSquared - (9.0 * tanSquared(phiPrime) * etaSquared)); var IX = (Math.tan(phiPrime) / (720.0 * rho * Math.pow(v, 5.0))) * (61.0 + (90.0 * tanSquared(phiPrime)) + (45.0 * tanSquared(phiPrime) * tanSquared(phiPrime))); var X = sec(phiPrime) / v; var XI = (sec(phiPrime) / (6.0 * v * v * v)) * ((v / rho) + (2 * tanSquared(phiPrime))); var XII = (sec(phiPrime) / (120.0 * Math.pow(v, 5.0))) * (5.0 + (28.0 * tanSquared(phiPrime)) + (24.0 * tanSquared(phiPrime) * tanSquared(phiPrime))); var XIIA = (sec(phiPrime) / (5040.0 * Math.pow(v, 7.0))) * (61.0 + (662.0 * tanSquared(phiPrime)) + (1320.0 * tanSquared(phiPrime) * tanSquared(phiPrime)) + (720.0 * tanSquared(phiPrime) * tanSquared(phiPrime) * tanSquared(phiPrime))); phi = phiPrime - (VII * Math.pow(E - E0, 2.0)) + (VIII * Math.pow(E - E0, 4.0)) - (IX * Math.pow(E - E0, 6.0)); lambda = lambda0 + (X * (E - E0)) - (XI * Math.pow(E - E0, 3.0)) + (XII * Math.pow(E - E0, 5.0)) - (XIIA * Math.pow(E - E0, 7.0)); return new LatLng(rad2deg(phi), rad2deg(lambda)); } // ================== LatLngToOSREF Conversion Functions ===================== function LatLngToOSRef() { var airy1830 = new RefEll(6377340.189, 6356034.447); var OSGB_F0 = 1.000035; var N0 = 250000.0; var E0 = 200000.0; var phi0 = deg2rad(53.5); var lambda0 = deg2rad(-8.0); var a = airy1830.maj; var b = airy1830.min; var eSquared = airy1830.ecc; var phi = deg2rad(this.lat); var lambda = deg2rad(this.lng); var E = 0.0; var N = 0.0; var n = (a - b) / (a + b); var v = a * OSGB_F0 * Math.pow(1.0 - eSquared * sinSquared(phi), -0.5); var rho = a * OSGB_F0 * (1.0 - eSquared) * Math.pow(1.0 - eSquared * sinSquared(phi), -1.5); var etaSquared = (v / rho) - 1.0; var M = (b * OSGB_F0) * (((1 + n + ((5.0 / 4.0) * n * n) + ((5.0 / 4.0) * n * n * n)) * (phi - phi0)) - (((3 * n) + (3 * n * n) + ((21.0 / 8.0) * n * n * n)) * Math.sin(phi - phi0) * Math.cos(phi + phi0)) + ((((15.0 / 8.0) * n * n) + ((15.0 / 8.0) * n * n * n)) * Math.sin(2.0 * (phi - phi0)) * Math.cos(2.0 * (phi + phi0))) - (((35.0 / 24.0) * n * n * n) * Math.sin(3.0 * (phi - phi0)) * Math.cos(3.0 * (phi + phi0)))); var I = M + N0; var II = (v / 2.0) * Math.sin(phi) * Math.cos(phi); var III = (v / 24.0) * Math.sin(phi) * Math.pow(Math.cos(phi), 3.0) * (5.0 - tanSquared(phi) + (9.0 * etaSquared)); var IIIA = (v / 720.0) * Math.sin(phi) * Math.pow(Math.cos(phi), 5.0) * (61.0 - (58.0 * tanSquared(phi)) + Math.pow(Math.tan(phi), 4.0)); var IV = v * Math.cos(phi); var V = (v / 6.0) * Math.pow(Math.cos(phi), 3.0) * ((v / rho) - tanSquared(phi)); var VI = (v / 120.0) * Math.pow(Math.cos(phi), 5.0) * (5.0 - (18.0 * tanSquared(phi)) + (Math.pow(Math.tan(phi), 4.0)) + (14 * etaSquared) - (58 * tanSquared(phi) * etaSquared)); N = I + (II * Math.pow(lambda - lambda0, 2.0)) + (III * Math.pow(lambda - lambda0, 4.0)) + (IIIA * Math.pow(lambda - lambda0, 6.0)); E = E0 + (IV * (lambda - lambda0)) + (V * Math.pow(lambda - lambda0, 3.0)) + (VI * Math.pow(lambda - lambda0, 5.0)); return new OSRef(E, N); } // ================== UTMRefToLatLng Conversion Functions ===================== /** * Convert an UTM reference to a latitude and longitude * * param ellipsoid A reference ellipsoid to use * param utm the UTM reference to convert * return the converted latitude and longitude * since 0.2 */ function UTMRefToLatLng() { var wgs84 = new RefEll(6378137, 6356752.314); var UTM_F0 = 0.9996; var a = wgs84.maj; var eSquared = wgs84.ecc; var ePrimeSquared = eSquared / (1.0 - eSquared); var e1 = (1 - Math.sqrt(1 - eSquared)) / (1 + Math.sqrt(1 - eSquared)); var x = this.easting - 500000.0;; var y = this.northing; var zoneNumber = this.lngZone; var zoneLetter = this.latZone; var longitudeOrigin = (zoneNumber - 1.0) * 6.0 - 180.0 + 3.0; // Correct y for southern hemisphere if ((ord(zoneLetter) - ord("N")) < 0) { y -= 10000000.0; } var m = y / UTM_F0; var mu = m / (a * (1.0 - eSquared / 4.0 - 3.0 * eSquared * eSquared / 64.0 - 5.0 * Math.pow(eSquared, 3.0) / 256.0)); var phi1Rad = mu + (3.0 * e1 / 2.0 - 27.0 * Math.pow(e1, 3.0) / 32.0) * Math.sin(2.0 * mu) + (21.0 * e1 * e1 / 16.0 - 55.0 * Math.pow(e1, 4.0) / 32.0) * Math.sin(4.0 * mu) + (151.0 * Math.pow(e1, 3.0) / 96.0) * Math.sin(6.0 * mu); var n = a / Math.sqrt(1.0 - eSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad)); var t = Math.tan(phi1Rad) * Math.tan(phi1Rad); var c = ePrimeSquared * Math.cos(phi1Rad) * Math.cos(phi1Rad); var r = a * (1.0 - eSquared) / Math.pow( 1.0 - eSquared * Math.sin(phi1Rad) * Math.sin(phi1Rad), 1.5); var d = x / (n * UTM_F0); var latitude = ( phi1Rad - (n * Math.tan(phi1Rad) / r) * (d * d / 2.0 - (5.0 + (3.0 * t) + (10.0 * c) - (4.0 * c * c) - (9.0 * ePrimeSquared)) * Math.pow(d, 4.0) / 24.0 + (61.0 + (90.0 * t) + (298.0 * c) + (45.0 * t * t) - (252.0 * ePrimeSquared) - (3.0 * c * c)) * Math.pow(d, 6.0) / 720.0)) * (180.0 / Math.PI); var longitude = longitudeOrigin + ( (d - (1.0 + 2.0 * t + c) * Math.pow(d, 3.0) / 6.0 + (5.0 - (2.0 * c) + (28.0 * t) - (3.0 * c * c) + (8.0 * ePrimeSquared) + (24.0 * t * t)) * Math.pow(d, 5.0) / 120.0) / Math.cos(phi1Rad)) * (180.0 / Math.PI); return new LatLng(latitude, longitude); } // ================== LatLngToUTMRef Conversion Functions ===================== /** * Convert a latitude and longitude to an UTM reference * * param ellipsoid A reference ellipsoid to use * param latitudeLongitude The latitude and longitude to convert * return the converted UTM reference * since 0.2 */ function LatLngToUTMRef() { var wgs84 = new RefEll(6378137, 6356752.314); var UTM_F0 = 0.9996; var a = wgs84.maj; var eSquared = wgs84.ecc; var ePrimeSquared = eSquared / (1.0 - eSquared); var longitude = this.lng; var latitude = this.lat; var latitudeRad = latitude * (Math.PI / 180.0); var longitudeRad = longitude * (Math.PI / 180.0); var longitudeZone = Math.floor((longitude + 180.0) / 6.0) + 1; // Special zone for Norway if (latitude >= 56.0 && latitude < 64.0 && longitude >= 3.0 && longitude < 12.0) { longitudeZone = 32; } // Special zones for Svalbard if (latitude >= 72.0 && latitude < 84.0) { if (longitude >= 0.0 && longitude < 9.0) { longitudeZone = 31; } else if (longitude >= 9.0 && longitude < 21.0) { longitudeZone = 33; } else if (longitude >= 21.0 && longitude < 33.0) { longitudeZone = 35; } else if (longitude >= 33.0 && longitude < 42.0) { longitudeZone = 37; } } var longitudeOrigin = (longitudeZone - 1) * 6 - 180 + 3; var longitudeOriginRad = longitudeOrigin * (Math.PI / 180.0); var UTMZone = getUTMLatitudeZoneLetter(latitude); ePrimeSquared = (eSquared) / (1 - eSquared); var n = a / Math.sqrt(1 - eSquared * Math.sin(latitudeRad) * Math.sin(latitudeRad)); var t = Math.tan(latitudeRad) * Math.tan(latitudeRad); var c = ePrimeSquared * Math.cos(latitudeRad) * Math.cos(latitudeRad); var A = Math.cos(latitudeRad) * (longitudeRad - longitudeOriginRad); var M = a * ((1 - eSquared / 4 - 3 * eSquared * eSquared / 64 - 5 * eSquared * eSquared * eSquared / 256) * latitudeRad - (3 * eSquared / 8 + 3 * eSquared * eSquared / 32 + 45 * eSquared * eSquared * eSquared / 1024) * Math.sin(2 * latitudeRad) + (15 * eSquared * eSquared / 256 + 45 * eSquared * eSquared * eSquared / 1024) * Math.sin(4 * latitudeRad) - (35 * eSquared * eSquared * eSquared / 3072) * Math.sin(6 * latitudeRad)); var UTMEasting = (UTM_F0 * n * (A + (1 - t + c) * Math.pow(A, 3.0) / 6 + (5 - 18 * t + t * t + 72 * c - 58 * ePrimeSquared) * Math.pow(A, 5.0) / 120) + 500000.0); var UTMNorthing = (UTM_F0 * (M + n * Math.tan(latitudeRad) * (A * A / 2 + (5 - t + (9 * c) + (4 * c * c)) * Math.pow(A, 4.0) / 24 + (61 - (58 * t) + (t * t) + (600 * c) - (330 * ePrimeSquared)) * Math.pow(A, 6.0) / 720))); // Adjust for the southern hemisphere if (latitude < 0) { UTMNorthing += 10000000.0; } return new UTMRef(UTMEasting, UTMNorthing, UTMZone, longitudeZone); } // ================== getUTMLatitudeZoneLetter ===================== function getUTMLatitudeZoneLetter(latitude) { if ((84 >= latitude) && (latitude >= 72)) return "X"; else if ((72 > latitude) && (latitude >= 64)) return "W"; else if ((64 > latitude) && (latitude >= 56)) return "V"; else if ((56 > latitude) && (latitude >= 48)) return "U"; else if ((48 > latitude) && (latitude >= 40)) return "T"; else if ((40 > latitude) && (latitude >= 32)) return "S"; else if ((32 > latitude) && (latitude >= 24)) return "R"; else if ((24 > latitude) && (latitude >= 16)) return "Q"; else if ((16 > latitude) && (latitude >= 8)) return "P"; else if ((8 > latitude) && (latitude >= 0)) return "N"; else if ((0 > latitude) && (latitude >= -8)) return "M"; else if ((-8 > latitude) && (latitude >= -16)) return "L"; else if ((-16 > latitude) && (latitude >= -24)) return "K"; else if ((-24 > latitude) && (latitude >= -32)) return "J"; else if ((-32 > latitude) && (latitude >= -40)) return "H"; else if ((-40 > latitude) && (latitude >= -48)) return "G"; else if ((-48 > latitude) && (latitude >= -56)) return "F"; else if ((-56 > latitude) && (latitude >= -64)) return "E"; else if ((-64 > latitude) && (latitude >= -72)) return "D"; else if ((-72 > latitude) && (latitude >= -80)) return "C"; else return 'Z'; } </script> <script src="/Content/js/general.js"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-40178382-1']); _gaq.push(['_setDomainName', 'cvrt.ie']); _gaq.push(['_trackPageview']); (function () { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <!-- Hotjar Tracking Code for http://www.cvrt.ie --> <script> (function (h, o, t, j, a, r) { h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments) }; h._hjSettings = { hjid: 608874, hjsv: 6 }; a = o.getElementsByTagName('head')[0]; r = o.createElement('script'); r.async = 1; r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv; a.appendChild(r); })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv='); </script> </head> <body> <div id="fullWrap"> <div id="header" class="row"> <div id="branding" class="rowInner"> <table class="right" style="width: 447px"> <tr> <td style="text-align: left; color: white; padding-top: 20px"> </td> <td> <div id="langBox" class="right"> <a class="left active" href="/Account/ChangeCulture?lang=en-IE&returnUrl=%2F">English</a> <a class="right" href="/Account/ChangeCulture?lang=ga&returnUrl=%2F">Gaeilge</a> </div> </td> </tr> <tr> <td colspan="2" style="text-align: left; color: white; padding-top: 10px"> </td> </tr> </table> </div> </div> <div id="main" role="main" class="row"> <section class="content-wrapper main-content clear-fix"> <div id="main" role="main" class="row"> <div class="rowInner rightSidebar" id="loginPg"> <h1>Log in or Register</h1> <div class="mainContent"> <div class="halfCol left"> <h2>Existing User Login</h2> <form action="/Account/Login" method="post"> <div class="orange contentBox loginBox" > <div class="botDots wide block"> <label for="UserName">Username</label> <input id="UserName" name="UserName" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span> <label for="Password">Password</label> <input autocomplete="off" id="Password" name="Password" type="password" /> <span class="field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span> </div> <div class="buttonFrame"> <p> <input class="button ieBtnO0" type="submit" value="Log in" /> <br /> <a class="sprite arrowBg" href="/Account/ForgottenPassword">Forgotten Password?</a> <br /> <a class="sprite arrowBg" href="/Account/ForgottenUsername">Forgotten Username?</a> </p> </div> </div> </form> </div> <div class="halfCol right"> <h2>Not Registered?</h2> <div class="contentBox loginBox"> <div class="botDots wide block"> <h3>Register for a CVRT Online Account in order to:</h3> <ul> <ul><li>Book HCV, ADR and LCV tests</li><li>Submit your Operator Self-Declaration</li><li>View your vehicle information (including reports)</li><li>Receive alerts or reminders about your vehicles</li></ul><p> </p> </ul> </div> <form action="/Account/Register" > <div class="buttonFrame"> <input type="submit" class="button ieBtnO165" value="Register now" /> </div> </form> </div> </div> <div class="clearfix"></div> </div> <div id="aside"> <div class="linkBox"> <h3>Looking for LCV test booking?</h3> <div class="linkBoxInner" id="Operator_Login_SidebarLookingLgvTest"> <ul> <a class="sprite arrowBg" href="/Test/BookPublicLGVTest?type=LGV">Book LCV test</a> </ul> <ul> <a class="sprite arrowBg" href="/Home/Help">Help</a> </ul> </div> </div> <div class="postIt"> <div class="postItInner" id="Operator_Login_SidebarWhatDoPortal"> <p><strong>Do you operate a Heavy Commercial Vehicle?</strong></p><p>You are <strong>required by law</strong> to make an <strong>online </strong>Self-Declaration to the RSA <strong>every year </strong>in relation to your HCVs, Goods trailers, Buses and Ambulances.</p><p><a href="https://www.cvrt.ie/assets/pdf/Download%20Demonstration%20Guide%20to%20Registration%20and%20Self%20Declaration%20(PDF)">Download Demonstration Guide to Registration and Self Declaration (PDF)</a></p><p><strong>No Longer Trading/Operating HCV's?</strong> - Notify us by logging into your CVRT Online Account.</p><p> </p><p> </p> </div> </div> </div> <div class="clearfix"></div> </div> </div> <div id="loading" class="loader"></div> <script type="text/javascript"> $("form").submit(function () { // Show the loader if the form is valid if ($("form").valid()) { $("#loading").show(); } }); $(document).ready(function() { // Focus the username field on page load $("#UserName").focus(); if ($("#UserName").val() != "") { // if username is already filled, focus on password $('#Password').focus(); } }); </script> </section> </div> </div> <div id="footer" class="row"> <div class="rowInner"> <div class="right"> Questions about this application? <a href="/Home/Help" target="_blank">Go to our help section</a>. </div> <div class="left"> Your Personal Data! <a href="https://www.cvrt.ie/en/Pages/Privacy-Policy.aspx" target="_blank">Find out how the RSA use your personal data.</a> </div> </div> </div> </body> </html>