/* Popular phrases - RESTAURANTFURNITURE - 1:37:33, Thu Feb 23, 2012 */
var asPhrases=new Array ('hercules','bar stools','cocktail tables','48 round table','marble','table base','table tops','dolly','high top tables','booths','folding tables','chiavari chairs','hercules wood chair','used chairs','vinyl stack chair','reception chairs','swivel bar stools','fdc04allgold2804gg','go-901-bk-gg','church chairs','coffee','aluminum chairs','hf-mc-309as-bk-gg','metal ladder back chairs','bolt down stools','loveseat','end tables','ladder back stools','outdoor chairs','bar height tables','hercules calcutta','cushion','outdoor table bases','bfdh-8241mbk','parsons chair','resin folding chair','60 round table','48 round','72 round','casters','fdbhf1allgoldbngg','tables','sofa','logo tables','bar table sets','lorane','arm chairs','metal bar stools','mahogany','oak chair','34 bar stools','zb-imag-sofa-gg','outdoor tables','backless barstools','caster chair','bucket','lounge','bucket seat bar stools','classic swivel bar stools','stainless steel table base','captain chair','1774-acf','stools','xudgw0030amrmahgg','l1270t5-fs-ro','product search','6144b-hnd','2800-acf','fdbhf1silverveinbygg','2800 chair','mrg09-fs-os','bierdermeier chairs','hercules stack chair','chairs with casters','labella','ottoman','mts','black ladder back metal','w21fls','fdbhf2gg','solid wood tables','xut3030gg','ng-c01-brown-gv-gg','barrel chairs','lf-w-518-dkbrn-lea-2-gg','xut0522gg','500 lb capacity','booster','folding chairs','xudgw0015barlatmahblkvgg','8279-hnd','bierdermeier','xudgw0014bierchygg','xudgw0008barvrtmahblkvgg','teak tables','xu3colxbasgg','xu-tr18-gg','bt-353-by-gg','solo24squarelaminateatc','square to round table','xudgw0005ladchyblkvgg','700-30-mts','fdbhf1gg','xudg6r8bschbarblkvgg','wood chairs','xut2222bargg','fdc01silverveins076gg','404acf','httvs-3030-sfw','xudg6r7bwinbarburvgg','rbrfwinbfms','xudg6q4bschburvgg','6060r-vco','101abc-bl-bfms','folding wood chairs','bt-350-brn-lea-008-gg','xudg6r9bladbarblkvgg','milano chair','rattan','lf-w-518-bk-lea-gg','22-sat','xudg6r7bwinbarblkvgg','xuwnt2430gg','xutr24bargg','xudgw0014barbiermahgg','6200-hnd','lel3bkgg','xudgw0015latchyblkvgg','table dolly','9657-acf','4544-acf','unfinished','xudg697bladbarblkvgg','bal-607tk-fls','as-36-sat','xudgw0005ladwalgg','bar stools backless','xu-8700-chr-b-30-gg','bases','xu-dg-6q2b-vrt-chyw-gg','trash receptacle','fd-c01-goldvein-3169-gg','xudgw0006barmahgg','xu-dgw0014bier-mah-gg','xudg6q2bvrtburvgg','trevor','school house','ruteo1bkgg','aluminum tables','fddg694bladnatburvgg','xu-dgw0015lat-chy-burv-gg','xudg6q3bwinchywgg','laminate tables','lel3whitegg','booster seats','wood table tops','xu-dgw0005lad-wal-blkv-gg','upholstered chairs with casters','xudg6q6b1ladblkvgg','lf-w-518-white-lea-3-gg','dadycz244gg','lattice','xu-dgw0008barvrt-wal-gg','xumbt2430gg','xu-dgw0005lad-chy-burv-gg','xudgw0006mahgg','xudgw0008vrtmahblkvgg','xurd24mbtgg','hercule window bar stools','409-vam606mfo','cherry','mahogany bar stool','rut-188-bk-chr-gg','rut-f01a-bk-gg','rut-nc258-white-gg','htls2424vinylsfw','2650','xumbt2442gg','xudgw0015barlatchygg','ad-36-sat','go-s-01-bk-qtr-gg','xudg6r9bladbarchywgg','hf-mc309av','xutr18gg','go901bngg','xu-dgw0015barlat-chy-blkv-gg','plastic folding table','xut2230bargg','xurd36mbtgg','rut-188-by-gg','xurdmbtgg','kitb500bfms','metal wood chairs','ki100bbl-bfms','xumbt3636gg','xu-dgw0008vrt-chy-gg','xumc168dollygg','hercules lattice','l7c1-purdueuniv-fs-hob','xudgw0005ladwalburvgg','logo table top','wd383-fs-os','xumbt3030gg','stainless steel table top','442-58x2x3-wea','ki024r-bfms','xudgw0014barbierchygg','walnut chair','xudg6q3bwinmahwgg','xudg6f2bcirnatwgg','xudg6q6b1ladchywgg','ytwrft60tblgg','xumbt3045gg','teak','xumbt3060gg','al-03-0-fls','xurd30wntgg','xu-dgw0008barvrt-chy-gg','42 table','metal folding chairs','htbvs-3030-sfw','lf-w23-blue-gg','receptacles','barstools','xu6fobxbkblkvgg','30x72 table top','34','xudgw0005ladnatgg','hfc01t104burggg','xumbt3048gg','rut-188-bk-gg','rutnc258bkgg','xu-8700-blk-b-30-gg','parma','xu-wnt-3048-gg','fdbanchdollygg','1774','36x70fls','chair cushions','rental chairs','xf-2903-nat-wood-gg','xudg694bladmahwgg','xudg6q3bwinblkvgg','xumbt3042gg','9476bl-fs-saf','granite tables','ng108svbkvylgg','xudg697bladbarchywgg','xumbt2424gg','tktpsquareal1804fls','ngdy60gg','burlington','conference tables','square to round','white leather sofas','2151bw-sb-bfms','fdc04allgold2811gg','parsons','ts-32-fls','coffe chair','xu-mbt-3048','fdbhf2byvylgg','bt905gg','801v','xu-dgw0007win-mah-blkv-gg','wc102blblw-bfms','ladder back bar stools','butcher block','2151bblv-sb-bfms','al5625fls','ha-mc309af-bge-gg','bt-353-bk-lea-gg','x back','fdc04silverveins076gg','xudg6r9bladbarburvgg','bistro table','bt-1404-bkgy-gg','ac furniture','bt-350-bk-lea-023-gg','lf-w95-lea-bk-gg','tops','xu-dgw0015barlat-mah-burv-gg','fd-c01-goldvein-208-gg','double sided booth','hmft-36r-bfms','al308tkblackfls','bar chair table','bal601tkfls','xu-dgw0007win-mah-burv-gg','wood tables','ue-ls-907-2-nobel-bk-gg','p830-sat','bfms','swivel','xu-dgw0005barlad-wal-blkv-gg','uels9071nobelbkgg','xudg697bladbarburvgg','linens','akrin','le-l-4-white-gg','801l','bal-5624-fls','xu-mbt-sqr-gg','le-l-7d-mah-resin-gg','sl8871-fs-os','al01fls','xu-dg6r7bwin-bar-mahw-gg','xudgw0005ladchygg','teak inlay','xudg6g7bslatnatwgg','you-303-gg','36 table','hfmc700whitegg','al-308tk-fls','dad-ycz-183b-gw-gg','bar height bases','hanging chair dolly','shelves','xudgw0005ladnatblkvgg','xudg6q2bvrtblkvgg','lel1blackgg','xudgw0005ladnatburvgg','tsc-32x48-fls','bz100brngg','go-930-bk-gg','xu-t2222','round table top','cp-b176a01-green-gg','760r-hnd','xu-6f8bxbk-bar-mahw-gg','rbrf-blv-bfms','xu-dg6q3bwin-burv-gg','xu6fobxbkburvgg','xut3333bargg','b-z105-brn-gg','xudgw0005barladmahgg','ki0025-bfms','ki401ch-al-bfms','go-5301b-bk-lea-gg','dadycz152zgg','xu-dg-6h3b-slat-bar-blkv-gg','zbimagchairgg','760s-hnd','rico','xudgw0008vrtchyblkvgg','xu-dgw0008vrt-chy-burv-gg','xu-dgw0007barwin-mah-burv-gg','rut-nf02-bk-gg','xu-dgw0005barlad-chy-gg','xu-dgw0015barlat-mah-gg','legacy tables','8 table','xu4colxbasgg','walnut','xudgw0008vrtmahgg','dad-ycz-71-gw-gg','7030fr-rm-mts','fdc01allgold3169gg','xudgw0005ladmahgg','american table seat','sl2271-ec6-fs-os','xudg6q6b1ladburvgg','al-03-fls','xudgw0005barladnatblkvgg','cp-d119a01-bk-gg','laminate table top','xu-dgw0008vrt-wal-blkv-gg','36','30','mid-back black leather manager\'s chair','bt60qos','xu-dgw0008barvrt-mah-gg','ng-fc-dolly-gg','conference chairs','bt-509','xu-dg6r8bsch','rut-208-2k-bk-cas-gg','xudg6g7bslatblkvgg','stainless steel table','nb-3-mfo','double booth','l7c4-usmarinecorps-fs-hob','as-36t-sat','xudgw0005barladnatgg','bt350ivory050gg','24 x 48','al-308tk-black-fls','ladder back beech wood chairs','xu6f8bxbkbarblkvgg','mrg12-fs-os','teardrop','7013-mes','7030fr-rd-mts','window back chairs','xudg6f2bcirburvgg','school house bar stool','xudgw0030amrmahburvgg','fountain stools','qd-5058m-white-gg','8635b-w-hnd','cp-a118b-mtlk-gg','rt-2448-s-wtl-24-spt','xu-3col18rbas-gg','30 x 48','university of tennessee','6151-hnd','xut0522bargg','xu6f8bxbkbarburvgg','bt-660-1-gy-gg','cafe table','60 tables','pb-4cedpet-jay','ytyja07bkgg','tr-32-fls','plastic chairs','h-9637l-2-mid-gg','sq-30-s-xl-spt','fd-c01-goldvein-s0810-gg','university of north carolina steel stool with flat ring logo seat and l8c2c base','xu-dgw0007win-chy-gg','sq-30-s c442-18plp-fr-spt','xudgw0005barladwalgg','go-st-6-nvy-gg','57-sat','yt-yja03-mah-gg','xudgw0005barladchyblkvgg','loretto','l7c4-univoftenn-fs-hob','xudg6r6bvrtbarblkvgg','ssp-s-4636-pb-ccb','6157-hnd','htlr2430vinylsfw','sc32-fls','beechwood','6144-hnd','xuwnt3048gg','143 american','chaise','fd-dg-694blad-nat-blkv-gg','xudgw0015latchygg','8630mblackhnd','xu-dgw0008vrt-nat-gg','xudg6r9bladbarmahwgg','al30-sat','524-sat','fdstkdollygg','chair mat','as-36','fd-bhf-2-bn-gg','2161bblv-sb-bfms','aluminum bench','bamboo','ki607tk-bfms','xudg6r7bwinbarchywgg','xuwnt3045gg','xu-dgw0005barlad-chy-burv-gg','rental tables','xudg6r8bschbarmahwgg','york','restroom sign','high tops','rutiwhitegg','88n-sat','bt-516-1-vinyl-gg','fls','xu-6fobxbk','6301-hnd','1917-acf','delran','ue-ls-907-3-nobel-bk-gg','300-xl-vam-603-ofm','fd-bhf-1-allgold-0847-by-gg','xuwnt3030gg','xudgw0015barlatchyburvgg','al-5625-fls','go-930f-bk-arms-gg','regal','xudg6q6b1ladmahwgg','xudgw0030amrmahblkvgg','55-sat','glass tables','sofa sets','xudgw0005ladmahburvgg','ttrd30-reg','metal swivel stool','xu-8700-blk-b-vyl-30-gg','zb-seany-8073-ls-bk-gg','xu-dgw0008vrt-mah-burv-gg','patio','xu-dg6q4bsch-blkv-gg','ruteo1bygg','htbbd-24-sfw','rt03fls','s305ev-mft','sat','xudg6f2bcirblkvgg','xuwnt2442gg','rutgk01bkgg','wl735sygbkleagg','xf2902bkwoodgg','ue-ls-905-1-dolly-bk-gg','window back bar stool','lf-w-118a-bk-gg','ice cream chair','xu-dg-6r6b-vrt-bar-chyw-gg','seating','ruteo101padgg','xut3030bargg','zbpatricianbrowngg','l7c4-univofwash-fs-hob','waterhog','xudgw0007barwinchyblkvgg','white resin','mes','wic-07b-fls','xuwnt3060gg','paris side chair','ht-wr-2430-sfw','xu-dgw0005barlad-mah-burv-gg','xudgw0007barwinmahblkvgg','marietta','xu-6f8bxbk-bar-blkv-gg','slotted back','xu-dg-6r6b-vrt-bar-burv-gg','ki0063-al-bfms','zb-roman-brown-gg','ki303tk-bfms','higs4642ubpccb','193mts','xu-dg697blad-bar-mahw-gg','850-sat','single booth','ue-ls-905-2-dolly-bk-gg','le-l-7e-bk-resin-gg','ue-ls-905-3-dolly-bk-gg','8676-hnd','2163bw-sb-bfms','951-mts','2151cv-sb-bfms','7016-hnd','wb102mhblv-bfms','yld09-fs-os','xudg6g7bslatburvgg','zb-calcutta-801-chair-bk-gg','marietta stool','6147-hnd','xu-wnt-2430','9900','x back metal chairs','metal chairs','solid wood chair','xudgw0008vrtwalburvgg','xudgw0007winchyblkvgg','75-sat','xudgw0008barvrtwalburvgg','xu-dg-6h3b-slat-bar-natw-gg','lf-w-518-cream','zb-kelsey-845-1-chair-bk-gg','university of washington','mayline tables','xu-dg-6f2b-cir-gg','7024-hnd','zb-roman-black-gg','white table','ng-dolly-309-50-gg','9729-fs-saf','ropes','500','2163bblw-sb-bfms','white wood folding','maple','wb7218mhblv-bfms','7024-141','870-sat','9474bl-fs-saf','xudgw0015latmahburvgg','you-101-bk-gg','2652-acf','ki0021-bfms','tabply36rd-as','xudg6r8bschbarburvgg','1930-acf','2130bv-sb-bfms','zb-seany-8073-sofa-bk-gg','zb-trinity-8094-chair-bk-gg','2652','zb-lacey-831-2-sofa-bk-gg','sq-30-s c4-18plp-spt','280-andc','22 x 22 base','8635-dm-hnd','xu-dgw0008vrt-nat-blkv-gg','87sat','1930 side chair','87 style metal dining chair','503-acf','rt01fls','430ef-mft','university of michigan','wc101wablv-bfms','rut-208-2k-bk-a-gg','le-l-7a-wht-resin-gg','wa-01b-fls','ov36ev','wood chairs with arms','2130cv-sb-bfms','xu-6fobxbk-chyw-gg','outdoor bar stools boca grande collection barstool wa-01b-fls','ki290bs-gb-bfms','ngc01coffeegvgg','qr48ev','518ev','hr30ev','xudgw0008vrtnatburvgg','xu-dgw0007win-chy-burv-gg','metal bar stool with swivel bucket seat fd-f-125-gg','30 x 45','texas tech','pc02-os','9477bl-fs-saf','napled','route 66','truck','5131','parma aluminum chair','metal school house chair','8241-w-w-hnd','met806-fs-os','xu-dg-6f6b-cir-bar-blkv-gg','tiki bar','4 white gg','57-bs-sat','tec-mft','rd-30-s w18rb-spt','55-bs-sat','portable post','nct4496-pd','506-acf','7024-rm-mts','ng-dy3072-gg','bt-9996-bk-gg','1911','you-101-wh-gg','xudgw0008barvrtchyblkvgg','utility table','rush seat','305-p17-mfo','brt-05-fls','xurd24wntgg','25-1802-fs-hob','bal03fls','xudgw0008vrt','2090cw-sb-bfms','xu-rd-24-wnt-gg','2151bv-sb-bfms','lelcwhitegg','lime green','xu-dg-6f6b-cir-bar-natw-gg','black metal chairs','bt-660-1-bk-gg','nautical','black banquet chair','xu-dgw0008barvrt-nat-burv-gg','922mts','black wood bar stool','56sat','lt-213-texasa-muniv-fs-hob','2160cw-sb-bfms','valentu','wl-a277-gy-a-gg','trash','r60ef-qs-mft','8635-wc-hnd','2652 lounge chair','xu-dgw0005barlad-nat-burv-gg','backless swivel barstool','palm beach','bt-873-bn-gg','xf-9630-wd-tbl-gg','met806','wc7218mhv-bfms','wc102blw-bfms','6185b-hnd','yt-yja01-gold-gg','159-30-mts','r60ef-mft','xudg6r8bschbarchywgg','2151cw-sb-bfms','630eqsmft','tabres72as','2150cv-bfms','8241-w-black-hnd','830ef-mft','l8c3c-miamiuniv-fs-hob','5 round tables','wenge','tabply3072-as','8242b-m-black-hnd','rt-bhf2-allgold-sh25-gg','6185b','xu-dg6q4bsch','ki24rtk-bfms','9975mhbk-fs-reg','449-andc','7030fr','york-pub-table-fs-hob','2160cv-sb-bfms','t base','6155hnd','wer-2226-sp','long ep series rectangular plywood core folding table','24 bar table','lt-211-univofmich','bt5151nvygg','cupv-black-csp','wnt-3048-gg','8242b-w-w-hnd','t2222','quick ship armless traditional slatted back dining chair','rbt236-fs-pd','nch-38','zoe','676-mts','1993','410','830e-mft','black parsons chair','rut188bngg','marble bases');
/* $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);
    }
