var collection=new Array();var isCommaDelimiter=true;function freezeEvent(b){if(b.preventDefault){b.preventDefault()}b.returnValue=false;b.cancelBubble=true;if(b.stopPropagation){b.stopPropagation()}return false}function isWithinNode(g,d,h,b,f){answer=false;te=g;while(te&&!answer){if((te.id&&(te.id==d))||(te.className&&(te.className==d+"Class"))||(!b&&h&&te.className&&(te.className==h))||(!b&&h&&te.className&&(te.className.indexOf(h)!=-1))||(b&&te.tagName&&(te.tagName.toLowerCase()==b))||(f&&(te==f))){answer=te}else{te=te.parentNode}}return te}function getEvent(b){return(b?b:window.event)}function getEventElement(b){return(b.srcElement?b.srcElement:(b.target?b.target:b.currentTarget))}function findElementPosX(b){curleft=0;if(b.offsetParent){while(b.offsetParent){curleft+=b.offsetLeft;b=b.offsetParent}}else{if(b.x){curleft+=b.x}}if(b.offsetLeft!=undefined&&siw.isWinIE){curleft+=b.offsetLeft}return curleft}function findElementPosY(b){curtop=0;if(b.offsetParent){while(b.offsetParent){curtop+=b.offsetTop;b=b.offsetParent}}else{if(b.y){curtop+=b.y}}return curtop}function handleKeyPress(b){e=getEvent(b);eL=getEventElement(e);if(typeof handleKeyUpCustom!="undefined"){handleKeyUpCustom(eL)}upEl=isWithinNode(eL,null,"wickEnabled",null,null);kc=e.keyCode;if(siw&&((kc==13))){siw.selectingSomething=true;if(siw.isSafari){siw.inputBox.blur()}siw.inputBox.focus();siw.inputBox.value=siw.inputBox.value.replace(/[ \r\n\t\f\s]+$/gi," ");hideSmartInputFloater();freezeEvent(e)}else{if(upEl&&(kc!=38)&&(kc!=40)&&(kc!=37)&&(kc!=39)&&(kc!=13)&&(kc!=27)){if(!siw||(siw&&!siw.selectingSomething)){processSmartInput(upEl)}}else{if(siw&&siw.inputBox){siw.inputBox.focus()}}}}function handleKeyDown(b){e=getEvent(b);eL=getEventElement(e);if(siw&&(kc=e.keyCode)){if(kc==40){siw.selectingSomething=true;freezeEvent(e);if(siw.isGecko){siw.inputBox.blur()}selectNextSmartInputMatchItem()}else{if(kc==38){siw.selectingSomething=true;freezeEvent(e);if(siw.isGecko){siw.inputBox.blur()}selectPreviousSmartInputMatchItem()}else{if((kc==13)){siw.selectingSomething=true;activateCurrentSmartInputMatch();freezeEvent(e)}else{if(kc==27){hideSmartInputFloater();freezeEvent(e)}else{siw.selectingSomething=false}}}}}}function handleFocus(b){e=getEvent(b);eL=getEventElement(e);if(typeof handleFocusCustom!="undefined"){handleFocusCustom(eL)}if(focEl=isWithinNode(eL,null,"wickEnabled",null,null)){if(!siw||(siw&&!siw.selectingSomething)){processSmartInput(focEl)}}}function handleBlur(b){e=getEvent(b);eL=getEventElement(e);if(typeof handleBlurCustom!="undefined"){handleBlurCustom(eL)}if(blurEl=isWithinNode(eL,null,"wickEnabled",null,null)){if(siw&&!siw.selectingSomething){hideSmartInputFloater()}}}function handleClick(b){e2=getEvent(b);eL2=getEventElement(e2);if(siw&&siw.selectingSomething){selectFromMouseClick()}}function handleMouseOver(b){e=getEvent(b);eL=getEventElement(e);if(siw&&(mEl=isWithinNode(eL,null,"matchedSmartInputItem",null,null))){siw.selectingSomething=true;selectFromMouseOver(mEl)}else{if(isWithinNode(eL,null,"siwCredit",null,null)){siw.selectingSomething=true}else{if(siw){siw.selectingSomething=false}}}}function showSmartInputFloater(){if(!siw.floater.style.display||(siw.floater.style.display=="none")){if(!siw.customFloater){x=findElementPosX(siw.inputBox);y=findElementPosY(siw.inputBox)+siw.inputBox.offsetHeight;if(!siw.isGecko&&!siw.isWinIE){x+=8}if(!siw.isGecko&&!siw.isWinIE){y+=10}siw.floater.style.left=x+"px";siw.floater.style.top=y+"px"}else{}siw.floater.style.display="block";siw.floater.style.visibility="visible";if(typeof showFloaterCustom!="undefined"){showFloaterCustom()}}}function hideSmartInputFloater(){if(siw){siw.floater.style.display="none";siw.floater.style.visibility="hidden";siw=null;if(typeof hideFloaterCustom!="undefined"){hideFloaterCustom()}}}function processSmartInput(b){if(!siw){siw=new smartInputWindow()}siw.inputBox=b;siw.autoShow=b.accept;classData=b.className.split(" ");siwDirectives=null;for(i=0;(!siwDirectives&&classData[i]);i++){if(classData[i].indexOf("wickEnabled")!=-1){siwDirectives=classData[i]}}if(siwDirectives&&(siwDirectives.indexOf(":")!=-1)){siw.customFloater=true;newFloaterId=siwDirectives.split(":")[1];siw.floater=document.getElementById(newFloaterId);siw.floaterContent=siw.floater.getElementsByTagName("div")[0]}setSmartInputData();if(siw.matchCollection&&(siw.matchCollection.length>0)){selectSmartInputMatchItem(0)}content=getSmartInputBoxContent();if(content){modifySmartInputBoxContent(content);showSmartInputFloater()}else{hideSmartInputFloater()}}function smartInputMatch(b,d){this.cleanValue=b;this.value=d;this.isSelected=false}function simplify(b){return b.toLowerCase().replace(/^[ \s\f\t\n\r]+/,"").replace(/[ \s\f\t\n\r]+$/,"")}function getUserInputToMatch(b){a=b;if(isCommaDelimiter){fields=b.split(",");if(fields.length>0){a=fields[fields.length-1]}}return a}function getUserInputBase(){s=siw.inputBox.value;a=s;if((lastComma=s.lastIndexOf(","))!=-1){a=a.replace(/^(.*\,[ \r\n\t\f\s]*).*$/i,"$1")}else{a=""}return a}function runMatchingLogic(d,b){d=simplify(d);uifc=d.charAt(0).toLowerCase();if(uifc=='"'){uifc=(n=d.charAt(1))?n.toLowerCase():"z"}if(b){d=uifc}if(siw){siw.matchCollection=new Array()}pointerToCollectionToUse=collection;if(siw&&siw.revisedCollection&&(siw.revisedCollection.length>0)&&siw.lastUserInput&&(d.indexOf(siw.lastUserInput)==0)){pointerToCollectionToUse=siw.revisedCollection}else{if(collectionIndex[d]&&(collectionIndex[d].length>0)){pointerToCollectionToUse=collectionIndex[d]}else{if(collectionIndex[uifc]&&(collectionIndex[uifc].length>0)){pointerToCollectionToUse=collectionIndex[uifc]}else{if(siw&&(d.length==1)&&(!collectionIndex[uifc])){siw.buildIndex=true}else{if(siw){siw.buildIndex=false}}}}}pointerToCollectionToUse=collection;tempCollection=new Array();re1m=new RegExp('^([ "><-]*)('+d+")","i");re2m=new RegExp('([ "><-]+)('+d+")","i");re1=new RegExp('^([ "}{-]*)('+d+")","gi");re2=new RegExp('([ "}{-]+)('+d+")","gi");for(i=0,j=0;(i<pointerToCollectionToUse.length);i++){displayMatches=((!b)&&(j<siw.MAX_MATCHES));entry=pointerToCollectionToUse[i];mEntry=simplify(entry);if(!b&&(mEntry.indexOf(d)==0)){d=d.replace(/\>/gi,"\\}").replace(/\< ?/gi,"\\{");re=new RegExp("("+d+")","i");if(displayMatches){siw.matchCollection[j]=new smartInputMatch(entry,mEntry.replace(/\>/gi,"}").replace(/\< ?/gi,"{").replace(re,"<b>$1</b>"))}tempCollection[j]=entry;j++}else{if(mEntry.match(re1m)||mEntry.match(re2m)){if(!b&&displayMatches){siw.matchCollection[j]=new smartInputMatch(entry,mEntry.replace(/\>/gi,"}").replace(/\</gi,"{").replace(re1,"$1<b>$2</b>").replace(re2,"$1<b>$2</b>"))}tempCollection[j]=entry;j++}}}if(siw){siw.lastUserInput=d;siw.revisedCollection=tempCollection.join(",").split(",");collectionIndex[d]=tempCollection.join(",").split(",")}if(b||siw.buildIndex){collectionIndex[uifc]=tempCollection.join(",").split(",");if(siw){siw.buildIndex=false}}}function setSmartInputData(){if(siw){orgUserInput=siw.inputBox.value;orgUserInput=getUserInputToMatch(orgUserInput);userInput=orgUserInput.toLowerCase().replace(/[\r\n\t\f\s]+/gi," ").replace(/^ +/gi,"").replace(/ +$/gi,"").replace(/ +/gi," ").replace(/\\/gi,"").replace(/\[/gi,"").replace(/\(/gi,"").replace(/\./gi,".").replace(/\?/gi,"");if((siw.autoShow||userInput&&(userInput!=""))&&(userInput!='"')){runMatchingLogic(userInput)}else{siw.matchCollection=null}}}function getSmartInputBoxContent(){a=null;if(siw&&siw.matchCollection&&(siw.matchCollection.length>0)){a="";for(i=0;i<siw.matchCollection.length;i++){selectedString=siw.matchCollection[i].isSelected?" selectedSmartInputItem":"";a+='<p class="matchedSmartInputItem'+selectedString+'">'+siw.matchCollection[i].value.replace(/\{ */gi,"&lt;").replace(/\} */gi,"&gt;")+"</p>"}}return a}function modifySmartInputBoxContent(b){siw.floaterContent.innerHTML='<div id="smartInputResults">'+b+(siw.showCredit?('<p class="siwCredit">Powered By: <a target="PhrawgBlog" href="http://chrisholland.blogspot.com/?from=smartinput&ref='+escape(location.href)+'">Chris Holland</a></p>'):"")+"</div>";siw.matchListDisplay=document.getElementById("smartInputResults")}function selectFromMouseOver(b){currentIndex=getCurrentlySelectedSmartInputItem();if(currentIndex!=null){deSelectSmartInputMatchItem(currentIndex)}newIndex=getIndexFromElement(b);selectSmartInputMatchItem(newIndex);modifySmartInputBoxContent(getSmartInputBoxContent())}function selectFromMouseClick(){siw.inputBox.focus();activateCurrentSmartInputMatch();hideSmartInputFloater()}function getIndexFromElement(b){index=0;while(b=b.previousSibling){index++}return index}function getCurrentlySelectedSmartInputItem(){answer=null;for(i=0;((i<siw.matchCollection.length)&&!answer);i++){if(siw.matchCollection[i].isSelected){answer=i}}return answer}function selectSmartInputMatchItem(b){siw.matchCollection[b].isSelected=true}function deSelectSmartInputMatchItem(b){siw.matchCollection[b].isSelected=false}function selectNextSmartInputMatchItem(){currentIndex=getCurrentlySelectedSmartInputItem();if(currentIndex!=null){deSelectSmartInputMatchItem(currentIndex);if((currentIndex+1)<siw.matchCollection.length){selectSmartInputMatchItem(currentIndex+1)}else{selectSmartInputMatchItem(0)}}else{selectSmartInputMatchItem(0)}modifySmartInputBoxContent(getSmartInputBoxContent())}function selectPreviousSmartInputMatchItem(){currentIndex=getCurrentlySelectedSmartInputItem();if(currentIndex!=null){deSelectSmartInputMatchItem(currentIndex);if((currentIndex-1)>=0){selectSmartInputMatchItem(currentIndex-1)}else{selectSmartInputMatchItem(siw.matchCollection.length-1)}}else{selectSmartInputMatchItem(siw.matchCollection.length-1)}modifySmartInputBoxContent(getSmartInputBoxContent())}function activateCurrentSmartInputMatch(){baseValue=getUserInputBase();if((selIndex=getCurrentlySelectedSmartInputItem())!=null){addedValue=siw.matchCollection[selIndex].cleanValue;theString=(baseValue?baseValue:"")+addedValue;if(isCommaDelimiter){theString=theString+", "}siw.inputBox.value=theString;runMatchingLogic(addedValue,true)}}function smartInputWindow(){this.customFloater=false;this.floater=document.getElementById("smartInputFloater");this.floaterContent=document.getElementById("smartInputFloaterContent");this.selectedSmartInputItem=null;this.MAX_MATCHES=15;this.isGecko=(navigator.userAgent.indexOf("Gecko/200")!=-1);this.isSafari=(navigator.userAgent.indexOf("Safari")!=-1);this.isWinIE=((navigator.userAgent.indexOf("Win")!=-1)&&(navigator.userAgent.indexOf("MSIE")!=-1));this.showCredit=false}function registerSmartInputListeners(){inputs=document.getElementsByTagName("input");texts=document.getElementsByTagName("textarea");allinputs=new Array();z=0;y=0;while(inputs[z]){allinputs[z]=inputs[z];z++}while(texts[y]){allinputs[z]=texts[y];z++;y++}for(i=0;i<allinputs.length;i++){if((c=allinputs[i].className)&&(c=="wickEnabled")){allinputs[i].setAttribute("autocomplete","OFF");allinputs[i].onfocus=handleFocus;allinputs[i].onblur=handleBlur;allinputs[i].onkeydown=handleKeyDown;allinputs[i].onkeyup=handleKeyPress}}}siw=null;if(document.addEventListener){document.addEventListener("keydown",handleKeyDown,false);document.addEventListener("keyup",handleKeyPress,false);document.addEventListener("mouseup",handleClick,false);document.addEventListener("mouseover",handleMouseOver,false)}else{document.onkeydown=handleKeyDown;document.onkeyup=handleKeyPress;document.onmouseup=handleClick;document.onmouseover=handleMouseOver}window.addEventListener?window.addEventListener("load",registerSmartInputListeners,false):window.attachEvent("onload",registerSmartInputListeners);document.write('<table id="smartInputFloater" class="floater" cellpadding="0" cellspacing="0"><tr><td id="smartInputFloaterContent" nowrap="nowrap"></td></tr></table>');for(x=0;x<collection.length;x++){collection[x]=collection[x].replace(/\,/gi,"")}collectionIndex=new Array();ds="";function debug(b){ds+=(b+"\n")};