/* Popular phrases - WWSPORT - 20:26:55, Wed Feb 8, 2012 */
__SLI_ClientDefaults =
[
    ['TargetURL', 'http://wrestling-volleyball-gear-apparel.wwsport.com/search#?w=']

];
var asPhrases=new Array ('mat tape','youth singlets','asics','youth wrestling shoes','gable','socks','singlets','tape','headgear','ohio state singlet','wrestling socks','bags','under armour','volleyball shirts','adidas','returns','ankle braces','shamrock','rulon','headband','backpack','fight shorts','mouthguard','sock guy','iowa hawkeyes','wrestling shoes','defense soap','volleyball spandex','wrestling mat','womens singlet','cabrillo','knee pads','sports bras','wrestling tshirts','mats','chin cup','hk67c','the gable wrestling shoes','germany wrestling','gable classic','shorts','omniflex','long sleeve wrestling','dan gable','penn state singlet','pink sock','iowa','wrestling dvd','custom fight shorts','chin strap','penn state','volleyball socks','pink wrestling shoes','crew socks','kids wrestling shoes','aggressor wrestling shoes','knee brace','knee high socks','jackets','asics wrestling shoes','purple wrestling shoes','rulon wrestling shoes','compression shorts','dan gable wrestling shoes','wrestling tights','sweatshirt','wrestling shorts','posters','circuit 7','face guard','wrestling jackets','shamrock wrestling singlet','sweatpants','adidas socks','shoelaces','split second 9','asics aggressor wrestling shoes','mizuno','spandex shorts','fleece','kneepads','asics socks','cleatskins','volleyball shoes','nimbus 12','asics media','womens shorts','dan gable ultimate','elbow pad','shoulder brace','tights','asics bag','briefs','cliff keen headgear','tattoo','volleyball keychain','adidas wrestling','whistles','fdny','polo','headgear strap','new balance','iowa singlet','lanyard','dan gable classic','cornell','hair slicker','sock guy technical sock','asics wrestling bag','track spikes','wrestling videos','ohio state','hoodie','active ankles','wall brackets','michigan wrestling','duffel','e58w','eagle','low cut singlets','cornell wrestling','soap','tachikara sv5w gold','tie dye','shipping','hamburger sock','navy','youth','cheer shorts','scorebook','wrestling headgear','cliff keen','asics aggressor','gable shoes','ohio state wrestling','volleyball lip balm','iowa shorts','two tone headgear','chin cup and strap','zebra mats','brute singlet','asics knee pads','zebra print','new york','mizuno vs-1 volleyball kneepads','defense','head gear','athletic tape','jump ropes','oklahoma state sweatpants','mizuno socks','4163','my house shorts','csm','mizuno volleyball socks','l7943j','mens volleyball shoes','shamrock wrestling','germany','a4','wrestling shoe skins','monkey socks','0125','womens wrestling singlet','compression tee','custom wrestling singlets','minnesota wrestling','scoreboard','extero ii','singlet builder','colored tape','penn state wrestling','wrestling','j200y','brackets','mini volleyball','volleyball t-shirts','j901y','beast','star socks','tornado headgear','under armour kneepads','volleyball zebra pants','youth socks','clock','under armour pants','dan gable ultimate 2','ussr','pink','arizona state','nimbus','prewrap','0138','asics matflex 3 gs','youth wrestling singlets','marines','weiner socks','mouthpiece','iowa state','adidas scorch','nose plug','college wrestling sweatshirts','zebra','hip pads','beast t-shirt','gear bag','mwrap','kaepa','asics rulon wrestling shoes','wineglass','gi','timers','asics pants','skort','wrestling shirts','minnesota','gum','floor tape','cosmic','spandex','aggressor','fries sock','kids volleyball shoes','relentless','nw3201','nose','takedown and falls','cliff keen fight shorts','sneakerballs','red spandex','onitsuka','holloway','badger sport pant','marine wrestling','twister wrestling headgear','wrestling mom','ohio','shirts','nfinity shorts','ironworks','omniflex pursuit','balega','black spandex','asics the gable wrestling shoes','sv5wsc','sg29','navy singlet','j900y','mouth guard','singlet gold and black','mouth','heatgear','teal','red knee pads','0129b','wrestling bags','black volleyball shoes','lacrosse','under armour socks','zk1104','quench gum','camouflage','gymnastics','response','long sleeve shirts','hair','missouri fight shorts','wwmt4','purple headgear','mat mop','oklahoma state','asics omniflex-pursuit wrestling shoe','disinfectant','nw3002','ja186','headgear decals','youth volleyball shorts','baden','mva200','track order','nvbcs','nvbbp1','pre wrap','jy800','folding mat','asics volleyball bag','adidas pants','wrestling ankle bands','china singlet','badger shirts','wraptor 2.0','volleyball hat','black wrestling singlet','captivate','wrestling flip score','wrestling straps','cliff keen scorebook','vls300','split second','wrestling singlet','4 mat tape','mueller','cookie','youth volleyball','0126','gel domain 2','oklahoma state wrestling','iowa scarecrow singlet','arm sleeve','asics shoes','volleyball shorts','reversible singlet','tsr','cliff keen air brace','cliff keen singlet','edinboro','canada','black crew socks','ankle','under armour hoodie','adidas singlet','ja149','skunkies deodorizers','custom singlets','defense shower gel','stickers','split','got balls','stopwatch','ignite slide','cliff keen kneepads','mizuno knee pads','0088','youth head gear','reaction ball','clinch gear shorts','fit2win','stanford wrestling','tattoo wrestling shoes','dsgel','gemgear lightning volleyball spandex shorts','iowa scarecrow red','ja902','mens mizuno volleyball shoes','under armour ignite slide','track','volleyball scorebooks','colorado','mizuno wave','long cut singlets','unrestrained','youth reversible singlet','half zip','u.s.a mma shorts','molten super touch','dmayp','yellow singlets','camo wrestling shoes','sgcok','asics stride short','tennis shoes','wrestling trophies','wss02b','princess','ankle guards','men\'s long sleeve volleyball jersey','cliff keen loose gear','vaporspeed','ireland wrestling','c129n','volleyball net','finger supports','adizero london','zk1103','youth headgear','neon','pink ribbon','zr1125','pins','mizuno wave lightning 7 women\'s','f3','adidas pretereo 2 wrestling shoes','catalog','youth volleyball knee pads','ohio state wrestling hoodie','ben askren','usa','w9050','0208','womens volleyball shoes','l2143','purple socks','crew','warm up suit','pillowcase','asics dan gable','granby system','nypd','youth wrestling','head bands','train4vb','yt1100','animal print','zr1126','sizes of socks','adidas london','response ii','ms0975','create your own singlet','brute chin strap','asics sleeve','vikings','wrestling apparel','tension','mizuno wave lightning 7','under','wrp1','usa singlet','wrestling t-shirts','beaver','zr900','forever fierce','0272','elbow','sleeve warmers','cejudo','clinch gear','sand socks','youth knee pads','zebra socks','bring it shirt','usa wrestling','varsity jacket','bt752','yb1000','cael shoes','air force','combat speed','lip balm','pink camo','volleyball kneepads','ultratek','asics gel nimbus 12 womens','lyteflex','alleson','brute wrestling shoes','tepin','usa wrestling shorts','zk1108','wwmt3','2 piece singlets','polo shirts','4120','banp','vball zebra pants','cliff keen twister','mat cleaner','pink shirts','hip pad spandex','adidas adizero','p907y','adizero','w9032','f5','adidas adissage','adzr1','extero','jerzees','crew neck wrestling sweatshirt','max128g','ja905','mesh shorts','zd7000','dan gable shoes','asics super sleeve','two piece singlets','green volleyball socks','neon wrestling shoes','head gear straps','asics gt','brute maverick wrestling singlet','youth volleyball jerseys','volleyball crew','matflex 3','clinch','score','v58x','john smith','w9045','bt936','iowa wrestling','volleyball','sleeve','mesh bag','cgws1','tshirts','b102n','asics shorts','youth sweatpants','3107','kids size wrestling shoes','jt1153','twister','mtapec1','sneakers','padded volleyball shorts','extra long','french fry socks','snap down socks','tx5','lehigh','dsbar','mat transporter','crewneck','shoe laces','nfinity knee pads','black and white headgear','cliff keen relentless','skirt','designed singlets','twin city','gettin better','scorch jacket','nfinity','gable ultimate 2','bringit2','wskins','volleyball cart','boardshorts','jamaica','nebraska','wrestlers mom','cold gear','michigan','shoe skin','c920y','wrestling chin cup','mop','singlets iowa hawkeyes','oregon','compression socks','licwr1','slides','mat wizard 3','brute exo kneepads','video','wrestling rule book','asics cael','american','halo','9682','active ankle chameleon','brute','sore sport','fries','bringit3','asics cleats','goggles','neon volleyball','passing bands','purdue wrestling','cgwt4','e58','zr820','asics spandex shorts','ja211','wide wrestling shoe','zd701','youth volleyball socks','tornado','brute wrestling bag','socks black','fit2win youth short','shin','duffle bags','lcac43j','adam frey','volleyball headbands','knee socks','irish singlets','arm warmers','b953n','nebraska wrestling','mat wizard iv','0274','badger jersey','wave tornado 7','itlfsger','molten pro touch','montana','compression','zmmapro','0194','air brace','russ rose','defense soap shower gel','referee','brute youth predator','j001y','7736','signature','body wipes','old school socks','wrestling face guard','iowa wrestling t shirt','throw mat','dye','cliff keen headgear straps','adidas adissage slide','molten soft touch','white singlet','cliff keen tornado headgear','sport cookies','volleyball knee pads','pink wrestling','youth volleyball shoes','custom shorts','motivational tees','score clocks','jerzees youth','svforza','svfa01','water bottle','mizuno wave tornado 7','orange socks','mouthguard for braces','asics split second wide wrestling shoes','green','asics team crew socks','asics split second 8','tf925','t1h3n','bt632','hoosiers','3749','faith','wrestling chin strap','sv5w','holloway momentum','orange','men warm up','blue socks','custom t-shirts','9341','brute high cut lycra','volley lite','asics volleycross','setters volleyball','3843a','asics womens volleyball shoes','nvbs2','b055n','adidas combat speed','scorch pant','vb447','ja221','iowa hawkeyes wrestling','gem29','wrestling poster','asics warm up','clinch gear tshirt','dan gable limited edition','weiner','cael sanderson','lycra','iwrestle2','mens warm up suits','judo','maroon and white','adidas women\'s adissage slides','youth soccer cleats','recharge','youth shorts','cheerleading','old-school wrestling shoes','alleson long sleeve','wrestling timers','athletic body care','orange wrestling shoes','adidas spandex','v7022','sgpir','wipes','brute tights','mizuno backpack','under armour womens','sublimated','0229b','iowa state singlet','hsl96','tiger','tyrint v','wrestling motivation tees','9916r','adidas sandals','devil','0191','i am a wrestler','zk1106','pretereo','0107nyr','w9047','compression shirts men','t095n','dots','youth soccer shoes','0128','warm up sets','warm ups','female singlets','cliff','cliff keen lycra briefs','virginia tech wrestling','iv58l3','7679','asics spandex','iowa compression shorts','back packs','attack','throwback','adtfs3','kids running shoes','rally','attackers jersey','adidas hooded sweatshirt','vbp4','4164','scale','bt873','f44blpk','zd0920','zd902','w9039','0375','zr307','orange volleyball socks','adidas compression','tall pant','adissage','zd360','itlfsusa','brute nylon mesh bag','oklahoma','florida gators','ssk88','kayano','wrist band','nypd shorts','mat straps','wrestling scales','gt-2150','youth wrestling t shirts','mat flex','wrist support','zd0508','cliff keen short','sg25','setters ball','stars','h3501','victory iowa','2324','reversal','mizuno daypack','wrestling pants','table tennis','ml7','under armour compression','under armour bag','f16adotn','custom headgear','spider socks','womens compression shirt','0211','asics team backpack','brute knee pad','zr895','iowa youth','metallic spandex','tsy','cael v.5','wrestling helmet','clinch gear singlet','vb376','green volleyball shoes','ireland','penn state sweatpants','krblvb','bowling','tapout','asics volleyball shorts','zd600','asics matflex','gem26','asics cael v4.0 wrestling shoes','hibiclens','black wrestling shoes','wrestling brackets','zk1105','loh43j','gem34','vte3','funky','dsgtk','foam','otcy10','youth warm up','sublimated singlets','sequin','bt1106','green wrestling shoes','zd0152','asics cabrillo jacket','youth tornado','5 spandex short','under armour long sleeve','gym mats','british','active ankle volt','quench','ja198','ankle bands','henry cejudo','f19ha','pvhn','mizuno organizer daypack','gel knee pads','nvbk1','measuring net height','ice pack','rope ratchet','underwear','pktr','itltsusa','mlss1ia','ja171','asics the gable exclusive limited edition','cael','red lion','mlss1ar','ja137','ja206','under armour shorts','wide','army wrestling','m-wrap','wave lightning 7','ktapec','mlss1mo','vb426','necklace','volleyball sleeves','shoe deodorizers','grab bag','buckeye','mizuno volleyball shoes','0109','2150','tr161','mva300attr','wrestling warm up jacket','block it','brute wrestling ankle bands','clear mat tape','blue yellow wrestling shoes','asics the gable','gu','pocket pump','adidas jacket','sandals','gemsb','f2whb','pink spandex','youth wrestling headgear','0117','warmups','knee sleeve','warm up jacket','pink volleyball','blue headgear','zebra spandex','youth volleyball shirts','under armour briefs','armed forces singlet','needles','sbhf','smlls2usa','vb383','mizuno volleyball','ussr wrestling','3955','vb359','pink shoes','wrestling kneepads','f19pt','vbsock','vicia01','asics jackets','asics omniflex pursuit','adidas pretereo','vb370','wrestling youth warmups','dan gable old school','asics youth volleyball knee pads','defensive sleeve','9385','adidas adistar beijing black wrestling shoes','asics wide wrestling shoes','cliff keen wrestling headgear','wilson volleyball','cgwt3','army','asics crew sock','cael v4.0','body wash','zd712','aggression','iv58ln','maroon singlets','b150n','sg30','rk29','pursuit','mizuno lightning','0241b','mrc02','bring it','asics rocket','j000y','6161','hooded sweatshirts','briefcase','asics turf','75wp','maryland wrestling','kilt','wrestling license plate frame','white spandex','asics liquid metal spandex short','j america sweatpants','medical kit','zr450','hooded','adidas techfit','shamrock socks','cliff keen two-tone signature wrestling headgear','oklahoma state singlet','shammhs01','youth wrestling shirts','ja220','wrist brace','snap down','rocket 5','rk30','conquest','0260','sanitizer','itlfsire','kcdvd4','wsst2','war','license plate frame','tachikara sv-5wsc','skin care','yellow socks','dig','flame socks','pink volleyball knee pads','j600a','sg18','asics men\'s gel volley lyte volleyball shoe','w9048','mizuno bag','j america','0107ire','sleeveless jersey','bucknell','collegiate','dvd','red lion knee sock','mizuno women\'s wave tornado 7 volleyball shoes','ball bags','mhms','bt1017','mens underwear','t045n','corning','bottle','captivate mens polo','fas4','beast tee','camo socks','balls','under armour fleece','split second 8','ab99','minihoop','iaspl8','soft v','flip score');
/* $Revision: 6883 $
 *
 */

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';
          if ( theSearchbox.clientWidth < __SLI_customisations[ __SLI_ApplicationName ][ 'DropListMinWidth' ] )
          {
            theDropDown.style.width = __SLI_customisations[ __SLI_ApplicationName ][ 'DropListMinWidth' ];
          }
          else
          {
            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=' + escape(__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' ] + escape(__AutoComplete[id]['element'].value) + asugvar;
          }
          else
          {
            if(f.onsubmit)
            {
              if(f.onsubmit() !== false)
              {
                f.submit();
              }
            }
            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);
    }
