
function showStates(booAll,ST)
  {        
    document.write('<option value="0">Select a State...</option>');
    if (booAll)
    {
      document.write('<option value="all" ');
      if (ST=='all')
        document.write('selected');
      document.write('>All States</option>');
	  }
      document.write('<option value="AL" '); 
      if (ST=='AL') 
        document.write('selected');
      document.write('>Alabama</option>');
			document.write('<option value="AK" '); 
      if (ST=='AK') 
        document.write('selected');
      document.write('>Alaska</option>');
		  document.write('<option value="AZ" '); 
      if (ST=='AZ') 
        document.write('selected');
      document.write('>Arizona</option>');
			document.write('	<option value="AR" '); 
      if (ST=='AR') 
        document.write('selected');
      document.write('>Arkansas</option>');
			document.write('	<option value="CA" '); 
      if (ST=='CA') 
        document.write('selected');
      document.write('>California</option>');
			document.write('	<option value="CO" '); 
      if (ST=='CO') 
        document.write('selected');
      document.write('>Colorado</option>');
			document.write('	<option value="CT" '); 
      if (ST=='CT') 
        document.write('selected');
      document.write('>Connecticut</option>');
			document.write('	<option value="DE" '); 
      if (ST=='DE') 
        document.write('selected');
      document.write('>Delaware</option>');
			document.write('	<option value="DC" '); 
      if (ST=='DC') 
        document.write('selected');
      document.write('>Dist. of Columbia</option>');
			document.write('	<option value="FL" '); 
      if (ST=='FL') 
        document.write('selected');
      document.write('>Florida</option>');
			document.write('	<option value="GA" '); 
      if (ST=='GA') 
        document.write('selected');
      document.write('>Georgia</option>');
			document.write('	<option value="HI" '); 
      if (ST=='HI') 
        document.write('selected');
      document.write('>Hawaii</option>');
			document.write('	<option value="ID" '); 
      if (ST=='ID') 
        document.write('selected');
      document.write('>Idaho</option>');
			document.write('	<option value="IL" '); 
      if (ST=='IL') 
        document.write('selected');
      document.write('>Illinois</option>');
			document.write('	<option value="IN" '); 
      if (ST=='IN') 
        document.write('selected');
      document.write('>Indiana</option>');
			document.write('	<option value="IA" '); 
      if (ST=='IA') 
        document.write('selected');
      document.write('>Iowa</option>');
			document.write('	<option value="KS" '); 
      if (ST=='KS') 
        document.write('selected');
      document.write('>Kansas</option>');
			document.write('	<option value="KY" '); 
      if (ST=='KY') 
        document.write('selected');
      document.write('>Kentucky</option>');
      document.write('	<option value="LA" '); 
      if (ST=='LA') 
        document.write('selected');
      document.write('>Louisiana</option>');
			document.write('	<option value="ME" '); 
      if (ST=='ME') 
        document.write('selected');
      document.write('>Maine</option>');
			document.write('	<option value="MD" '); 
      if (ST=='MD') 
        document.write('selected');
      document.write('>Maryland</option>');
			document.write('	<option value="MA" '); 
      if (ST=='MA') 
        document.write('selected');
      document.write('>Massachusetts</option>');
			document.write('	<option value="MI" '); 
      if (ST=='MI') 
        document.write('selected');
      document.write('>Michigan</option>');
			document.write('	<option value="MN" '); 
      if (ST=='MN') 
        document.write('selected');
      document.write('>Minnesota</option>');
			document.write('	<option value="MS" '); 
      if (ST=='MS') 
        document.write('selected');
      document.write('>Mississippi</option>');
			document.write('	<option value="MO" '); 
      if (ST=='MO') 
        document.write('selected');
      document.write('>Missouri</option>');
			document.write('	<option value="MT" '); 
      if (ST=='MT') 
        document.write('selected');
      document.write('>Montana</option>');
			document.write('	<option value="NE" '); 
      if (ST=='NE') 
        document.write('selected');
      document.write('>Nebraska</option>');
			document.write('	<option value="NV" '); 
      if (ST=='NV') 
        document.write('selected');
      document.write('>Nevada</option>');
			document.write('	<option value="NH" '); 
      if (ST=='NH') 
        document.write('selected');
      document.write('>New Hampshire</option>');
			document.write('	<option value="NJ" '); 
      if (ST=='NJ') 
        document.write('selected');
      document.write('>New Jersey</option>');
			document.write('	<option value="NM" '); 
      if (ST=='NM') 
        document.write('selected');
      document.write('>New Mexico</option>');
			document.write('	<option value="NY" '); 
      if (ST=='NY') 
        document.write('selected');
      document.write('>New York</option>');
			document.write('	<option value="NC" '); 
      if (ST=='NC') 
        document.write('selected');
      document.write('>North Carolina</option>');
			document.write('<option value="ND" '); 
      if (ST=='ND') 
        document.write('selected');
      document.write('>North Dakota</option>');
			document.write('	<option value="OH" '); 
      if (ST=='OH') 
        document.write('selected');
      document.write('>Ohio</option>');
			document.write('	<option value="OK" '); 
      if (ST=='OK') 
        document.write('selected');
      document.write('>Oklahoma</option>');
			document.write('	<option value="OR" '); 
      if (ST=='OR') 
        document.write('selected');
      document.write('>Oregon</option>');
			document.write('	<option value="PA" '); 
      if (ST=='PA') 
        document.write('selected');
      document.write('>Pennsylvania</option>');
			document.write('	<option value="RI" '); 
      if (ST=='RI') 
        document.write('selected');
      document.write('>Rhode Island</option>');
			document.write('	<option value="SC" '); 
      if (ST=='SC') 
        document.write('selected');
      document.write('>South Carolina</option>');
			document.write('	<option value="SD" '); 
      if (ST=='SD') 
        document.write('selected');
      document.write('>South Dakota</option>');
			document.write('	<option value="TN" '); 
      if (ST=='TN') 
        document.write('selected');
      document.write('>Tennessee</option>');
			document.write('	<option value="TX" '); 
      if (ST=='TX') 
        document.write('selected');
      document.write('>Texas</option>');
			document.write('	<option value="UT" '); 
      if (ST=='UT') 
        document.write('selected');
      document.write('>Utah</option>');
			document.write('	<option value="VT" '); 
      if (ST=='VT') 
        document.write('selected');
      document.write('>Vermont</option>');
			document.write('	<option value="VA" '); 
      if (ST=='VA') 
        document.write('selected');
      document.write('>Virginia</option>');
			document.write('	<option value="WA" '); 
      if (ST=='WA') 
        document.write('selected');
      document.write('>Washington</option>');
			document.write('	<option value="WV" '); 
      if (ST=='WV') 
        document.write('selected');
      document.write('>West Virginia</option>');
			document.write('	<option value="WI" '); 
      if (ST=='WI') 
        document.write('selected');
      document.write('>Wisconsin</option>');
			document.write('	<option value="WY" '); 
      if (ST=='WY') 
        document.write('selected');
      document.write('>Wyoming</option>');
			document.write('	<option value=".">----------------------</option>');
			document.write('	<option value="AB" '); 
      if (ST=='AB') 
        document.write('selected');
      document.write('>Alberta</option>');
			document.write('	<option value="BC" '); 
      if (ST=='BC') 
        document.write('selected');
      document.write('>British Columbia</option>');
			document.write('	<option value="QB" '); 
      if (ST=='QB') 
        document.write('selected');
      document.write('>Quebec</option>');
			document.write('	<option value="MB" '); 
      if (ST=='MB') 
        document.write('selected');
      document.write('>Manitoba</option>');
			document.write('	<option value="NB" '); 
      if (ST=='NB') 
        document.write('selected');
      document.write('>New Brunswick</option>');
			document.write('	<option value="NF" '); 
      if (ST=='NF') 
        document.write('selected');
      document.write('>Newfoundland</option>');
			document.write('	<option value="NS" '); 
      if (ST=='NS') 
        document.write('selected');
      document.write('>Nova Scotia</option>');
			document.write('	<option value="ON" '); 
      if (ST=='ON') 
        document.write('selected');
      document.write('>Ontario</option>');
			document.write('	<option value="SK" '); 
      if (ST=='SK') 
        document.write('selected');
      document.write('>Saskatchewan</option>');					
    }
  function isEnter(event)
  { 	
	  var code = 0;

	  if (event.which)
      code = event.which;
    else
      code = event.keyCode;
  		
	  if (code==13)					
		  return true;		
	  else
		  return false;			
  }
  
  function isAlpha(event)
  {
    var code = 0;
    var rxp = new RegExp(/[a-zA-Z]/);
    var booNumLockON = false;
    
    if (event.which)
      code = event.which;
    else
      code = event.keyCode;
    
    if (code>=96 && code<=105)
        booNumLockON=true;
    
    var sCode = String.fromCharCode(code);        
        
    if(rxp.test(sCode) && !booNumLockON)
    {
      alert('Please enter a valid zipcode. We currently do not handle Canadian postal codes. Sorry for any inconvenience.');
      return true;
    }
    else
      return false;
  }
  function validateSearch(searchBox) 
  {		
  
    if ((document.forms[searchBox].tbZip.value.length<5)||(document.forms[searchBox].tbZip.value.substring(0,3).toLowerCase()=='zip'))
    {    
	      if ((document.forms[searchBox].srg.selectedIndex==0)||(document.forms[searchBox].srg.value.length<2))
	      {
		      alert('Please select a state or enter a valid zipcode.\nThis will display any regional results for your search.');
		      return false;
	      }
      else
        document.forms[searchBox].loc.value='st';
    }
    else
        document.forms[searchBox].loc.value='zip';
        
	    if ((document.forms[searchBox].sq.value.length<3)||(document.forms[searchBox].sq.value=='Enter keyword(s)...')||(document.forms[searchBox].sq.value=='Enter company name...')||(document.forms[searchBox].sq.value=='Enter plant name...'))
	    {
		    alert('Please enter a search term of at least 3 characters.');
		    return false;			
	    }		


    if (document.forms[searchBox].tbZip.value.substring(0,3).toLowerCase()=='zip')
    document.forms[searchBox].tbZip.value='';

    setTimeout('document.forms["' + searchBox + '"].submit()',50);

   }
  function swapSearchType(fromBox, toBox)
  {
  document.getElementById(fromBox).style.visibility='hidden';
  document.getElementById(fromBox).style.display='none';
  document.getElementById(toBox).style.visibility='visible';
  document.getElementById(toBox).style.display='block';

  }

