/**
 * Provides suggestions for gifts 
 * @class
 * @scope public
 */
function GiftSuggestions() {
    this.gift = [
		"adorable",
		"almonds",
		"amber",
                "anthurium",
		"babies",
		"baby",
		"baked",
		"basket",
		"bath",
		"bear",
		"birthday",
		"biscotti",
		"biscuits",
		"blanc",
		"blossom",
		"blue",
		"board",
		"body",
		"bonbons",
		"box",
		"boy",
		"breadsticks",
		"breakfast",
		"brie",
		"brown",
		"bubble",
		"bunny",
		"butter",
		"butterscotch",
		"bv",
		"cabernet",
		"caffe",
		"candy",
		"cappuccino",
		"caramel",
                "carnation",
		"cashews",
		"caviar",
		"ceramic",
		"champange",
		"chardonnay",
		"cheddar",
		"cheese",
              "cheese basket",
		"cheesecake",
		"cherry",
		"children",
		"chili ",
		"chips",
		"chocolate",
		"chocolates",
		"chox",
		"christmas",
              "christmas gift",
              "christmas basket",
              "chrysanthemum",
		"cinnamon",
		"cocoa",
		"coffee",
		"conundrum",
		"cookie",
		"cracker",
		"crackers",
		"cranberry",
		"cream",
		"cru de",
		"cup",
		"cute",
		"cutting",
		"cutting board",
		"dark",
		"david",
		"deck of cards",
		"delight",
		"dessert",
		"dish",
		"divorce",
		"doom",
		"doubletree",
		"dredel",
		"drops",
		"easter",
		"elephant",
		"father",
		"favorites",
                "ferrero",
                "ferrero rocher",
		"festive",
		"flower",
		"flowers",
		"food",
		"foot",
		"franc",
		"french",
		"fressia",
		"frog",
		"fume",
		"fun",
		"games",
		"gel",
                "gerbera",
		"get well",
		"ghirardelli",
		"girl",
		"godiva",
		"golf",
		"gourmet",
		"graham",
		"grahams",
		"green tea",
		"groth",
		"ground",
		"guy ",
		"gwel",
		"gwell",
		"haley",
		"hampton",
		"hanukah",
		"happy",
		"hazelnut",
		"heart",
		"hearts",
		"hilton ",
		"holiday",
		"homer",
		"honey",
		"hot",
		"hugs",
		"ice cream",
		"included",
                "iris",
		"italian",
		"italy",
		"kent",
		"kids",
		"knife",
                "korkunov",
		"kosher",
		"kyle",
		"lady",
		"landsberg",
		"large",
		"lavender",
		"lemongrass",
                "lilies",
                "lily",
		"lime",
		"lindor",
		"lindt",
		"lollipop",
		"lotion",
		"lotions",
		"love",
		"macadamia",
		"male",
		"man",
		"margarita",
		"meritage",
		"merlot",
		"milk",
		"mints",
		"monkey",
		"mother",
		"mozzarella",
		"mug",
		"mustard",
		"mvp",
		"napa",
		"navspec",
		"neprica",
		"new",
		"new born",
		"news",
		"nomatch",
		"nuts",
		"ny",
		"ocean",
		"office",
		"olives",
		"opus",
		"oracle",
		"orvieto",
		"pancakes",
		"party",
                "passover",
		"pasta",
		"patticakes",
		"peanut",
		"pepper",
		"photo",
		"pink",
		"pinot noir",
		"pita",
		"plate",
		"popcorn",
		"port",
		"pretzels",
                "purim",
		"raisins",
                "raffaello",
                "ramadan",
		"red",
		"red rose",
		"roast",
		"robe",
		"roca",
		"rocky",
		"rose",
		"roses",
		"rosh",
                "rosh hashanah",
		"salami",
		"salmon",
		"sangiovese",
		"sauce",
		"sauvignon",
		"shower",
		"simple",
		"slippers",
		"soap",
		"sobe",
		"soup",
		"spa",
		"special",
		"specials",
		"spray",
		"spread",
		"spring",
		"squares",
		"starbuck",
		"starbucks",
		"sterling",
		"stuffed",
		"summer",
		"surprise",
		"sweet",
		"syrah",
		"tapenade",
		"tea",
		"teas",
		"teddy",
		"thank you",
		"theme",
		"thoughts",
		"toffee",
		"towel",
		"tower",
		"toys",
		"travel",
		"tray",
		"treat",
		"truck",
		"truffles",
                "tulips",
		"valentine",
		"valentines",
		"vanilla",
		"vineyards",
		"viogner",
		"waffles",
		"walker",
		"walkers",
		"wedding",
		"white",
		"wine",
		"winer",
		"xmas",
		"zinfandel"
    ];
}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
GiftSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    
    if (sTextboxValue.length > 0){
    
        //convert value in textbox to lowercase
        var sTextboxValueLC = sTextboxValue.toLowerCase();

        //search for matching gifts
        for (var i=0; i < this.gift.length; i++) { 

            //convert gift name to lowercase
            var sGiftLC = this.gift[i].toLowerCase();
           
            //compare the lowercase versions for case-insensitive comparison
            if (sGiftLC.indexOf(sTextboxValueLC) == 0) {

                //add a suggestion using what's already in the textbox to begin it                
                aSuggestions.push(sTextboxValue + this.gift[i].substring(sTextboxValue.length));
            } 
        }
    }

    //provide suggestions to the control
    oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
};

