/* Popular phrases - VMD - 10:51:9, Wed Feb 22, 2012 */
var asPhrases=new Array ('medicated feedingstuffs prescription','small animal exemption scheme','flubendazole','saes','alamycin','mfsp','flubenvet','panacur','fenbendazole','griseofulvin','prescription writing','tylosin','tilmicosin','cow','special import certificate','cloprostenol','fees','special treatment certificate','cascade','adverse reaction report','adverse reaction','tiamulin','miconazole','cydectin','itrafungol','amoxicillin','dispensing label','oxytetracycline','parallel import','closantel','record keeping requirements','jobs','annual fees','oramec','controlled drugs','stc form','metronidazole','bees','medicated feed prescriptions','flunixin meglumine','sic','ati','medicated grit','medicated feeding stuffs prescription','malachite green','wholesalers dealers authorisation','trichostrongylus tenuis','duphamox','unforeseen variations','benazecare','guidance note 21','mannitol','annual report 2010','amoxycillin','avatec','improvement notices','good manufacturing practice','2010 sarss','spc','benefortin','ketoprofen','sarcoma','tylan premix','register of sqps','bovidec','stem cells','online pharmacy','spc furosemide','monothioglycerol','fees 2011 veterinary medicines','diazepam','oxytetracycline injection','ivermectin','ketoconazole','medrone v','doxycycline hyclate','bovilis','classifications of veterinary medicines','ms222','sqp','organisation chart','chorulon','logo','doxycycline','colistin sulphate','batch recall','variation fees','ringworm','sheep dip','vitamin k1 certificate','herbal medicines','category 8 distributor','triclabendazole','comfortan','selenate','autogenous vaccines','erythromycin','tylosin injectable','treatment of pasteurella haemolytica','antimicrobial sales 2010','lignocaine','feed additives','vaccines','prescription','acepromazine','cascade guidance note','seresto','fee calculator','vacancies','water soluble powder','import certificate','penethamate','clik','dysect','variations','vetergesic','canaural','misuse of drugs','lidocaine','ventipulmin','application forms','approved premises','alamycin 300','renewal form','partnership initiative','worksharing','enrofloxacin','nutraceuticals','mavis 2011','sulfadiazine trimethoprim suspension','product information database','clinical trials','business plan','baytril','stellamune','colistin','ceftiofur sodium','injection site sarcoma','florfenicol','export certificate','ivomec','micotil','aquaculture','norbrook','labelling','advocate','esbl','kenocidin','access to information','tetracycline','frontline spot on','veterinary cascade','alfaxalone','antibiotic residues in milk','antibiotic sales','vmgn','endofluke','cytotoxic','op dip','legal category','felocell cvr','calciject 40 cm','lambivac','zermasect','2297','benzodiazepines','tryptophan','covexin 10','notice','coopers ectoforce','terbinafine','vetrazin','autogenous vaccine authorisation','amitraz','mavis','ceftiofur','vmgn 10','aurofac','relabelling','prescription charges','equest','organogram','antimicrobial resistance','flevox','juramate','drontal','labelling pom-v','rqp','prescribing','adverse events','bob martin fipronil','tse','haccp plan','leptospirosis','control of veterinary medicines','haccp','pharmacovigilance','ciprofloxacin','drontal plus','albendazole','depocillin','pom-v','sunset clause','ronidazole','veterinary medicines regulations 2005','sheep worming','equest pramox','honey bees','ketamine','fibrosarcoma','grandfather rights','iodine','list of controlled drugs','auroto ear drops','otomax','prosecutions','regulin','disposal of medicine','product literature standard','inspection','veterinary medicines regulations','variation form','regulations','levothyroxine','honey','cyclix porcine','ivomec super','fenflor','consultation','medicated premixture','controlled drugs schedule 2','antimicrobial use 2010','residues','cefquinome','tse template','levamisole','doramectin','azamethiphos','african horse sickness','mange','equine influenza vaccine','acp','vetofol','lactovac','imidacloprid','sededorm','change of ownership application','mfs','veterinary formulary','kennel cough','hornex','phenoxyethanol','surolan','immucept','pulmotil ac','anna-maria brady','requisition','nuflor','alfaxan','schedule 2 drugs','sodium lauryl sulphate','imaverol','nobivac dhp','medicines act 1968','felimazole','cephalosporin','atc application form','pen strep','orbenin','adverse drug reaction reporting','dextrose 50','emea 410 01','clikzin','medetomidine','cover letter','medicated feedingstuffs','buprecare','probiotics','multivitamin','residues results','nfa vps','pom vps','abamectin','specified feed additive','summary of product characteristics','veterinary practice inspections','inclusion rate','ampicillin trihydrate','nitroxynil','pet travel scheme','vitamin k1','baytril 10%','suspected adverse reaction surveillance scheme','karidox','avipro','pentobarbital sodium','synulox','pregsure','euthanasia','frontline','fortekor','homeopathic','oxytetracycline spray','vmp','medicines','pentosan','complaints','leventa','specific batch control','active substance list','material safety data sheets','zincotec','dolton','terramycin','frontline combo','maximum residual limit','mavis 2012','chloramphenicol','manufacturing authorisation','fipronil','sales of antimicrobial products','esbl report','antibacterial','disposal','glucose','streptomycin','fleas','dispensing','danilon','antibiotic resistance','residue charges','codex','equipalazone','alamycin 300 la','buscopan','alex tait','vetmedin spc','report of antimicrobial resistance','neopen','prescription fees','lma fee','storage of schedule 3 drugs','prid delta','sta certificate','coliplus','informed consent','scalibor','amikacin','advertising online','florfenicol injection','trimethoprim','wholesale dealers license','ectoparasiticides','atc','withdrawal period','neomycin','excenel','vmgn 23','thimerosal','noroclav','spc cydectin','recall','report an adverse reaction','atopica','spectinomycin','rimadyl','alverin plus','dolpac','type ii variations','permethrin','effipro','avinew','cobactan lc','vaccines for cats and dogs','shampoo','resistance','record keeping','carprieve','avm-gsl','decentralised procedure','chlortetracycline','labelling drugs','borriello','tse declaration form','bovocycline','oxytocin','galastop','advantage','ceftiofur pharmacokinetic','defra','drontal puppy','veddra terms','distributor','marbocyl 10%','racemate','ma application form','lungworm','gallimune','dog vaccinations','temperature','sarss form','stresnil','vetmulin','supply problems','tetsol','import','orbeseal','fasinex 10%','cobactan','wqp','dossier','homeopathic medicines','wholesale','milbemycin','electronic submission','gentamycin','scheduled drugs','vecoxan','cephalonium','stc','baycox','propofol','sales','gmp','horse passport','rabisin','eqvalan duo','e-submission','faq','wholesale dealers import certificate','sunset','anticoccidial','vmgn3','cloxacillin','engemycin','draxxin','pma','procaine penicillin','format 2 declaration','deosan','drugs to report','registration of premises','insulin','guidance notes','veterinary medicines guidance note 3','dexafort','records','labelling regulation','domitor','flukiver','special import','adverse event report','fiproline','bob martin','vmgn 13','jack kay','manufacturers','founderguard','fees 2012','cloxacillin benzathine','zinc','sarss','convenia','estrumate','alizin','expert reports','variation application form','vmd download','oxalic acid','dog vaccination','regumate','nobivac lepto','accounts','pom v','freedom of information requests','scabivax forte','doxivet','free sale certificate','clenbuterol','e-submissions','homogeneity test','table of allowed substances','responsible use','ultrapen la','animal feed','product','pen-strep','fiprodog','potassium bromide','ceporex','guidance for retailers','medical device','crystal violet','gcp','horse medicines','enrox','morphine','kesium','internet pharmacy regulation','selectan','chief executive','coccidiosis','nutritional supplements','piperazine','code of practice','antibiotic residues milk','hemovet','konakion','special import certificate application','sarrs','category 8','fish degree days','vmd inspection','rompun','fish','mrl','special import site','ectofly','diazinon','psur','toltrazuril','minor species','controlled drug prescription','apralan','heptavac p','closamectin','marbofloxacin','variation guidance','rycarfa','the veterinary medicinal products directive 2001 82 ec','stabox','rms','distribution categories','antimicrobial','mums','off licence use','metacam spc','non-medicinal','marbocyl','darc','pimobendan','eurican','organophosphate','requirements for record keeping of controlled drugs','vitamin','equine stem cell centre','cdlo','pom advertising','antimicrobial sales','artuvetrin','atropine','ofloxacin','selamectin','28 day','honey residues','torbugesic','vaccination schedules for dogs','notice to applicants','spc template','norfloxacin','pig vaccines','gsl','stc cost','mycoplasma gallisepticum','copycat','sulfaquinoxaline','endogard','nitroxynil injection','parafend','duramune','internet selling','in feed medication','annual report','anthelmintics','fluoxetine','feligen','off-label','annual review','stc renewal','phenobarbitone','antirobe','variation timescale','fasinex','flunixin','propentofylline','ibr','antimicrobial use','enacard','acp injection','epilease','vitamin b1','ceo','distribution','fiprospot','vich','type 1a','batch numbers','benazepril','phenoleptil','dimethyl sulfoxide','hipnoton','dry cow therapy','finadyne','oxytetracycline oral','equibactin','parallel','feed mill','antibiotic use in poultry','kefloril','residue surveillance','clostridium vaccine','fish feed','duvaxyn','digoxin','zinc oxide','sebolyse','cestem','vanguard 7','chloromed','deccox','enroxil','horse','qualified person','millophyline','methadone','crovect','product literature','category 6','uk public assessment','hampton','noromectin','faq\'s','buprenorphine','lc','procaine','ampicillin','rabies','cefotaxime','guidance note 15','controlled drugs schedule','sp dips','mla252a','directives','carbimazole','tetanus','national variation','enalapril','newcastle disease vaccine','lincocin','storage','apivar','dectomax','bob martin spot on cats','cyclix','ammonium tetrathiomolybdate','vaccine adverse reaction','veterinary record','mavis 81','flavophospholipol','fumagillin','sustainable development','large animal immobilon','libromide','fleaclear','bimamix','mrls','dicyclanil','vetplus','febantel','enforcement','vetmedin','eprinomectin','vetremox','wholesaler licences','vmg 29','euthatal','antisedan','forcat','equine stem cell','barry','format 2','isoflo','in cycling animals','schedule 5 products','vetoquinol','prascend','furosemide','monzaldon','moxidectin','oxytetracycline horse','mastitis','baycox spc','bimectin','metacam 1mg','vetflurane','nta','medicine records','circovac','special treatment certificate application form','oxfendazol','nick renn','sqp courses','drugs','prednisolone','danofloxacin','phenobarbital epilepsy','dcp','prescription record','paracetamol','supaverm','extemporaneous','solubenol','heartworm','spartrix','sedator','denagard','wholesale supply','application','withdrawal','millward','waste disposal','environmental','specials manufacturing','sqp qualification','martha','batch records','butorphanol','versifel','cevaxel','morphine prescription','seizure notices','aerosol','phenylbutazone paste','veddra','guidance note 16','meloxicam','flumequine','immobilon','advertising','blood','canine vaccines','levacide injection','albensure','non medicinal products','prilactone','lethobarb','plerion','storage temperatures','vmg 15','sulfadimidine','eurovet','how to identify legal or illegal medicine','booster','advantix','grouped variations','vmgn 20','oxalic','ketofen','theophylline','xylazine','folligon','analgesia','ovuplant','omeprazole','zanil','aquarium','vetoryl','clavulanic','repeat prescriptions','bimoxyl','zuprevo','poultry','2377 90','vmgn 7','danofloxacin mesylate','wdic','myxomatosis','sheep fluke','nobivac','list of approved premises','inspection criteria','mixing','emtryl','neomycin sulphate','tse tables','amoxinsol 50','treatment of pasteurella haemolytica in calves','fertipig','neem oil','pulmodox','thyroid','carprofen 25 mg','xeden','carprofen rimadyl','mg poulvac','autologous','do and tell','anabolic','renewal','rilexine spc','published standards','pulmotil 200','sqp retail premises','optimmune','marbox','placing on the market','nitrofurazone','melarsomine','transparency','price','out of date medicines','schedule 2','register of farms','epiphen','isoba spc','list of sqp','limited marketing authorisation','checkmite','sop','ubrolexin','prescribing controlled drugs','feed','lincomycin spectinomycin','vpc','opioids','vanguard','diclazuril','wholesale dealer list','local anaesthetic','paracox','rimadyl cattle','cefalexin','nfa','imizol','sarah gibbons','cascade consent','copper sulphate','noroseal','on line pharmacies','tiges','drontal cat','oxytetracycline tablet','consent','anti-epileptics','dermisol','lincospectin','defect reporting','iit','sqp code of practice','medicinal words and phrases','lgc','equip ft','ketamine storage','practice inspections','equilis','asmf','tolfedine','animal test certificate','validation form','dexamethasone','gentamicin','therios','osmonds goldfleece sheep dip 60%','overview of antimicrobial usage','legislation','wdic application','emeprid','jackie atkinson','tolfenamic acid','cardisure spc','salmosan','steve spencer','pyrantel embonate horses','mebendazole oral suspension','chlorsol 50','rd114','procaine benzyl penicillin','qrd template','freedom of information','bovaclox','altrenogest','cascade horses','swaycop','guideline','promotion','controline','enzovax','steve dean','jukes','events contact','unlicensed products','microbex','beaphar','unforeseen','ceftiofur hydrochloride','liquid feed','eudralex','cepravin','isoxsuprine','nsaids cattle','guidance note 20','local anaesthetic cattle','website','bovilis ringvac','enrofloxacin injection','propoflo','wholesalers list','fortekor flavour','naloxone','change of distributor','gallivac se','tablets','renegade','note 20','gudair','tse format','apiculture','glossary','vomend','dimpylate','tribrissen','milbemycin oxime','bilosin','special import licence','pyratape','esubmission','medicines storage','john millward','medicines on internet','oxytetracycline flunixin injection','florfenicol oral solution','schedule 5','feline vaccination guidelines','stomorgyl','teat dips','bupivacaine','vmg notes','seleen','guidance note 3','vasotop','cattle','ddps','phenobarbital 30mg','ma application','authorised products','gdp','footvax','fmd','controlled','salenvac','antimicrobial overview','bacitracin','transfer of mah','quinoflox','pharmacies','pulmotil','levacide','libby bell','horse substances','johnes vaccine','rearguard','note 16','transfer of marketing authorisations','special import application','summit veterinary pharmaceuticals','mebendazole','dolethal','deltamethrin','frontline spray','simethicone','annual account','pfizer','fines','definition','vmr 2010','virbamec','change label','canigen','angel eyes','dimetridazole','controlled drug record book','surveillence programme','marbocyl p','clamoxyl','nobilis salenvac','guidance note 29','chlorphenamine','aspirin','pluset','nystatin','practise standard registration','transmune','meloxicam for cat','pyriproxyfen','variation to mana','classification of variations','enovex','variations qp','news','cypermethrin','blue box','dopram v','furosemide 40mg','national procedure','sandra russell','cadmium','varroa','approvals register','spc vetmulin','kay goodyear','virginiamycin','ivermectin in dogs','axiom','cloprostenol horse','apistan','cefoperazone','ivermectin horses','batch specific variation','premises','christmas','atc form','about us','proforma','covexin','vmgn 6','fuciderm','slice','enforcement team','metronex','genetically modified organism','eprinex pour-on','stock audit','cylap spc','statistics','closiver','sales antibiotics 2010','staff handbook','phenobarbital cats','parallel import fee','pig feed','passport','cosequin','serotonin','competent authority','plt tablets','adequan','andrew crowther','article 34 referral','clinacox','communications strategy','amelia','controlled drug book','penalties','medroxyprogesterone','authorised drugs','amr overview','ctd','androgens','availability of veterinary medicines','mia','claims','change of legal category','advocin','sfa','avipro salmonella','colombovac','poland','povidone iodine','prescription diets','panomec','colostrum','autogenous','angel eye','cylap','mavis 78','singvac','clindamycin','anaesthetic','code of practice on the responsible use of animal medicines','communication','medicine test certificate','vmd batch release','anaphylaxis','attp','apply for sic','martha spagnuolo-weaver','marbiflox','circoflex','sutures','service standard','chondroitin','citronella','animec','copycat ma','pyroflam','medicinal claims','flypor','carprodyl','milk replacer','amoxypen','controlled substances','veterinary specials','cattle vaccines','selling medicated feeds','catherine webb','prid','protamine','vmd practice number','product disposal','pml','cleaning validation','marbocyl p 80 mg spc','auriplak','coliplus spc','piperazine citrate','anabolic steroids','ceftriaxone','farm record','sogeval','application for a variation','saddlery','current vacancies','feedingstuffs','authorisation route','fleegard','sulphur','propylene glycol','amoxicilline in broilers','product recall','scops','mavis 66','finance','standards','suspended','biologicals post','macrocyclic lactone dogs','botulism vaccine','croft','vmgn no.23','code of practice on the responsible use of animal medicines on farm','suspect adverse reactions scheme','spc karidox','spironolactone','chloral hydrate','coopers','veterinary medicines regulations 2006','autoworm','pasteurella haemolytica calves','pig induce farrowing','pasteurella haemolytica florgane','vitamin ad3e','cancel','combimox','special license','combisyn','sulfonamides','arhai minutes','postal application form','stem','clarke','farmers records','catherine','security','sheep vaccinations','prazitel');
/* $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);
    }
