/* Popular phrases - ADOREBEAUTY - 12:48:22, Fri Jan 27, 2012 */
__SLI_ClientDefaults =
[
    ['ShowBrandingFooter', false ]
];
var asPhrases=new Array ('color bug','opi','butter london','aesop','kevin murphy','kevin murphy color bug','clarisonic','benefit','becca','essie','gift with purchase','alpha h','jane iredale','mascara','tinted moisturiser','primer','o&m','sun verbena','trilogy','invisible zinc','laura mercier','clinique','travel','asap','mirenesse','skii','lipstick','bb cream','lancome','lanolips','opi nail polish','clarins','dermalogica','tokyo milk','nail polish','ojon','o','original mineral','inika','fake bake','nail','tan','burts bees','highlighter','alpha-h','colour bug','eyelash curler','shipping','st tropez','skindinavia','sk ii','moroccan oil','nicole by opi','clarisonic mia','aesop hand wash','conditioner','aha','butter','morrocan oil','ultraceuticals even skintone serum','modelco','massage','becca beach tint','terax','rosehip oil','retinol','shea butter','laura mercier tinted moisturiser','urban decay','hand cream','priori','bloom','badger','brush','ultraceuticals','eye makeup remover','aesop moisturiser','fake tan','jurlique','blonde shampoo','kevin murphy colour bug','travel set','evo','foundation brush','straight','cellulite','clinique makeup','kardashian','illuminator','thalgo','mineral makeup','apivita','mia','napoleon primer','moisturiser','ole henriksen','guinot','american crew','protein treatment','tanning lotion','kp','ultraceuticals protective daily moisturiser spf30 150ml','opi muppets','ultraceuticals ultra moisturiser cream','alpha h micro cleanse','napoleon perdis','model co','lip liner','mask','shatter','laura mercier secret camouflage','enlarged pores','mist','pigmentation','mop','murphy','biotherm','color.bug','clarins vital light','acne treatment','set','oh lola','gift','clarins beauty flash balm','bb','sk ii facial treatment essence','visionnaire','bag','bug','night rider','thalgo eye','alpha h liquid gold','mor','laura mercier mineral foundation','lip tint','aesop travel case','eos','salicylic acid','unico','icurl','rosehip','paper','oil blotting paper','eyeliner','benefit eye bright','juicy tubes','magic mitt','concealer','oil free','mirenesse foundation','muppets','foundation','beach tint','rind concentrate body balm','lavender oil','vanilla','deodorant','sun beam','glycolic acid','becca shimmering skin perfector','tweezerman','sara happ','rosacea','aesop hand balm','clarins super restorative','kora','scar','lashes','genifique','clarins powder','kevin murphy night rider','asap moisturising daily defens','tea tree','even skintone serum','lip stain','eye shadow','pirates','dry shampoo','christina fitzgerald','clinique even better','subtle energies facial blend','candle','stretch marks','brow zings','porefessional','kusco murphy','shatter nail polish','hair spray','loccitane','self tanner','clarins extra firming day cream','beauty fix','anti gravity','cosmetic','avojuice','napoleon','oil','clearskin gel','bareminerals','hand','parlux','blackheads','exfoliant','becca mineral spf 30+ primer','aesop hand','dark circle','clarins lipstick','tinted moisturizer','jw organics','lotus','smashbox','vitamin c','pore','instant light','ingrown hair removal','riffi mitt','glasshouse','print','bikini saver','microdermabrasion','ingrown hair','super restorative total eye concentrate','bha','decleor baume excellence','mirenesse primer','giorgio armani','benefit you rebel','contest','ultraceuticals even skintone','jemma kidd','benefit they\'re real mascara','cream cleanser','4711','silicone','brow powder','demeter fragrance','loreal true match','sk-ii facial treatment essence','cloud nine','skinceuticals','powder puff','beauty flash balm','mineral','case','base coat','shower gel','bare minerals','argan','christmas','body wash','speed brow','kevin murphy mini','leave in hair','jane iredale purepressed','napoleon perdis foundation','china doll','leave in','clearance','subtle energies','eye primer','mirenesse icurl','sk-ii gift with purchase','lancome mascara','alchemy','soap','eye cream','revolotion','aesop masque','hair dryer','bumble and bumble','body brush','calvin klein','opi shimmer','serge','laura mercier lipstick','clinique anti blemish','the wave','hairspray','capillaries','lancome visionnaire','bronzer','eyelash','marc jacobs','hair serum','glycolic','smiths','katy perry','clarins foundation','sea salt','harlotte','clarins gift set','high beam','eye tint','loreal','oil control','aesop conditioner','mario badescu','instant brow','justin bieber','body butter','ultraceuticals tinted moisturiser','demeter','burts','lash growth','zirh','shampoo for itchy scalp','serum','brush cleaner','rose','leave in conditioner','kevin murphy angel','toner','crema','curl','tweezer','clarins illuminator','opi teenage dream','shave','hydraquench','clarins cleansing milk','shanti body lotion','daisy','nail envy','butter london top coat','waterproof eyeliner','glue','chromawhite','bitter orange','butter london cuticle','competition','sunblock','sun care','uv protection','biotherm moisturizer','protein','hair growing','aesop parsley','tokyo','heat protection','triple action','atomiser','dermadoctor','clarins gift packs','roc','angel rinse','spf30','decleor','makeup setting spray','gift set','dermalogica ultracalming','aesop exfoliate','white balance','aesop set','vein','visionaire','shiseido','becca tint','hydrating','biotherm white','face primer','clarins lift','cult','lancome artliner','hydra quench','aesop camellia nut facial hydrating cream 120ml','perfumeria','lip care','wrinkle freeze','mint','glycolic acid cleanser','clinique moisture surge tinted moisturizer','tanning oil','rose hip oil','lanolin','special cleansing gel','lip brush','uchi','becca skin perfect','napoleon perdis powder','ultra c facial cream','benefit primer','pore minimizer','tresor midnight rose','sun protection','facial treatment essence','lip','detangler','curling tong','ultimate hydration','cream blush','becca concealer','volume shampoo','balance of power','liquid roller','natural products','tan remover','24 hour','waterline','hydra','biopur','tart with a heart','verbena','lancome hypnose','mirenesse secret weapon mascara','hand wash','biotherm bb','sk','makeup remover','milia','eleusian','mini','foot','super c serum','rollers','tresor','poshe','lip scrub','cosmetic bag','black knight','eyebrow kits','gel bronzer','big apple red','top coat','o&m balance of power','opi brights','dmk','age spots','after sun','best eye cream','jurlique purely white','airbrush face','stranger tides','serum 15','sulfate free shampoo','patchouli','nars sheer glow foundation','lancome teint idole ultra','cream eyeshadow','aesop blemish','becca primer','gold eyeshadow','dermalogica ultra sensitive face block spf25','eye bright','jurlique rose hand cream','antioxidant','eye brow','french','clarins gentle day lotion','express the truth','laura mercier concealer','almond','thalgo tea','ultracalming','acne scars','ck one','powder','opi base','bedroom hair','whitening','hermes','sandalwood','mixed greens','korres','kevin murphy motion lotion','originalmineral','2 peas in a pod','cetaphil','tea with the queen','gel moisture','opi french','travalo','surf bomb','tinted lip balm','marine','aesop body cleanser','poeme','micro cleanse','face powder','aesop primrose','avene','lola','beauty flash','teeth whitener','ghd','kevin murphy anti gravity','darphin','l\'artisan','clarins joli rouge','lip lava','benefit smokin','mr bright','lancome miracle','mop lemongrass volume shampoo','prevage','australian','all about eyes','rice','kiehls','mineral veil','phyto','biotherm bb cream','aesop sage','makeup bag','lancome genifique','propoline','caudalie','hair mask','dermalogica skin smoothing','clarisonic cleanser','sally hansen','razor','sk-ii uv','o&m hydrate conquer shampoo','redness','leg','face mask','dermalogica foundation','eye roll on','evian','urban decay eye primer','easy rider','clarins daily','sensitive eye','opi top','crystal nail file','pure fiji','salve','gradual tan','night cream','smith \'s rosebud salve','tan mitt','teeth','facial treatment clear lotion','kevin murphy wave clips','hyaluronic','biodepyl','sugar scrub','cleaner','cloth mask','eye gel','nail treatment','2 free samples','liquid harmony','exfoliation glove','power base','ask allison','kabuki brush','cellumination essence','asap clearskin gel','chloe','cellex c','mirenesse liquid silk foundation','keratosis pilaris','eyebrow mascara','perricone','henley regatta','amazing face','ultraceuticals ultra moisture','mud','opi crackle','marrow','bubble bath','murad','kevin murphy session spray','calendula cream','vital light serum','st tropez mousse','opi burlesque','young again','ysl','hydra zen','moisturizer','mirinesse','la mer','benefit coralista','truly matte','lipfinity','invisible zinc junior','mirenesse eye shadow','clinique redness solutions','kevin murphy easy rider','essie good to go','combination','asap pure','eye mask','clinique pore minimiser','peel','free gift','badgal','skin prep scrub','eye make up remover','hamadi','white eyeliner','hydra zen neocalm','bungee','hypoallergenic','bloom organic','firewall','essie lilacism','annick','estee lauder double wear','aesop rejuvenate','jurlique eye','hair rollers','burts bees tinted lip balm','soothing gel','liquid eyeliner','aesop body balm','fan brush','eye','eye liner','benefit dr feelgood','purse spray','jurlique hand','balancing cleanser','asap hydrate lip balm','arnica','benefit porefessional','crystal file','crew shampoo','acid peel','emjoi','alchemy shampoo','rose cream','essie summer','frizz','remover','illamasqua','eyeshadow','clinique dark spot corrector','alpine snow','translucent powder','strivectin','angel','multivitamin','white plus hp','loccitane olive','no more shine','neostrata','certified organic','moonglow','organic lip','bare minerals concealer','sheer foundation','lipstick spf','shanti','cargo','lip plump','blotting','lancome concealer','fabulous face oil','mogra','mogra and indian rose gold cream','anti cellulite','under eye','invisible','bird of paradise','dermal clay','cosmedix','love','kevin murphy young again','scoundrel','lip concealer','mogra kewda','wildaid','gradual','loreal mascara','nicole','spf tinted moisturiser','clarins moisture rich body lotion','napoleon brush','sulfate free','blotting paper','clarins flash balm','l\'occitane hand cream','peony','bloom pure mineral','priori eye','skinceuticals cleanser','solid perfume','viola','roseacea','firming','bare escentuals starter kit','serena williams','moisturiser spf','nicole opi','clarins daily energiser','jonathan','olive','organic surge','clean start','horse power','sk-ii essence','thalgo organic infusion tea','eyesential','carmex','lip glace','white heads','ingrow','asap night cream','studio fix','burts bees ointment','heated eyelash curler','hoola','supersmile','clarins set','annick goutal','john masters','cellex','aloe vera gel','essential cleansing solution','clarins energising','fibre','cattitude','balancing wash','face','bonne mine','aesop rejuvenate intensive body balm','eye serum','opi nail lacquer','wallis','tresor in love','body moisturiser','medibac','eve lom','butter london wallis','wild kashmir','skin tightening','antiperspirants','clarins body treatment oil','gel eclat','daily resurfacer','butter london big smoke','miracle oil','skin brush','bathina','self tan face','hydroquinone','burts bees baby','waterproof','hair curlers','biotherm aquasource','opi red','medik8 eye','moisturisers sensitive skin','papaw','obagi','nail care','kevin murphy damage manager','skincare kit','biotherm force','clarins white plus all spots whitening corrector','benefit brush','hydrate me','scalp','asap eye','luxury rinse','mandragore','hydrating mask','baux','revitalift','gift bag','medik8 ce tetra','lancome uv','active moist 100ml','kai oil','rose soap','medic8','renergie microlift rare','hylexin','gradual tanner','caviar','malin','apivita body milk','pouch','sharpener','thalgo densifying firming serum','top hair spray','benefit bright','delice des','aesop fabulous face oil','l\'occitane verbena','mercier primer','cellumination','thalgo vital balm','velvet','rose hand','handcream','thalgo soothing concentrate','vital light night','thalgo vital fluid','l\'occitane delice','spray tan','delice des fruits','moulin rouge','radiance serum','opi designer','all hail','benefit some kind-a gorgeous foundation','organix','sea salt spray','marrakech','brush bag','body guard','acqua','bourjois','shaving serum','stella','paw paw','ferulic','harlotte cosmetics','hair bungee','cruelty free','oil free tinted moisturiser','burts bees hair','megan gale','belle de jour','secret brightener','miracle','setting lotion','lancome powder','beckham','asap articles','aesop mens','crescent row','sable','miniature','nail stickers','makeup brush','b tea balancing toner','hand cleanser','regenerate','osmosis','holiday sets','holiday','clarins face','clarins super restorative tinted cream','eco tan','clarins fragrance','eye bags','ojon dry recovery','magnifying mirror','biotherm aquasource non stop norm combo skin','nightrider','becca jewel','lash comb','clarins lip balm','clinique almost makeup','promotion','cleansers for dry skin','festive hand set','clarins hand','chest','magnifique','boi-ing','mop c','bad gal','sanitiser','aura','fine hair','hand care','cosmeceutical','bali balm','clarins eye','benefit watts up','pore filler','body firming cream','shaving brush','chimney sweep','highlight cream','mineral concealer','coriander','barrel brush','clarins oil','benefit set','fake bake spray','becca pressed shimmer powder','concealing spot treatment','body cleanser','bust','clarins cleanser','blemish','skin renewal booster','french nail','aesop spf','skin refining masque','bubble','cube','makeup kit','burts bees gift sets','mor candle','bath salts','collections','chemical peel','l\'occitane almond','luxe','cooling hand gel','chamomile','clay facial masks','c serum','burberry weekend','clarins self tan','minger','lancome base','clinique foundation','body powder','soy melts','love unleashed','lancome hydra','come to bed','aesop rosehip seed lip cream','asap brush','bronzy babe','spray tan products','morroccan','becca boudoir skin','clarins eye cream','bn1','aquasource non stop','bath oil','butter nail','burts bees lip balm','moroccan oi','latte','clarins tonic','liquid eye liner','aesope bitter orange','bon bon','seed','angled brush','baby powder','lancome spf','mario','silk cream foundation','aesop shave','summer bisque','clarins foot','asap skin','bronzer brush','clarins multi active','lancome visionnaire advanced skin corrector','animal','alpha h moisturiser','atonic','absolute eye','sanctum','breathless','clarins body lotion','clinique perfectly real','shavers','colour quartet for eyes','bare escentual foundation','best primer','clarins gentle','sheer lipstick','lancome toner','cleansing sponge','sensitive','laura mercier secret finish','clarins leg','aesop scrub','l\'occitane baby','bellapierre','badgal liner','lipbalm','clarins after sun','burt\'s bees lip','charged up cherry','bloom lip definer','burts bee conditioner','lippie','mineral make up','aesop gift','alpha-h clear skin','asap ultimate','scrub and mask','cellular radiance','l\'occitane gift pack','clarins true comfort','skinceuticals phyto','clinique redness','asap skin care','aesop parsley seed anti-oxidant serum','mineral sunscreen','biotherm white d-tox','shadow','barefoot in barcelona','alchemy conditioner','sweat','stretchmark','bloom cream','bloom cheek','mineral brush','airbrush','skinceuticals phyto corrective gel','all over face colour','multivitamin power concentrate','mason','mrs o\'leary\'s bbq','la roche posay','akin body wash','breakouts','becca eye colour','la source','berry','clear lip gloss','benefit bronzer','maison','chroma','asap daily exfoliating facial scrub','mascara primer','bath','moisture defense antioxidant lotion','bloom brow','lengthening mascara','shading','children','bust cream','soften','light diffusing makeup','best foundation','liquid lipstick','benefit gift','shimmering skin','lucas','b triple c facial balancing gel','purely age-defying','complexion','benefit powder','biosilk','white d-tox','baby shampoo','clarins vital','lip spf','b','lip wax','cult products','cabotine','sage scalp','sulfur','childrens shampoo','cleansing wipes','clarins truly matte','bottle','bo-ing','clarins shower','a kin','asap foundation','burt\'s bees lemon butter cuticle creme','bloom moisturising ginseng lotion','benefit erase','apivita lip','biotherm hydra','aesop violet leaf hair balm 60ml','benefit eyeliner','balancing day care cream','body mask','spf lip gloss','multi-active','biotherm celluli laser slim.code','sun spot','benefit lip liner','body milk','bloom palette','buttermilk lotion','badger brush','bella bamba','body oil mist','biotherm sos','body silk','al \'chemy rice aminos wheat protein intensive moisture shampoo','brazilian','boar bristle','bn2','skin kit','burt \'s bees baby bee','american','c12','skin firm','blond brow','benefit ultra','bath gel','batana','clarins scrub','bloom bronzing duo','citrus hand','arsenic','creme brulee','all\'s well','clarins shampoo','cleansing gel','shadow liner','bareminerals blush','crayon','bloom lotion','spain','cover','baxter facial scrub','stocking','becca nectar','clarins essential');
/* $Revision: 3828 $
 *
 */

