var global_array=new Array();var tid=0;var keycode=0;var req_search=null;var prev_hilighted_index=-1;var hilighted_index=-1;var enter=false;var result_bg_color="#FFFAEE";var result_fg_color="#000000";var result_hi_color="#C58610";var head_bg_color="#FFCC00";function search_keyword(D,C,B){var A=0;if(!C&&window.event){C=window.event}if(document.layers){A=(C.modifiers&Event.CONTROL_MASK)>0}else{A=C.ctrlKey}if(tid){return }keycode=C.keyCode;if(A){return true}if(isCtrlKey(keycode)){return true}if(isSendKey(keycode)){tid=setTimeout("SendQuery('"+D+"','"+B+"')",100)}return UpDown(D,keycode)}function isCtrlKey(A){if(A==16||A==17||A==18){return true}else{return false}}function isSendKey(B){var A=true;switch(B){case 13:case 27:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 45:A=false;break;default:break}return A}function SendQuery(D,C){tid=0;var B=document.getElementById("global_search").value;if(B.length!=0&&B.search(/\S/)!=-1){var A="http://"+C+"/utils/search_data_xml.html?keyword="+encodeURIComponent(B);if(req_search){req_search.abort()}req_search=(!window.XMLHttpRequest)?(ActiveXObject?(new ActiveXObject("Microsoft.XMLHTTP")):""):(new XMLHttpRequest());req_search.open("GET",A,true);req_search.onreadystatechange=new Function("Process('"+D+"')");req_search.send(null)}else{hide_div()}}function Process(E){if(req_search.readyState==4){try{if(req_search.status==200){if(req_search.responseText==""){alert("empty response got");hide_div()}else{ShowDiv(E);response=req_search.responseXML.documentElement;var M=response.getElementsByTagName("data");var D=document.getElementById("global_search");var P=findPosX(D);var O=findPosY(D);O=O+D.offsetHeight;var Q=window.document.getElementById("gs_auto_div");var F=document.createElement("DIV");setStyle(F,"cbad");F.innerHTML='<b><font color="#412041" size="2">Choose a suggestion or type and click search.</font></b>';F.style.background=head_bg_color;while(Q.childNodes.length>0){Q.removeChild(Q.childNodes[0])}Q.style.top=O+"px";Q.style.left=P+"px";var A="";global_array=new Array();if(!M.length){hide_div()}Q.appendChild(F);for(var G=0;G<M.length;G++){var H=M[G].getElementsByTagName("search")[0].firstChild.nodeValue;var K=M[G].getElementsByTagName("count")[0].firstChild.nodeValue;var C=M[G].getElementsByTagName("headline")[0].firstChild.nodeValue;K="&nbsp;";global_array[G]=String(H);var J=document.createElement("DIV");J.id=G;J.onmouseover=new Function("mouse_in('"+G+"')");J.onmouseout=new Function("mouse_out('"+G+"')");J.onclick=new Function("submitItem('"+G+"')");var B=document.createElement("SPAN");B.id=String("global_"+G);var N=document.createElement("SPAN");N.id=String("search_"+G);setStyle(N,"abcd");var I=document.createElement("SPAN");I.id=String("count_"+G);setStyle(I,"bcda");N.innerHTML=C;B.displaySpan=I;I.innerHTML=K;B.appendChild(N);B.appendChild(I);J.appendChild(B);Q.appendChild(J)}hilighted_index=-1;pre_hilighted_index=-1;enable_blur()}}}catch(L){hide_div()}}}function setStyle(B,A){switch(A.charAt(0)){case"a":B.style.visibility="visible";B.style.width="80%";B.style.fontSize="12px";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.color=result_fg_color;B.style.whiteSpace="nowrap";B.style.styleFloat="left";B.style.cssFloat="left";B.style.textAlign="left";break;case"b":B.style.visibility="visible";B.style.width="20%";B.style.fontSize="12px";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.color="#0000DE";B.style.styleFloat="right";B.style.cssFloat="right";B.style.textAlign="right";break;case"c":B.style.width="100%";B.style.weight="bold";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.fontSize="15px";B.style.styleFloat="left";B.style.cssFloat="left";B.style.textAlign="left";break;default:break}}function ShowDiv(A){document.getElementById("gs_auto_div").style.visibility="visible";document.getElementById("gs_auto_div").style.background=result_bg_color;document.getElementById("gs_auto_div").style.border="solid 1px black"}function hide_div(){if(global_array.length){hide_all()}document.getElementById("gs_auto_div").style.visibility="hidden"}function hide_div_later(){setTimeout("hide_div()",100)}function hide_all(){for(var A=0;A<global_array.length;A++){document.getElementById("search_"+A).style.visibility="hidden";document.getElementById("count_"+A).style.visibility="hidden";document.getElementById("global_"+A).style.visibility="hidden";document.getElementById(A).style.visibility="hidden"}}UpDown=function(A,B){if(handleCursorUpDownEnter(B,A)||isShowKey(B)){return true}else{return false}};function isShowKey(A){if(A==40||A==38||A==33||A==34||A==13){return false}else{return true}}function handleCursorUpDownEnter(C,A){var B=document.getElementById("gs_auto_div");if(C==40){if(B.style.visibility=="visible"){highlightNewValue(Number(hilighted_index)+Number(1),C,A);return false}}else{if(C==38){if(B.style.visibility=="visible"){highlightNewValue(hilighted_index-1,C,A);return false}}else{if(C==13||C==3){if(C==13){enter=true;return submitHandlerIncr1(A)}return false}}}if(keycode!=0){ForEachKeyPressed(keycode,A)}return true}function highlightNewValue(A,C,B){if(A<0){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2");prev_hilighted_index=-1}hilighted_index=-1;return }if(A>global_array.length-1){change_background(A-1,"1");hilighted_index=global_array.length-1;prev_hilighted_index=global_array.length-1;return }if(C==40){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2")}change_background(A,"1");hilighted_index=A;prev_hilighted_index=A}if(C==38){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2")}change_background(A,"1");hilighted_index=A;prev_hilighted_index=A}}function change_background(B,A){switch(A.charAt(0)){case"1":document.getElementById("search_"+B).style.backgroundColor=result_hi_color;document.getElementById("count_"+B).style.backgroundColor=result_hi_color;break;case"2":document.getElementById("search_"+B).style.backgroundColor=result_bg_color;document.getElementById("count_"+B).style.backgroundColor=result_bg_color;break;default:break}}function mouse_in(A){basic_style();change_background(A,"1");hilighted_index=A;prev_hilighted_index=A;disable_blur()}function mouse_out(A){change_background(A,"2");enable_blur()}function enable_blur(){var A=document.getElementById("global_search");A.onblur=new Function("hide_div_later()")}function disable_blur(){var A=document.getElementById("global_search");A.onblur=null}function basic_style(){for(i=0;i<global_array.length;i++){change_background(i,"2")}}function findPosX(A){var B=0;if(A.offsetParent){while(A.offsetParent){B+=A.offsetLeft;A=A.offsetParent}}else{if(A.x){B+=A.x}}return B}function findPosY(B){var A=0;if(B.offsetParent){while(B.offsetParent){A+=B.offsetTop;B=B.offsetParent}}else{if(B.y){A+=B.y}}return A}function ForEachKeyPressed(F,D){var A=document.getElementById("global_search");var B=document.getElementById("gs_auto_div");var E=A.value;var C=global_array.length;if(E==""||C==0||keycode==27||E.search(/\S/)==-1||(B.style.visibility=="hidden"&&(keycode==35||keycode==36))){hide_div()}}function submitHandlerIncr1(A){var B=document.getElementById(hilighted_index).id;document.getElementById("global_search").value=global_array[B];hide_div()}function submitItem(A){document.getElementById("global_search").value=String(global_array[A]);hide_div()};