WP.search_data = [
    {
        value:  'About Us',
        url:    '/about.html'
    },
    {
        value:  'Apron Storage',
        url:    '/xray/clothing/storage.html'
    },
    {
        value:  'Audio System',
        url:    '/mr/relaxation/audio.html'
    },
    {
        value:  'Bespoke Engineering',
        url:    '/services/engineering.html'
    },
    {
        value:  'Cassette Hatch',
        url:    '/xray/equipment/cassette_hatch.html'
    },
    {
        value:  'Catheter Storage',
        url:    '/xray/equipment/catheter_storage.html'
    },
    {
        value:  'CCTV',
        url:    '/mr/safety/cctv.html'
    },
    {
        value:  'Chemistry',
        url:    '/xray/misc/chemistry.html'
    },
    {
        value:  'Colocode Labels',
        url:    '/xray/filing/colocode.html'
    },
    {
        value:  'Contact Us',
        url:    '/contact.html'
    },
    {
        value:  'Curtains',
        url:    '/structural/xray/curtains.html'
    },
    {
        value:  'CyberKnife',
        url:    '/structural/cyberknife1.html'
    },
    {
        value:  'Door Sets',
        url:    '/structural/xray/doors/index.html'
    },
    {
        value:  'Double Sided Aprons',
        url:    '/xray/clothing/double.html'
    },
    {
        value:  'Drug Administration System',
        url:    '/mr/safety/tesla_4fusion.html'
    },
    {
        value:  'DVD System',
        url:    '/mr/relaxation/video.html'
    },
    {
        value:  'Engineering',
        url:    '/services/engineering.html'
    },
    {
        value:  'Ferroguard',
        url:    '/mr/safety/ferroguard.html'
    },
    {
        value:  'Film Hopper',
        url:    '/xray/equipment/film_hopper.html'
    },
    {
        value:  'Film Processor',
        url:    '/xray/equipment/film_processor.html'
    },
    {
        value:  'Film Storage Bags',
        url:    '/xray/filing/bags.html'
    },
    {
        value:  'Film Wallets',
        url:    '/xray/filing/wallets.html'
    },
    {
        value:  'Fire Extinguisher',
        url:    '/mr/safety/fire_extinguisher.html'
    },
    {
        value:  'Fire Rated Doors',
        url:    '/structural/xray/doors/hinged.html'
    },
    {
        value:  'Fixed Screens',
        url:    '/structural/xray/screens.html'
    },
    {
        value:  'fMRI DVD System',
        url:    '/mr/relaxation/video.html'
    },
    {
        value:  'FSC Products',
        url:    '/FSC_products.html'
    },
    {
        value:  'Functional MRI',
        url:    '/mr/fmri/index.html'
    },
    {
        value:  'Home',
        url:    '/index.html'
    },
    {
        value:  'Image Collection',
        url:    '/mr/relaxation/image/index.html'
    },
    {
        value:  'Image Gallery',
        url:    '/mr/relaxation/image/gallery/index.html'
    },
    {
        value:  'Laryngoscope',
        url:    '/mr/monitors/laryngoscope.html'
    },
    {
        value:  'Latest Newsletter',
        url:    '/news/index.html'
    },
    {
        value:  'Lead Acrylic',
        url:    '/structural/materials/premac.html'
    },
    {
        value:  'Lead Glass',
        url:    '/structural/materials/glass.html'
    },
    {
        value:  'Mammography Wallets',
        url:    '/xray/filing/mammography.html'
    },
    {
        value:  'Mediladder',
        url:    '/mr/accessories/mediladder.html'
    },
    {
        value:  'MediMattress',
        url:    '/mr/accessories/mattresses.html'
    },
    {
        value:  'Metal Detector',
        url:    '/mr/safety/metal_detector.html'
    },
    {
        value:  'MiniMuffs',
        url:    '/mr/paediatric/noise_attenuators.html'
    },
    {
        value:  'Mobile Screens',
        url:    '/xray/personnel/screens.html'
    },
    {
        value:  'MR Accessories',
        alt:    'MRI Accessories',
        url:    '/mr/accessories/index.html'
    },
    {
        value:  'MR Blood Pressure Monitor',
        alt:    'MRI Blood Pressure Monitor',
        url:    '/mr/monitors/nibp.html'
    },
    {
        value:  'MR Blood Pressure Set',
        alt:    'MRI Blood Pressure Set',
        url:    '/mr/monitors/manual_bp_set.html'
    },
    {
        value:  'MR CCTV',
        alt:    'MRI CCTV',
        url:    '/mr/safety/cctv.html'
    },
    {
        value:  'MR Coil Trolley',
        alt:    'MRI Coil Trolley',
        url:    '/mr/accessories/coil_trolley.html'
    },
    {
        value:  'MR Drug Cabinet',
        alt:    'MRI Drug Cabinet',
        url:    '/mr/accessories/drug_cabinet.html'
    },
    {
        value:  'MR Evacuation Mattress',
        alt:    'MRI Evacuation Mattress',
        url:    '/mr/safety/evac_mattress.html'
    },
    {
        value:  'MR Examination Lamps',
        alt:    'MRI Examination Lamps',
        url:    '/mr/accessories/exam_lamps.html'
    },
    {
        value:  'MR Fire Extinguisher',
        alt:    'MRI Fire Extinguisher',
        url:    '/mr/safety/fire_extinguisher.html'
    },
    {
        value:  'MR Hand Tools',
        alt:    'MRI Hand Tools',
        url:    '/mr/accessories/hand_tools.html'
    },
    {
        value:  'MR Instrument Trolleys',
        alt:    'MRI Instrument Trolleys',
        url:    '/mr/accessories/trolleys.html'
    },
    {
        value:  'MR IV Drip Stand',
        alt:    'MRI IV Drip Stand',
        url:    '/mr/accessories/ivstand.html'
    },
    {
        value:  'MR Labels',
        alt:    'MRI Labels',
        url:    '/mr/accessories/labels.html'
    },
    {
        value:  'MR Laryngoscope',
        alt:    'MRI Laryngoscope',
        url:    '/mr/monitors/laryngoscope.html'
    },
    {
        value:  'MR Linen Stand',
        alt:    'MRI Linen Stand',
        url:    '/mr/accessories/linen_stand.html'
    },
    {
        value:  'MR Mattresses',
        alt:    'MRI Mattresses',
        url:    '/mr/accessories/mattresses.html'
    },
    {
        value:  'MR Metal Detector',
        alt:    'MRI Metal Detector',
        url:    '/mr/safety/metal_detector.html'
    },
    {
        value:  'MR Monitors',
        alt:    'MRI Monitors',
        url:    '/mr/monitors/index.html'
    },
    {
        value:  'MR Oxygen Monitor',
        alt:    'MRI Oxygen Monitor',
        url:    '/mr/safety/oxygen_monitor.html'
    },
    {
        value:  'MR Patient Handling',
        alt:    'MRI Patient Handling',
        url:    '/mr/transport/index.html'
    },
    {
        value:  'MR Patient Safety',
        alt:    'MRI Patient Safety',
        url:    '/mr/safety/index.html'
    },
    {
        value:  'MR Prism Glasses',
        alt:    'MRI Prism Glasses',
        url:    '/mr/accessories/prism_glasses.html'
    },
    {
        value:  'MR Prismatic Spectacles',
        alt:    'MRI Prismatic Spectacles',
        url:    '/mr/accessories/spectacles.html'
    },
    {
        value:  'MR Products & Solutions',
        alt:    'MRI Products & Solutions',
        url:    '/mr/index.html'
    },
    {
        value:  'MR Pulse Oximeter',
        alt:    'MRI Pulse Oximeter',
        url:    '/mr/monitors/tesla_one.html'
    },
    {
        value:  'MR Step Stools',
        alt:    'MRI Step Stools',
        url:    '/mr/accessories/step_stools.html'
    },
    {
        value:  'MR Stethoscope',
        alt:    'MRI Stethoscope',
        url:    '/mr/monitors/stethoscope.html'
    },
    {
        value:  'MR Surgeons Stools',
        alt:    'MRI Surgeons Stools',
        url:    '/mr/accessories/surgeon_stool.html'
    },
    {
        value:  'MR Surgical Instruments',
        alt:    'MRI Surgical Instruments',
        url:    '/mr/accessories/surgical_instruments.html'
    },
    {
        value:  'MR Transport',
        alt:    'MRI Transport',
        url:    '/mr/transport/index.html'
    },
    {
        value:  'MR Trolleys',
        alt:    'MRI Trolleys',
        url:    '/mr/transport/trolleys.html'
    },
    {
        value:  'MR Utility Trolleys',
        alt:    'MRI Utility Trolleys',
        url:    '/mr/accessories/trolleys.html'
    },
    {
        value:  'MR Venous Compression Set',
        alt:    'MRI Venous Compression Set',
        url:    '/mr/monitors/venous_comp.html'
    },
    {
        value:  'MR Warning Light',
        alt:    'MRI Warning Light',
        url:    '/mr/safety/warning_light.html'
    },
    {
        value:  'MR Warning Sign',
        alt:    'MRI Warning Sign',
        url:    '/mr/safety/warning_sign.html'
    },
    {
        value:  'MR Waste Bin',
        alt:    'MRI Waste Bin',
        url:    '/mr/accessories/waste_bin.html'
    },
    {
        value:  'MR Waste Bowl',
        alt:    'MRI Waste Bowl',
        url:    '/mr/accessories/waste_bowl.html'
    },
    {
        value:  'MR Wheelchairs',
        alt:    'MRI Wheelchairs',
        url:    '/mr/transport/wheelchairs.html'
    },
    {
        value:  'MRI Shielding',
        url:    '/structural/mri.html'
    },
    {
        value:  'NDT',
        url:    '/structural/ndt.html'
    },
    {
        value:  'Neonatal Ventilator',
        url:    '/mr/paediatric/neonatal_ventilator.html'
    },
    {
        value:  'Neutron Shielding',
        url:    '/structural/neutron.html'
    },
    {
        value:  'Noise Attenuators',
        url:    '/mr/paediatric/noise_attenuators.html'
    },
    {
        value:  'Noise Reducing Headphones',
        url:    '/mr/relaxation/headphones.html'
    },
    {
        value:  'Non-Destructive Testing',
        url:    '/structural/ndt.html'
    },
    {
        value:  'Observation Windows',
        url:    '/structural/xray/windows.html'
    },
    {
        value:  'Overhead Suspension Shields',
        url:    '/structural/xray/shields.html'
    },
    {
        value:  'Oxygen Monitor',
        url:    '/mr/safety/oxygen_monitor.html'
    },
    {
        value:  'Paediatric Cardiac Array',
        url:    '/mr/paediatric/cardiac_array.html'
    },
    {
        value:  'Paediatric Coils',
        url:    '/mr/paediatric/coils.html'
    },
    {
        value:  'Paediatric Monitoring',
        url:    '/mr/paediatric/index.html'
    },
    {
        value:  'Paediatric Securing System',
        url:    '/mr/paediatric/bebx.html'
    },
    {
        value:  'Panels and Partitions',
        url:    '/structural/xray/panels.html'
    },
    {
        value:  'Patient Handling',
        url:    '/mr/transport/index.html'
    },
    {
        value:  'Patient Monitors',
        url:    '/mr/monitors/index.html'
    },
    {
        value:  'Patient Safety',
        url:    '/mr/safety/index.html'
    },
    {
        value:  'PEFC Products',
        url:    '/PEFC_products.html'
    },
    {
        value:  'Power Operated Doors',
        url:    '/structural/xray/doors/power.html'
    },
    {
        value:  'Premac Lead Acrylic',
        url:    '/structural/materials/premac.html'
    },
    {
        value:  'Premadex Neutron Shielding',
        url:    '/structural/neutron.html'
    },
    {
        value:  'Proctology Chair',
        url:    '/xray/equipment/proctology_chair.html'
    },
    {
        value:  'Pulse Oximeter',
        url:    '/mr/monitors/tesla_one.html'
    },
    {
        value:  'PureSound Audio System',
        url:    '/mr/relaxation/audio.html'
    },
    {
        value:  'Relax & View Images',
        url:    '/mr/relaxation/image/gallery/index.html'
    },
    {
        value:  'Relax & View Image Collection',
        url:    '/mr/relaxation/image/index.html'
    },
    {
        value:  'Relax & View Video System',
        url:    '/mr/relaxation/video.html'
    },
    {
        value:  'RF Testing',
        url:    '/services/servicing.html'
    },
    {
        value:  'S.U.P.A SLIDE Sheets',
        url:    '/mr/accessories/supaslide_sheets.html'
    },
    {
        value:  'Screen Colours',
        url:    '/structural/xray/screens.html'
    },
    {
        value:  'Security Flaps',
        url:    '/xray/personnel/security_flaps.html'
    },
    {
        value:  'Self Assist Ladder',
        url:    '/mr/accessories/mediladder.html'
    },
    {
        value:  'Servicing',
        url:    '/services/servicing.html'
    },
    {
        value:  'Shielding Materials',
        url:    '/structural/materials/index.html'
    },
    {
        value:  'Stethoscope',
        url:    '/mr/monitors/stethoscope.html'
    },
    {
        value:  'Structural Shielding',
        url:    '/structural/index.html'
    },
    {
        value:  'Superlite Viewers',
        url:    '/xray/equipment/viewers/superlite.html'
    },
    {
        value:  'Support',
        url:    '/services/servicing.html'
    },
    {
        value:  'Suspension Shields',
        url:    '/structural/xray/shields.html'
    },
    {
        value:  'Technical Support',
        url:    '/services/servicing.html'
    },
    {
        value:  'Tesla 4Fusion',
        url:    '/mr/safety/tesla_4fusion.html'
    },
    {
        value:  'Tesla Guard',
        url:    '/mr/monitors/tesla_guard.html'
    },
    {
        value:  'Tesla One',
        url:    '/mr/monitors/tesla_one.html'
    },
    {
        value:  'Top and Kilt',
        url:    '/xray/clothing/topkilt.html'
    },
    {
        value:  'Training',
        url:    '/services/servicing.html'
    },
    {
        value:  'Utility Trolleys',
        url:    '/xray/equipment/utility_trolleys.html'
    },
    {
        value:  'Video System',
        url:    '/mr/relaxation/video.html'
    },
    {
        value:  'Weiko Viewers',
        url:    '/xray/equipment/viewers/weiko.html'
    },
    {
        value:  'Windows',
        url:    '/structural/xray/windows.html'
    },
    {
        value:  'Workstations',
        url:    '/xray/personnel/screens.html'
    },
    {
        value:  'X-ray Apron Storage',
        alt:    'Xray Apron Storage',
        url:    '/xray/clothing/storage.html'
    },
    {
        value:  'X-ray Chemistry',
        alt:    'Xray Chemistry',
        url:    '/xray/misc/chemistry.html'
    },
    {
        value:  'X-ray Curtains',
        alt:    'Xray Curtains',
        url:    '/structural/xray/curtains.html'
    },
    {
        value:  'X-ray Doors',
        alt:    'Xray Doors',
        url:    '/structural/xray/doors/index.html'
    },
    {
        value:  'X-ray Panels',
        alt:    'Xray Panels',
        url:    '/structural/xray/panels.html'
    },
    {
        value:  'X-ray Partitions',
        alt:    'Xray Partitions',
        url:    '/structural/xray/panels.html'
    },
    {
        value:  'X-ray Portering Chairs',
        alt:    'Xray Portering Chairs',
        url:    '/xray/transportation/wheelchairs.html'
    },
    {
        value:  'X-ray Screens (Fixed)',
        alt:    'Xray Screens (Fixed)',
        url:    '/structural/xray/screens.html'
    },
    {
        value:  'X-ray Screens (Mobile)',
        alt:    'Xray Screens (Mobile)',
        url:    '/xray/personnel/screens.html'
    },
    {
        value:  'X-ray Shielding',
        alt:    'Xray Shielding',
        url:    '/structural/xray/index.html'
    },
    {
        value:  'X-ray Step Platforms',
        alt:    'Xray Step Platforms',
        url:    '/xray/equipment/step_platforms.html'
    },
    {
        value:  'X-ray Trolleys',
        alt:    'Xray Trolleys',
        url:    '/xray/transportation/trolleys.html'
    },
    {
        value:  'X-ray Warning Lights',
        alt:    'Xray Warning Lights',
        url:    '/xray/misc/signage.html'
    },
    {
        value:  'X-ray Warning Signs',
        alt:    'Xray Warning Signs',
        url:    '/xray/misc/signage.html'
    },
    {
        value:  'X-ray Windows',
        alt:    'Xray Windows',
        url:    '/structural/xray/windows.html'
    },
    {
        value:  'X-ray Workstations',
        alt:    'Xray Workstations',
        url:    '/xray/personnel/screens.html'
    }
];

WP.escape_regex = function(value) {
    return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
};

WP.search_filter = function(term) {
    var matcher = new RegExp( WP.escape_regex(term), "i" );
    return $.grep( 
        WP.search_data, 
        function(item, n) {
            return matcher.test(item.value)
                || (item.alt ? matcher.test(item.alt) : false);
        }
    );
};

WP.init_search = function(e, args) {
    var panel  = $(e);
    var input  = panel.find('input');
    var prompt = input.val();
    var config = jQuery.extend({
        url_prefix: ''
    }, args);
        
    input.focus(
        function() {
            if (input.val() == prompt) {
                input.val('');
            }
        }
    ).autocomplete({
        source: function (request, response) {
            return response(
                WP.search_filter(request.term)
            );
        },
        position: {
            my:     'left top',
            at:     'left bottom',
            offset: '20 0'
        },
        appendTo:   '#search-results',
        open: function() { 
            $('#search-results .ui-menu').width(225).css('z-index', 200);
        },
        select: function(event, ui) {
            var url = config.url_prefix + ui.item.url;
//          WP.debug("SELECT: %o (%s) => ", this.value, config.url_prefix, url);
            window.location = url;
            return false;
        }
    });
};