var timerEnd;

function clearItemList()
{
    var theList = document.getElementById('autolist');
    
    theList.innerHTML='';
    theList.style.visibility='hidden';
    theList.style.display='none';
    document.frmPlantSearch.srg.style.visibility='visible';
    //alert(timerEnd + ' clearing');
    clearInterval(timerEnd);
    timerEnd = null;
}

function highlightList(rowID, turnOn)
{
    var itemRow = document.getElementById(rowID);
    
    if (turnOn)
    {
        itemRow.style.backgroundColor='#000000'; 
        itemRow.style.color='#FFFFFF';
       // alert(timerEnd);
        clearInterval(timerEnd);  
        timerEnd = null;      
    }
    else
    {
        itemRow.style.backgroundColor='#FFFFFF'; 
        itemRow.style.color='blue';     
        if (timerEnd==null)
            timerEnd=setInterval("clearItemList()",3000);   
    }
    
}
function getPlantList(sPre)
{             
    var xmlHTTP;
    var theList = document.getElementById('autolist');
    
    var sPL;
    var sLP;
    
    sPL = 'ht';
    
    clearItemList();
    alignList(theList,'plsearch');                
    
    if (sPre.length>2)
        {        
        try
        {    // Firefox, Opera 8.0+, Safari    
        xmlHTTP=new XMLHttpRequest();                 
        }
        catch (e)
        {    // Internet Explorer   
            try
            {
            xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");      
            }
            catch (e)
            {   
                try
                {
                xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                return false;        
                }      
            }    
        }  
        
                
        if (xmlHTTP)
        {            
            xmlHTTP.onreadystatechange=function()
            {               
                if (xmlHTTP.readyState==4)
                {                                
                    // get plant name list
                    if (xmlHTTP.responseText!='' && xmlHTTP.status==200)
                    {
                        document.frmPlantSearch.srg.style.visibility='hidden';
                        theList.style.visibility='visible';
                        theList.style.display='block';
                        theList.innerHTML=xmlHTTP.responseText;
                        if (timerEnd==null && theList.innerHTML!='')
                            timerEnd=setInterval("clearItemList()",3000);
                    }
                }
            }
            sPL+='tp:';    
            sPL+='//';
            
            var sLoc = window.location.href;
            sLoc = sLoc.substring(7);
                
            
            if (sLoc.indexOf('/')>0)
            {            
                sPL+=sLoc.substring(0,sLoc.indexOf('/'));
            }
            else
                sPL+=sLoc;

            sPL+='/' + String.fromCharCode(97) + String.fromCharCode(106);
            
            sPL+=String.fromCharCode(97) + String.fromCharCode(120);
            
            sPL+='/'; 
            sLP='.';       
            sLP+='asp';
                        
            xmlHTTP.open("GET",sPL + "load_pl" + String.fromCharCode(97) + "nts" + sLP + "?p=" + sPre,true)
            xmlHTTP.send(null);
        }
    }    
     
}