if(typeof(_sli_init )!='object'){var _sli_init=new Array();}
if(typeof(sli_init )!='function'){function sli_init(){ for(var x=0;x<_sli_init.length;x++) _sli_init[x]();}}
if(typeof(asPhrases)!='object'){ var asPhrases = new Array(); }
if(typeof(__SLI_customisations)!='object'){var __SLI_customisations = new Object();}
if(typeof(__SLI_ClientDefaults)!='object'){ var __SLI_ClientDefaults=[]; }
if(typeof(__SLI_validSearchBoxes)!='object'){ var __SLI_validSearchBoxes = new Array(); }
if(typeof(__SLI_asug_used_flag)!='object'){ var __SLI_asug_used_flag = false; }
if(typeof(__SLI_width)!='object'){ var __SLI_width = 0; }
if(typeof(sli_targeturl)!='object'){ var sli_targeturl = ""; }


    __AutoComplete = new Object(); //namespace...
    __AutoComplete_mouseMoved=false;

    // Basic UA detection
    isIE = document.all ? true : false;
    isGecko = navigator.userAgent.toLowerCase().indexOf('gecko') != -1;
    isOpera = navigator.userAgent.toLowerCase().indexOf('opera') != -1;

    /* defaults and options */

    var __SLI_ApplicationName = 'AutoSuggest';
        __SLI_customisations[ 'AutoSuggest' ] =
                {
                    'ShowBrandingFooter' : true
                    ,
                    'TextBoxIDPrefix' : 'sli_search_'
                    ,
                    'BrandingFooterImagePath' : 'http://assets.resultspage.com/autosuggest/sli_systems-powered_150_15.gif'
                    ,
                    'BrandingFooterTitleTooltip' : 'AutoSuggest Powered by SLI Systems'
                    ,
                    'DropListMinWidth' : 150
                    ,
                    'MaxListItems' : 10
                    ,
                    'Alignment' : true
                    ,
                    'TextBoxIDCustom' : []
                    ,
                    'ValidSearchBoxes' : false 
                    ,
                    'IE6SelectBox' : false 
                    ,
                    'IE6SelectBoxPadding' : 0
                    ,
                    'TargetURL' : ''
                    ,
                    'IframeAlignment' : false
                    ,
                    'AlignmentBorderBug' : false
                    ,
                    'IE6OnFocus' : false
                };
    /* 0 = keyname, 1 = value */
    for( defaultValuePair in __SLI_ClientDefaults )
    {
        __SLI_customisations[__SLI_ApplicationName][__SLI_ClientDefaults[defaultValuePair][0]]=__SLI_ClientDefaults[defaultValuePair][1];
    }

    /* pre-fetch branding footer image if being used...
     */
    if( __SLI_customisations[ __SLI_ApplicationName ][ 'ShowBrandingFooter' ] )
    {
        
        if(location.protocol == "https:")
        {
            __SLI_customisations[ __SLI_ApplicationName ][ 'BrandingFooterImagePath' ] = __SLI_customisations[ __SLI_ApplicationName ][ 'BrandingFooterImagePath' ].replace(/http:/i, 'https:');
        }
    
        var __AutoCompleteBranding = new Image();
        __AutoCompleteBranding.src=__SLI_customisations[ __SLI_ApplicationName ][ 'BrandingFooterImagePath' ];
    }


    function AutoComplete_init()
    {
        if(!isOpera)
        {
            var oldonresize=function(){};
            if(typeof(window.onresize)=='function')
                oldonresize = window.onresize;//play nicely with other people's toys
            window.onresize= function(){ oldonresize(); AutoComplete_HideAll(); AutoComplete_Create( asPhrases ); }

            AutoComplete_Create( asPhrases );
            
            var els = document.getElementsByTagName('input');
            if(els)
            {
               for ( i = 0; i < els.length; i++ )
               {
                  if(els[i].name == "asug")
                  {
                     els[i].disabled = true;
                  }
               }
            }
        }
    }




    /**
    * Attachs the autocomplete object to a form element. Sets
    * onkeypress event on the form element.
    *
    * @param string formElement Name of form element to attach to
    * @param array  data        Array of strings of which to use as the autocomplete data
    */
    //function AutoComplete_Create (id, data)
    /*
     * iterate over 'sli_search_*' assumes one or more search boxes numbered from 1...
    */
    function AutoComplete_Create( data )
    {
        var idx=1, e, id, searchBoxPrefix=__SLI_customisations[ __SLI_ApplicationName ][ 'TextBoxIDPrefix' ];
        while( e = document.getElementById(searchBoxPrefix+idx) )
        {
            AutoComplete_AttachHandlers(e, data);
            if( __SLI_customisations[ __SLI_ApplicationName ][ 'ValidSearchBoxes' ] )
            {
                __SLI_validSearchBoxes.push(searchBoxPrefix+idx);
            }
            idx++;
        }
        
        
        //this array comes from the customised list
        var otherTextBoxIdList = __SLI_customisations[ __SLI_ApplicationName ][ 'TextBoxIDCustom' ];
        if( otherTextBoxIdList)
        {
            for(idx=0;idx<otherTextBoxIdList.length;idx++)
            {
                e = document.getElementById(otherTextBoxIdList[idx]);
                if(e)
				{
					if( __SLI_customisations[ __SLI_ApplicationName ][ 'ValidSearchBoxes' ] )
                	{
	                    __SLI_validSearchBoxes.push( otherTextBoxIdList[idx] );
                	}
					AutoComplete_AttachHandlers(e, data);
				}
            }
        }
        
    } 

    function AutoComplete_AttachHandlers(e, data){
        var iframe,id;
        id=e.id;


        __AutoComplete[id] = {'data':data,
                              'isVisible':false,
                              'element':document.getElementById(id),
                              'dropdown':null,
                              'highlighted':null};

        __AutoComplete[id]['element'].setAttribute('autocomplete', 'off');
        __AutoComplete[id]['element'].onkeydown = function(e) {if (!e) e = window.event; return AutoComplete_KeyDown(this.getAttribute('id'), e);}
        __AutoComplete[id]['element'].onkeyup = function(e) {if (!e) e = window.event; return AutoComplete_KeyUp(this.getAttribute('id'), e);}
        // The function call on the next line was changed by Andrew Grieve April 2008
        __AutoComplete[id]['element'].onkeypress = function(e) {if (!e) e = window.event; return AutoComplete_KeyPress(this.getAttribute('id'), e);}
        __AutoComplete[id]['element'].onclick = function(e)
        {
            if( __SLI_customisations[ __SLI_ApplicationName ][ 'IE6OnFocus' ] )
            {
                __AutoComplete[id]['element'].focus();
            }
            if (!e) e = window.event; e.cancelBubble = true; e.returnValue = false;
        }



        // Hides the dropdowns when document clicked
        var docClick = function()
        {
            if( __SLI_customisations[ __SLI_ApplicationName ][ 'ValidSearchBoxes' ] )
            {
               for(var i=0; i < __SLI_validSearchBoxes.length; i++)
               {
                   if(document.getElementById(__SLI_validSearchBoxes[i]))
                   {
                       AutoComplete_HideDropdown(__SLI_validSearchBoxes[i]);
                   }
               }
            }
            else
            {
                for (id in __AutoComplete)
                {
                   AutoComplete_HideDropdown(id);
                }
            }
        }

        if (document.addEventListener) {
            document.addEventListener('click', docClick, false);
        } else if (document.attachEvent) {
            document.attachEvent('onclick', docClick, false);
        }


        // Max number of items shown at once
        if (arguments[2] != null) {
            __AutoComplete[id]['maxitems'] = arguments[2];
            __AutoComplete[id]['firstItemShowing'] = 0;
            __AutoComplete[id]['lastItemShowing'] = arguments[2] - 1;
        }

        AutoComplete_CreateDropdown(id);

        // Prevent select dropdowns showing thru
        if (isIE) {
            iframe = document.createElement('iframe');
            __AutoComplete[id]['iframe'] = iframe;
                iframe.id = id +'_iframe';
                iframe.style.position = 'absolute';
                iframe.style.top = '0';
                iframe.style.left = '0';
                iframe.style.width = '0px';
                iframe.style.height = '0px';
                iframe.style.zIndex = '98';
                iframe.style.visibility = 'hidden';
                
                if(location.protocol == "https:")
                {
                   iframe.src = 'https://assets.resultspage.com/autosuggest/blank.html';
                }
                
                if( __SLI_customisations[ __SLI_ApplicationName ][ 'IE6SelectBox' ] )
                {
                  iframe.style.width = __SLI_width  + __SLI_customisations[ __SLI_ApplicationName ][ 'IE6SelectBoxPadding'];
                }

            if( __SLI_customisations[ __SLI_ApplicationName ][ 'IframeAlignment' ] )
            {
                document.body.insertBefore( iframe );
            }
            else
            {
                __AutoComplete[id]['element'].parentNode.insertBefore( iframe, __AutoComplete[id]['element'] );
            }
        }
    }

    /**
    * Creates the dropdown layer
    *
    * @param string id The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_CreateDropdown(id)
    {
        var theSearchbox = __AutoComplete[id]['element'];
        var theDropDown;
        var left_top = AutoComplete_getPos( theSearchbox );
        var left  = left_top[0];
        var top   = left_top[1] + theSearchbox.offsetHeight;
        var width = theSearchbox.offsetWidth;

        if ( width < __SLI_customisations[ __SLI_ApplicationName ][ 'DropListMinWidth' ] )
        {
            width = __SLI_customisations[ __SLI_ApplicationName ][ 'DropListMinWidth' ];
        }

        theDropDown = document.createElement('div');
        theDropDown.className = 'autocomplete'; // Don't use setAttribute()


        if(__SLI_customisations[ __SLI_ApplicationName ][ 'Alignment' ] == true && document.body)
        {
            theDropDown.style.position = 'absolute';
            document.body.insertBefore(theDropDown, document.body.nextSibling);
            
            // Position it
            theDropDown.style.visibility = 'hidden';
            theDropDown.style.left       = left + 'px';
            theDropDown.style.top        = top + 'px';
            theDropDown.style.width      = width + 'px';
            theDropDown.style.zIndex     = '99999';
        }
        else if(__SLI_customisations[ __SLI_ApplicationName ][ 'Alignment' ] == "offsetrelative" && document.body)
        {
          theSearchbox.parentNode.insertBefore(theDropDown, theSearchbox);
          // Position it
          if(sli_getStyle(theSearchbox.offsetParent, 'position') != "absolute")
          {
            theSearchbox.offsetParent.style.position = 'relative';
          }
          theDropDown.style.position = 'absolute';
          theDropDown.style.left = (theSearchbox.offsetLeft) + 'px';
          theDropDown.style.top = (theSearchbox.offsetTop + theSearchbox.offsetHeight) + 'px';
          theDropDown.style.width = (theSearchbox.clientWidth) + 'px';
          theDropDown.style.visibility = 'hidden';
          theDropDown.style.zIndex     = '99999999';
        }
        else
        {
            theSearchbox.parentNode.insertBefore(theDropDown, theSearchbox);
            // Position it
            theDropDown.style.visibility = 'hidden';
            theDropDown.style.left       = left + 'px';
            theDropDown.style.top        = top + 'px';
            theDropDown.style.width      = width + 'px';
            theDropDown.style.zIndex     = '99999';
        }
        

        __AutoComplete[id]['dropdown'] = theDropDown;
        __SLI_width = width;
    }

    function /* array [ left, top ] */ AutoComplete_getPos( obj )
    {
        var curleft = curtop = 0;
        var sli_flag = 0;

        if (obj.offsetParent)
        {
           do
           {
              if ( __SLI_customisations[ __SLI_ApplicationName ][ 'AlignmentBorderBug' ] )
              {         
                
                if(sli_flag == 1)
                {
                    var clientTop = (obj.offsetHeight - obj.clientHeight) / 2;
                    curtop += clientTop;

                    var clientLeft = (obj.offsetWidth - obj.clientWidth) / 2;
                    curleft += clientLeft;
                }
                sli_flag = 1;
              }
           
              curleft += obj.offsetLeft;
              curtop += obj.offsetTop;
           }
           while (obj = obj.offsetParent);
        }
        return [curleft,curtop];
    }

    /**
    * Shows the dropdown layer
    *
    * @param string id The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_ShowDropdown(id)
    {

        AutoComplete_HideAll();



        var value = __AutoComplete[id]['element'].value;
        var toDisplay = new Array();
        var newDiv    = null;
        var text      = null;
        var numItems  = __AutoComplete[id]['dropdown'].childNodes.length;

        __AutoComplete_mouseMoved=false;
        // SLI Code Modification - Start - Andrew Grieve April 08
        // Trim the textbox so that if is starts with a space then the feature will still work
        //value = value.replace(/^\s+|\s+$/g,"");
        value = value.replace(/^\s+/g,"");

        if(value.length == "")
        {
            // If Textbox length is nothing (after the trim) then don't show dropdown.
            return;
        }
        // SLI Code Modification - End

        // Remove all child nodes from dropdown
        while (__AutoComplete[id]['dropdown'].childNodes.length > 0) {
            __AutoComplete[id]['dropdown'].removeChild(__AutoComplete[id]['dropdown'].childNodes[0]);
        }


        var count=0;
        // Go thru data searching for matches
        for (i=0; i<__AutoComplete[id]['data'].length; ++i)
        {
            // SLI Code Modification - Start - Andrew Grieve April 08 - Added lower casing
            if (__AutoComplete[id]['data'][i].substr(0, value.length).toLowerCase() == value.toLowerCase())
            {
                // SLI Code Modification - End
                toDisplay[toDisplay.length] = __AutoComplete[id]['data'][i];
                count++;
                /* how many to display? */
                if(count == __SLI_customisations['AutoSuggest']['MaxListItems'] ) /* Code inserted to keep list to a maximum of 10 values (was 20 or 30) */
                {
                    break;
                }
            }
        }

        // No matches?
        if (toDisplay.length == 0) {
            AutoComplete_HideDropdown(id);
            return;
        }



        // Add data to the dropdown layer
        for (i=0; i<toDisplay.length; ++i) {
            newDiv = document.createElement('div');
            newDiv.className = 'autocomplete_item'; // Don't use setAttribute()
            newDiv.setAttribute('id', 'autocomplete_item_' + i);
            newDiv.setAttribute('index', i);
            newDiv.style.zIndex = '99999';

             // Scrollbars are on display ?
            if (toDisplay.length > __AutoComplete[id]['maxitems'] && navigator.userAgent.indexOf('MSIE') == -1) {
                newDiv.style.width = __AutoComplete[id]['element'].offsetWidth - 22 + 'px';
            }

            newDiv.onmouseover =
        function()
        {
            if( __AutoComplete_mouseMoved )
                AutoComplete_HighlightItem(__AutoComplete[id]['element'].getAttribute('id'), this.getAttribute('index'));
        };

            newDiv.onclick     =    function()
                                    {
                                    	  __SLI_asug_used_flag = true;
                                                                           
                                        AutoComplete_SetValue(__AutoComplete[id]['element'].getAttribute('id'));
                                        AutoComplete_HideDropdown(__AutoComplete[id]['element'].getAttribute('id'));
                                        AutoComplete_submitForm(id);
                                    }



            text   = document.createTextNode(toDisplay[i]);
            newDiv.appendChild(text);
            newDiv.title='Search for ' + toDisplay[i];

            /* ellipsis for IE only */
            if( isIE )
            {
                newDiv.style.textOverflow = 'ellipsis';
                newDiv.style.width = '100%';
                newDiv.style.whiteSpace = 'nowrap';
                newDiv.style.overflow = 'hidden';

            }
            __AutoComplete[id]['dropdown'].appendChild(newDiv);
        }
        /*
         * append DIV containing footer branding...
         */
        if(__SLI_customisations['AutoSuggest']['ShowBrandingFooter'])
        {
            i = toDisplay.length;
            newDiv = document.createElement('div');
            newDiv.className = 'autocomplete_footer'; // Don't use setAttribute()
            newDiv.setAttribute('id', 'autocomplete_item_' + i);
            newDiv.setAttribute('index', i);
            newDiv.style.zIndex = '99999';
            newDiv.innerHTML = '<a href="http://www.sli-systems.com/powered-by.php" title="' +
                                __SLI_customisations[ __SLI_ApplicationName ][ 'BrandingFooterTitleTooltip' ] +
                                '"><img class="autocomplete_footer_branding" src="'+__AutoCompleteBranding.src+'" /></a>';

            __AutoComplete[id]['dropdown'].appendChild(newDiv);
        }


        // Too many items?
        if (toDisplay.length > __AutoComplete[id]['maxitems']) {
            __AutoComplete[id]['dropdown'].style.height = (__AutoComplete[id]['maxitems'] * 15) + 2 + 'px';

        } else {
            __AutoComplete[id]['dropdown'].style.height = '';
        }


        /**
        * Set left/top in case of document movement/scroll/window resize etc
        */
        if(__SLI_customisations[ __SLI_ApplicationName ][ 'Alignment' ] == "true" || __SLI_customisations[ __SLI_ApplicationName ][ 'Alignment' ] == "false")
        {
            var left_top = AutoComplete_getPos( __AutoComplete[id]['element'] );
            __AutoComplete[id]['dropdown'].style.left = left_top[0];
            __AutoComplete[id]['dropdown'].style.top  = left_top[1] + __AutoComplete[id]['element'].offsetHeight;
        }


        // Show the iframe for IE
        if (isIE) {
            
            if(!__SLI_customisations[ __SLI_ApplicationName ][ 'Alignment' ] == true)
            {
               __AutoComplete[id]['iframe'].style.width  = __AutoComplete[id]['dropdown'].offsetWidth;
            }
            
            
            __AutoComplete[id]['iframe'].style.top    = __AutoComplete[id]['dropdown'].style.top;
            __AutoComplete[id]['iframe'].style.left   = __AutoComplete[id]['dropdown'].style.left;
            __AutoComplete[id]['iframe'].style.height = __AutoComplete[id]['dropdown'].offsetHeight;

            __AutoComplete[id]['iframe'].style.visibility = 'visible';
        }

    e =  __AutoComplete[id]['dropdown'];

    e.onmousemove =
        function()
        {
            if(!__AutoComplete_mouseMoved){__AutoComplete_mouseMoved=true;}
            this.onmousemove = null;
        }

        // Show dropdown
        if (!__AutoComplete[id]['isVisible']) {
            __AutoComplete[id]['dropdown'].style.visibility = 'visible';
            __AutoComplete[id]['isVisible'] = true;
        }


        // If now showing less items than before, reset the highlighted value
        if (__AutoComplete[id]['dropdown'].childNodes.length != numItems) {
            __AutoComplete[id]['highlighted'] = null;
        }
    }



    /**
    * Hides the dropdown layer
    *
    * @param string id The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_HideDropdown(id)
    {
        if (__AutoComplete[id]['iframe'])
        {
            __AutoComplete[id]['iframe'].style.visibility = 'hidden';
        }
        
        if (__AutoComplete[id]['dropdown'])
        {
            __AutoComplete[id]['dropdown'].style.visibility = 'hidden';
        }

        __AutoComplete[id]['highlighted'] = null;
        __AutoComplete[id]['isVisible']   = false;
    }


    /**
    * Hides all dropdowns
    */
    function AutoComplete_HideAll()
    {
         if( __SLI_customisations[ __SLI_ApplicationName ][ 'ValidSearchBoxes' ] )
         {
               for(var i=0; i < __SLI_validSearchBoxes.length; i++)
               {
                   if(document.getElementById(__SLI_validSearchBoxes[i]))
                   {
                       AutoComplete_HideDropdown(__SLI_validSearchBoxes[i]);
                   }
               }
         }
         else
         {
                for (id in __AutoComplete)
                {
                   AutoComplete_HideDropdown(id);
                }
         }
    }


    /**
    * Highlights a specific item
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    * @param int    index The index of the element in the dropdown to highlight
    */
    function AutoComplete_HighlightItem(id, index) // mouseover, index is the list element index, zero-based
    {
        if (__AutoComplete[id]['dropdown'].childNodes[index]) {
            for (var i=0; i<__AutoComplete[id]['dropdown'].childNodes.length; ++i) {
                if (__AutoComplete[id]['dropdown'].childNodes[i].className == 'autocomplete_item_highlighted') {
                    __AutoComplete[id]['dropdown'].childNodes[i].className = 'autocomplete_item';
                }
            }

            __AutoComplete[id]['dropdown'].childNodes[index].className = 'autocomplete_item_highlighted';
            __AutoComplete[id]['highlighted'] = index;

            //also see below...
            //__AutoComplete[id]['element'].value = __AutoComplete[id]['dropdown'].childNodes[index].innerHTML;
            //AutoComplete_SetValue(id);
        }
    }


    /**
    * Highlights the menu item with the given index
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    * @param int    index The index of the element in the dropdown to highlight
    */
    function AutoComplete_Highlight(id, index) // keyboard up/down - index is the direction of travel, 1==down,-1=up
    {
        var childNodes = __AutoComplete[id]['dropdown'].childNodes;
        if(childNodes.length)
        {
	        var lastItem = ( ( childNodes[ childNodes.length - 1 ].className != 'autocomplete_footer' ) ? childNodes.length - 1 : childNodes.length - 2 );

            // Out of bounds checking
            //if (index == 1 && __AutoComplete[id]['highlighted'] == __AutoComplete[id]['dropdown'].childNodes.length - 1) {
            if (index == 1 && __AutoComplete[id]['highlighted'] == lastItem ) {
                childNodes[__AutoComplete[id]['highlighted']].className = 'autocomplete_item';
                __AutoComplete[id]['highlighted'] = null;

            } else if (index == -1 && __AutoComplete[id]['highlighted'] == 0) {
                childNodes[0].className = 'autocomplete_item';
                __AutoComplete[id]['highlighted'] = lastItem;
                index = 0;//hack!
            }

            // Nothing highlighted at the moment
            if (__AutoComplete[id]['highlighted'] == null) {

                childNodes[0].className = 'autocomplete_item_highlighted';
                __AutoComplete[id]['highlighted'] = 0;
                newIndex = 0;
                
            } else {

                if (childNodes[__AutoComplete[id]['highlighted']]) {
                
                    childNodes[__AutoComplete[id]['highlighted']].className = 'autocomplete_item';
                }

                var newIndex = parseInt( __AutoComplete[id]['highlighted'] ) + parseInt(index);

                if (childNodes[newIndex]) {

                    childNodes[newIndex].className = 'autocomplete_item_highlighted';

                    __AutoComplete[id]['highlighted'] = newIndex;
                }
            }

            //populate textbox with currently highlighted term...
            //__AutoComplete[id]['element'].value = __AutoComplete[id]['dropdown'].childNodes[newIndex].innerHTML;
            AutoComplete_SetValue(id);
        }
    }


    /**
    * Sets the input to a given value
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_SetValue(id)
    {
        __AutoComplete[id]['element'].value = __AutoComplete[id]['dropdown'].childNodes[__AutoComplete[id]['highlighted']].innerHTML.replace(/&amp;/, "&");
    }


    /**
    * Checks if the dropdown needs scrolling
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_ScrollCheck(id)
    {
        // Scroll down, or wrapping around from scroll up
        if (__AutoComplete[id]['highlighted'] > __AutoComplete[id]['lastItemShowing']) {
            __AutoComplete[id]['firstItemShowing'] = __AutoComplete[id]['highlighted'] - (__AutoComplete[id]['maxitems'] - 1);
            __AutoComplete[id]['lastItemShowing']  = __AutoComplete[id]['highlighted'];
        }

        // Scroll up, or wrapping around from scroll down
        if (__AutoComplete[id]['highlighted'] < __AutoComplete[id]['firstItemShowing']) {
            __AutoComplete[id]['firstItemShowing'] = __AutoComplete[id]['highlighted'];
            __AutoComplete[id]['lastItemShowing']  = __AutoComplete[id]['highlighted'] + (__AutoComplete[id]['maxitems'] - 1);
        }

        __AutoComplete[id]['dropdown'].scrollTop = __AutoComplete[id]['firstItemShowing'] * 15;
    }


    /**
    * Function which handles the keypress event
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_KeyDown(id, e)
    {
        var result = true;

       var event;
       event = e;
       if(!event) event = window.event;

        var keyCode = event.keyCode;

        switch (keyCode) {

            // Return/Enter
            case 13:
                if (__AutoComplete[id]['highlighted'] != null) {
                    AutoComplete_SetValue(id);
                    AutoComplete_HideDropdown(id);
					
                    __SLI_asug_used_flag = true;
					
                    if( e = __AutoComplete[id]['element'].form['asug'] )
                    {
                        
                        e.disabled=false;
                        e.value = __AutoComplete[id]['asug'];
                    }

                }

                result = AutoComplete_submitForm(id);

                break;

            // Escape
            case 27:
                AutoComplete_HideDropdown(id);
                event.returnValue = false;
                event.cancelBubble = true;
                break;

            // Up arrow
            case 38:
                if (!__AutoComplete[id]['isVisible']) {
                    AutoComplete_ShowDropdown(id);
                }

                AutoComplete_Highlight(id, -1);
                AutoComplete_ScrollCheck(id, -1);
                
                if( e = __AutoComplete[id]['element'].form['asug'] )
                {
                   e.disabled=false;
                   e.value = __AutoComplete[id]['asug'];
                }

                                
                result = false;
                break;

            // Tab
            case 9:
                if (__AutoComplete[id]['isVisible']) {
                    AutoComplete_HideDropdown(id);
                }
                return;

            // Down arrow
            case 40:

                if (!__AutoComplete[id]['isVisible']) {
                    AutoComplete_ShowDropdown(id);
                }

                AutoComplete_Highlight(id, 1);
                //AutoComplete_ScrollCheck(id, 1);

                if( e = __AutoComplete[id]['element'].form['asug'] )
                {
                   e.disabled=false;
                   e.value = __AutoComplete[id]['asug'];
                }

                result = false;
                break;
        }
        return result;
    }


    /**
    * Function which handles the keyup event
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_KeyUp(id, e)
    {
       var event;
       event = e;
       if(!event) event = window.event;

        var keyCode = event.keyCode;

        switch (keyCode) {
            case 13:
                event.returnValue = false;
                event.cancelBubble = true;
                
                break;

            case 27:
                AutoComplete_HideDropdown(id);
                event.returnValue = false;
                event.cancelBubble = true;
                break;

            case 38:
            case 40:
                return false;
                break;

            default:
                AutoComplete_ShowDropdown(id);
                
                __AutoComplete[id]['asug']=__AutoComplete[id]['element'].value;

                if( e = __AutoComplete[id]['element'].form['asug'] )
                {
                   e.disabled=true;
                   e.value = "";
                }  
                
                break;
        }
    }

    /**
    * Function which handles the keypress event
    * This function added April 2008 by Andrew Grieve
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */

    // SLI Code Modification - Start - Andrew Grieve April 08
    function AutoComplete_KeyPress(id, e)
    {
        var event = e;
        if(!event) event = window.event;
        var keyCode = event.keyCode;

        if (keyCode == 13 && isGecko || isOpera)
        {
            return false;
        }
        
        if( __SLI_customisations[ __SLI_ApplicationName ][ 'TargetURL' ] )
        {
            if (keyCode == 13 && isIE)
            {
                return false;
            }
        }
        
    }
    // SLI Code Modification - End

    /**
    * Returns whether the dropdown is visible
    *
    * @param string id    The form elements id. Used to identify the correct dropdown.
    */
    function AutoComplete_isVisible(id)
    {
        return __AutoComplete[id]['dropdown'].style.visibility == 'visible';
    }

    function AutoComplete_submitForm(id)
    {
        var e, f, result=true;
        if( f = __AutoComplete[id]['element'].form )
        {
            if( __AutoComplete[id]['element'].value != '' )
            {
            	if(__SLI_asug_used_flag == true)
            	{
                   if( e = f['asug'])
                   {
                      e.value = __AutoComplete[id]['asug'];
                      e.disabled=false;
                   }
                }
                
                if( __SLI_customisations[ __SLI_ApplicationName ][ 'TargetURL' ] )
                {
                	asugvar = "";
                	if(__SLI_asug_used_flag == true)
                	{
                	  asugvar = '&asug=' + __AutoComplete[id]['asug'];
                  	}
                    
                    sliRegex = /resultsdemo\.com/;
                    if(sliRegExArray = sliRegex.exec(document.domain))
                    {
                    	sliRegex = /^http:\/\/(.*)\//;
                    	sliTargetDomain = sliRegex.exec(__SLI_customisations[__SLI_ApplicationName ][ 'TargetURL' ]);
                    	__SLI_customisations[__SLI_ApplicationName ][ 'TargetURL' ] = __SLI_customisations[__SLI_ApplicationName ][ 'TargetURL' ].replace(sliTargetDomain[1], document.domain);
                    }
                    
                	document.location.href = __SLI_customisations[__SLI_ApplicationName ][ 'TargetURL' ] + __AutoComplete[id]['element'].value + asugvar;
                }
                else
                {
                	f.submit();
                }
                
                AutoComplete_HideAll();
            }
            else
                result = false;
        }
        return result;
    }
    
    // get the style that will be applied by the browser, including stylesheets
    function sli_getStyle(el,styleProp)
    {
      if (el.currentStyle)
        var y = el.currentStyle[styleProp];
      else if (window.getComputedStyle)
        var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
      return y;
    }

    // register with onLoad(er...
    _sli_init.push( AutoComplete_init );
    
    function sli_addEvent(obj, evType, fn) {
    	if (obj.addEventListener) {
    		obj.addEventListener(evType, fn, false);
    		return true;
    	} else if (obj.attachEvent) {
    		var r = obj.attachEvent("on" + evType, fn);
    		return r;
    	} else {
    		return false;
    	}
    }
    
    function sli_load()
    {
    	sli_addEvent(window, 'load', sli_init);
    }
