	var xmlhttp = createXmlHttpRequestObject();
		function createXmlHttpRequestObject()
		{
			// will store the reference to the XMLHttpRequest object
			var xmlhttp;
			var pippo;
			// if running Internet Explorer
				if(window.ActiveXObject){
					try	{
						xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch (e){
						xmlhttp = false;
					}
				}
				// if running Mozilla or other browsers
				else{
					try{
						xmlhttp = new XMLHttpRequest();
					}
					catch (e){
						xmlhttp = false;
				}
			}
			// return the created object or display an error message
			if (!xmlhttp)
				alert("Error creating the XMLHttpRequest object.");
			else
				return xmlhttp;
		}
		
		function autocomplete (thevalue, e){
		theObject = document.getElementById("autocompletediv");
		theObject.style.visibility = "visible";
		theObject.style.innerHTML = "";
		theObject.style.position = "absolute";
		theObject.style.width = "152px";
		var posx = 0;
		var posy = 0;
		//posx = (findPosX (document.getElementById("category")) + 0);
		//posy = (findPosY (document.getElementById("category")) + 33);
		posx = (findPosX (document.getElementById("category")) + 262);
		posy = (findPosY (document.getElementById("category")) );
		theObject.style.left = posx + "px";
		theObject.style.top = posy + "px";
		var theextrachar = e.which;
		if (theextrachar == undefined){
		theextrachar = e.keyCode;
		}
		var objID = "autocompletediv";
		if (theextrachar == 8){
			if (thevalue.length == 1){
				var serverPage = "autocomp.php";
			} else {
				var serverPage = "autocomp.php" + "?sstring=" + thevalue.substr (0, (thevalue.length -1));
			}
		} else {
			var serverPage = "autocomp.php" + "?sstring=" +	thevalue + String.fromCharCode (theextrachar);
		}
			
			var obj = document.getElementById(objID);
			xmlhttp.open("GET", serverPage);
			xmlhttp.onreadystatechange = function() {
			
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
		}
		function findPosX(obj){
			var curleft = 0;
			if (obj.offsetParent){
				while (obj.offsetParent){
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			} else if (obj.x){
				curleft += obj.x;
			}
			return curleft;
		}

		function findPosY(obj){
			var curtop = 0;
			if (obj.offsetParent){
				while (obj.offsetParent){
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			} else if (obj.y){
				curtop += obj.y;
			}
				return curtop;
		}
		function setvalue (thevalue){
		acObject = document.getElementById("autocompletediv");
		acObject.style.visibility = "hidden";
		acObject.style.height = "0px";
		acObject.style.width = "0px";
		document.getElementById("category").value = thevalue;
		}
		function hide (){
			acObject = document.getElementById("autocompletediv");
			acObject.style.visibility = "hidden";
			acObject.style.height = "0px";
			acObject.style.width = "0px";
		}