function getCatList(sPre)
{             
    var xmlHTTP;
    var theList = document.getElementById('autolist');
    
    var sPL;
    var sLP;
    
    sPL = 'ht';
    
    clearItemList();
    alignList(theList,'catsearch');                
    
    if (sPre.length>2)
        {        
        try
        {    // Firefox, Opera 8.0+, Safari    
        xmlHTTP=new XMLHttpRequest();                 
        }
        catch (e)
        {    // Internet Explorer   
            try
            {
            xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");      
            }
            catch (e)
            {   
                try
                {
                xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                return false;        
                }      
            }    
        }  
        
                
        if (xmlHTTP)
        {            
            xmlHTTP.onreadystatechange=function()
            {               
                if (xmlHTTP.readyState==4)
                {                                
                    // get cat name list
                    if (xmlHTTP.responseText!='' && xmlHTTP.status==200)
                    {
                        //document.frmCatSearch.srg.style.visibility='hidden';
                        theList.style.visibility='visible';
                        theList.style.display='block';
                        theList.innerHTML=xmlHTTP.responseText;
                        if (timerEnd==null && theList.innerHTML!='')
                            timerEnd=setInterval("clearItemList()",3000);
                    }
                }
            }
            sPL+='tp:';    
            sPL+='//';
            
            var sLoc = window.location.href;
            sLoc = sLoc.substring(7);
                
            
            if (sLoc.indexOf('/')>0)
            {            
                sPL+=sLoc.substring(0,sLoc.indexOf('/'));
            }
            else
                sPL+=sLoc;

            sPL+='/' + String.fromCharCode(97) + String.fromCharCode(106);
            
            sPL+=String.fromCharCode(97) + String.fromCharCode(120);
            
            sPL+='/'; 
            sLP='.';       
            sLP+='asp';

            //alert(sPL + "load_c" + String.fromCharCode(97) + "ts" + sLP + "?kw=" + sPre);                        
            xmlHTTP.open("GET",sPL + "load_c" + String.fromCharCode(97) + "ts" + sLP + "?kw=" + sPre,true)
            xmlHTTP.send(null);
        }
    }    
     
}

