/*** Author Natalia Bazhenova www.fh54.de (c) 2005 ***/
	
/********************************/
/*******start config****************/
/*******************************/
//array with suggest texts
var opttext=new Array(); 
//fill array 
opttext[0]="5th Avenue"
opttext[1]="academic credit"
opttext[2]="Air and Space Museum"
opttext[3]="airboat ride"
opttext[4]="Alcatraz"
opttext[5]="Alexandria"
opttext[6]="American Museum of Natural History"
opttext[7]="American River"
opttext[8]="Amish Country"
opttext[9]="Animal Kingdom"
opttext[10]="Annapolis"
opttext[11]="Arenal Observatory Lodge"
opttext[12]="Arenal Volcano"
opttext[13]="Arlington National Cemetery"
opttext[14]="Astronaut Hall of Fame"
opttext[15]="Baltimore"
opttext[16]="Barrier Island"
opttext[17]="Boston"
opttext[18]="Broadway"
opttext[19]="Brooklyn Bridge"
opttext[20]="Bureau of Engraving and Printing"
opttext[21]="Butterfly Garden"
opttext[22]="cable cars"
opttext[23]="Caladesi Island"
opttext[24]="California"
opttext[25]="California State Capitol"
opttext[26]="California State Railroad Museum"
opttext[27]="California Vietnam Veterans Memorial"
opttext[28]="canopy tour"
opttext[29]="Capitol Building"
opttext[30]="Cathedral of St. John the Divine"
opttext[31]="Central Park"
opttext[32]="Challenger Memorial"
opttext[33]="Changing of the Guard"
opttext[34]="Charlottesville"
opttext[35]="Chinatown"
opttext[36]="Cloud Forest Reserve"
opttext[37]="Coloma"
opttext[38]="Colonial Williamsburg"
opttext[39]="Concord"
opttext[40]="Costa Rica"
opttext[41]="Costa Rica presentation"
opttext[42]="Costa Rican cooking"
opttext[43]="Costa Rican dancing"
opttext[44]="Crystal River"
opttext[45]="Crystal River National Wildlife Refuge"
opttext[46]="D.C."
opttext[47]="Daniel’s Story"
opttext[48]="Discover D.C."
opttext[49]="Discovering Our Golden State"
opttext[50]="Discovering Our Past"
opttext[51]="Discovery Cove"
opttext[52]="Discovery for Credit"
opttext[53]="Discovery Mountain"
opttext[54]="Disney"
opttext[55]="Dive In"
opttext[56]="Dolphin swim"
opttext[57]="Dolphins Plus"
opttext[58]="Egmont Key"
opttext[59]="Ellis Island"
opttext[60]="Ellis Island"
opttext[61]="Embassy Row"
opttext[62]="Empire State Building"
opttext[63]="entertainment"
opttext[64]="Epcot"
opttext[65]="ePostcard"
opttext[66]="Everglades National Park"
opttext[67]="Everglades Safari Park"
opttext[68]="Exploratorium"
opttext[69]="FDR Memorial"
opttext[70]="Federal Hall National Memorial"
opttext[71]="Fifth Avenue"
opttext[72]="flight"
opttext[73]="Florida"
opttext[74]="Florida Aquarium"
opttext[75]="Ford’s Theatre"
opttext[76]="Fort DeSoto"
opttext[77]="Freedom Trail"
opttext[78]="Frog Pond"
opttext[79]="fundraising"
opttext[80]="games"
opttext[81]="Garden Cove Kayak Trip"
opttext[82]="George Washington"
opttext[83]="Gettysburg"
opttext[84]="Gold Country"
opttext[85]="Greenwich Village"
opttext[86]="Ground Zero"
opttext[87]="Habitat H20"
opttext[88]="Harlem"
opttext[89]="Harpers Ferry"
opttext[90]="Historic Triangle"
opttext[91]="historical"
opttext[92]="history"
opttext[93]="Holocaust Museum"
opttext[94]="Homosassa Springs"
opttext[95]="Homosassa Springs State Wildlife Park"
opttext[96]="INBioparque"
opttext[97]="Intrepid Sea-Air-Space Museum"
opttext[98]="Island Dolphin Care Center"
opttext[99]="Iwo Jima"
opttext[100]="Jamestown"
opttext[101]="Jefferson Memorial"
opttext[102]="John Pennekamp Coral Reef State Park"
opttext[103]="John Sutter"
opttext[104]="kayak trip"
opttext[105]="Kennedy Center"
opttext[106]="Kennedy Gravesites"
opttext[107]="Kennedy Space Center"
opttext[108]="Key Largo"
opttext[109]="Korean Memorial"
opttext[110]="Land Pavilion at Epcot"
opttext[111]="Lexington"
opttext[112]="Library of Congress"
opttext[113]="Lido Beach"
opttext[114]="Lincoln Center"
opttext[115]="Lincoln Memorial"
opttext[116]="Little Italy"
opttext[117]="Living Seas Pavillion"
opttext[118]="Magic Kingdom"
opttext[119]="Make New York Yours"
opttext[120]="Marshall Gold Discovery Park"
opttext[121]="Martin Luther King, Jr."
opttext[122]="memorials"
opttext[123]="merchandise"
opttext[124]="Metropolitan Museum of Art"
opttext[125]="Miami Seaquarium"
opttext[126]="Mini Golf"
opttext[127]="money"
opttext[128]="Monteverde Butterfly Garden"
opttext[129]="Monteverde Canopy Tour"
opttext[130]="Monteverde Cloud Forest"
opttext[131]="Monteverde Frog Pond"
opttext[132]="MOSI"
opttext[133]="Mote Marine Lab"
opttext[134]="Mount Vernon"
opttext[135]="Museum of Natural History"
opttext[136]="Museum of Science and Industry"
opttext[137]="Myakka River State Park"
opttext[138]="MyTrip"
opttext[139]="National Air and Space Museum"
opttext[140]="National Archives"
opttext[141]="National Cathedral"
opttext[142]="National Gallery of Art"
opttext[143]="National Portrait Gallery"
opttext[144]="National Postal Museum"
opttext[145]="National Zoo"
opttext[146]="Native American"
opttext[147]="Natural History Museum"
opttext[148]="Naval Museum"
opttext[149]="Neil Armstrong"
opttext[150]="New York City"
opttext[151]="New York Stock Exchange"
opttext[152]="Nimbus Fish Factory"
opttext[153]="Old Sacramento Schoolhouse Museum"
opttext[154]="Old Schoolhouse Museum"
opttext[155]="Olde Coloma Theatre"
opttext[156]="Orlando"
opttext[157]="packing list"
opttext[158]="panning for gold"
opttext[159]="Penguin Encounter"
opttext[160]="personality quiz"
opttext[161]="Petersen House"
opttext[162]="Philadelphia"
opttext[163]="photos"
opttext[164]="pictures"
opttext[165]="Pier 39"
opttext[166]="pioneer camp"
opttext[167]="Plymouth"
opttext[168]="postcards"
opttext[169]="Powhatan Indian Village"
opttext[170]="program" 
opttext[171]="questions"
opttext[172]="quiz"
opttext[173]="Radio City Music Hall"
opttext[174]="Railroad Museum"
opttext[175]="Rainbow River" 
opttext[176]="real students"
opttext[177]="reef"
opttext[178]="register"
opttext[179]="Rockefeller Center"
opttext[180]="Rockefeller Plaza"
opttext[181]="Sacramento"
opttext[182]="Salem"
opttext[183]="San Francisco"
opttext[184]="San Jose"
opttext[185]="San Jose"
opttext[186]="Sandra Day O’Connor"
opttext[187]="Sarapiqui"
opttext[188]="Sarapiqui River"
opttext[189]="Sarasota"
opttext[190]="Sarchi"
opttext[191]="science"
opttext[192]="Science in Motion"
opttext[193]="SeaWorld"
opttext[194]="shark dissection"
opttext[195]="Shark Valley"
opttext[196]="Smithsonian Institution"
opttext[197]="snorkel"
opttext[198]="South Street Seaport"
opttext[199]="Splash into Science"
opttext[200]="St. Patrick’s Cathedral"
opttext[201]="Statue of Liberty"
opttext[202]="student photos"
opttext[203]="Supreme Court"
opttext[204]="Susan B. Anthony"
opttext[205]="Sutter’s Fort"
opttext[206]="swim with dolphins"
opttext[207]="swim with manatees"
opttext[208]="Tampa"
opttext[209]="Thomas Edison"
opttext[210]="Thomas Jefferson"
opttext[211]="Times Square"
opttext[212]="Tinsmith"
opttext[213]="Tirimbina Rainforest Center"
opttext[214]="Tomb of the Unknown Soldier"
opttext[215]="tour"
opttext[216]="Travelers Photos"
opttext[217]="Trinity Church"
opttext[218]="trivia"
opttext[219]="t-shirts"
opttext[220]="Turtle Hospital"
opttext[221]="U.S. Capitol"
opttext[222]="United Nations"
opttext[223]="United States Marine Corps Memorial"
opttext[224]="Valley Forge"
opttext[225]="Vietnam Veterans Memorial"
opttext[226]="Vietnam Wall"
opttext[227]="virtual tour"
opttext[228]="Volcanic Hot Springs"
opttext[229]="Volcanic Springs"
opttext[230]="Volcano"
opttext[231]="wagon ride"
opttext[232]="Wall Street"
opttext[233]="Washington Monument"
opttext[234]="Washington, D.C."
opttext[235]="weather"
opttext[236]="White House"
opttext[237]="white water rafting"
opttext[238]="Williamsburg"
opttext[239]="World War II Memorial"
opttext[240]="Yorktown"
opttext[241]="zipline"


