/* Popular phrases - GTMSPORTSWEAR - 16:38:19, Sat Nov 21, 2009 */
var asPhrases=new Array ('challenger','victory jacket','infinity warm up','challenger warm up','poms','warm ups','embroidery designs','cheerleading uniforms','infinity','extreme','ljapt03','surge','defender','bags','legacy warm-ups','pom poms','elite','medalist','pinnacle warm-up','energy tee','victory','xtreme','jackets','ljapt04','screen print designs','ljapt06','challenger jacket','dazzle','pinnacle','bowling','ljapt07','legacy','garment bag','defender jacket','fleece jacket','icon','velocity','sweatshirt','booster jacket','eclipse warm up','briefs','eliminator','tackle twill','windshirt','medalist jacket','challenger pant','xtreme warmup','sideline tee','competitor warm up','mascots','embroidery','jersey','basketball warm ups','tall warmups','hoodie','japt08','fan jersey','intimidator','lja3701','jafj03','pulse jacket','conquest','beanie','dazzle warm-up','jafp03','japt02','sequin','ypa3701','jersey tee','velocity warm up','japt03','pulse','sizing','japt01','medalist warmup','legacy warm up','reversible practice jersey','sport performance polo','youth warm-ups','cotton tee','ypapt02','lpapt03','fpa100','shipping','japt05','basketball designs','cardinal','ladies nylon competitor jacket','trophies','hats','eclipse','spirit flex','100% polyester','pkg4','t shirts','t-shirt','backpacks','competitor','lpapt07','black red white','papt02','eliminator pant','rhinestone','sideline performance','lpa3701','rain pro','lpapt04','lja186','elite warm up','travel package','bows','pullover','sideline performance tee','performance tee','long sleeve tee','power performance polo','logos','warmups','jafv03','ljadk03','lja182','yja3700','lja200','fleece pants','vest','bloomers','usbc jerseys','booster','long sleeve performance tee','bodysuit','eliminator warm up','ladies xtreme jacket','booster package','youth warm ups','challenger package','horizontal cheer','rffb6','victory pant','spirit','lpadk01','athletic performance polo','yun500','youth','pom pons','megaphone','fleece','zig zag','yja180','elite jacket','sweat pants','crop top','texture stripe polo','shock','infinity jacket','lpa186','director polo','chill shield jacket','raglan sleeve','polo','super challenger package','icon warm up','ljadk01','lpapt06','lja1100','spirit jacket','all weather pant','texas orange','sideline briefcase','ljapt08','hooded sweatshirts','infinity pant','attacker jersey','yja3800','elite pant','keyhole tank','fpa150','papt06','youth uniforms','spirit warm up','polytek pants','tricot challenger','full zip fleece','flexi print','butterfly package','icon jacket','mesh shorts','surge warm-up','ljapt05','medals','duffle bags','rain jacket','rffb17','tricot infinity','rffb3','100% polyester tricot','pullover jackets','youth jackets','yja3701','bulldog mascot','volleyball uniforms','liberty','ypapt06','hornet','nylon eliminator warm up','mesh sling bag','ladies infinity warm up','tees','lined jacket','mlch5','youth pants','textured stripe','microfleece','capri pants','yljadk01','sale','track jackets','horizontal stripe','twill hat','water repellant','cbow2','speed suit','powerhouse polo','yjapt02','ladies challenger warm up','classic polo','football capri pants','spirit warmup','ylpapt03','fleece warm up','yun106','dazzle jacket','defender ja190','lun302','youth polo','orange','yja195','tank','duffle','ltfj01','chrome dog tag','skirts','yljapt07','jazz pants','coaches polos','cheer','ladies fan jersey','surge warm up','tall pants','pplst','papt01','chill fleece','defender pant','youth t','medalist warm up','shock sport polo','liberty jacket','reversible','ladies elite warm up','tfj01','ribbed tank','tbowl','pinnacle warm up','legacy warmup','nylon pants','zip fleece','ypapt05','wrestling','infinity warm-up','deluxe challenger','velocity jacket','storm pro','dcs41','teal','sleeveless polo','pkg116','eclipse pants','screen print','poplin shirt','tights','surge jacket','lpadk03','sideline performance polo','designs','speedsuit','xtreme jacket','yfpa100','white tee','pkg127','long sleeve t','fitted tee','baseball uniforms','twill shirts','long sleeve sideline','x-treme','rffb14','rffb5','tri tone','micro-polyester medalist warm up','velocity warm-up','polyester tricot legacy warm up','papt05','garment','ypa182','lsh300','pocket tee','ladies v neck t','yun156','dsbg7216','pants','challenger warm up jacket','shoes','zephz butterfly shoe','butterfly shoes','pinnacle jacket','ladies competitor warm up','lsh600','pkg196','shtn02','youth shorts','dance warm ups','crew','henley','brown pants','super eclipse package','yun300','lpa7633v','chill shield fleece','football','v neck tee','ypapt01','pleated skirt','energy','lady challenger warmup','lined nylon pants','cheer uniforms','stadium seats','hwycoke1','fleece vest','practice jerseys','double v','brown jackets','chill shield','pull-over','youth sweatshirts','lun600','small sport backpack','v notch','singlet','short sleeve g2m performance tee','uns300','ja-185','yun152','ylpadk01','dcs51','deluxe challenger package','sleeveless track speed top','texas','football jersey','sspb','papt08','full zip','bobblehead','lettering','campwear','poly tricot knit','water resistant warmups','spirit flex pant','ylja186','accessories','cbow','energy performance tee','lun301','jazz short','ladies icon jacket','vegas gold','water resistant warm ups','ladies surge warm up','chill shield fleece jacket','competitor warmup','football tee','youth warmups','pkg208','storm pro pants','legacy warm-up','lun602','lthy144','transfer','ldsg851l','rain pro warm up','pkg130','toss','100% micro-poly shell warm ups','knights','ypa3700','tch413','home and away package','pyramid shell','challenger warmup','micro-polyester storm pro jacket','white jacket','lshs03','hourglass tee','a-line skirt','medalist pants','energy polo','women warmups','dazzle pants','flannel','red bloomers','baby doll tee','polyester jacket','pinnacle pant','ylpapt07','v notch skirt','ringer tee','eliminator jacket','lpa182','sport backpack','mlch100','mlfb2','legacy pants','ybs3310','metallic uniform','lpapt08','awards','energy performance polo','micro poly','ypapt08','visors','lun300','cheerleading briefs','boy-cut briefs','royal','fleece lined jacket','pkg260','black white gold','warm up jackets','ltn05','tank tops','appointment polo','cheer shorts','pkg231','warm-up pants','jacket with hoods','tshirts','backstroke','cheerleading','legacy jacket','half zip','defender warmup','yun104','mlfb100','microfiber','all star','pkg177','cheer shoes','shell','eagles','polyester tricot challenger warm up','heavy jackets','pkg114','3 4 sleeve performance polo','brass package','powerline','ltn02','black and silver warmups','ladies long sleeve','elite warmup','energy long sleeve','mock turtleneck','sleeveless','nylon','capri','training jacket','shtn7','shtn04','cap sleeve tee','elite warm-up','pkg234','ysh801','gymnastics sweatshirts','wildcats','achiever','advantage jersey','micro poly windshirt','triple sequin bow','red white and blue','yjapt01','challenger warm-ups','pyramid','bdn601','nylon booster warm up','shirts','pkg207','pocketed fleece pant','booster warm-up','v-notch skirt','mesh practice','work','black and green','ladies dazzle warm up','dcs29','yun108','pkg112','tricot legacy','hooded warm ups','golf towels','spirit flex crop top white','long sleeve polo','mens challenger','lun513','royal blue and gold','ladies warm up','canvas','double v shell','brown bag','coach','slam dunk','dcs50','long sleeve energy tee','ladies icon','spirit flex cheer uniform','bgb5811','skort','long sleeve sideline tee','waterproof','forest gold','purple','tote bag','usbc bowling','sideline polo','mens challenger pant','yun103','colored cotton tee','ladies eclipse','tct501','dance screen prints','pkg111','ylpa100','compression shirts','yljadk03','tops','lpapt05','ladies challenger pants','sweetheart','football pants','ladies challenger jacket','ladies energy performance polo','ltn04','ltn03','ttn05','maroon and gold jacket','yljapt03','ladies challenger','pkg159','hooded warm-up','v-notch','gold','racer back','black purple','yct100','ldsg751l','nylon eliminator','booster warm up','color guard','hgbean','shtn03','lsh19660','polyester warmups','intimidator package','sling bag','lts03','zig zag uniform','v-neck shell and a-line skirt cheerleading uniform','black and purple warm up','rfch16','eclipse jacket','tri-tone','dance bags','dance','spirit warm-up','hooded','super spirit','ytw100g','competitor jacket','high v','ladies polyester tricot challenger jacket','polyester pants','help','youth briefs','plastic poms','basketball','lunw1001','canvas jackets','ldsb6216','yun101','youth long sleeve t','dazzle shorts','burn out shirt','tricot','rain','icon pant','sweetheart cheerleading uniform shell','mock performance tee','sideline duffle','lpa100','baseball jersey','volleyball','back designs','jamv05','hockey','spandex shorts','drawstring short','lunw5001','pocket','half-zip','tns600','tns701','2ol05','ribbons','ttn02','sideline','columbia blue warm ups','ladies infinity jacket','distressed applique','gtmhs04-117','leggings','sequin briefs','sweetheart shell','infinity package','boxer','texas orange warm up pants','infinity shooting package','ltwill','soccer bags','surge pant','football capri','expandable briefcase','ladies pleated flip skort','yjapt08','pkg120','slam dunk shorts','rftr17f','ljadk01 elite jacket','low rise pant','rftr17','mlfb3','chill fleece headband','youth competitor pants','soccer uniforms','velocity warmup','tie dye tee','camo','premier jersey','youth icon jacket','hilhhs2c','parkas','sideline duffle bag','anklet socks','briefcase','all star package','track embroidery','2-point sports','ytch48','golf vest','maroon cheer briefs','swim bags','classico','turquoise','ladies tee','ysh100','pqph810','micro polyester pants','ladies surge pants','stadium jacket','dragon','infinity warmup','trojan','shs03','hooded fleece sweatshirt','stwill','mens','ladies surge jacket','gtmvb15','soccer jersey','football warm-ups','yun502','basketball uniforms','yun100','2ol60','yun503','white t-shirts','yun501','poly tricot','paj218','dazzle warm up','maroon and gold warm ups','papt03','headband','shtn055','columbia blue','polytek','mens challenger jacket','lun517','performance anklet sock','womens challenger','briefs ladies','rain pants','tch923','fleece hoodie','dsch580','track speed shorts','youth sizes','yja182','youth medalist jacket','pleat','ladies full zip fleece','mens sideline performance polo','mlvb100','ladies polyester tricot challenger warm up','long sleeve shirts','rainbow shirt','mock','jppt01','metallic','freestyle sling package','pkg50','ladies nylon competitor','lun32220','ypa3800','school','lja186 ladies micro-polyester eclipse jacket','ringer t','basketball practice jerseys','basketball shorts','high v uniform shell','black and gold','pkg172','mlcc14','nylon booster jacket','performance polo','mens competitor','nylon hooded jacket','hars','micro fiber jacket','lsh19650','gtm0834','microfiber jacket','ladies surge','yun107','rainbow','cheerleading socks','flexfit hat','yjapt05','gtm0004','sport polo','athletic polo','mens sport performance polo','ladies jazz pant','yac1502','royal and silver','t-shirts','ladies polyester tricot','youth football','director','jackets and pants','shimmer','surge warmup','large sport backpack','youth fleece','womens jackets','metallic top','team','ladies full zip','men\'s infinity','yljapt04','jersey shirts','dazzle warmup','spirit flex dance top','ladies v neck tee','warm-ups','nylon booster','bulldog','mesh bags','ladies power performance polo','rain pro pant','skp1764','ladies performance polo','ylpapt04','ladies polyester tricot dazzle jacket','ylpadk03','#ja180','yun154','v-neck','ladies jackets','metallic crop top','wicking','black orange warmups','odh100','athletics','youth elite pant','gtm0147','royal blue','youth elite jacket','swim','maroon','chill jacket','stretch racer back tank','tote','ladies polyester tricot xtreme warm up','classic','cheer bows','ladies polyester tricot xtreme','ladies polyester tricot infinity','tennis','dss300','ladies dazzle jacket','blue and white','rip stop pant','black and gold cheerleading uniforms','uniform packages','ladies polyester tricot challenger','yjapt06','sideline bag','youth victory','ladies polo','discontinued','hazdvhs1a','large backpack','pleated flip skort','sequin crop top','sweats','hilcam1a','performance fleece','youth victory jacket','basic singlet','yun112','metallic poms','cheerleading skirts','nylon warm ups','v-neck shell','ram','ladies nylon competitor warm up','2ol68','flyte','poly','texas orange jackets','hooded rain jacket','purple pom','ladies tank top lt1080','men\'s velocity','pink cheer','bobcats','rfch17','industrial','sport performance','mlch9','performance short','170','booster warmup','storm','tricot velocity jacket','power performance','attacker','hch04','superior','mlch11','pink jersey','ladies fleece','ladies eclipse pant','men\'s polo','nylon eliminator jacket','ljp186','ladies elite','ladies pleated skort','bears','purple gold white','carolina blue','oxford','kelly','ladies infinity pants','pirates','ladies football capri pant','attacker short','retro','womens fleece','jamv-05','knit beanie','shimmer crop top','mlwr2','red and black','ladies dress shirts','class of','clear rain jackets','spirit flex uniform','pomchie','warm up pants','hcalhs1a','lsh5230','pinnacle warmup','power polo','home away','ringer shorts','blue orange','mesh jersey','jersey t','slam dunk jersey','womens infinity warm up','standard size embroidery layouts','polyester warm ups','medalist warm-ups','devil','tns603','cheer sling bag','long sleeve tshirt','tricot velocity','navy gold','coaching shorts','scrunch','weather','cheer briefs youth','thrower','youth cheerleading uniforms','blue and gold','metallic shell','hcawhe5','knit hats','youth basketball uniforms','ladies trainer polo','polytek victory','3 4','odf100','ladies polyester elite warm up','womens competitor','shoulder stripe','storm jacket','lun601','polyester elite warm up navy white','polyester elite warm up','ljpdk03','eliminator warm-up','striker','mens shorts','huggie','wildcat embroidery','bottle openers','2 chrome dog tags','hooded fleece warm up','hooded pullover jacket','ladies ringer short','mesh sling','ladies cotton shorts','ladies icon pants','can cooler','ladies x-treme jacket','micro-polyester medalist warmup','polyester spirit warmup','purple and gold','ladies full zip fleece jacket','ttn04','tch915','ldsl629','sequin bow','polyester tricot pinnacle warm up','volleyball jersey','mens power performance polo','tri-tone bag','pkg129','kaepa shoes','pique polo','tri-tone warm up','ladies hoodies','football girdle','mens jackets','black and columbia blue','men\'s warmups','8hiphopch','yun600','performance t','heathered ringer','booster pants','youth surge','polytek defender warm up','arrow','deer','159','yja50945','g2m performance lining','maroon silver white','youth cheerleading warmups','mesh visor','tennis skort','ladies cut challenger jacket','triple pleat skirt','knee socks','cheerleading bags','ljpt06','wrist','columbia blue and black warm up','polytek defender jacket','jersey tee shirts','fleece hats','large equipment bag','black green white','mesh shirts','hcanotd1a','uniform skirt','lshf40','ljppt05','mens shell','spirit sweatshirt','double stripe','cheerleading jersey tee','attacker uniform','two color hoodie','sandwich hat','sharks','wrestling medal','athletic performance','new','cardinal polo','volleyball screen prints','kelly warm ups','ladies polyester tricot infinity jacket','medalist warm up jacket','mascot hat','guard','youth skirts','youth warm-up','camo cap','track uniforms','all-star package','dance jackets','dcs09','shield','lstwill','tri-tone uniform','screen print tee','cgtmsp32','juniors fitted tee','flex','volleyball warmups','cotton shirt','v neck tshirt','maroon and gold cheerleading','womens t shirts','mens power performance','cotton','football bag','ladies white tee','license','#ja183','flyte shoes','3 4 sleeve','spirit flex crop top','youth pinnacle','metallic briefs','black tee','bbe004','tennis shirt','tie-dye','screen','softball warm ups','double knit','ladies tricot challenger','cap sleeve','metallic silver','pleated skort','gtmvb03','nylon eliminator pants','striker short','cheer warm ups','solid pom polos','polytek intimidator','spirit flex shell','drawstring pants','basic briefs','ladies classic polo','men\'s challenger warm up','youth infinity jacket','advantage','dance sling bag','mecmp25','ladies sideline','white','wolverines','coaches bags','small backpack','ladies sideline polo','spartans','jazz','pike shell','triple bow','twill visor','tch936','ladies football jerseys','stadium','hksmhs42a','wicking t-shirt','moisture management','polyester tricot xtreme warm up','spirit flex skirt','mens surge pant','dazzle uniforms','sport performance training jacket','mens sideline','red white','speed','#pa184','keyhole','super quick','polyester spirit warm up','tri-tone sling bag','coaches hats','cross','ladies t-shirt','black jacket','ladies cut challenger','dcs25','roll down capri','cheerleading tshirts','flip skort','stripe collar polo','football warm ups','button down shirts','ladies micro-polyester velocity warm up','tshirt jersey','daisy','100% cotton','ja-195','youth baseball','superior crew tee','micro poly pants','cotton polyester blend two color fleece hoodie','tritone bag','metallic gold','3 4 length','micro-polyester medalist pant','ladies rainbow shirt','maroon bag','ladies sequin','pink warmups','micro polyester medalist pant','competitor pant','volunteer','hazsrr2c','thrower\'s short','white performance tee','softball pant','tch12','impact jersey','ladies warm-up','mens singlet','hazsrr2d','mock tee','moisture management short','orange black and white warmup','womens infinity','ankle zip pants','pink warm-up','micro-polyester medalist','huskies','zig zag cheer','cotton warm up','cheer bodysuit','ladies eclipse warm-up','ladies singlet','superior tights','mesh lined jackets','black gold uniforms','metals','ladies polyester tricot challenger pant','ladies spirit pants','brown warmups','ladies v neck fan tee','junior fitted','red black white warm-up','black and white jacket','navy','2ol35','soccer jackets','two color warm up fleece','spirit sweat','sport backpack large b4004 forest white','black maroon','navy white','ladies cut','navy fleece','full zip pants','v-neck shell pleated skirt cheerleading uniform','micro','#b4007','stripe','black warm up pants','ljppt03','ladies competitor pant','plaid boxers','basketball mascot','2ol02','layout','orange black and white skirts','watta500','ladies competitor warmup','tch501','ladies v neck','tshirt colors','anklet','horse','lds2100l','billed beanie','youth lined jacket','powerbow','mini plaid','womens tshirts','black white teal','pick a color inserts','rattler','navy pants','bus','three pleat skirt','black white purple','gtm0018','taffeta nylon','cheer crop','orange and black jackets');
/* $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);
    }