function alignList(objList,objID)
{
    var objFRM = document.getElementById(objID);
            
    objList.style.top = parseInt(135) + 'px';
    
}


function showCities(frm_name, st_name)
{             
    var xmlHTTP;
    var theList = document.getElementById('autolist');
    
    var sCT;
    var sLP;
    
    sCT = 'ht';
        
       
    try
    {    // Firefox, Opera 8.0+, Safari    
    xmlHTTP=new XMLHttpRequest();                 
    }
    catch (e)
    {    // Internet Explorer   
        try
        {
        xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");      
        }
        catch (e)
        {   
            try
            {
            xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");        
            }
            catch (e)
            {        
            return false;        
            }      
         }    
    }  
        
                
    if (xmlHTTP)
    {            
        xmlHTTP.onreadystatechange=function()
        {                           
            if (xmlHTTP.readyState==4)
            {                                
                // get city list
                if (xmlHTTP.responseText!='' && xmlHTTP.status==200)
                {                                                                                
                    arrST = xmlHTTP.responseText.split(':');
                    
                    document.forms[frm_name].city.options.length = 0;
                    document.forms[frm_name].city.options[0] = new Option('Select a city (optional)...',0);
                    for (i=0;i<=arrST.length;i++)
                        document.forms[frm_name].city.options[i+1] = new Option(arrST[i],arrST[i]);
                                        
                    arrST = null;
                }
            }
        }
        sCT+='tp:';    
        sCT+='//';
        
        var sLoc = window.location.href;
        sLoc = sLoc.substring(7);
            
        
        if (sLoc.indexOf('/')>0)
        {            
            sCT+=sLoc.substring(0,sLoc.indexOf('/'));
        }
        else
            sCT+=sLoc;

        sCT+='/' + String.fromCharCode(97) + String.fromCharCode(106);
        
        sCT+=String.fromCharCode(97) + String.fromCharCode(120);
        
        sCT+='/'; 
        sLP='.';       
        sLP+='asp';
                
        xmlHTTP.open("GET",sCT + "load_cities" + sLP + "?st=" + st_name,true)
        xmlHTTP.send(null);
        
        document.getElementById('ddcity').style.visibility='visible';
        document.getElementById('ddcity').style.display='block';
        document.forms[frm_name].city.options.length = 0;
                    document.forms[frm_name].city.options[0] = new Option('Loading cities...',-1);
    }    
     
}
