var ajaxRequest;
function cekAjax(){
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer Browsers
		try	{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				// Something went wrong
				alert("Your browser doesn't support Ajax!");
				return false;
			}
		}
	}
}

function getPosisi(){
	cekAjax();
	var posisi = document.getElementById('posisi').value; //menangkap id barang yang dicari
	ajaxRequest.open("GET","posisiAjax.php?id=" + posisi,true); //mengirim id barang ke halaman
																				 //hasilcaridata.php
	ajaxRequest.send(null); 
	ajaxRequest.onreadystatechange = function(){
		document.getElementById('hasilPosisi').innerHTML = ajaxRequest.responseText;
	}
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {
  		field.value = field.value.substring(0, maxlimit);
	}
	else {
  		countfield.value = maxlimit - field.value.length;
 	}
}

function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("search.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup
	
function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}