//id of the textbox element
var inputID="look_for"
//max size of "selectbox"
var maxcount=5 
/*******************************/
/**********end config***********/
/*******************************/

opttext.sort();
var scripting=false;
//initialize:
//for mozilla
if (window.captureEvents) {
    window.captureEvents(Event.LOAD)
    window.onload=suggestInput_init;
	}
//for ie
document.onreadystatechange=ieInit;
function ieInit()
{
   if (document.readyState=="complete")
   {
      document.body.onload=function() {suggestInput_init()}
   }
}
var SIs
var SItxt
var newdiv=document.createElement("DIV")
var globalN=0; //how much options scrolled up
//for ie
if (document.attachEvent)
document.attachEvent("onclick",hideSelect)
// for Mozilla
if (document.captureEvents) {
document.captureEvents(Event.CLICK);
document.onclick = hideSelect;
}
function hideSelect() {
newdiv.style.display="none"
}
function suggestInput_init() {
if (document.createElement("DIV")) {
scripting=true;
SIs=document.createElement("SELECT")
SIs.onkeyup=function(e){if(!e) e=event; setInputValue(this.selectedIndex,e)}
SIs.className="select_input"
SIs.setAttribute("id","selectInput");
SIs.style.position="absolute"
SIs.style.top="-9999px"
SIs.style.left="-9999px"
SIs.style.visibility="hidden"
document.body.appendChild(SIs)
SItxt =document.getElementById(inputID);
 SItxt.setAttribute("autocomplete","OFF")
 SItxt.onkeyup=function(e){if (!e) e=event; showSelection(this.value,e)}
SItxt.focus()
for (i=0;i<opttext.length;i++) {
o=document.createElement("OPTION");;
o.innerHTML=opttext[i];
SIs.appendChild(o)
SIs.style.visibility="visible"; // for Opera
}
// find the actual position of the input element 
topdiv=0;leftdiv=0; elt=SItxt 
do {
 b=(elt.style.borderTopWidth)?(elt.style.borderTopWidth):(0)
 b=(b)?(parseInt(b.substring(0,b.length-2))):(0);
 p=(elt.style.paddingTop)?(elt.style.paddingTop):(0);
 p=(p)?(parseInt(p.substring(0,p.length-2))):(0)
 b2=(elt.style.borderLeftWidth)?(elt.style.borderLeftWidth):(0)
 b2=(b2)?(parseInt(b2.substring(0,b2.length-2))):(0);
 p2=(elt.style.paddingLeft)?(elt.style.paddingLeft):(0);
 p2=(p2)?(parseInt(p2.substring(0,p2.length-2))):(0)
 try {
 topdiv+=elt.offsetTop+b+p; leftdiv+=elt.offsetLeft+b2+p2;  } catch(err) {} elt=elt.offsetParent; 
   } 
  while (elt.tagName!="BODY")
  
topdiv+=SItxt.offsetHeight
widthdiv=SItxt.offsetWidth

newdiv.style.backgroundColor="#ffffff"
newdiv.style.position="absolute"
newdiv.style.zIndex="100"
newdiv.style.border="1px solid black"
newdiv.style.top=topdiv;newdiv.style.left=leftdiv;newdiv.style.width=widthdiv;
newdiv.style.display="none"
buildDiv(0)
document.body.appendChild(newdiv)
 }
} 
 
