/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
google.load("jquery", "1.3.1");
google.setOnLoadCallback(function()
{
	// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard
		'-webkit-box-shadow' : '#888 5px 10px 10px', // Safari
		'-moz-box-shadow' : '#888 5px 10px 10px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);
	
	// Fade out the suggestions box when not active
	 $("input").blur(function(){
	 	$('#suggestions').fadeOut();
	 });
});

function lookup_nr(inputString) {
	var cijfers = true;
  	if (!check(inputString)) {
    	var cijfers = false;
  	}
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} 
	else if (cijfers == true) {

		$.post("rpc.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}

function lookup(inputString) {
	var letters = true;
  	if (check(inputString)) {
    	var letters = false;
  	}
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else if (letters == true) {
		$.post("rpc.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions').html(data); // Fill the suggestions box
		});
	}
}


function check(input) {
  var ok = true;
	cijferreeks = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "/", "-", " ");
  for (var i = 0; i < input.length; i++) {
    var chr = input.charAt(i);
    var found = false;
    for (var j = 0; j < 12; j++) {
      if (chr == cijferreeks[j]) {
	  found = true;

}
    }
    if (!found) {
	ok = false;

	}
  }
 
  return ok;
}



