
var suggestions=new Array("Boris","Bäcker","Peter","Test","Bums");var outp;var oldins;var posi=-1;var words=new Array();var input;var key;var ph;var xmlhttp;function DoLookup(myPH)
{oEvent=window.event;if(oEvent==null)
{KeyUp(myPH);return;}
var iKeyCode=oEvent.keyCode;if(iKeyCode==8||iKeyCode==46)
{KeyUp(myPH);}
else if(iKeyCode<32||(iKeyCode>=33&&iKeyCode<46)||(iKeyCode>=112&&iKeyCode<=123))
{}
else
{KeyUp(myPH);}}
function KeyUp(myPH){ph=window.document.getElementById(myPH);if(xmlhttp!=null)
{if(xmlhttp.readyState!=0)
xmlhttp.abort();xmlhttp=null;}
var url="";if(document.forms[0]==null)
{url="http://www.ticketnest.com/searchquery.php?searchedWord=&returnedRecord=50&category=a";return;}
else
{url="http://www.ticketnest.com/searchquery.php?searchedWord="+document.forms[0].text.value+"&returnedRecord=50&category=a";}
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();xmlhttp.onreadystatechange=FindPlaceRquestCallBack;xmlhttp.open("GET",url,true);xmlhttp.send(null);}
else if(window.ActiveXObject)
{try
{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{try
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){}}
if(xmlhttp)
{try
{xmlhttp.onreadystatechange=FindPlaceRquestCallBack;xmlhttp.open("GET",url,true);xmlhttp.send();}
catch(e){}}}}
var customarray=new Array('alman','an apple','alligator','elephant','pear','kingbird','kingbolt','kingcraft','kingcup','kingdom','kingfisher','kingpin');var obj=null;function FindPlaceRquestCallBack()
{if(xmlhttp.readyState==4&&xmlhttp.status==200)
{var row=xmlhttp.responseText;row=row.substr(row.indexOf("[")+1,row.lastIndexOf("]")-1);suggestions=row.split(",");words=suggestions;init();lookAt();}}
function btn(tf)
{if(tf.value.length!=0)
{if(document.getElementById("dhtmlgoodies_q1")!=null)
{document.getElementById("dhtmlgoodies_q1").style.visibility="hidden";document.getElementById("dhtmlgoodies_q1").style.display="none";document.getElementById("sub2").style.display="block";document.getElementById("sub2").style.visibility="visible";}}
else
{if(document.getElementById("dhtmlgoodies_q1")!=null)
{document.getElementById("dhtmlgoodies_q1").style.visibility="visible";document.getElementById("dhtmlgoodies_q1").style.display="block";document.getElementById("sub2").style.display="none";document.getElementById("sub2").style.visibility="hidden";}}}
function display()
{var x=document.getElementById("answer");if(x.style.visibility=="hidden")
{x.style.visibility="visible";}}
function Go()
{var txt_search=document.forms[0].text.value;if(document.forms[0].text.value=='')
{document.forms[0].text.focus();setVisible("hidden");setVisibleOPT("hidden");display();return 0;}
if(txt_search=="Type in Cities, and press Search")
{document.forms[0].text.focus();return 0;}
else if(txt_search=="Type in Event, and press Search")
{document.forms[0].text.focus();return 0;}
else if(txt_search=="Type in Venues and press Search")
{document.forms[0].text.focus();return 0;}
else if(txt_search=="Type in City, Venue or Events and press Search")
{document.forms[0].text.focus();return 0;}
document.forms[0].action="http://www.ticketnest.com/searchresult.php?kwds="+txt_search.replace(" (Event)","").replace(" (City)","").replace(" (Venue)","");+"& category=a";document.forms[0].submit();}
function CheckForGo()
{var x=document.getElementById("output");if(x.style.visibility=="visible")
{}
else
{Go();}}
function setVisible(visi){var x=document.getElementById("shadow");var t=document.getElementsByName("text")[0];x.style.position='absolute';x.style.top=(findPosY(t)+3)+"px";x.style.left=(findPosX(t)+3)+"px";x.style.visibility=visi;x.style.width="250px";}
function setVisibleOPT(visi)
{var x=document.getElementById("output");x.style.fontFamily="tahoma";x.style.fontSize="9pt";x.style.color="#666666";x.style.paddingLeft="6px";x.style.paddingTop="3px";x.style.border="1px solid #000000";x.style.width="310px";x.style.background="#F5F5F5";x.style.overflow="auto";x.style.height="250px";x.style.visibility=visi;}
function init(){outp=document.getElementById("output");setVisible("hidden");document.onkeydown=keygetter;document.onkeyup=keyHandler;}
function findPosX(obj)
{var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;return curleft;}
function findPosY(obj)
{var curtop=0;if(obj.offsetParent){curtop+=obj.offsetHeight;while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}
else if(obj.y){curtop+=obj.y;curtop+=obj.height;}
return curtop;}
function lookAt(){var ins=document.getElementsByName("text")[0].value;if(oldins==ins)return;else if(posi>-1);else if(ins.length>0){setVisibleOPT("visible");if(words.length>0){clearOutput();for(var i=0;i<words.length;++i)addWord(words[i]);setVisible("visible");input=document.getElementsByName("text")[0].value;}
else{setVisible("hidden");posi=-1;}}
else{setVisible("hidden");document.getElementById("shadow").style.visibility="hidden";document.getElementById("output").style.visibility="hidden";posi=-1;}
oldins=ins;}
function addWord(word){var sp=document.createElement("div");sp.appendChild(document.createTextNode(word));sp.onmouseover=mouseHandler;sp.onmouseout=mouseHandlerOut;sp.onclick=mouseClick;outp.appendChild(sp);}
function clearOutput(){while(outp.hasChildNodes()){noten=outp.firstChild;outp.removeChild(noten);}
posi=-1;}
function getWord(beginning){var words=new Array();for(var i=0;i<suggestions.length;++i){var j=-1;var correct=1;while(correct==1&&++j<beginning.length){if(suggestions[i].charAt(j)!=beginning.charAt(j))correct=0;}
if(correct==1)words[words.length]=suggestions[i];}
return words;}
function setColor(_posi,_color,_forg){if(outp.childNodes[_posi]!=null)
{outp.childNodes[_posi].style.background=_color;outp.childNodes[_posi].style.color="#666666";}}
function keygetter(event){if(!event&&window.event)event=window.event;if(event)key=event.keyCode;else key=event.which;}
function keyHandler(event){if(document.getElementById("shadow").style.visibility=="visible"){var textfield=document.getElementsByName("text")[0];if(key==13)
{textfield.value=textfield.value.replace(" (Event)","").replace(" (City)","").replace(" (Venue)","");setVisibleOPT("hidden");setVisible("hidden");posi=-1;oldins=input;}
else if(key==40){if(words.length>0&&posi<words.length-1){if(posi>=0)setColor(posi,"#fff","black");else input=textfield.value;setColor(++posi,"blue","white");if(posi>0)
{textfield.value=outp.childNodes[posi].firstChild.nodeValue;if(posi>3)
document.getElementById("output").scrollTop+=10;if(posi>30)
{document.getElementById("output").scrollTop+=5;}
if(posi>50)
{document.getElementById("output").scrollTop+=4;}}
else
{var pos=0;pos=posi;textfield.value=outp.childNodes[++pos].firstChild.nodeValue;}}}
else if(key==38){if(words.length>0&&posi>=0){if(posi>=1){setColor(posi,"#fff","black");setColor(--posi,"blue","white");textfield.value=outp.childNodes[posi].firstChild.nodeValue;if(posi>3)
{document.getElementById("output").scrollTop-=7;}
else
{document.getElementById("output").scrollTop=0;}}
else{setColor(posi,"#fff","black");textfield.value=input;textfield.focus();posi--;}}}
else if(key==27){textfield.value=input;setVisible("hidden");setVisibleOPT("hidden");posi=-1;oldins=input;}
else if(key==8){posi=-1;oldins=-1;}}}
var mouseHandler=function(){for(var i=0;i<words.length;++i)
setColor(i,"white","black");this.style.background="blue";this.style.color="white";}
var mouseHandlerOut=function(){this.style.background="white";this.style.color="black";}
var mouseClick=function(){document.getElementsByName("text")[0].value=this.firstChild.nodeValue.replace(" (Event)","").replace(" (City)","").replace(" (Venue)","");setVisibleOPT("hidden");setVisible("hidden");posi=-1;oldins=this.firstChild.nodeValue;}