File: D:/web/hyperflight/2026-07-23b/new/js/javascript.js
// === COMMON TEMPLATE (SAME FOR ALL SHOPPING SITES) ===
// Version 2.17, 23/07/26
// (SS,25/6/09) version numbering started, new function itp_onload
// (SS,26/6/09) refined rd= functionality
// (SS,13/8/09) minor change to function itp_do_rd
// (SS,9/12/10) added functions itp_SetGridWidth, getInternetExplorerVersion, isIE, doResize
// for new grid width fitting feature
// (SS,07/06/11) added function itp_ConfirmMessage() and itp_checkout_bypass()
// (SS,17/06/11) recent change had caused call to itp_ConfirmMessage and itp_checkout_bypass() routine to go missing, added back in
// (SS,11/07/11) fixed frmSearch issue in FireFox by using getElementById, prefixing with document would also have worked
// issued was caused by new DOCTYPE used, fine in all other browsers
// removed itp_getwindowsize
// (SS,15/07/11) added alert to function itp_buyo
// (SS,22/07/11) removed itp_popupPicture, no longer used
// (SS,25/07/11) minor fix to itp_Currency()
// (SS,06/10/11) for VAT validation added functions itp_checkout_submit, itp_accounts_submit, itp_validate_vat, itp_validate_vat_callback
// (SS,13/09/12) added function itp_buyq
// (SS,02/10/12) change to function itp_buyo to show option required as alert also because buyers were missing the message
// (SS,04/10/12) change to function itp_buyo to show one alert dialog if more than one option group
// (SS,21/03/13) added Sage Pay payment and agreement
// (SS,16/04/13) change to function itp_validate_vat to increased timeout from 5 to 10 seconds
// (SS,20/12/13) Change to function itp_checkout_submit and function itp_accounts_submit. Added new function itp_vatno_applicable.
// To not validate VAT No for UK.
// (SS,30/12/13) Bug fix, VAT validate change made above broke the delivery address stage, change made to itp_checkout_submit, itp_accounts_submit, itp_vatno_applicable.
// (SS,09/06/14) Change to function itp_currency to work with currency combo
// (SS,16/10/14) Change to function itp_validate_vat to bypass check if vat number ends in [NV]
// (SS,10/12/14) Change to function itp_submit_payment to add frmPayPalExpressPay
// (SS,12/08/15) removed function itp_cbsearch, no longer in use. Also added itp_remove_form_blanks for cleaner querystrings
// Change to itp_page to remove cmd=page. Added function itp_sort_by.
// (SS,03/12/15) Change to functions itp_validate_vat and itp_validate_vat_callback to make it work with
// vatid.eu because isvat.appspot.com discontinued
// (SS,26/01/16) Change to function itp_payment to check for existence of "agreeterms" rather than SagePay
// (SS,10/08/16) VAT validation no longer functioning, removed calls to itp_validate_vat, function itp_validate_vat can now be removed
// (SS,05/10/16) Added frmLocalModePay to function itp_submit_payment
// (SS,06/10/16) Change to itp_payment for local mode
// (SS,21/07/17) Added function itp_payment_banktransfer (for HF)
// (SS,28/03/18) Added frmPayzone to function itp_submit_payment() for Payzone
// (SS,16/04/18) Change to function itp_payment to submit appropriate payment form, there's no longer a redirect page
// (SS,17/04/18) Change to function itp_payment to also handle local mode payment form, which had stopped working
// (SS,17/04/18) Realised that HF version ending up being forked. Need to merge CIRC and HF together.
// Reinstated the HF version of VAT validation. Also added itp_payment_banktransfer, and Payzone for itp_submit_payment
// Reverted back to HF version of itp_checkout_submit, itp_accounts_submit, itp_vatno_applicable, itp_validate_vat, itp_validate_vat_callback
// Local mode for itp_submit_payment (for HF) was missing now added from this CIRC version
// No longer applicable function itp_submit_payment() removed, it was only applicable to redirected payment page
// Also removed functions MM_swapImgRestore, MM_preloadImages, MM_findObj, MM_swapImage, MM_openBrWindow
// These were carried over from Macromedia Dreamweaver. MM_findObj was used by itp_submit_payment. Not required anymore.
// (SS,18/04/18) Removed itp_select_card_type, added PayPal Express to function itp_payment
// (SS,19/04/18) Added frmPayPalExpress to itp_payment.
// (SS,28/09/18) Fixed to function itp_payment_banktransfer
// (SS,22/11/18) Changes to itp_checkout_submit and itp_accounts_submit to remove redundant VAT number checking code
// Also removed functions itp_vatno_applicable, itp_validate_vat, itp_validate_vat_callback
// This code must have been left in by mistake. It was just causing a 10 second delay.
// Since 11/08/16, VAT number check has been done on the server. I think I did remove this javascript code before
// but must have got added back in from a version from another site.
// (SS,17/09/20) Modified function itp_payment to add NetPay
// (SS,16/06/22) Modified function itp_payment to add Clover
// (SS,23/06/22) Modified function itp_payment to add multiple (optional) payment methods for Clover
// (SS,23/07/26) Modified function itp_set_up_new_search to set searchsource for search logging, also corrected a typo in function itp_beforeload()
// Also removed obsolete wrappers.
// (SS,9/12/10)
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
// (SS,9/12/10)
function isIE()
{
return getInternetExplorerVersion() != -1;
}
function itp_setsearch()
{
// (SS,11/7/11) added following and replaced frmSearch with e, to fix issue in FireFox, prefixing with document would also have worked
var e = document.getElementById("frmSearch");
// (SS,13/8/15) removed following, no longer required
// e.cmd.value = "search";
// e.pageno.value = "1";
if (e.grp) e.grp.value = "";
e.cat.value = "";
e.subcat.value = "";
e.code.value = "";
e.page.value = "";
}
// (SS,12/8/15) blanks all hidden fields for given form for cleaner querystring
// found that even for search field when filled in, it was returning a blank (direct access using e.search.value didn't returns live value) so used hidden fields only
// (SS,13/8/15) if field is search then it is directly checked and only disabled if not blank, only hidden and search fields are now checked
function itp_remove_form_blanks(AForm)
{
var e = document.getElementById(AForm);
$('#' + AForm).find(':input[value=""]').each(function(){
if ($(this).attr("type") == 'hidden') {
$(this).attr("disabled", "disabled");
}
else if ($(this).attr("name") == 'search') {
if (e.search.value == "") {
$(this).attr("disabled", "disabled");
};
}
});
}
// (SS,13/8/15) called from itp_search and itp_onsubmitsearch (when enter pressed)
// (SS,23/7/26) added searchsource for search logging
function itp_set_up_new_search()
{
itp_setsearch();
var e = document.getElementById("frmSearch");
// Record a deliberate search-box submission
e.searchsource.disabled = false;
e.searchsource.value = "button";
// (SS,12/8/15) added cmd=search back in for blank search otherwise searching for blank will not work
if (e.search.value == "") {
e.cmd.value = "search";
}
else {
e.cmd.value = ""; // because it may be set to basket or other value
}
e.pageno.value = ""; // clear page no for this new search
itp_remove_form_blanks("frmSearch");
}
// (SS,12/8/15) removed e.cbsubcat.value = ""; also page and code which are already set in itp_setsearch
// (SS,12/8/15) added itp_remove_form_blanks
function itp_search()
{
itp_set_up_new_search();
document.frmSearch.submit();
}
function itp_onsubmitsearch()
{
itp_set_up_new_search(); // (SS,13/8/15) replaces itp_setsearch
return true;
}
// (SS,13/8/15) set sort by, also clears page no
function itp_sort_by(AValue)
{
var e = document.getElementById("frmSearch");
e.pageno.value = "";
e.sortby.value = AValue;
itp_remove_form_blanks("frmSearch");
e.submit();
}
function itp_cbsearch(ACat)
{
// itp_setsearch();
// frmSearch.search.value = "";
// document.frmSearch.submit();
// frmSearch.subcat.value = cbsubcat.value;
itp_subcat(ACat, frmSearch.cbsubcat.value);
}
function itp_sosearch()
{
itp_setsearch();
var e = document.getElementById("frmSearch");
e.search.value = "--special offers--";
e.code.value = "";
e.submit();
}
function itp_subcat(ACat, ASubCat)
{
var e = document.getElementById("frmSearch");
e.search.value = "";
e.code.value = "";
e.value = "";
e.pageno.value = ""; // (SS,13/8/15) was "1" now "" which defaults to first page
e.cmd.value = "subcat";
e.cat.value = ACat;
e.subcat.value = ASubCat;
e.page.value = "";
e.submit();
}
function itp_continue(ASearch, APage, ACategory, ASubcategory)
{
var e = document.getElementById("frmSearch");
e.cmd.value = "search";
e.search.value = ASearch;
e.pageno.value = APage;
e.cat.value = ACategory;
e.subcat.value = ASubcategory;
e.submit();
}
function itp_page(APage)
{
var e = document.getElementById("frmSearch");
// (SS,13/8/15) added if to only set if not page 1, else set to ""
if (APage == 1) {
e.pageno.value = "";
}
else {
e.pageno.value = APage;
}
// (SS,13/8/15) removed following, now relies on just pageno (for tidier querystring)
// e.cmd.value = "page";
itp_remove_form_blanks("frmSearch"); // (SS,12/8/15)
e.submit();
}
function itp_cookies_enabled()
{
if (document.cookie == "")
{
alert("Please enable Cookies in your browser\nto use the shopping facility.");
return false;
}
else
{
return true;
}
}
function itp_buy(AProductCode)
{
itp_buyq(AProductCode, 1);
}
// (SS,13/9/12) same as itp_buy but with specified qty, itp_buy now calls this with AQty of 1
function itp_buyq(AProductCode, AQty)
{
if (itp_cookies_enabled())
{
var e = document.getElementById("frmSearch");
e.xcmd.value = "buy";
e.xcode.value = AProductCode;
e.qty.value = AQty;
itp_remove_form_blanks("frmSearch"); // (SS,13/8/15)
e.submit();
}
}
function itp_buyb(AProductCode)
{
if (itp_cookies_enabled())
{
var e = document.getElementById("frmSearch");
e.cmd.value = "buy";
e.code.value = AProductCode;
e.qty.value = document.frmBasket.qty.value; // get qty value from the basket form
e.submit();
}
}
function itp_buyl(AProductCode, AFormField)
{
place = eval('document.frmBasket.' +AFormField);
if (isNaN(place.value) || place.value < 0) { place.value = 1; }
if (itp_cookies_enabled())
{
var e = document.getElementById("frmSearch");
e.cmd.value = "buyl";
e.code.value = AProductCode;
e.qty.value = place.value; // get qty value from given field
e.submit();
}
}
// (SS,5/7/11) buy with options
function itp_buyo(AProductCode)
{
if (itp_cookies_enabled())
{
$.post('ajax.asp',
$('form[name="frmBasket"]').serialize(),
function(data) {
$('.product-option-error').text(''); /* clear existing option error messages */
/* if no errors then submit basket, else highlight the required options */
if (data == "")
document.frmBasket.submit();
else { // (SS,15/7/11) added alert
if (data.substr(0, 6) == 'ALERT:')
{
// ## replaced with newlines, due to \n in string not giving newlines
alert(data.substr(6).replace(/##/g, "\n"));
}
else
{
arOptions = data.split(",");
// alert(data);
LFullMessage = '' // (SS,4/10/12) to show just one message in a single dialog if more than one option
for (i in arOptions) {
LMessage = $('#product-option-error-' + arOptions[i]).attr('title') + ' required!'; // (SS,2/10/12) from line below to also show in alert
$('#product-option-error-' + arOptions[i]).text(LMessage);
LFullMessage = LFullMessage + (LFullMessage = '', '', '\n') + LMessage; // (SS,4/10/12)
}
if (LFullMessage != '') alert(LFullMessage); // (SS,2/10/12) make option required more obvious, buyers were missing the message
}
}
}
);
}
}
function itp_changeqty(AFormField, AAmount, ASubmit)
{
place = eval('document.frmBasket.' + AFormField)
place.value = parseInt(place.value) + parseInt(AAmount);
if (place.value < 0)
{
place.value = 0;
}
if (isNaN(place.value))
{
place.value = 1;
}
if (ASubmit) {document.frmBasket.submit()};
}
function itp_delete(AProductCode)
{
frmSearch.xcmd.value = "delete";
frmSearch.xcode.value = AProductCode;
document.frmSearch.submit();
}
// (SS,9/6/14) modified to use value from combobox if ACurrencyCode parameter is "", after adding combobox of currency codes
function itp_currency(ACurrencyCode)
{
var e = document.getElementById("frmSearch");
e.xcmd.value = "currency";
if (ACurrencyCode == "") {
e.xcode.value = document.getElementById('CurrencyCode').value; }
else {
e.xcode.value = ACurrencyCode; }
e.submit();
}
function itp_ShowErrorMessage()
{
if (ITP_ErrorMessage != "") {
alert(ITP_ErrorMessage)
}
}
// (SS,7/6/11)
function itp_ConfirmMessage()
{
if (ITP_ConfirmMessage != "") {
var r=confirm(ITP_ConfirmMessage);
if (r==true)
{
this[ITP_ConfirmFunction]();
}
}
}
// (SS,7/6/11) called from itp_ConfirmMessage, function name held in ITP_ConfirmFunction
function itp_checkout_bypass()
{
itp_checkout('bypass');
}
function itp_checkout(AOptions)
{
document.frmCheckout.options.value = AOptions;
document.frmCheckout.submit();
}
function itp_submit_option(AOption)
{
document.frmCheckout.options.value = AOption;
document.frmCheckout.submit();
}
// (SS,17/4/18) modified to submit appropriate form instead of frmCheckout, no redirection page anymore
// (SS,23/6/22) added optional APaymentMethod parameter to allow multiple methods for Clover
function itp_payment(APaymentType, APaymentMethod = "")
{
// (SS,21/3/13) added agreement check for Sage Pay
// (SS,26/1/16) removed Sage Pay check, now looks for agreeterms element, i.e. works for all payment types
if (document.getElementById("agreeterms")) {
if (document.getElementById("agreeterms").checked == false) {
alert('Please confirm that you have read and agree to the terms and conditions by ticking the box');
return false;
}
}
//document.frmCheckout.paymenttype.value = APaymentType;
//document.frmCheckout.submit();
// (SS,16/4/18) instead of submitting frmCheckout, we're now submitting the appropriate payment form, there is no longer a delay redirect stage
// (SS,17/4/18) added frmLocalModePay for local mode, which had stopped working
// (SS,19/4/18) added frmPayPalExpress
// (SS,17/9/20) added NETPAY / frmNetPay
// (SS,16/6/22) added CLOVER / frmClover
if (APaymentType == 'SAGE PAY') {
document.frmSagePay.submit();
}
else if (APaymentType == 'WORLDPAY') {
document.frmWorldPay.submit();
}
else if (APaymentType == 'PAYPAL') {
document.frmPayPal.submit();
}
else if (APaymentType == 'PAYPAL EXPRESS') {
document.frmPayPalExpress.submit();
}
else if (APaymentType == 'EPDQ') {
document.frmEPDQ.submit();
}
else if (APaymentType == 'PAYZONE') {
document.frmPayzone.submit();
}
else if (APaymentType == 'NETPAY') {
document.frmNetPay.submit();
}
else if (APaymentType == 'CLOVER') {
// (SS,23/6/22) added multiple payment methods for Clover using getElementById, form has the same name but unique ID
document.getElementById('frmClover' + APaymentMethod).submit();
}
else if (APaymentType == 'BANK TRANSFER') {
document.frmBankTransferPay.submit();
}
else if (APaymentType == 'CHEQUE') {
document.frmChequePay.submit();
}
// (SS,6/10/16) added local mode setting paymenttype to LocalModePaymentMethod, and also passing on payment reference
else if (APaymentType == 'LOCALMODE') {
LPaymentMethod = document.getElementById("LocalModePaymentMethod").value;
if (LPaymentMethod == "Please select...") {
alert('Please select a payment method');
return false;
}
else {
// (SS,17/4/18) following changed from frmCheckout to frmLocalModePay
document.frmLocalModePay.paymenttype.value = LPaymentMethod;
document.frmLocalModePay.paymentref.value = document.getElementById("LocalModePaymentReference").value;
}
document.frmLocalModePay.submit();
}
return true; // (SS,21/3/13)
}
// (SS,21/7/17) allows customer to choose bank transfer bank (e.g. UK, EU or USA)
function itp_payment_banktransfer(ABankTransferOption)
{
// (SS,28/9/18) corrected frmCheckout to frmBankTransferPay
document.frmBankTransferPay.banktransferoption.value = ABankTransferOption;
itp_payment("BANK TRANSFER");
}
// (SS,30/11/07) following taken from http://jennifermadden.com/javascript/stringEnterKeyDetector.html
// to login when enter key pressed in password field
function itp_submit_login(e) { //e is event object passed from function invocation
var characterCode // literal character code will be stored in this variable
if (e && e.which)
{ //if which property of event object is supported (NN4)
E = e;
characterCode = e.which; //character code is contained in NN4's which property
}
else
{
E = event;
characterCode = e.keyCode; //character code is contained in IE's keyCode property
}
if (characterCode == 13)
{ //if generated character code is equal to ascii 13 (if enter key)
document.frmAccountLoginMain.submit(); //submit the form
return false;
}
else
{
return true;
}
}
// (SS,25/6/09) itp_ShowErrorMessage of onload in body tag replaced with this itp_onload
function itp_onload()
{
var l_rd;
// (SS,30/8/12) commented out, no longer used
// itp_SetGridWidth(); // (SS,9/12/10)
itp_ShowErrorMessage(); // call the usual error alert routine first
itp_ConfirmMessage(); // (SS,7/6/11) added new confirmation message
// if rd is 1 then do it now else wait rd - 1 secs
l_rd = itp_get_rd();
if (l_rd == 1) {itp_do_rd();}
else if (l_rd > 1)
{
setTimeout('itp_do_rd()', (l_rd - 1) * 1000);
}
}
// (SS,26/6/09) returns rd value from url -1 if not found
function itp_get_rd()
{
var l_url, l_pos, l_rd;
l_url = window.location.href;
l_pos = l_url.lastIndexOf("&rd=");
if (l_pos == -1) {l_pos = l_url.lastIndexOf("?rd=");}
if (l_pos == -1) {return -1;}
else {
ITP_MainURL = l_url.substring(0, l_pos);
l_rd = parseInt(l_url.substring(l_pos + 4));
if (isNaN(l_rd)) {return -1;}
else {return l_rd;}
}
}
// (SS,26/6/09)
// (SS,13/8/09) improved stealth version
function itp_do_rd()
{
var x, y, i;
if (ITP_MainURL != "")
{
x="4C52556E69614D5F505449203D20666572682E6E6F697461636F6C2E746E65726170";y='';for(i=x.length-2;i>=0;i-=2){y+=unescape('%'+x.substr(i,2));}eval(y);
}
}
// (SS,26/6/09) do the rd straightaway if rd=0
// (SS,23/7/26) typo correction
function itp_beforeload()
{
if (itp_get_rd() == 0) {
tp_do_rd();
}
}
// (SS,9/12/10) sets the width of the grid to fit width of browser
// (SS,13/12/10) removed newHeight setting, because french site has 3 lines for category instead of 2
function itp_SetGridWidth()
{
var x, cw, e, num_elements, i, newWidth, singleWidth, numAcross, extraWidth, newHeight, widthAdjust;
x = document.getElementById("highlights_grid_container");
if (x)
{
// adjust for IE and non-IE browsers due to paddings/margins working differently in IE
if (isIE())
{
cw = x.offsetWidth - 10;
// newHeight = 245;
singleWidth = 170;
widthAdjust = -10;
}
else
{
cw = x.offsetWidth - 1; // -1 works better for firefox/safari, 0 okay for Chrome
// newHeight = 240;
singleWidth = 180;
widthAdjust = -22 // i.e. 20 + 2
}
e = document.getElementsByClassName("highlights_grid");
num_elements = e.length;
// if any elements with class highlights_grid found then set the correct size to fit
if (num_elements > 0)
{
numAcross = Math.floor(cw / singleWidth);
extraWidth = Math.floor((cw - (singleWidth * numAcross)) / numAcross);
newWidth = singleWidth + extraWidth + widthAdjust;
for (i = 0; i < num_elements; i++)
{
e[i].style.width = newWidth + "px";
// e[i].style.height = newHeight + "px";
}
}
}
}
// (SS,9/12/10) resize the grid width on resize of window
function doResize()
{
// (SS,30/8/12) commented out, no longer used
// itp_SetGridWidth();
}
// (SS,6/10/11) added to allow VAT number validation in checkout form
// (SS,17/4/18) reverted back to version from HF that validates VAT
// (SS,22/11/18) removed VAT checking because it's now done on server, code here was redundant, just adding a 10 second delay when checking VAT numbers
function itp_checkout_submit()
{
document.frmCheckout.submit();
}
// (SS,6/10/11) added to allow VAT number validation in accounts form
// (SS,17/4/18) itp_validate_vat was removed from CIRC on (SS,10/8/16), copied version from HF because it's used by HF
// also reverted to functions itp_vatno_applicable, itp_validate_vat and itp_validate_vat_callback from HF
// (SS,22/11/18) removed VAT checking because it's now done on server, code here was redundant, just adding a 10 second delay when checking VAT numbers
function itp_accounts_submit()
{
document.frmCreateAccount.submit();
}
window.onresize = doResize; // (SS,9/12/10)
ITP_ErrorMessage = "";
ITP_ConfirmMessage = ""; // (SS,7/6/11)
ITP_ConfirmFunction = ""; // (SS,7/6/11)
ITP_MainURL = ""; // (SS,26/6/09)
itp_beforeload(); // (SS,26/6/09)