function buildDiv(n) {
if (n>SIs.childNodes.length) return false; 
for (i=0;i<newdiv.childNodes.length;i++)
{newdiv.removeChild(newdiv.childNodes[i]);i--}
if (n>0) {// insert top "..." - div
d1=document.createElement("DIV");
d1.id="lessDiv"
d1.style.width="100%"
d1.style.fontSize="0.8em"
d1.onmouseover=function() {this.style.backgroundColor="#000099";this.style.color="#ffffff"}
d1.onmouseout=function() {this.style.backgroundColor="#ffffff";this.style.color="#686868"}
d1.onclick=function() {buildDiv(n-1);
d1.style.backgroundColor="#000099";d1.style.color="#ffffff"
} 
d1.innerHTML="......"; 
newdiv.appendChild(d1); 
}
m=(maxcount<SIs.childNodes.length)?(maxcount):(SIs.childNodes.length)
for(i=0;i<m;i++) {
d=document.createElement("DIV")
d.style.width="100%"
d.style.fontSize="0.8em"
d.onmouseover=function() {
	this.style.backgroundColor="#000099";this.style.color="#ffffff";
	SItxt.value=this.innerHTML
}
d.onmouseout=function() {this.style.backgroundColor="#ffffff";this.style.color="#686868"}
d.onclick=function() {SItxt.value=this.innerHTML;newdiv.style.display="none"}
try {d.innerHTML=SIs.childNodes[i+n].innerHTML;}
catch(err) {}
newdiv.appendChild(d)
};
globalN=n;
if (SIs.childNodes.length-n>maxcount) {// insert bottom "..." - div
d2=document.createElement("DIV");
d2.id="moreDiv"
d2.style.width="100%"
d2.style.fontSize="0.8em"
d2.onmouseover=function() {this.style.backgroundColor="#000099";this.style.color="#ffffff"}
d2.onmouseout=function() {this.style.backgroundColor="#ffffff";this.style.color="#686868"}
d2.onclick=function() {
 buildDiv(n+1); d2.style.backgroundColor="#000099";d2.style.color="#ffffff"
  }
 d2.innerHTML="......"; d2.style.backgroundColor="#ffffff";d2.style.color="#686868"
 newdiv.appendChild(d2) } 
 }
 
