$(function() {
	function format(cityzip) {
		return cityzip.c + " " + cityzip.z;
	}
        $("#from_zip").focus(function() {
            if ($(this).val() == 'Type City Here'){
                $(this).val('');
            }
        });

	$("#from_zip").autocomplete('zips.php', {
                minChars: 3,
		width: 232,
                cacheLength: 1,
                max: 100,
		dataType: "json",
		parse: function(data) {
			return $.map(data, function(row) {
				return {
					data: row,
					value: row.c + " " + row.z,
					result: row.c + " " + row.z
				}
			});
		},
		formatItem: function(item) {
			return format(item);
		}
	});

        $("#to_zip").focus(function() {
            if ($(this).val() == 'Type City Here'){
                $(this).val('');
            }
        });

	$("#to_zip").autocomplete('zips.php', {
                minChars: 3,
		width: 232,
                cacheLength: 1,
                max: 100,
		dataType: "json",
		parse: function(data) {
			return $.map(data, function(row) {
				return {
					data: row,
					value: row.c + " " + row.z,
					result: row.c + " " + row.z
				}
			});
		},
		formatItem: function(item) {
			return format(item);
		}
	});
});
