	document.write('<link type="text/css" rel="stylesheet" href="/v2/css/jquery.ui.all.css" />');
   	document.write('<script src="/v2/js/jquery.ui.all.js"></script>');

	$(function() {
		$( "#keyword" ).autocomplete({
			source: function( request, response ) {
				$.ajax({
					url: "http://www.hongkonghomes.com/api/searchBuildingName.php",
					dataType: "jsonp",
					data: {
						featureClass: "P",
						style: "full",
						maxRows: 12,
						name_startsWith: request.term,
						word: request.term
					},
					success: function( data ) {
						response( $.map( data.records, function( item ) {
							return {
								label: item.building,
								value: item.building
							}
						}));
					}
				});
			},
			minLength: 2,
			select: function( event, ui ) {
			},
			open: function() {
				$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
				$('.ui-autocomplete').width(210);
				$('.ui-autocomplete').css('z-index', '999');
			},
			close: function() {
				$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
			}
		});

		$(window).resize(function() {
			$('.ui-autocomplete').hide();
		});

	});