function setInputValue(m,ev) {
if (!scripting) return;
isLess=(document.getElementById("lessDiv"))?(1):(0)
if (m>globalN+maxcount+isLess+1) {m=globalN+maxcount;SIs.selectedIndex=m}
if (m<isLess) {m=globalN-1;SIs.selectedIndex=globalN-1}
a=SIs.childNodes[m].innerHTML
SItxt.value=a;
try {
if (newdiv.childNodes[m-globalN+isLess]) {  if (newdiv.childNodes[m-globalN+isLess].id=="moreDiv") {  buildDiv(globalN+1);  
newdiv.childNodes[maxcount].style.backgroundColor="#000099";
newdiv.childNodes[maxcount].style.color="#ffffff"
return
  }
 }
} catch (err) {}
try {
if (newdiv.childNodes[m-globalN+isLess]) {  if (newdiv.childNodes[m-globalN+isLess].id=="lessDiv") {  buildDiv(globalN-1);
 isLess_new=(document.getElementById("lessDiv"))?(1):(0)
 newdiv.childNodes[isLess_new].style.backgroundColor="#000099";
 newdiv.childNodes[isLess_new].style.color="#ffffff"
 return
  }
 }
} catch (err) {}
try {
for (i=0;i<newdiv.childNodes.length;i++)
{
newdiv.childNodes[i].style.backgroundColor="#ffffff";
newdiv.childNodes[i].style.color="#686868";
}
 newdiv.childNodes[m-globalN+isLess].style.backgroundColor="#000099";
 newdiv.childNodes[m-globalN+isLess].style.color="#ffffff"
} catch(err) {};
 
if ((ev.keyCode!=40) && (ev.keyCode!=38) && (ev.keyCode!=0)) // if not arrow down, arrow up or mouseclick  
{
  newdiv.style.display="none"
  SItxt.focus();
 }
}
 
function showSelection(t,ev) {
if (!scripting) return;
if (ev.keyCode==40) { //with arrow down comes into suggestion select
 if (SIs.childNodes.length>0)
 {
  newdiv.childNodes[0].style.backgroundColor="#000099"
  newdiv.childNodes[0].style.color="#ffffff"
  SItxt.value=SIs.childNodes[0].innerHTML; 
  try {SIs.focus();} catch(err){}
  SIs.childNodes[0].selected=true;
 }
  return            }
if (t=="") { return ;}
t=t.toLowerCase();
l=t.length; 
for (i=0;i<SIs.childNodes.length;i++) {SIs.removeChild(SIs.childNodes[i]);i--}
for(i=0;i<opttext.length;i++)
{
 if (opttext[i].substr(0,l).toLowerCase()==t)
 {
  oOption = document.createElement("OPTION");
  SIs.appendChild(oOption)
  oOption.innerHTML = opttext[i];
 }
}
if (SIs.childNodes.length>0)  {
newdiv.style.display=""
buildDiv(0)
 } else newdiv.style.display="none";
SItxt.focus()
}
 