﻿/*
* Autocomplete configure options.  This file is used to configure and override default
*   options for all autocompletes on the site that use jquery-autocomplete.js.
*/
$(document).ready(function() {

	var searchBox = $('.doctor-autocomplete');
	searchBox.autocomplete('Search',
	{
		minChars: 2,
		max: 200,
		width: 334,
		delay: 0,
		matchSubset: true,
		scrollHeight: 400,
		mustMatch: false,
		multiple: false,
		multipleSeparator: "~",
		acWebServiceURL: "/sites/Emerson/services/DoctorSearch.aspx/SearchDoctors",
		formatItem: function(data, i, n, value) {
			return data[1];
		}
	}).result(
		function(event, data, formatted) {
			//searchBox.attr('value', data[0]);
			location.href = data[2];
		});
	searchBox.bind("keypress", function(e) {
		var code = e.charCode || e.keyCode;
		return (code == 13 ) ? false : true;
	});
	
	var searchBox2 = $('.medsvc-autocomplete');
	searchBox2.autocomplete('Search',
	{
		minChars: 2,
		max: 200,
		width: 334,
		delay: 0,
		matchSubset: true,
		scrollHeight: 400,
		mustMatch: false,
		multiple: false,
		multipleSeparator: "~",
		acWebServiceURL: "/sites/Emerson/services/MedServiceSearch.aspx/MedicalServiceSearch",
		formatItem: function(data, i, n, value) {
			return data[1];
		}
	}).result(
		function(event, data, formatted) {
			//searchBox.attr('value', data[0]);
			location.href = data[2];
		});
	searchBox2.bind("keypress", function(e) {
		var code = e.charCode || e.keyCode;
		return (code == 13 ) ? false : true;
	});
	
});
