/* Popular phrases - PEGASUSASSOCIATES - 10:34:42, Sun Mar 21, 2010 */
__SLI_ClientDefaults =
[
    ['ShowBrandingFooter', false ]
];
var asPhrases=new Array ('led lights','xenon under cabinet light','track lighting','battery operated lights','puck lights','xenon bulbs','t5 fluorescent light fixture','ic rated recessed lights','led','under cabinet lights','step light','rope light','t4','hard wired cabinet lights','night light','mr16 recessed lights','transformers','shower lights','cove lighting','psl-123eb','recessed shower light','low voltage under cabinet lighting','lighted mirrors','dimmers','pddu','plms','g8 xenon','under cabinet task light','mr16','psp','dimmable','dimmable fluorescent','led recessed lights','maestro dimmer','t8 light fixtures','ptisl','track','ic remodel housing','bulbs','hard wired under cabinet lighting','7 watt','xenon line voltage thin under cabinet task light','pnm-254','4 in ic remodel housing','g4 halogen','p043x','psg5','psl','display lights','t5','pmm-204','wall lights','xenon low voltage light strip','p043t','psg5a','p024','t2 fluorescent','psp-20-sw','outdoor lighting','swing down','puck','low voltage transformer','clamp','pruler','kitchen lighting','pdl-024','pndsc-x','flexible','pelxteu','pnlr-404qat-50-120','plr-led-ww','louver','task light','xenon','electronic transformer','t5 fluorescent','pdl-214','pddu-28led','g4','battery operated under cabinet lights','dimmable under cabinet lights','recessed lighting','battery','can lights','ppa','12v','par 16','pdl-150','lvt-175-12v-dc','mini pendants','pfpoc','light switch','pnt-29','f54t5830ho','mr 11 bulbs','par20','pl-856','hanging ceiling lights','hardwire undercabinet lights','battery operated','pnsr-404q-at','pnm-247','motion sensor','t8 fixtures','led step light','mirror','t8','pnl-469','plug in pendant','pf-32-t8-uv','4-inch line voltage trims wall wash with baffle','triangles','pstlp','step','door switch','plr6','shower','showcase light','ic 4 remodel','undercabinet lights','led recessed','plr-led','led under cabinet lights','shower light trim','plxcp-20-bp','pled-dl-cw-15','exn-fg','g8','mini recessed led','strip lighting','wall washers','pnl-413','xenon lamp bulb','led recessed mini swivel lights','fluorescent fixtures','las vegas','p023-0003','solux','120 volt under cabinet lighting','dimmable led','psg4a','pnl-401q-50-120','switch','led in-wall louver night light','xenon under cabinet','xenon low voltage puck lights','t5 high output','flexible display light','t4 fluorescent light fixture','pnm-245','biax fluorescent','t5 fluorescent light bulbs','pnm-247-w','stair lighting','puceo','skylark dimmer','dc transformer','pnl-3365','es59','plms-3','exhaust fan','7487','festoon','pendant light','pled','led rope light','pdl-167','led recessed can lights','uv tube guards','12 volt','mr16 halogen flexible display light','12 volt transformer','bathroom exhaust fan','t9','xenon t4','pnsi-602','sloped ceiling','mr16 lenses','pal-155','ruler','battery powered cabinet lights','recessed halogen square trim','bullet lights','microfluorescent t4 light fixtures','t4 bulb','picture light','pset-75','24 volt','phd60-120','pns-401q-at','cfl','palpx','pnm-244','hard wired cabinet lights no transformer','pml-300','psp-22-sw','xenon strip','pezxteu','bathroom exhaust fan with light','light bulbs','colored lighting','cove','t5 thin inch','pmb-530','exit signs','pf32t8uvclear','pnm-242','plug in fluorescent light','fiber optic','pnhric-504q-at','f8t5','pnt-28','mr11','pctl-8016','recessed low voltage light','pled-step10-cc','trim','clip on lights','pal-200-sc-24','psl-1301','shipping','linear spread lens','mr16 halogen fixed arm display light','pf7162','ppavl','diffused light','replacement bulbs','pfpoc-7w-120','pns-401q','pal-200','pnl-490','pnsi-661','pdl-024-bk','closet lighting','colored glass light filter','pnl-401q','led mini step light','t12','door jamb light switch','high output','palpx-2','p043x-1-br','bbq','hanging lights','mr11 lamp','pfl-2004','cabinet lighting','bbq lights','trade show lighting','mounting channel','mr11 recessed','p ruler 5','battery operated ceiling lights','recessed light housings','r-12 light bulb','t5 slimlite xl','pcxteu','10s81','pl-7010','colored led','recessed','pl-871','psp-24-sw','pnuls-28','recessed halogen','plsl-16','can recessed 30 degree','plxc','halogen track lighting fixture','t5 ho','under cabinet light with outlet','return','petp-60','square recessed light','in cabinet lighting','vanity mirror','pnl-414','pstlp-sm','psm-0300','ptri','moving lights','pezxteu-2rwem','star lights','psl-801','xenon low voltage gemstone puck lights','mini swivel','75-watt par30','pl-7020','4 led recessed lights','l.e.d lights','par halogen flexible ceiling lights','pnm-248','halogen bulbs','spot light','under cabinet lights hardwire','junction box','psp-20','light box','connector','t4 fluorescent light bulbs','display case lighting','dvlv-600p-wh','pendant light kits','led color changing step light kit','plxc-xh-wh','psp-24','romex','pv-6711-2','mini recess light','6 watt','led bullet','plug in light','pmm204','energy star','p-4200','hera fluorescent t5','pmb360','exnfg','pfl2121','compact fluorescent','pdl024','mesh wire lamp shield','ultraviolet','end cap','pgs-60s50','bathroom heat lamp','slope remodel housing','pnl-301q','mr16 bulb','rope light mounting clips','plr6c','diva dimmer','recessed sloped','277','6 power cord','371','under cabinet','g4 base','pnhric-504q','exit lights','pns-53','pnl-412','par30','led under cabinet','xenon line voltage hardwire thin under cabinet task lights','motion sensor led','recessed lighting trims','pl-1199','low voltage','pns53','pled-dl-ww','par','power strip','halogen under cabinet','pns-25','pdl 024','recessed downlight','pnsi-661w','flexible halogen','adjustable recessed','emergency light','black light bulb','blue pendant','4-inch low voltage recessed lighting trim with recessed adjustable baffle pnl-468','8-foot','pnhric','wall shower light','star ceiling','pendant light shades','fan light','pndsl','pcxteu-2rw','plr4','remodel recessed can','g6 halogen bulb','pxncc','night light with outlet','mini lights','exit','pnuls','pnsi-662','pnt','brite strip','t8 fluorescent bulbs','plant light','remote control lights','t4 lamp','reading light for bed','fluorescent task light','xenon bulbs g-8','theater lighting','led driver','t-5 fixture','rope light mounting strips','recessed uplight','lutron','passion','recessed accent light 4','outside sign','shower trim','lvt-151-12v-ac','downlight','receptacle','halogen par38','plr6x','pnm-249','pmo-048','clamp on light','xenon light strip','pnm-251','metal halide','recessed wall sconce','fluorescent tubes','g8 base','gy6.35','puck light bulbs','movie','pnl-3365-n','psg4','hera es46','pnm-143','ic','t4 light bulbs','t4 fluorescent bulbs 17.5 inch','par20 lamp','low voltage dimmer','fluorescent light bulbs','shower recessed','pl-7011','path light','low voltage strip','puce','clamp lights','pcgf','pjc-20w-xe-12-cl','psp-xx-sw-xx','in cabinet','f35t5','t5 with cord','customer comments','mr11 light','pl 856','f35t5-864','hat light','t5 bulb','can lights adjustable','eyeball','pnl-09','dimmable lighting','trade show','halogen track lighting','uv','puck light kit','diffuser','cable','pnl-425','psl-423eb','petp-60-cord','light bulbs low voltage','pnm 254','sleek plus adjustable','uv glass','installation','blue led','pnm-254-w','pdl-007-bk','halogen wedge bulb','pnl-426','puc-lv','star','pl7012','fluorescent t5 lamps','2 inch recessed lighting','12 volt rope light','6 inch can lights','microfluorescent t4','ceiling fan','psg5ho','pnl-318','pnl-327','p-ruler','led display box','terminal block','touch light','fluorescent t8','color filter','puce-33','led cabinet lights','led display lights','pnm-254-g-l','pf-7178','recessed fixtures halogen','50par20-cap-sp-120v','weatherproof lighting','mr16 socket','wall mounted task light','g-8','xenon g8 bulb','ppa-x00vl','pnlic-301q','t2','t5 light','magnetic transformer','hera','pnl-317','pnlic-401qsat-50-120','pndsc','backlighting light boxes','fluorescent','pal155','pnlic-401qsat','battery powered under cabinet lighting','dimmable cove light','wall mount reading light','pta','miniature mr11','jewelry','ctl-9020','fixed arm display lights','12volt transformer','pmo','dimmable t5 fixtures','psp-8-sw','4 recessed','led fixtures','low profile housing','pnsi','p024-ch','gimbal','star ceiling kit','pelxteu-xgcaem','pnt-5060','pl7022','palflsw-1621','psl-l8','power cord','pnm-243','t8 lighting','led machine light','6 shower trim','g9 halogen','halogen bulbe g9','pl872','p043x-3','pnm-250','psp-28-sw','psl-601','square trim','reading light','comparison of lighting','p043x-br','low voltage puck light','lenses','pxen-12-5w-cl','pl-297','led battery operated puck light','pnl-418','tube guard','p023','eyelid','pal-100','pnm-146','pmb-980','bi-pin','halogen track','pnm','low profile','dv-600p-wh','ppld-g403','pl-1240','lantern','an-600p-wh','spare pendant glass shades','surface mount damp location','low voltage puck','shower fan','basement','mr16 halogen bulb','4 inch recessed led downlight','barbecue grill light','plxc-xh-br','canopy','clamp on','colored lenses','artwork','cove lighting fixtures','t-8 fluorescent light fixture','24v transformer','pqmp-m1rn','incandescent','fan','electronic low voltage dimmer','5 inch recessed','voltage drop','plr','plxc-4h-br','pinhole trim','pf-7176-53','transformers for puck lights','uv tube','palflsw','hard wire','halogen 20 watts 12 volts','pal-305','pns-46','fluorescent under cabinet','pnhic-501q-at','pnlr-304q','pndsc-4','ps-3713','psg5a-21-s','low voltage light','614','p043x-2','f14t5','pndsa','palpx-20-wh','p043x-1-bs','magnetic base','pg-611','w a c','pg-611-x','direct connectors','large pendant lights','12 volt led light','pta-502','f32t8','pcgf-mr16-red','wall wash can light','pnl-465','ic rated recessed lights remodel','direct wire puck lights','copper','wire connector','mr11 festoon','puc','p-8500','xenon low voltage under cabinet task lights','pv-6629-33','wall lamps','12 volt xenon bulbs','thin xenon','sea gull knotts','decorative wall sconces','low voltage fixtures for insulated ceilings','pdl-024-wt','pnm247','6400k','backlighting','color change','es46','mr 11 recessed lights','pnl469','battery powered','stick on','pf-28-t5-uv-clear','festoon bulb','300 watt low voltage transformer','5 trim','low voltage decolume','psp20-sw','shield','3 mini pendant','side mount','led warm','pfl-2192','undercabinet','pns-12','jewelry case lighting','bright battery operated clamp lights','t4 light','lutron dimmer','pnl-3310','cold cathode','6500k','recessed low voltage','277 volt','infrared','pnl3365','pnl465','plr-led-ww-9','t4 tube','4 inch led','light with receptacle','flexible connector','aquarium','led very thin light bars','thin undercabinet light','plvt-01','slimlite xl','hardwire box','reading','pnuls-18','puc-lv17','box','power connector','halogen floor','ic remodel','pink','plxcp','rope','low voltage rope','spc-s-xl','mr16 halogen flexible wall lights','mini bullet light','beam spread','transformer faq','frosted glass lens','kitchen fluorescent','t8 light bulbs','light shades','pns-4','museum lighting','warm','mini downlights','touch','t5 fixture twin','043x','pnlr-404q-75-120','palpx-60','pfosc-175','lutron credenza','pdl-214-b','puc-lv-36','hutch lights','pnl 465','recessed copper light','recessed remodel','halogen display','pnl-445','inside cabinet lighting','15 watt fluorescent bulb','36 w t4','led light box','led emergency lights','3-inch recessed lighting','psg5-6','r lamp','4 inch white trim with natural baffle','3 8 twin screw','48 fluorescent light fixture','pnl-491','p023-0001','f17t8','bullet','es46 xl','6-inch line voltage recessed','pnl-495','hat','par lights','pdl-188-b','0002','plug-in track lighting','xenon lamps','blue t4 fluorescent light bulbs','pezxteu-2xwem','closet','pnhric504qat','submersible led rope lights','white rope light','submersible led lights','line voltage under cabinet','color temperature','pgs-10s51','pns-49','pl-872w','dimmer line voltage','pjc-15w-xe-12-cl','garden','battery operated step light pmb-530','dvlv-10p-wh','pal-150','pntm-53','pnm 243','pnm242','natural metal','pns-40-a','halogen clamp','pmb-542','pnl-3325','pnl-497','4 in ic housing','pmb-723','psg4-26','pnsi-662p','general electric','crystal','mol','17w t8','recessed mini led lights','plastic light box','skylark','head work light','xenon line voltage under cabinet task lights','palpx-60-wh-pxx60','maelv-600','pnsi-662w','pl-7008','psp 20','crystal pendant','pmbs','23 fluorescent ceiling light fixtures','polished brass recessed lighting','p-023-0001','plt','inch light','pnsic-401q-at','pnsi-601','pnuls 28','t8 warm white','shower exhaust fan with light','pinhole','housing','faq','pnl-401qat-50-120','creamery','ether','multi tap','t3 halogen','frost','fo25','clarity','lens clip','3 foot lighting fixtures','pl-871w','paintable wall sconce','dim','pl871','tikal','pnl-401q-75','p-043x','pdl-167-l','pnl-440','led recessed mini visor lights','indoor step lights','6 foot cord with roller switch','spc s xl','slimlite power cord','low profile under cabinet lighting','paz','pdl-188','pnt-23','led color changing','led undercabinet','custom order','3 low voltage','fluorescent vanity','17w t8 linear light bulbs','energy star led','wall wash trim','led reading light','black light fixtures','pv','pnl-3326','4 in trim chrome','psg5at','xenon triangles','puce21','aisle lighting','diva low voltage','pf-9870','halogen pendant','puck table','halogen spot','pf-7174','pnt-5021','pns-46a','pns-24','pnrs80-476','pns-50','pns-52','pnhr-504q','psg5aho','pf-32-t8-uv-clear','pnh-501q','pnl-3318','pled-dl-cw-75','t5 swivel stick','pnhr-926q','pnl-422','pnl-410','pnl-453','pnl-448','pnl-401q-50-277','pezxteu-2rw','pnl-401qat','pnl-468','pnl-421','pnl-452','pnl-416','pnl-450','pnl-422-w','pnl-3345','pnl-419','polycarbonate guard','pnl-411','pnl-423','lutron low voltage','palpx-20-bk','pml 300','ppld-g454','pathway','pset-105','t-5 28','pnrs80-477','puce 42','pns-48','pnt5001','plug','pnt-5049','pnt-5024','pg-934','lighting over tables','low profile 21 watt t5 fluorescent under cabinet','pnsr','ppcs-1','p-043x-4-4','p043x-3-bs','plug in cabinet light','pns-46-a','pnhic','pdl 188','pqp','prdsw','pnl410','pctl-8016-x','path','pset105','psbs','pset','pqp-601','ppld-mo96','gift certificate','light dimmer','psm','psl-bk','pf-7162','paz-70','pf-7164-30','pjc-5w-xe-12-c','phl-16','plr-dl-cw','pnl-3326-w','pl-7001','psbs-16','pnrs80-454','pattern','pnl465n','pnl495-bu','pl 7008','pntm-513','pxen-24-10w-cl','pnm146','led hat','palpx-60-bk-pxx60','pndsa-x','pnuls-xx','prismatic lens','pnuls 13','led mini lights','line voltage pendants','led in-wall night light','palpx-60-bk','pmb371','pns-26-w','pa-3-p','pdl-150-x','pmbs-16-x','psl1301','privacy','left angle connector','pl-7000','pbg','pa4-p','pmbs-16','ppcs','psp-12 sw 18','psp 12 sw','pf-8992','puclv36','l-7020','pv-6707','prl-trk3','pv-6604','pv-6711','lighting in museum','pg-524g','ppldg453','psp6','ppld-g405-cb','pg-523','pg-527','pqp-902-pt','pnm 143','pg-518','pg-513','pg-541','lighting tips','pg-711','plr-led-ext3','pg-811','light open','pf8992-29','pdl 701 x','product selection assistance','pns-18-b','psl-l16','pg-514','psp12sw','pl7000','l box','psp 22','lyra fluorescent','pjc-50w-xe-24cl','psp24','pled-dl-cw-18','low uv','pg-515','pg-618','plastic tubes for t8 bulbs','pndsl-7','pnh','puc lv9','pla-6','plxcxhbr','pf-7172','pfl2wr','pnl-401q-75-277','pnm244b','psp20','pg-914','pegasus recessed w shower lens','pnm-245b','psg5-ho','plxc-xp-wh');
/* $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);
    }