(function(){
function H(a,b,c){var d="on"+b;if(a.addEventListener){a.addEventListener(b,c,false)}else if(a.attachEvent){a.attachEvent(d,c)}else{var f=a[d];a[d]=function(){var e=f.apply(this,arguments),h=c.apply(this,arguments);return e==undefined?h:(h==undefined?e:h&&e)}}};var l=window,p=document,ha,P,D,n,V,J="",M=null,y=null,v=null,B=-1,R,g,s,u,C=null,r=null,x,F,ma={},m=null,X,G=0,K=0,U=0,A=null,S,I=false,$=false,da,L;{var xa=navigator.userAgent.toLowerCase();da=xa.indexOf("opera")!=-1;L=xa.indexOf("msie")!=-1&&!da}var Q=null,ya=new RegExp("^[\\s\\u1100-\\u11FF\\u3040-\\u30FF\\u3130-\\u318F\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\u9FFF\\uAC00-\\uD7A3\\uF900-\\uFAFF\\uFF65-\\uFFDC]+$"),j="google-ac-",la=true;function Ca(a,b,c,d,f,e){R=a;g=b;ha=d;Q=f;la=e;P=qa()==null&&
!ha;var h=l.google.kHL;S=/^(zh-(CN|TW)|ja|ko)$/.test(h);if(c=="search")c="";X="/complete/search?hl="+ba(h)+(c?"&ds="+ba(c):"")+"&client=suggest";if(P)fa("");R.onsubmit=oa;g.setAttribute("autocomplete","off");H(g,"blur",Fa);H(g,"beforedeactivate",Ga);if(g.addEventListener){g.onkeypress=ua;g.onkeyup=va}else{H(g,L?"keydown":"keypress",ua);H(g,"keyup",va)}n=(V=(D=g.value));s=t("table");s.id="completeTable";s.cellSpacing=(s.cellPadding="0");u=s.style;w(s,j+"m");z();o(p.body,s);if(L){C=t("iframe");r=C.style;
C.id="completeIFrame";r.zIndex="1";r.position="absolute";r.display="block";r.borderWidth=0;o(p.body,C)}W();ja("",[],[]);Ba();if(P){var k=t("div"),i=k.style;O(i,false);i.position="absolute";i.left="0";i.top="-10000";i.width=(i.height="0");var q=t("iframe");q.name=(q.id="completionFrame");q.src=X;o(k,q);o(p.body,k)}H(l,"resize",W);H(l,"pageshow",Ja);if(S)l.setInterval(Ka,10);x=na("aq","f",false);F=na("oq","",true);Z()}function Ja(a){if(a.persisted)x.value="f";F.value=""}function Ba(){var a=p.body.dir==
"rtl",b=a?"right":"left",c=a?"left":"right",d=p.getElementsByTagName("head")[0],f=t("style"),e=null,h=null,k=false;if(p.styleSheets){o(d,f);k=true;e=f.sheet?f.sheet:f.styleSheet}if(!e){h=p.createTextNode("");o(f,h)}var i=function(q,E){var ia=q+" { "+E+" }";if(e){if(e.insertRule){e.insertRule(ia,e.cssRules.length)}else if(e.addRule){e.addRule(q,E)}}else{h.data+=ia+"\n"}};i("."+j+"m","font-size:13px;font-family:arial,sans-serif;cursor:default;line-height:17px;border:1px solid black;z-index:99;position:absolute;background-color:white;margin:0;");
i("."+j+"a","background-color:white;");i("."+j+"b","background-color:#3366cc;color:white;");i("."+j+"c","white-space:nowrap;overflow:hidden;text-align:"+b+";padding-"+b+":3px;"+(L||da?"padding-bottom:1px;":""));i("."+j+"d","white-space:nowrap;overflow:hidden;font-size:10px;text-align:"+c+";color:green;padding-"+b+":3px;padding-"+c+":3px;");i("."+j+"b td","color:white;");i("."+j+"e td","padding:0 3px 2px;text-align:"+c+";font-size:10px;line-height:15px;");i("."+j+"e td","color:blue;text-decoration:underline;cursor:pointer;");
if(!k)o(d,f)}function W(){if(s){u.left=pa(g,"offsetLeft")+"px";u.top=pa(g,"offsetTop")+g.offsetHeight-1+"px";u.width=g.offsetWidth+"px";if(C){r.left=u.left;r.top=u.top;r.width=u.width;r.height=s.offsetHeight+"px"}}}function t(a){return p.createElement(a)}function o(a,b){a.appendChild(b)}function O(a,b){a.visibility=b?"visible":"hidden"}function na(a,b,c){var d=t("input");d.type="hidden";d.name=a;d.value=b;d.disabled=c;o(R,d);return d}function Fa(a){if(!I)z();I=false}function Ga(a){if(I){l.event.cancelBubble=
true;l.event.returnValue=false}I=false}function ua(a){var b=a.keyCode;if(b==27&&ka()){z();N(n);a.cancelBubble=true;a.returnValue=false;return false}if(!T(b))return true;U++;if(U%3==1)ea(b);return false}function va(a){var b=a.keyCode;if(!(S&&T(b))&&U==0)ea(b);U=0;return!T(b)}function ea(a){if(S&&T(a))Aa();if(g.value!=D||a==39){n=g.value;if(a!=39)F.value=n}if(ra(a)){wa(B+1)}else if(sa(a)){wa(B-1)}W();if(J!=n&&!A)A=l.setTimeout(z,500);D=g.value;if(D==""&&!M)Z()}function sa(a){return a==38||a==63232}
function ra(a){return a==40||a==63233}function T(a){return sa(a)||ra(a)}function Ha(){g.blur();x.value=B;N(this.completeString);if(la){if(oa()){R.submit()}}else{z()}}function ta(){if($)return;if(v)w(v,j+"a");w(this,j+"b");v=this;for(var a=0;a<y.length;a++){if(y[a]==v){B=a;break}}}function Ia(){if($){$=false;ta.call(this)}}function wa(a){if(J==""&&n!=""){V="";Z();return}if(n!=J||!M)return;if(!y||y.length<=0)return;if(!ka()){ga();return}var b=y.length;if(Q)b-=1;if(v)w(v,j+"a");if(a==b||a==-1){B=-1;
N(n);ca();x.value="f";return}else if(a>b){a=0}else if(a<-1){a=b-1}x.value=a;B=a;v=y.item(a);w(v,j+"b");N(v.completeString)}function z(){if(A){l.clearTimeout(A);A=null}O(u,false);if(C)O(r,false)}function ga(){O(u,true);if(C)O(r,true);W();$=true}function ka(){return u.visibility=="visible"}function za(a,b,c){if(c.length==0||c[0]<2)return;var d=[],f=[],e=c[0],h=Math.floor((c.length-1)/e);for(var k=0;k<h;k++){d.push(c[k*e+1]);f.push(c[k*e+2])}Y(a,b,d,f)}function Y(a,b,c,d){if(G>0)G--;ja(b,c,d);if(b!=
n)return;if(A){l.clearTimeout(A);A=null}J=b;La(s,c,d);B=-1;y=s.rows;if(y.length>0){ga()}else{z()}}function Da(a){var b;a.unshift(b);if(a.length>=3){if(a.length<4)a.push([])}Y.apply(null,a)}function ja(a,b,c){ma[a]=[b,c]}function oa(){if(P)fa("");z();F.disabled=true;if(F.value!=g.value){x.value=B;F.disabled=false}else if(K>=3||G>=10){x.value="o"}return true}function Z(){if(K>=3)return false;if(V!=n){var a=ba(n),b=ma[n];if(b){Y(null,n,b[0],b[1])}else{G++;if(ha){var c=t("script");c.setAttribute("type",
"text/javascript");c.setAttribute("charset","utf-8");c.setAttribute("id","jsonpACScriptTag");c.setAttribute("src","http://suggestqueries.google.com"+X+"&json=t&jsonp=window.google.ac.jsonRPCDone&q="+a);var d=p.getElementById("jsonpACScriptTag"),f=p.getElementsByTagName("head")[0];if(d){f.removeChild(d)}o(f,c)}else if(P){fa(a);l.frames.completionFrame.document.location.reload(true)}else{Ma(a)}}ca()}V=n;var e=100;for(var h=1;h<=(G-2)/2;++h){e*=2}e+=50;M=l.setTimeout(Z,e);return true}function ba(a){if(l.encodeURIComponent)return encodeURIComponent(a);
return escape(a)}function N(a){g.value=a;D=a}function ca(){g.focus()}function pa(a,b){var c=0;while(a){c+=a[b];a=a.offsetParent}return c}function fa(a){p.cookie="qu="+a+"; path=/complete/search"}function w(a,b){a.className=b}function aa(a,b){a.appendChild(p.createTextNode(b))}function La(a,b,c){while(a.rows.length>0)a.deleteRow(-1);for(var d=0;d<b.length;++d){var f=a.insertRow(-1);f.onmousedown=Ha;f.onmouseover=ta;f.onmousemove=Ia;f.completeString=b[d];w(f,j+"a");var e=t("td");aa(e,b[d]);w(e,j+"c");
if(L&&ya.test(b[d]))e.style.paddingTop="2px";o(f,e);var h=t("td");aa(h,c[d]);w(h,j+"d");o(f,h)}if(Q&&b.length>0){var k=a.insertRow(-1);k.onmousedown=function(E){if(E&&E.stopPropagation){E.stopPropagation();ga();g.focus()}else{I=true}return false};var i=t("td");i.colSpan=2;w(k,j+"e");var q=t("span");o(k,i);o(i,q);aa(q,Q);q.onclick=function(){z();J="";l.clearTimeout(M);M=null;x.value="x"}}}function qa(){var a=null;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){a=
null}}if(!a&&typeof XMLHttpRequest!="undefined")a=new XMLHttpRequest;return a}function Ma(a){if(m&&m.readyState!=0&&m.readyState!=4){m.abort()}if(m)m.onreadystatechange=Ea;m=qa();if(m){m.open("GET",X+"&js=true&q="+a,true);m.onreadystatechange=function(){if(m.readyState==4&&m.responseText){switch(m.status){case 403:K=1000;break;case 302:case 500:case 502:case 503:K++;break;case 200:var b=m.responseText;if(b.charAt(0)!="<"&&(b.indexOf("sendRPCDone")!=-1||b.indexOf("Suggest_apply")!=-1)){eval(b)}else{G--}default:K=
0}}};m.send(null)}}function Ea(){}function Ka(){var a=g.value;if(a!=D)ea(0);D=a}function Aa(){I=true;g.blur();l.setTimeout(ca,10)}l.google.ac={install:Ca,Suggest_apply:za,sendRPCDone:Y,jsonRPCDone:Da,setFieldValue:N};
})();
