/* Popular phrases - PEGASUSASSOCIATES - 12:42:20, Fri Nov 20, 2009 */
__SLI_ClientDefaults =
[
    ['ShowBrandingFooter', false ]
];
var asPhrases=new Array ('led lights','xenon bulbs','ic rated recessed lights','track lighting','xenon under cabinet light','under cabinet lights','led','battery operated lights','puck lights','rope light','cove lighting','t5 fluorescent light fixture','transformers','mr16 recessed lights','4 in ic remodel housing','p043x','t4','step light','low voltage under cabinet lighting','hard wired under cabinet lighting','hard wired cabinet lights','mr16','dimmable under cabinet lights','ic 4 remodel','night light','t5','shower lights','12 volt transformer','dimmers','battery powered','recessed shower light','metal halide','t4 fluorescent light bulbs','pnm-245','xenon','stair lighting','psg4-20','t8 fixtures','puce','t4 fluorescent lamp','psp','t8','pdl-214','halogen bulbs','401qat','recessed wall lights','track','xenon light bulb','led rope light','romex connector','shower','display lights','battery operated under cabinet lights','jewelry display lighting','low voltage transformer','low profile','sloped ceiling','light bulbs','led recessed mini bullet lights','clamp on light','recessed lighting','recessed','465','pnuls','hardwire xenon under cabinet light','strip lighting','triangles','puce-24','rope lighting channel','pnsr-404q','closet lighting','pendant light','tungsten halogen lamp','plr6','palpx-60-bk-pxx60','hardwire undercabinet lights','pl-7022','bullet lights','color filter','bulbs','pf-9870','pnlic-401qsat','wall washers','undercabinet lights','g8 xenon','battery operated','can lights','picture light','battery operated led lights','exit signs','led mini swivel','f17t8','t4 bulb','pnuls-24','dimmable','colored lenses','mini recess light','countertop lighting','psg4-22','in-wall louver night light','plr-4','hera es59 slimlite xl','stairs leds light','xenon lights','pled-dl-ww-3','recessed low voltage light','pnl-422','p024','colored lens','pl-856','cree led lighting','pntm','bullet','led recessed lights','pnl-401q-50-120','pnt-5060','twinkle lights','miniature mr11 low voltage recessed lighting','plxc','plms','pruler','ic remodel housing','star','slim light','pnsi-661','t5 bulb','par30','plr4','fluorescent t5 lamps','festoon','12 volt fixtures','pmo-024','recessed low voltage','ballast','pnsic-401q-at','microfluorescent adjustable t4','pdl-167','wall sconce','recessed halogen square trim','shower trim','commercial lighting','pnuls 13','led mini lights','bathroom exhaust fan with light','t8 fluorescent light bulbs','puceo','12 volt rope light','pnl-470','pelxteu','es34','pnm-254','recessed light fixture','pnm-242','dimmable led','microfluorescent t5 grounded light fixture','sloped ceiling recessed light','work light','light box','palpx','mr16 halogen flexible wall lights','damp location','fluorescent fixtures','pnhic-501qat','palflsw','pendant','psg5a','p043t','120v step lights','pnlic-401sat-50-277','battery powered under cabinet lighting','outlet light','t5ho','fiber optic','led undercabinet lights','halogen light bulb','recessed ceiling light','par lights','t5 fluorescent light bulbs','pmm-204','uv filters','xenon under cabinet','trade show lighting','led step light','plr-led-ww','recessed regressed lighting','led fixtures','lightbox','linear fixtures','ic recessed light','pset-75','led light bar','multi tap connector','psg4-28','lighted mirrors','palpx-60-wh-pxx60','dimmable fluorescent','cool white','square recessed','plug-in under cabinet lights','dimmable task lighting','microfluorescent t4 light fixtures','halogen transformer','uv light filters','psg4a','wall mount reading light','gimbal','recessed halogen','sconce','psg5atho','fiber optic star ceiling kit','square','pta-502','hera slimlite','bbq lights','12v xenon bulbs','xenon line voltage','mr16 track','xenon low voltage under cabinet','national specialty lighting','pv-6629-33','led in-wall night light','t5 10w','wall sconce with switch','countertop','psp-16-sw','psg5','incandescent','multi-tap connectors','pddu-28','7487','deck','mr16 recessed fixture','pled-dl-cw','wall wash','return','transformer for low voltage halogen puck lights','clip-on holder','pled-dl-cw-30','pnm-249','thin','copper','exhaust','par38','linkable','led mini step light','led downlight','pnl 463','pmm204bn','4 trim recessed','stairway','50 watt reflector lamp','led bullet','plxc-1h','4 slope','ice cube pendant lamp','pnrs80-474','brushed nickel recessed lighting shower','pled-dl-ww','theatrical','rope','battery','hera es46','mirror','pmb-542','nursery','pnuls-13','power cord','4 recessed lighting','twinkle','pnl-3365','wall mount','24 volt','photometric','hardwire','colored','path light','dimmable t5','copper recessed lighting trim','inside cabinet','palpx-60-bk','pnsic-401','recessed lighting housing low','pmb371','star lights','mr11','remodel can lights','frosted lens','pmb-723','pnl3365','20 watt light bulb','cree','pled-step','pnl465','10 watt low voltage xenon','tv','lutron line voltage dimmer','hard wire','xenon low voltage','p043x-2-wh','12v dc lighting','mini bullet light','ctl-9020','cove','t4 fluorescent light fixture','led battery','pndsl-5x','pfl-2wr','fluorescent t5 swivel stick light fixtures psl','fluorescent puck','lantern','par38 halogen light bulb','recessed shower light slope','pddu-28led-wh','restaurant','remote control lights','wall reading lamp','mini pendant lights','under cabinet light with outlet','direct wire xenon','track section','photocell','pl-7021','surface mount','black light','par20','g4','reading light','xenon puck light','led in-wall louver night light','24 volt led','floor light','mini step lighting','remote controlled','garage lighting','recessed sconce','q','6 inch trim','pnhic-501q-at','plr4-1527','recessed spot light','psl','es59','recessed slope ceiling','mounting clips','wet location','pns-46','par16','psp-6','kitchen lighting','led rope','mini led','lenses','flexible connector','pl-297','decolume','glass filter','pfl-2004','pezxteu-2rwem','recessed light housings','battery operated under cabinet','motion activated','pns-26-w','p8500','pntm-53','wall lamps','toroidal','pnsi-601','3 housing','pnt-5022','pezxteu-2xwem','pal-200','pdl-150','psp-bm','fluorescent high bay fixture','bipin g8','flexible halogen','mr11 halogen arm light','p023','low profile under cabinet','recessed can lights','50 watt par20','gift certificate','channel','sale','pdl-024-bk','pnl469','bedroom','pnl-401q-50-277','pnm 254','pa-3-p','honeycomb louver','jill','mounting channel','t4 under cabinet lights','pl-7010','xenon undercabinet lighting','xenon under cabinet light bronze','led down lights','door light switch','pnm254','motion sensor','xenon bi-pin','ic','pnl-3312','led cabinet lights','pgs-10s81','cool white led rope light','plsl-16','bathroom vanity','pnhic','filter holder','track head','plr-6x','dimmer switches for low voltage transformers','es','pl-1785','motion','es46','t2','lxurbe','swivel led','xe 10','pml-300','recessed night light','pdl-007','psp-22','dimmer switch','motion sensor light','phd60-120 transformer','psp-12-sw','weatherproof fluorescent fixture','p-9005','battery cabinet','restaurant pendant','island lighting','50w mr16 24v','mini bullet led','flexible neck','wall mount halogen','skylark dimmers','ppa-700-vl','pndsa','t-8 light fixtures','pfl-2417','21 inch under cabinet light','12v ac','4 inch ic','pta','cabinet','pddu-28led','socket','color change','over cabinet lighting','colored glass light filter','flexible led','shade','t2 puck lights','pdl-168','plxc-2h-wh','t5 fixtures','psg4','pl-7011','psp-20-sw','gu10','plug in','energy star recessed lights','housing','slimlite','xenon lamps','pnlr-404-q50-120','pnl-3325','led display lights','10 watt','pal 305','plxc-1h-xx','led night light motion','pl857','slim','red mini pendant','halogen vanity lighting','pfosc-175','mr-16','lumens','bonita cube','task light','suspended ceiling','pal-150','pns-41','mr11 fixture','pstl20','pfpoc','pnm-243','recessed up light','enclosed junction box','beam spread','300 watt low voltage transformer','mr 8','p024 led','narrow spot','f14t5','pnhric-504q-at','f21t5','g8','thin inch','pnm-249-w','pr-1','5 trim','louver','cfl','halogen light fixtures','plvt-01','wedge base','led lantern','psp-24-sw','recessed housing','12v mr16','clip light','lutron diva dimmer','puce-33','low voltage faq','eyeball','led driver','xenon transformer','slimlite xl','pmb-980','spread lens','deco','greenhouse lights','pdl-150-x','t10','color temperature xenon lamps','plug-in transformer','cable fixtures','cord','pnm-247','plug in wall lighting','pl-872w','pal-100','remodel recessed can','motion lights','plr-led-ww-30','mr16 halogen flexible display light','4 low voltage','fluorescent light box','pnuls-28','par 30','interconnect','t5 fluorescent under cabinet','pns-12','xenon undercabinet','pns-40','pdl-024','task','pnm-254-c-l','pdl-167-l','psp28','halogen light','pl-856w','120v puck lights','pruler-5','6 inch led','lens mr16','replacement bulbs','plug in track lighting','flexible track','led in wall night lights','edge lit','pmbs-16-x','open trim','led under cabinet lights','led exit signs','pset-105','magnetic transformer','pf9870-53','puc-lv36','accent lighting','xenon light strip','pled-2228','vanity mirror','petp-60-cord','plms-3','pctl-9016','toroidal transformer','festoon lights','halogen reading','low voltage canopy','microfluorescent t4 grounded light fixtures','general electric','psp22','psg4a-24-s','pelxteu-1rcaem','pezxteu','pled-dl-cw-xx','pl7011','mr16 bulb','emergency','tube guard','plug in transformer','telescoping light','fixed mount halogen','multi-tap','high bay','petp-60','pnt-23','pjc-20w-xe-12-cl','bathroom fan light','dichroic filter','4 inch trim','4-inch line voltage ic housing','miniature lighting','led cove','sylvania','pns-401q','lvt-151-12v-ac','bathroom exhaust fan','magnetic dimmers','pns-23','louvered step light','halogen g8','puc-lv17','theatrical line voltage par20','plug in night lights','f8t5 830','mr11 12-volt halogen light bulbs','t5 tube guard','petp','triangle lights','shipping','pnt-5070','electronic dimmer','pns40','exterior lighting','high output fluorescent','led in-wall','microfluorescent t5','led can lights','jewelry case lighting','pjc-10w-xe-12-cl','energy star ceiling lights','xenon 120','lvt-175-12v-dc','pdl-188-bk','pnm-143','plug in display light','ruler','470','bi-pin xenon bulb','t5 light','12 volt bulbs','black under cabinet lights','t4 light fixtures','directional','24 volt ac transformer','pl-871','6 recessed can light','psg5at','step','pdl214','flush light','halogen track lighting fixture','wallplates','pctl-8020','bonita','plvt','hera slim light','pnm-254-g-l','fluorescent ceiling fixture','5 recessed','t8 fluorescent light switch','pal 150','pf-7174','recessed fixtures halogen','pnl416','hard wired xenon under cabinet lighting','indoor step lights','xenon under cabinet direct wire','fabric','bed reading light','surface mount cabinet lights','psl-801','pns-41b','pf-7178','12 volt recessed light','pnl301q','pf-7177','bronze under cabinet','shelf light','adjustable recessed','fluorescent linear ceiling mount light fixture','pdl-701','xenon festoon light bulb','5 inch recessed','pndsl-10x-f','pcgf-mr16','multi tap','selv 300-p','5 inch recessed lights','night light switch','materials list for xenon low voltage light strip','led ruler','in cabinet lighting','pl-857w','4 in remodel slope ceiling recessed','puce 42','fluorescent t5 swivel stick light fixture','pntm-53-w','8 foot fixture','recessed lighting for sloped ceilings','pezxteu-2rw','psp-28-3000k','mr16 recessed lights eyeball','psl1301','dining room lighting','halogen pendant','pnl-461','halogen clip on reading light','pl-857','compact fluorescent down light','pl-1240','pntm-513','ptri-20','pndsa-7','faq','lutron credenza','remote battery lights','backlight box','pnl-453','under cabinet','pnt-5030','comparison of lighting','dimmable low voltage transformer','plugin','hardwired undercabinet','customer service','jewelry store','slope can lighting','fixed arm display lights','l-7011','return policy','6 in remodel slope ceiling recessed','strain reliefs','pns-42','plug-in pendant lights','pnsi-661p','psp-b','green fluorescent','artwork lighting','in cabinet','pnrs80-457','3-wire commercial grade metal hardwire box','pal200','pqmp-m1rn','12v dc transformer','pnl-3310','17 watt 78 cri ge ecolux t8 fluorescent light bulbs','led spotlight','3in low voltage','green light bulbs','pnlr-404q-75-120','under cabinet triangle','lights with remote controls','privacy','pndsa-x','puclv','psp-xx-sw-xx','pnrs99','dimmable rope','zoom images','magnetic transformer 24v','254','xenon cove','pnl3310','led closet light','led retail lighting','left angle connector','pnt-5010','psbs','plxc-3h','pnm-254-b','pl-7000','pjc-20w-xe-12','psl-l20','plug in led lights','psg-pc72','pf-7171','pbg','plr-led-ww-3','led transformer','psp-16','puce 21','pinhole','par 38 halogen','pf7171','pnsr','puce21','pa4-p','puc-lv9','pnl-420','pnm-254-b-l','p','psp-24','puc-lv-36','pns-47','ppld-g404','pmbs-16','ppcs','psp-12 sw 18','ppcs-1','pqp-601','pendant cord','pnl-401qat','led night','psp 12 sw','plug-in pendant','plug in under cabinet','pf-8992','psp20-sw','puclv36','pnrs99-p45','l-7020','pv-6707','prl-trk3','pv-6604','pxncc','pv-6711','lighting in museum','ppld','pl-1199','pg-524g','psp-8','pqp-801','ppldg453','psp6','pns-49','psg5a-21-s','ppld-g405-cb','ppld-g453','pg-523','pg-527','ppld-g402','pqp-902-pt','pg-524s','pnm 143','pnl-09','pg-518','pqp-901','psp16','pg-513','pg-541','pqp-501','lighting tips','psp-8-sw','palslbox-xx','pg-611','pg-711','plr-led-ext3','pg-811','light open','pf8992-29','pnt-5021','pdl 701 x','product selection assistance','pns-18-b','lighting tips for cabinets','psl-l16','psbs-16','pipe clamp light','pg-514','pnm-254-w-l','pf-8994-30','pnl-414','pnm-254-w','psp12sw','line voltage new construction ic housing','pl7000','led kitchen lighting','led modules','l box','pegasus bathroom light','line voltage pendants','pnt-5020','light switch covers','pnt-24','pnl-413','pnl-411','pnl-412','pg-611-x','psp 22','lyra fluorescent','pjc-50w-xe-24cl','psp24','pled-dl-cw-18','low uv','pg-515','pg-530','pg-618','plastic tubes for t8 bulbs','4 cans','4 way dimmer','75par30 cap fl 120v','pnl-425','pndsl-7','pnh','puc lv9','pf-7161-30','line voltage strip lighting','pla-6','pdl-trk4','lutron nlv','paintable wall sconce','plxcxhbr','pf-7172','pelt','pfl2wr','product display lighting','led mini step lights lenses','pnl-401q-75-277','10 watts 12 volts t5 xenon','52','pnm244b','psp20','pf-8994','500 cfm','psp 20','4 inch line voltage trim','pg-914','18 vac','5-inch line voltage recessed lighting trims','pegasus recessed w shower lens','pnm-245b','psg5-ho','ppa-x00vl','plxc-xp-wh','pled-cw-15','pnl-421','par bulb','led dimmer switch','pf-7164-30','pnuls24','pnl-440','pxen-24-7w-cl','pg-615-x','pf7161','pf7163','puck lights bathroom','pnm254w','#psp-xx-sw-xx','pndsl-7x-24-f-longlife');
/* $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);
    }