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 = ['Acrobat Swallows (set of 3)','aequalis albus Yellow Trumpet (Cape Fuchsia)','autumnalis ssp. autumnalis - true species','Barn Owl','Bees Delight','belladonna (Belladonna Lily) AGM','Best Value Crocosmia Collection - 7 hybrids (£7.15 per pot)','Beth Chatto','bicolor','Bicolor AGM','Blackbird','Blackboard Marker Plant Label - pack of 10','Blackboard Marker Plant Label - single','Blue Moon Hare','Blue Tit','Blue Tit Tea-Light Holder','Bluebell','Bressingham Blaze','Bumblebee','Bumblebee Halo - brass finish (for in the home)','Bumblebee Halo - nickel finish (for in the home)','Bumblebee Mini Hanger - brass finish (for the home)','Bumblebee Mini Hanger - nickel finish (for the home)','Bumblebee on Stem','Buttercup','Carmin Brilliant AGM','Castle Ward Late AGM','Chickens at Dawn Trio','Citrone Spray - max 1 per customer','Cockerel & Chickens (set of three) - SAVE £14.97 ON INDIVIDUAL ITEMS','Coleton Fishacre','Columbus AGM','comosa - The Slender Pineapple Lily - green leaved form','Constance AGM','Cornflower','Cornish Chough','Cornish Copper - limited to 1 per customer, orders including this variety will be sent in late May','Cornish Red','Cornish Sunset','Crab Dune','Crocosmia Pocket Notepad','dalenii Lemon Form - recently potted, 1 corm','Dancing Crab','Dancing Hare','Dancing Puffin','Dancing Puffin Halo - brass finish (for in the home)','Dancing Puffin Halo - nickel finish (for the home)','Debutante AGM','Diademe','disticha ssp. rubrolucens','Dragonfly Hanger','Dragonfly Mini Hanger - brass finish (for the home)','Dragonfly Mini Hanger - nickel finish (for the home)','Ellenbank Firecrest','Fairy Mushroom (Fly Agaric)','Field Mouse Halo - brass finish (for in the home)','Field Mouse Halo - nickel finish (for in the home)','Field Poppy','Flower Lizard - heading left','Flower Lizard - heading right','Foxglove','fucata - winter growing species, needs a sheltered site','Fugue','Garden Border Stake for Silhouettes','George Davison','Hanging Bumblebee','Hanging Robin','Hard Fern - small','Hare Trio - nickel finish (for the home)','Harlequin - maximum 1 per customer','Harmonia','Hedgehog Family','Hedgehog Halo - brass finish (for in the home)','Hedgehog Halo - nickel finish (for in the home)','Hedgehog Mother','Hellfire AGM - limited to 2 per customer','Honey Angels - max 1 per customer','Hungry Chicken','India Runner Duck - Douglas','Indian Runner Duck - Desmond','Indian Runner Duck - Donald','Indian Runner Ducks (set of three) - SAVE £14.97 ON INDIVIDUAL ITEMS','Inkcap Mushrooms','Jupiter','Kingfisher','Lady Fern - small','Lady Jane','Lemon Spray - max 1 per customer - NOTE ORDERS WITH LEMON SPRAY WILL BE SENT IN JUNE','Limpopo AGM','Lucifer AGM','Magical Hares - Set of 3 - SAVE £10 ON INDIVIDUAL ITEMS','Magnetic Crocosmia Notepad','masoniorum','matthewsiana - ex Mpumalanga, RARE FORM - limited to 1 per customer','Mephistopheles','Moon Gazing Hare','Moon Gazing Hare Halo - brass finish (for in the home)','Moon Gazing Hare Halo - nickel finish (for the home)','Morning Hare','Mother Duck','Mount Congreve Coral','Mouse on Mushroom','Mushroom Gathering','nemorosa AGM','nemorosa Vestal AGM','Okavango','Oystercatcher','Pair of Robins Mini Hanger - brass finish (for the home)','Pair of Robins Mini Hangers - nickel finish (for the home)','Pair of Swallows Hanger','paniculata','paniculata Natal (red form)','paniculata x pottsii cross','papilio','papilio Ruby','Pauls Best Yellow AGM','Peach Spray','planiscapus Nigrescens (Black Mondo Grass) AGM','pottsii','Prince of Orange','Proud Cockerel','Puffin','Puffin Halo - brass finish (for in the home)','Puffin Halo - nickel finish (for the home)','Red Admiral & Peacock Butterflies','Red Admiral Butterfly','Red Fox','Red Squirrel','Resting Swallows','Robin','Robin Halo - brass finish (for in the home)','Robin Halo - nickel finish (for the home)','Robin Tea Light Holder','rooperi (Roopers Red Hot Poker) Autumn flowering','Rowallane Orange. - 1 bulb','Rusty Nail Robin','Rusty Nail Wren','S. Arnott - scented AGM - 2 bulbs in the green','Saracen','senescens - recently potted','Severn Sunrise AGM - freshly potted - limited to 1 per customer','Singing Chicken','Solfatare','Special Hybrid Collection - 5 varieties (£8.00 per pot)','Spitfire AGM','Star Of The East','striatula - great for dry sunny borders','Suction Hook for Halo Silhouettes','Sun Flare - maximum 1 per customer','Suzanna','Tamar Bronze','Tamar Double Red AGM - max 1 per customer','Tamar Glow - maximum one per customer','Tamar Gold','Tamar Golden Ring','Tamar New Dawn - limited to 1 per customer','Tea Light Holder','vandermerwei','Vulcan (Bloom)','Walberton Red','Wren','Wren Halo - brass finish (for in the home)','Wren Halo - nickel finish (for the home)','Zambesi','Zeal Giant AGM','Zeal Giant AGM 1 litre pots - limited to 1 per customer','Zeal Un-named AGM' ]; var productsIDs = [ ]; $('#our-products .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'products', limit: 40, source: substringMatcher(products) });