	var const_div_offsetx = -3;
	var const_div_offsety = 2;
	var glob_RecentKeyWord = "";
	var pDiv;
	var request = null;

//	var const_TargetInput    = "inputGlobalSearch";
//	var const_TargetFunction  = search;
//	document.getElementById(const_TargetInput).onkeyup = showSuggest;
//	document.getElementById(const_TargetInput).onblur  = hideSuggest;

	function defineTargetInput(targetId, pFunction) {
		const_TargetInput = targetId;
		const_TargetFunction  = pFunction;
		document.getElementById(const_TargetInput).autocomplete = "off";
		document.getElementById(const_TargetInput).onkeyup = showSuggest;
		document.getElementById(const_TargetInput).onblur  = hideSuggest;
		if (typeof pDiv != "undefined") {
			document.getElementsByTagName("body")[0].removeChild(pDiv);
		}
		pDiv = initDivSuggest();
	}
	
	function initDivSuggest() {
		var pDiv = document.createElement("div");
		pDiv.id = "divsuggest";
		pDiv.className = "divsuggest";
		pDiv.style.position = "absolute";
		pDiv.style.left = const_div_offsetx + getPosition(document.getElementById(const_TargetInput))[0] + "px";
		pDiv.style.top  = const_div_offsety + getPosition(document.getElementById(const_TargetInput))[1] + document.getElementById(const_TargetInput).clientHeight + "px";
		pDiv.style.visibility = "hidden";
		hideSelectElements();
		document.getElementsByTagName("body")[0].appendChild(pDiv);
		return pDiv;
	}
	
	function showSuggest(event) {
		var key;
		if (typeof event == "undefined") { //Internet Explorer
			if (typeof window.event != "undefined") {
				key = window.event.keyCode;
			}
		} else { //Mozilla Firefox
			if (typeof event.keyCode != "undefined") {
				key = event.keyCode
			}
		}
		
		if ((key == 38 || key == 40 || key == 13) && pDiv.style.visibility == "visible") {
			var highlight = false;
			for (var i = 0; i < pDiv.getElementsByTagName("span").length; i++) {
				if (pDiv.getElementsByTagName("span")[i].className == "spansuggesthighlight") {
					if (key == 13) {
						document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[i].getAttribute("phrase");
						pDiv.style.visibility = "hidden";
						hideSelectElements();
					}
					if (key == 40) {
						pDiv.getElementsByTagName("span")[i].className = "spansuggest";
						if (i + 1 < pDiv.getElementsByTagName("span").length) {
							pDiv.getElementsByTagName("span")[i + 1].className = "spansuggesthighlight";
							document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[i + 1].getAttribute("phrase");
						} else {
							pDiv.getElementsByTagName("span")[0].className = "spansuggesthighlight";
							document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[0].getAttribute("phrase");
						}
						
					}
					if (key == 38) {
						pDiv.getElementsByTagName("span")[i].className = "spansuggest";
						if (i - 1 >= 0) {
							pDiv.getElementsByTagName("span")[i - 1].className = "spansuggesthighlight";
							document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[i - 1].getAttribute("phrase");
						} else {
							pDiv.getElementsByTagName("span")[pDiv.getElementsByTagName("span").length - 1].className = "spansuggesthighlight";
							document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[pDiv.getElementsByTagName("span").length - 1].getAttribute("phrase");
						}
					}
					highlight = true;
					break;
				}
			}
			if (highlight == false) {
				if (key == 38) {
					pDiv.getElementsByTagName("span")[pDiv.getElementsByTagName("span").length - 1].className = "spansuggesthighlight";
					document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[pDiv.getElementsByTagName("span").length - 1].getAttribute("phrase");
				}
				if (key == 40) {
					pDiv.getElementsByTagName("span")[0].className = "spansuggesthighlight";
					document.getElementById(const_TargetInput).value = pDiv.getElementsByTagName("span")[0].getAttribute("phrase");
				}
			}
		} else {
			if (document.getElementById(const_TargetInput).value.length >= 2) {
				if (glob_RecentKeyWord != document.getElementById(const_TargetInput).value) {
					glob_RecentKeyWord = document.getElementById(const_TargetInput).value;
					httpRequest("GET", "/support/InputSuggest?word=" + encodeURI(document.getElementById(const_TargetInput).value), true, setDivContent);
				}
			} else {
				hideSuggest();
			}
		}
	}
	
	function setDivContent()
	{
		if (request.readyState == 4) {
			if (request.status == 200) {
				pDiv.innerHTML = "";
				var xmlDoc = request.responseXML;
				if (xmlDoc!=null) {
					for (var i = 0; i < xmlDoc.getElementsByTagName("phrase").length && document.getElementById(const_TargetInput).value.length > 0; i++) {
						var strPhrase = xmlDoc.getElementsByTagName("phrase")[i].firstChild.data;	//.text¶ÔFirefox²»¼æÈÝ£¬.data¶¼¼æÈÝ
						var reHighLight = new RegExp(document.getElementById(const_TargetInput).value, "gim");
						if (reHighLight.test(strPhrase)) {
							var reReplace = new RegExp("(" + document.getElementById(const_TargetInput).value + ")", "gim");
							var pSpan = document.createElement("span");
							//pSpan.innerHTML = strPhrase.replace(reReplace, "<font style=\"text-decoration: underline; \">$1</font>");
							pSpan.innerHTML = strPhrase.replace(reReplace, "<font style=\"background-color: #BBBBFF; \">$1</font>");
							pSpan.id = "spansuggest_" + i;
							pSpan.className = "spansuggest";
							pSpan.setAttribute("indexid", i);
							pSpan.setAttribute("phrase", strPhrase);
							pSpan.onmouseover = doHighLightSpanSuggest;
							pSpan.onmouseout = undoHighLightSpanSuggest;
							pSpan.onclick = clickSpanSuggest;
							pDiv.appendChild(pSpan);
							pDiv.appendChild(document.createElement("br"));
						}
					}
					pDiv.style.width = "";
					if (pDiv.offsetWidth < document.getElementById(const_TargetInput).offsetWidth - 2) {
						pDiv.style.width = document.getElementById(const_TargetInput).offsetWidth - 2;
					}
					pDiv.style.visibility = "visible";
					hideSelectElements();
					if (pDiv.innerHTML.length <= 0) {
						pDiv.style.visibility = "hidden";
						hideSelectElements();
					}
				}
			}
		}
	}
	
	function doHighLightSpanSuggest() {
		var pSpans = document.getElementsByTagName("span");
		for (var i = 0; i < pSpans.length; i++) {
			if (pSpans[i].className == "spansuggesthighlight") {
				pSpans[i].className = "spansuggest";
			}
		}
		this.className = "spansuggesthighlight";
	}

	function undoHighLightSpanSuggest() {
		this.className = "spansuggest";
	}
	
	function clickSpanSuggest() {
		document.getElementById(const_TargetInput).value = this.getAttribute("phrase");
		document.getElementById(const_TargetInput).focus();
	}
	
	function hideSuggest(event) {
		if (typeof pDiv != "undefined") {
			setTimeout("pDiv.style.visibility = \"hidden\"; hideSelectElements()", 100);
		}
	}
	
	function hideSelectElements() {
		if (typeof pDiv != "undefined") {
			if (pDiv.style.visibility == "hidden") {
				var pSelectElements = document.getElementsByTagName("select");
				for (var i = 0; i < pSelectElements.length; i++) {
					pSelectElements[i].style.visibility = "visible";
				}
			} else {
				var x1 = getPosition(pDiv)[0];
				var y1 = getPosition(pDiv)[1];
				var w1 = pDiv.clientWidth;
				var h1 = pDiv.clientHeight;
				var pSelectElements = document.getElementsByTagName("select");
				for (var i = 0; i < pSelectElements.length; i++) {
					var x2 = getPosition(pSelectElements[i])[0];
					var y2 = getPosition(pSelectElements[i])[1];
					var w2 = pSelectElements[i].clientWidth;
					var h2 = pSelectElements[i].clientHeight;
					if ((x2+w2>x1 && x2+w2<x1+w1 && y2+h2>y1 && y2+h2<y1+h1)
					 || (x2   >x1 && x2   <x1+w1 && y2+h2>y1 && y2+h2<y1+h1)
					 || (x2+w2>x1 && x2+w2<x1+w1 && y2   >y1 && y2   <y1+h1)
					 || (x2   >x1 && x2   <x1+w1 && y2>   y1 && y2   <y1+h1)) {
						pSelectElements[i].style.visibility = "hidden";
					}
				}
			}
		}
	}
	
	function getPosition(theElement)
	{
		var positionX = 0;
		var positionY = 0;
		var i = 0;
		while (theElement != null)
		{
			positionX += theElement.offsetLeft;
			positionY += theElement.offsetTop;
			theElement = theElement.offsetParent;
		}
		return [positionX, positionY];
	}
	
	function httpRequest(reqType,url,asynch,respHandle){
		//Mozilla-based browsers
		if(window.XMLHttpRequest){
			request = new XMLHttpRequest();
			//if the reqType parameter is POST, then the
			//5th argument to the function is the POSTed data
			if(reqType.toLowerCase() != "post") {
				initReq(reqType, url, asynch, respHandle);
			} else {
				//the POSTed data
				var args = arguments[4];
				if(args != null && args.length > 0){
					initReq(reqType, url, asynch, respHandle, args);
				}
			}
		} else if (window.ActiveXObject){
			request=new ActiveXObject("Msxml2.XMLHTTP");
			if (! request){
				request=new ActiveXObject("Microsoft.XMLHTTP");
			}
			if(request){
				//if the reqType parameter is POST, then the
				//4th argument to the function is the POSTed data
				if(reqType.toLowerCase() != "post") {
					initReq(reqType,url,asynch,respHandle);
				} else {
					var args = arguments[4];
					if(args != null && args.length > 0){
						initReq(reqType,url,asynch,respHandle,args);
					}
				}
			} else {
				alert("Your browser does not permit the use of all of this application's features!");
			}
		} else {
			alert("Your browser does not permit the use of all of this application's features!");}
	}

	/* Initialize a Request object that is already constructed */
	function initReq(reqType,url,bool,respHandle){
		try{
			/* Specify the function that will handle the HTTP response */
			request.onreadystatechange=respHandle;
			request.open(reqType,url,bool);
			//if the reqType parameter is POST, then the
			//5th argument to the function is the POSTed data
			if(reqType.toLowerCase() == "post") {
				request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
				request.send(arguments[4]);
			} else {
				request.send(null);
			}
		} catch (errv) {
			alert("The application cannot contact the server at the moment. Please try again in a few seconds.\n" + "Error detail: " + errv.message);
		}
	}