var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { matches.push(str); } }); cb(matches); }; }; var products = ['2-Ring Ceramic Hob','2-Ring Electric Hob','3-Tier Drying Rack','60Cm Curved Glass Chimney Cooker Hood - Stainless Steel','Airflow Divan Set','Airflow Mattress','Albany Extending Table','Alpen Bed Frame','Alpen Metal Bunk Bed Frame','Alpine 2 Door Combi Wardrobe','Alpine 2 Door Wardrobe','Alpine 2 Doors Wardrobe with Mirror','Alpine 3 Door Wardrobe','Alpine 3 Drawer Bedside','Alpine 5 Drawer Chest','Alpine Tall 2 Door Wardrobe','Alpine Tall 3 Door Wardrobe','America Short Bunk Bed With Mattresses','Andante 2 Door Robe','Andante 2 Door Robe w/ Mirror','Andante 2 Drawer Bedside','Andante 3 Drawer Bedside','Andante 3 Drawer Dressing Table','Andante 3-Door Robe w/ Mirror','Andante 5 Drawer Chest','Arundel Large Sideboard','Arundel Nest Table','Arundel Oval Coffee Table','Arundel Small Sideboard','Atlanta Chair','Atlanta Table & 4 Chairs','Atlanta Table & 6 Chairs','Baltimore Round Table','Barcelona Bunk Bed Frame','Barcelona Fabric Chair','Barcelona Pine Bed Frame','Barcelona White Bed Frame','Bedford 2 Door wardrobe','Bedford 2 Drawer Bedside','Bedford 2 Drawer Combi Wardrobe','Bedford 3 Doors wardrobe','Bedford 3 Drawer Bedside','Bedford 5 Drawer Chest','Bedford Dressing Table','Bedford Media Unit','Bedford Nest Lamp Table','Bendy Desk Lamp','Bosch Built-in Oven','Bosch Ceramic Hob 60cm','Bosch Dishwasher Freestanding 60cm Wide - White','Bosch Dishwasher Integrated 45cm Wide - White','Bosch Dishwasher Integrated 60cm Wide- White','Bosch Fridge Freezer Integrated 70/30 - White','Bosch Fridge Freezer X-Large 50/50 - White','Bosch Gas Hob - Stainless Steel','Bosch Integrated Washing Machine 8kg 1400 rpm - White','Bosch Series Induction Hob','Bosch Series Integrated Washer Dryer - White','Bosch Washer Dryer 8/5kg 1400rpm - White','Bosch Washing Machine 8Kg - White','Boston Chair','Boston Table & 4 Chairs','Boston Table & 6 Chairs','Brent Chair','Brooklyn Sofa Bed','Budget 1 Door Bedside','Budget 2 Door Combi Wardrobe','Budget 2 Door Wardrobe','Budget 3 Door Wardrobe With Mirror','Budget 3 Drawer Bedside','Budget 5 Drawer Chest','Budget Dressing Table','Built-In Double Oven','Built-in Oven - Stainless Steel','Built-in Oven- White','Ceramic Hob 60cm Wide','Chelsea Green Chair','Chelsea Grey Chair','Chelsea Navy Chair','Chest Freezer - White','Chester Fabric Ottoman Bed','Chester Grey Fabric Bed','Chesterfield 1 Seater PVC Sofa','Chesterfield 2 Seater Fabric Sofa','Chesterfield 2 Seater PVC Sofa','Chesterfield 3 Seater Fabric Sofa','Chesterfield 3 Seater PVC Sofa','Chesterfield Fabric 1 Seater Sofa','City Block Bed','City Block Bunk Bed Frame','Cleaning Set 5pc','Clifton Coffee Table','Clifton Large Sideboard','Clifton Media Unit','Clifton Small Sideboard','Colindale Grey PU Bar Stool','Colindale Navy Velvet Bar Stool','Comfy Sofa Bed','Condenser Tumble Dryer 8kg - White','Daewoo 12L Dehumidifier COL1471','Daewoo 2500W 11 Fin Oil Filled Radiator','Daewoo FLR00046 Vacuum Tornado 700W','Daewoo Mini Oven with Hot Plates 32L','Dallas Coffee Table','Davis Grey Accent Chair','Deluxe Grey Divan Guest Bed','Destiny Coffee Table','Divan Ortho Guest Bed','Dove Coffee Table','Dove Honeymoon Table & 2 Chairs','Dove Table & 4 Chairs','Dove Table & 6 Chairs','Dove White Chair','Drop-Leaf Table & 2 Chairs','Ebony Honeymoon Table & 2 Chairs','Ebony Round Table & 4 Chairs','Eden Coffee Table','Electric Hob - White - 4 Rings','Electric Hob 60cm - Stainless Steel','Eloise Grey Bed Frame','Emily 1 Seater Sofa','Emily 2 Seater Sofa','Executive 1 Seater Velvet Sofa','Executive 2 Seater Velvet Sofa','Florence Chair','Freestanding Electric Cooker 50cm wide- White','Freestanding Electric Cooker 60cm Wide - White','Freestanding Electric Cooker With Ceramic Hob 60cm Wide - White','Freestanding Full Size Dishwasher 60cm Wide - White','Freestanding Gas Cooker 50cm Wide - White','Freestanding Gas Cooker 60cm Wide - White','Freestanding Washer Dryer - White','Fridge Freezer Medium - White','Fridge Freezer Medium 70/30','Fridge Freezer Small - White','Fridge Freezer X-Large - White','Full Size Integrated Dishwasher - 60cm wide - White','Gas Hob 4 Burner - Stainless Steel','Gas Hob 4 Burner-White','Gramercy Brown Accent Chair','Grey Rug','Greyson 1 Seater Sofa','Greyson 2 Seater Sofa','Greyson 3 Seater Sofa','Hannover Bed','Hannover Ottoman Bed','Harmony Extending Table & 6 Liberty Grey Velvet Chairs','Haven Coffee Table','Henry Vacuum Cleaner','Honeymoon Table & 2 Chairs','Iceberg Headboard','Indesit Washing Machine 8kg - White','Induction Hob 60cm Wide','Integrated Fridge Freezer 50/50 - White','Integrated Fridge Freezer 70/30','Integrated Under Counter Fridge With Icebox - White','Integrated Washer Dryer - White','Integrated Washing Machine - White','Ironing Board','Isabela Chair','Jasmine Coffee Table','Jerry 1 Seater Sofa','Jerry 2 Seater Sofa','Jerry Corner Grey Fabric Sofa','Jerry Fabric 3 Seater Sofa','Joren Bar Stool (Set of 2)','Juliet Corner Sofa Bed','Kansas Chair','Kettle - Black','Kettle - White','Kimberley Chair','Kudos Table & 4 Chairs','Lambeth 2 Seater Sofa','Large Freestanding Fridge Freezer','Large Freezer - White','Liberty Grey Chair','Liberty Navy Chair','Lincoln Coffee Table','Lincoln Desk','Lincoln Lamp Table','Lincoln Large Sideboard','Lincoln Media Unit','Lincoln Small Sideboard','Loxley Bed','Lugano Black Chair','Lugano White Chair','Luxury Orthopaedic','Luxury Orthopaedic Divan Set','Madison Black Chair','Madison Grey Chair','Madrid Chair','Malay Chair','Malay Coffee Table','Malay Dining Table','Malay Table & 4 Chairs','Malay Table & 4 Upholstered Chairs','Malay Table & 6 Chairs','Malay Table & 6 Upholstered Chairs','Malay Upholstered Chair','Malvern Table','Malvern Table & 4 Violet Chairs','Malvern Table & 6 Violet Chairs','Marlow - Anthracite Oak 2 Door Combi Wardrobe','Marlow - Anthracite Oak 2 Door Wardrobe','Marlow - Anthracite Oak 3 Drawer Bedside','Marlow - Anthracite Oak 5 Drawer Chest','Marlow 2 Door Combi Robe','Marlow 2 Door Wardrobe','Marlow 3 Door Robe With Mirror','Marlow 3 Drawer Bedside','Marlow 3 Drawer Dressing Table','Marlow 5 Drawer Chest','Marlow Anthracite Oak 5 Drawer Chest','Mattress Protector','Mayfair divan Set','Mayfair Mattress','Medium Freezer White','Medium Larder Fridge RL254W.E','Merida Double Grey Lift-Up Ottoman Storage Bed','Merida Grey Bed Frame','Miami Coffee Table','Miami Concrete Fixed Top Table with Madrid Chairs','Miami Concrete Grey Extending Table & 6 Milan Chairs','Miami Fixed Table Top','Miami Table & 4 Milan Chairs','Miami Table & Barcelona Fabric Chairs','Milan Chair','Minnesota 2 Door Combi Wardrobe','Minnesota 2 Door wardrobe','Minnesota 3 Door Wardrobe','Minnesota 3 Drawer Bedside','Minnesota 5 Drawer Chest','Minnesota Dressing Table','Monica Sofa Bed','Monza 1 Seater Sofa','Monza 2 Seater Sofa','Monza 3-Seater Sofa','New York 1 Seater Sofa','New York 2 Seater','New York 3 Seater Sofa','Newby Divan Set','Newby Mattress','Oakleigh Dark 2 Drawer Bedside','Oakleigh Dark 5 Drawer Chest w/ Hanging Storage','Oakleigh Natural 2 Drawer Bedside','Oakleigh Natural 5 Drawer Chest w/ Hanging Storage','Orthopaedic Divan Set','Orthopaedic Mattress','Otto Sofa Bed','Owl Table & 4 Chairs','Oxford Bunk Bed Frame','Oxford Coffee Table','Oxford Table','Oxford Table Honeymoon Set','Pearl Eco 1 Seater Recliner Sofa','Pearl Eco 2 Seater Recliner Sofa','Pearl Eco 3 Seater Recliner Sofa','Pickwick Bed Frame','Polycotton Duvet 13.5 Tog','Portland Lamp Table','Portland Large Sideboard','Portland Media Unit','Portland Small Sidetable','Prime Sofa Bed','Quilted Divan Set','Quilted Mattress','Richmond Media Unit','Rocco White Bar Stool','Royal Orthopaedic Divan Set','Royal Orthopaedic Mattress','Russell Hobbs Steam Iron 25580','Savona Table','Scandy 2 Seater Fabric Sofa','Scandy 3 Seater Fabric Sofa','Scandy Fabric 1 Seater Sofa','Shaker Coffee Table','Shaker Table & 4 Chairs','Shaker Table & 6 Chairs','Slimline Freestanding Dishwasher - 45cm wide - White','Slimline Integrated Dishwasher - 45cm Wide - White','Soho 1 Seater Sofa','Soho 2 Seater Sofa','Soho 3 Seater Sofa','Soho Corner Sofa','Sorrento Bedding Set','Spin Mop & Bucket','Staten Student Desk','Stockholm Folding Bed with Mattress','Swan 20l 800W Microwave Digital Black','Table-Top 2-Ring Hotplate Hob','Toaster 2 Slice - White','Tower Manual Microwave 20L 800W','Under Counter Fridge Freezer Double Door -White','Under Counter Fridge with Ice Box 48cm- White','Under Counter Fridge with Ice Box 55cm Wide - White','Undercounter Larder Fridge - White','Uno Essentials Foam Mattess','Vencil Headboard','Vented Tumble Dryer 9kg - White','Veronica Sofa Bed','Victoria Lamp Table','Visco Flex Foam Mattress','Vivo Faux Leather Sofa Bed','Walnut Table & 4 Chairs','Washing Machine 6Kg - 2 Year Warranty - White','Windsor Divan Set','Windsor Mattress' ]; var productsIDs = [ ]; $('#our-products .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'products', limit: 40, source: substringMatcher(products) });