/* Popular phrases - GETFED - 21:27:33, Wed Mar 17, 2010 */
var asPhrases=new Array ('baltimore catechism','our lady of grace statue','divine mercy','liturgy of the hours','scapular','holy water font','rosary case','apologetics','jeff cavins','jeff cavins bible study','prayer cards','saints bracelet','missal','the great adventure bible study','baptism gifts','icons','veronica\'s veil','st francis of assisi','divine mercy print','guardian angel prayer','st rita of cascia','our lady of guadalupe statue','st joseph figurine','imitation of christ','galatians','book of kells','first communion certificates','pro life','baby','gospel of john','great adventure','immaculate heart of mary prayer card','first communion bracelet','garden plaque','ignatius study','dvd','last supper','rsv bible large print','st michael chaplet','rainbow silver','rsv bible','celtic cross necklace','veronica','ignatius study bible','crystal rosary','cd','church history','joan of arc','50th wedding anniversary','bible covers','charm bracelet','purple rosary','pocket','florentine collection','flowers','auto','pieta prayer book','st benedict','pieta','stretch bracelet','auto rosary','natural family planning','first communion invitations','st christopher key chain','catechism','charm','books st augustine','mass cards','pam stenzel videos','dvd\'s','no turning back','bible timeline','st nicholas','mens rosaries','ceramic bracelet','matthew kelly','wood box','damiano','novenas','pam stenzel','tim staples','scott hahn cd','father corapi','last supper plaque','baptism bear','why do catholics do that','rosario','children\'s bible','4 way cross','catholic childrens bible','san damiano cross','pyx','standing cross','baby angel','sacred heart','writers of the good word bookmarks','tim staples dvd','what catholics believe','karl keating','st justin','pope john paul ii','fulton sheen','confirmation certificate','st therese prayer card','baptism cards','rosary box','alex jones','pewter cross','stations of the cross','lovasik','promises of sacred heart','miraculous medal','family bible','elisabeth leseur books','francis de sales','standing crucifix','marian statues','our lady of perpetual help','communion veils','candle holder','irish','mark shea','fr corapi','angels','book of saints','shamrock','gethsemane','primera comunion','jesse romero','nightlight','ignatius catholic study bible complete set','benedict groeschel','my prayer book','nab study bible','font','kimberly hahn','childrens bibles','scriptural rosary','sunday missal','cancer','friend','crystal eyeglass chain','wooden bracelets','infant jesus of prague statues','the spiritual exercises of st ignatius of loyola','rosary on cd','rosary bracelet','st joseph','elf help','catechism of the catholic church','books by donna-marie cooper o\'boyle','john bosco','how to raise good catholic children','ladder rosary','theology of the body for teens','our sunday visitor\'s encyclopedia of catholic doctrine','10 commandments','essays on reading the bible','essential handbook','pentecost','benedict','misal','jean-pierre de caussade','st joseph medals','silver scapular','confirmation','st raphael','angel statue','summa theologica','papal crucifix','st michael statue','leather prayer book','mystery bar rosary','st.clare','mass dvd','wedding','san expedito','be not afraid','daily missal','rose','holy cards','catholic prayer book','christopher west','green scapular','puka','certificates','bible study','baptism photo album','navarre bible','st jude statue','dymphna','mother of pearl','reconciliation certificates','st george','st adrian','personalized','chaplet of st joseph','rosary necklace bracelet set','michael joncas cd','first communion bear','saint nicholas statue','decline and fall of the','st michael prayer card','st bede','prayer books','christ denied','papal encyclicals','gold youth heart bracelet','mother teresa','st lucy medal','keepsake box','snowglobe','sapphire communion bracelet','engagement','memorial','epic','baby gifts','divino nino jesus','heavenly protector','st michael','st theresa statue','corapi','peregrine','patrick madrid','framed our lady of perpetual help','lady of lourdes statue','coffee mugs','raymond arroyo','young people\'s book of saints','navarre new testament','baltimore','roman missal','st catherine of alexandria','lent','st joseph statue','baby wings','tim staples cd','risen crucifix','wooden rosary','young people','birthstone bracelet','medieval','theology of the body for teenagers','thomas more medal','saint pancracio','the truth exposed','holy hour of reparation','youth bible','music audio tapes','fathers plan','divine intimacy','cavins','homeschool','pink rosary bracelet','dark night of the soul','guadalupe','bible','jesus art','new testament','t3','butterfly','mp3','salvation history','locket','grief','st joseph heavenly protector statue','deacon gifts','madonna rosary holder','rosary necklace','baptism','rosary','medals','pregnancy prayers','sacred heart chaplet','west','ss rosary','first holy communion bible','irish blessing plate','rosary booklet','the catholic mass revealed','rcia cards','courage','lenten books','catholic mass cards','st patrick','irish blessing','spanish certificate','flight into egypt','madonna of the streets','sacred heart of jesus statue','prague','mitch pacwa','cross of christ','emmaus','saint michael','guardian angel charm','franciscan rosary','st colette','miraculous medal for children','vinny flynn','come to me in the blessed sacrament','st pio','john vianney','st jude','september birthstone','august birthstone','seven sorrows rosary','liturgy of the hours guide','peacock','rosary prayer card','navarra bible','scott hahn books','saint sebastian','song of angels','goddaughter','priest gifts','c.s lewis','divino nino','ruby crucifix','theology of the body','st philomena','garnet rosary','st clare','prayer cards for baby','crown of thorns','communion dress','rose pin','dios habla hoy','ave maria','alex jones story','nino de atocha','st jude prayer','navarre','year of the priest rosary','our fathers plan','triptych','st catherine prayer card','bear','hahn','chambers','personalize rosary','st john the baptist','wisdom of the saints','easter books','dawn of the messiah','immaculate heart sacred heart','mary prayer card','rosary beads','forgiveness','cruciform','frames','revised standard version catholic bible','bronze patrick','bosco','pray the rosary','james','archangel michael','kidney','theology of her body','on the council of nicea','st gianna','humanae vitae','st joachim','50th wedding anniversary gifts','chapel veil','thank you notes','penny catechism','matthew arnold','anniversary gifts','garden angel','pastel','confirmation cross','st therese','children\'s station of the cross','holy spirit medal','stations of the cross cd','love and responsibility','story of a soul','why catholic','mark','st michael prayer','first comes love','case','corpus crucifix','purgatory explained','the day the sun danced','marian bracelet','hours','holy water bottle','mystical city of god','psalms','infant of prague prayer card','st michael rosary','fireside giant print','paperweight','st joseph picture books','st therese of lisieux','gertrude','secrets of a soul','rose of lima','jerusalem cross pyx','our lady of the angels','sacred heart of jesus','st peregrine novena','angel pins','pearl rosary','saint dymphna','3 inch crucifix','god\'s heroes','catholic study bible','psalter','old testament','fireside bible','st joseph home sale','rosary crucifix','cure ars','jeff cavins great adventure','bronze','virgen del carmen','turquoise','casey','st benedict crucifix','st luke','saint dvd','music cd\'s','baptism invitations','magnificat','act of contrition','henri nouwen','christie helene','barbara','catholic bible tabs','day by day lent','first communion veil','how to say the rosary','holy souls','keating','first communion missal','god and the world','the 13th day','maps','aquinas','emt','catena aurea','handbook for catholic moms','carmelite','clearance','trinity medal','graduation gifts','st francis statue','transformed by grace','bible on cd','santo nino','silver rosary bracelets','holy spirit rosary','catholic treasure box','swarovski','orthodoxy chesterton','celtic rosary','saint joseph of cupertino','purgatory','st therese rosary','tree of life','wood crucifix','laminated prayer cards','circle cross','blessings','patron saint prayer card w medal','our lady of guadalupe medal','imitation of mary','video fulton sheen','bouguereau','st joseph bible','brown scapulars','the catholic faith handbook for youth','st joseph pendant','preparation for death','exorcist','small marian','baptismal prayer cards','angel figurine','fundamentals of catholic dogma','eucharistic adoration','posters','baltimore catechism no.2','scapular medal','the eight beatitudes','black wood rosary','christ','lenten handbook','dummies','scott hahn on st paul','st peregrine prayer','catherine laboure','women\'s bible study','precious moments','frankincense','aquamarine','bracelet','immaculate conception','divine mercy rosary','lapis rosary','rose rosary','bible index tabs','st bernadette','how to pray like jesus and the saints','amethyst rosary bracelet','fulton sheen dvd','parables of jesus','teen','saint valentine','st joseph of cupertino','software','summa','father of mercy','first communion tie','gifts of the holy spirit','coloring books','st.theresa','this is the faith','bella','catholic music','st therese of lisieux prayer book','irish angel','royal tara china','shamrock teapot','the four last things','hang it on the cross','kneeling santa','sapphire cross','st francis prayer','mouse pad','lourdes','plaques','first communion prayer card','stations of the cross rosary','interview with john paul 2','20 questions by john paul 2','pope john paul ii the theology of the body','14k crucifix','ephesians','dog tag necklace','our fathers guide','ruby rosary beads','indulgences','flight of faith','angel visor clip','patches','our lady of czestochowa','sign of','alabaster','sign of contradiction','children wooden rosary','letter of saint james','eucharistic miracles','rosary set','saint peregrine','year of the priest','new jerusalem bible','michael barber','first communion rosary case','africa','kevin perrotta','who am i','anniversary','journal','st joan of arc','gold rosary','pewter medals','holy communion','sorrows','totally lent','suggested readings for adoration','guardian angel plaque','st francis medal','homosexual','san damiano','introduction to christianity','deceased mass card','jeanne','thomas kempis','douay rheims','dictionary','joseph\'s studio','questions and answers about your journey to god','spiritual combat','picture of pope','broken chain photo frame','angelina','benedict rosary','sacred heart of jesus medal','agnus dei','innocence','april journey necklace','october journey heart','december journey necklace','st.bernadette statue','childrens spanish missals','st john rosary','st paul medal','the mass revealed','catholic bible dictionary','i said a prayer','interior castle','amethyst pendant','statue rosary holder','illustrated rosary','thomas howard','seven secrets of the eucharist','what catholic believe about the bible','st valentine','mugs','suffering','one hour with jesus','bread of life','large bead rosary','holy trinity','blue miraculous medal','heart rosaries','scripture matters','teaching children birds and bees','saint veronica','st gerard','st patrick prayer card','christening photo album','st barbara','liturgical calendar','footprints','kempis','books jews','fulton','mary beth bonacci','st matthew rosary','st mark','multicolored rosary bracelet','blessed sacrament','fr mcbrides teen catechism','st joseph daily missal','santisima trinidad','sacred heart statue','black rosary','baby music boxes','orthodox prayer book','yves congar','life of mary','crystalina evert','martha','st michael spanish','spanish chaplet of divine mercy cd','stewardship','saint board book','harp','christ\'s story bracelet','romance without regret','death of a child','courageous bible studies','girl\'s first communion rosary','jobs tears','come and see','alabaster madonna','decal','sacred heart that lights up','heart bracelet','st charbel','sacred and immaculate','inri','mormon','suicide','daily companion','rosalind moss','words of christ in red','dr ray guarendi','catherine emmerich','baby record book','books on saints','giant print catholic bible','handbook of indulgences','nab giant print','navarre acts','self discipline','st bridget prayer card','hermits','grain of wheat','francis fernandez','god creator','be holy a catholic guide to the spiritual life','catholicism and fundamentalism','silver miraculous medal','ceramic','st christopher pewter soccer medal','saint mark','tie','godmother','saint john','where is that in the bible','mysteries','hahn cds','murano heart bracelet','bob fishman','creche','the assumption of mary','white gold rosaries','gianna','st christopher military medal','birthday cards','daily bible','overcoming','spirit life','hand rosary','mary child pendant','chiseled cross jerusalem stone necklace','incorruptibles','pink heart','st clare of assisi','rsv red','escriva','eyeglass chain','virgen de loreto','st blaise','st patrick rosary','prayer book-jesus live in me','gemma','porcelain cross','lady of guadalupe','wall cross','catholicism and scripture','pope pius xii','st charles borromeo','raccolta','st maria goretti','renaissance collection crucifix','pure manhood','chesterton','reformation','mary and child','widow\'s mite','the gospel rosary of pope john paul ii','gift for godfather','magnificat magazine','christ is passing by','the everlasting man','st margaret','our lady of knock','sallman\'s head of christ','sacred heart scapular','saint anne medal','st stephen','lukewarmness','wild goose','thurible','mary kimberly hahn','message of fatima','champions of faith','st columba','sri','mysteries of the rosary pictures','champions of baseball','pendant','story bracelets','sterling silver cross','car','clock','st joseph cafasso','catholicism for dummies','st christopher golf medal','protestant minister','czestochowa','saint anthony','silver chain','kolbe','manger','knox','christ at hearts door','christmas ornaments','christmas from heaven','celtic frame','sacred heart medal','st gerard majella','st fina','st antony of the desert','lamb\'s supper scott hahn','the dialogue of st catherine of siena','st francis of paola','saint hubert','st bernard of clairvaux','saint cecilia','st christopher football','mom','kreeft','crusades','san judas tadeo','renaissance collection by joseph studio','noahs ark','saint james','serenity prayer pendant','michael dubruiel','mysteries of the rosary','susie lloyd','toddler','st patrick celtic cross','rev l lovasik','wings','santini pieta','the blessing of christmas','parts of the mass','st caroline','to know christ jesus','st justin medal','safety','st john of god','shroud','santa misa','covenanted happiness','penal rosary','camillus','spiritual exercises','love is kind','large spring green bible cover','the mass and modernity','papal','modern saints','saint matthew','vocation of labor','new dad','poinsettia','st john the evangelist prayer card','sell a home','serenity','st christopher blue medal','st henry','saint nicholas prayer cards','catholic bible on cd','carpenter','ccd','little book of saints','spanish way of the cross','nativity banner','st boniface','st fiacre','children christmas','souls day','saint trading cards','saint bernadette','st michael stone','st thomas aquinas prayer card','silver st christopher medals','jude','common objections','ties','pio','st michael scapular','men\'s crosses','st edith stein','the catholic home','true devotion','seven story mountain','the cantata of love','stephen','life teen','st ignatius bible study','spanish music','san jorge','scroll wreath','spiritual exercises of st ignatius','saint patrick','the way of divine love','st christopher soldier','sacred heart of mary and jesus','scarf','marriage a unity of three','we go to mass','mother daughter bracelet set','sick set crucifix','mark etling','lifework','word of life','st john bosco','st don bosco','st jude scapular','st peter medal','st christopher football medal','prayer to st raphael','moses','loyola','catholic and divorce','the best stories in bible','madonna icon','creation','jesus of israel','scroll','march','postcard from a volcano','st joseph pray card','st.dymphna','what\'s so great about christianity','st therese chaplet','statue st nicholas','st florian prayer cards','st peter claver','stan fortuna','sand dollar','st.anthony','st christopher pendant','st.claire of assisi','sterling silver bracelet','sick call crucifix','st therese dvd','scott hahn father','st matthew prayer','serenity bracelet','sterling silver','stocking holder','st francis rosary','st michael visor medal','salvation is from the jews','stephanie mann','st margaret mary','simplify','shamrock rosary','spiritual exercises ignatius','st isaac jogues','st rita medal','santa clara','st.francis statue','sagrado corazon','saint charles','sterling silver herringbone rosary','st patrick statue','safely home prayer','st nicholas prayer card','st hubert','slainte','st john\'s gospel a bible study guide and commentary','silver cross holy spirit','prove it jesus','study guide for the u s','catholic replies','saint joseph communications','st mark medal','socrates','single prayer cards','silver heart bracelet','st patrick dvd','cribmedal','st.francis biography','mother mary francis','stepmom','saint margaret mary','serenity cards','conception prayer card','st catherine medal','soldiers prayer','pope statue','st.francis','cancer rosary','classic radio','st therese of lisieux statue','st martha prayer card','christmas cookie cutters','mom cross');
/* $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);
    }