/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
//google.load("jquery", "1.3.1");

jQuery.noConflict();
jQuery(document).ready(function() {

//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+
	jQuery("#suggestions").css(cssObj);*/
	
	// Fade out the suggestions box when not active
	 jQuery("input").blur(function(){
	 	jQuery('#suggestions_box').fadeOut();
	 });
	 
});

function lookup(inputString) {
	if(inputString.length < 3) {
		jQuery('#suggestions_box').fadeOut(); // Hide the suggestions box
	} else {
		jQuery.post("mysite/php/rpc.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call 
			jQuery('.map_box').fadeOut();
			jQuery('#suggestions_box').fadeIn(); // Show the suggestions box
			jQuery('#suggestions_box').html(data); // Fill the suggestions box
			//jQuery('#map').jMapping('update');
			//jQuery('#map').data('jMapping').update();
			
			/* backup - DO NOT DELETE
			//Convert address tags to google map links
			jQuery('address').each(function () {
				
				var str = jQuery(this).text();
				var substr = str.split(',');
				var holder = substr[2];
																			 
				function initialize() {
					var myOptions = {
						zoom: 12,
						center: new google.maps.LatLng(substr[0],substr[1]),
						disableDefaultUI: true,
						mapTypeId: google.maps.MapTypeId.ROADMAP
					}					
					var map = new google.maps.Map(document.getElementById(holder),myOptions);
					var image = 'themes/blackcandy/images/icons/mapmarker.png';
					var myLatLng = new google.maps.LatLng(substr[0],substr[1]);
					var officeMarker = new google.maps.Marker({
							position: myLatLng,
							map: map,
							icon: image
					});
				}
				initialize();				
			});			
			*/
		});
	}
}
