var isSafari=true;var isMoz=false;var isIE=false;var GLASSFRAME;var POPUP;if(navigator.userAgent.indexOf("Safari")>0){isSafari=true;isMoz=false;isIE=false;}else{if(navigator.product=="Gecko"){isSafari=false;isMoz=true;isIE=false;}else{isSafari=false;isMoz=false;isIE=true;}}function liveUpdater(uriFunc,constructPostParamsFunc,postFunc,preFunc){if(!postFunc){postFunc=function(){};
}if(!preFunc){preFunc=function(){};}return createLiveUpdaterFunction(uriFunc,constructPostParamsFunc,postFunc,preFunc);}function recreateTR(parentElement,subtree){var i;for(i=parentElement.childNodes.length-1;i>=0;i--){parentElement.removeChild(parentElement.childNodes[i]);}for(i=0;i<subtree.childNodes.length;
i++){var cell=document.createElement(subtree.childNodes[i].nodeName);cell.innerHTML=flattenChildren(subtree.childNodes[i].childNodes);parentElement.appendChild(cell);}}function createLiveUpdaterFunction(uriFunc,constructPostParamsFunc,postFunc,preFunc){var request=false;if(window.XMLHttpRequest){request=new XMLHttpRequest();
}function update(){if(request&&request.readyState<4){request.abort();}if(!window.XMLHttpRequest){request=new ActiveXObject("Microsoft.XMLHTTP");}preFunc();request.open("POST",uriFunc(),true);request.onreadystatechange=processRequestChange;request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.setRequestHeader("Accept-Charset","utf-8");request.send(constructPostParamsFunc());return true;}function processRequestChange(){if(request.readyState==4){var xmlDoc=request.responseXML;var body=xmlDoc.getElementsByTagName("body");if(body.length>0){var nodes=body[0].childNodes;for(var i=0;i<nodes.length;
i++){if(nodes[i].nodeType==1){if(isIE&&nodes[i].nodeName=="tr"){recreateTR(POPUP,nodes[i]);}else{POPUP.innerHTML=flattenChildren(nodes[i].childNodes);}}}}postFunc();}}return update;}function autocomplete(id,uri,focus){var inputField=document.getElementById(id);var options=new Array();var current=-1;var initialValue="";
createPopupDivOnce();createGlassFrameOnce();function constructUri(){return uri;}function constructPostParams(){return"s="+inputField.value;}function hidePopup(){POPUP.style.visibility="hidden";if(GLASSFRAME){GLASSFRAME.style.display="none";GLASSFRAME.style.visibility="hidden";}}function handlePopupOver(){removeListener(inputField,"blur",hidePopup);
}function handlePopupOut(){if(POPUP.style.visibility=="visible"){addListener(inputField,"blur",hidePopup);}}function handleClick(e){inputField.value=transformLine(eventElement(e).innerHTML);POPUP.style.visibility="hidden";if(GLASSFRAME){GLASSFRAME.style.display="none";GLASSFRAME.style.visibility="hidden";
}focusAndSetCaret(inputField);}function handleOver(e){if(current>=0&&options[current]){options[current].className="";}current=eventElement(e).index;if(current>=0&&options[current]){options[current].className="selectedAC";}}function postFunc(){current=-1;initialValue=inputField.value;options=POPUP.getElementsByTagName("li");
if((options&&options.length>1)||(options&&options.length==1&&transformLine(options[0].innerHTML)!=inputField.value)){setPopupStyles();for(var i=0;i<options.length;i++){options[i].index=i;addOptionHandlers(options[i]);}}else{POPUP.style.visibility="hidden";if(GLASSFRAME){GLASSFRAME.style.display="none";
GLASSFRAME.style.visibility="hidden";}}}function preFunc(){}function setPopupStyles(){var popupBorder=1;var newPopupTop=mytop(inputField)+inputField.offsetHeight;var newPopupLeft=myleft(inputField)+popupBorder;var newPopupWidth=inputField.offsetWidth-2*popupBorder;if(newPopupWidth<150){newPopupWidth=150;
}var maxHeight;if(isIE){maxHeight=250;}else{maxHeight=window.outerHeight/3;}if(POPUP.offsetHeight<maxHeight){POPUP.style.overflow="hidden";}else{if(isMoz){POPUP.style.maxHeight=maxHeight+"px";POPUP.style.overflow="-moz-scrollbars-vertical";}else{POPUP.style.height=maxHeight+"px";POPUP.style.overflowY="auto";
}}POPUP.scrollTop=0;POPUP.style.top=newPopupTop+"px";POPUP.style.left=newPopupLeft+"px";POPUP.style.width=newPopupWidth+"px";POPUP.style.visibility="visible";if(GLASSFRAME){GLASSFRAME.style.top=newPopupTop+"px";GLASSFRAME.style.left=newPopupLeft+"px";GLASSFRAME.style.height=POPUP.offsetHeight+"px";GLASSFRAME.style.width=(newPopupWidth+2*popupBorder)+"px";
GLASSFRAME.style.display="block";GLASSFRAME.style.visibility="visible";}}function addOptionHandlers(option){addListener(option,"click",handleClick);addListener(option,"mouseover",handleOver);}var updater=liveUpdater(constructUri,constructPostParams,postFunc,preFunc);var timeout=false;function start(e){var event=e||window.event;
if(timeout){window.clearTimeout(timeout);}if(event.keyCode==38){if(current>=0&&options[current]){options[current].className="";}current=current>=0?current-1:options.length-1;if(current==-1){inputField.value=initialValue;}if(current>=0&&options[current]){options[current].className="selectedAC";inputField.value=transformLine(options[current].innerHTML);
}}else{if(event.keyCode==40){if(current>=0&&options[current]){options[current].className="";}current=current<options.length-1?current+1:-1;if(current==-1){inputField.value=initialValue;}if(current>=0&&options[current]){options[current].className="selectedAC";inputField.value=transformLine(options[current].innerHTML);
}}else{if((event.keyCode==13||event.keyCode==9)&&current>=0&&POPUP.style.visibility=="visible"){inputField.value=transformLine(options[current].innerHTML);POPUP.style.visibility="hidden";if(GLASSFRAME){GLASSFRAME.style.display="none";GLASSFRAME.style.visibility="hidden";}if(isIE){event.returnValue=false;
}else{event.preventDefault();}if(event.stopPropagation){event.stopPropagation();}else{event.cancelBubble=true;}}else{if((event.keyCode==27)&&POPUP.style.visibility=="visible"){POPUP.style.visibility="hidden";if(GLASSFRAME){GLASSFRAME.style.display="none";GLASSFRAME.style.visibility="hidden";}if(isIE){event.returnValue=false;
}else{event.preventDefault();}if(event.stopPropagation){event.stopPropagation();}else{event.cancelBubble=true;}}else{timeout=window.setTimeout(updater,300);}}}}}addKeyListener(inputField,start);addListener(POPUP,"mouseover",handlePopupOver);addListener(POPUP,"mouseout",handlePopupOut);if(focus!="nofocus"){focusAndSetCaret(inputField);
}}function focusAndSetCaret(oField){oField.focus();oField.value=oField.value;}function transformLine(txt){return txt.replace("<b>","").replace("</b>","").replace("<B>","").replace("</B>","");}function eventElement(event){var el=isMoz?event.currentTarget:event.srcElement;var elName=el.tagName.toLowerCase();
if(elName=="b"||elName=="i"){el=el.parentNode;}return el;}function addKeyListener(element,listener){if(isSafari){element.addEventListener("keydown",listener,false);}else{if(isMoz){element.addEventListener("keypress",listener,false);}else{element.attachEvent("onkeydown",listener);}}}function addListener(element,type,listener){if(element.addEventListener){element.addEventListener(type,listener,false);
}else{element.attachEvent("on"+type,listener);}}function removeListener(element,type,listener){if(element.removeEventListener){element.removeEventListener(type,listener,false);}else{element.detachEvent("on"+type,listener);}}function flatten(node){if(node.nodeType==1){return"<"+node.nodeName+flattenAttributes(node)+">"+flattenChildren(node.childNodes)+"</"+node.nodeName+">";
}else{if(node.nodeType==3){return node.nodeValue;}else{return"";}}}function flattenAttributes(node){var buffer="";for(var i=0;i<node.attributes.length;i++){var attribute=node.attributes[i];buffer+=" "+attribute.name+'="'+attribute.value+'"';}return buffer;}function flattenChildren(nodes){var buffer="";
if(nodes.length>0){for(var i=0;i<nodes.length;i++){buffer+=flatten(nodes[i]);}}return buffer;}function myleft(elem){var o=elem,r=o.offsetLeft;while(o=o.offsetParent){r+=o.offsetLeft;}return r;}function mytop(elem){var o=elem,r=o.offsetTop;while(o=o.offsetParent){r+=o.offsetTop;}return r;}function createPopupDivOnce(){if(!POPUP){POPUP=document.createElement("div");
POPUP.setAttribute("class","autocomplete");POPUP.setAttribute("className","autocomplete");document.body.appendChild(POPUP);}}function createGlassFrameOnce(){if(isIE&&!GLASSFRAME){GLASSFRAME=document.createElement("iframe");GLASSFRAME.setAttribute("class","autocompletefrm");GLASSFRAME.setAttribute("className","autocompletefrm");
document.body.appendChild(GLASSFRAME);}}
