/**
* fetch all states when user type a word
* @param    void
* @return   void
*/
function getStateAutocomplete()
{      	
	$("#state").autocomplete(baseUrl+"/index/get-state/", {
		width: 335,
		minChars: 2,
		cacheLength: 0
	});				
	$("#state").result(function(event, data, formatted) {
		if (data)
		$("#state_hidden").val(data[1]);
	});	
	$state = $("#state").val();
	if ($state == '') {
		$("#state_hidden").val('');
		$("#city").val('');
		$("#city_hidden").val('');
		$("#zipcode").val('');
	}
}
/**
* fetch all cities with respect to state when user type a word
* @param    void
* @return   void
*/
function getCityAutocomplete() 
{
	var stateId;
	stateId = $("#state_hidden").val();	
	$("#city").autocomplete(baseUrl+"/index/get-city/stateId/"+stateId, {
		width: 335,
		minChars: 2,
		cacheLength: 0
	});
	$("#city").result(function(event, data, formatted) {
		if (data) {
			$("#city_hidden").val(data[1]);
			cityId  = $("#city_hidden").val();
			getschool(cityId,baseUrl);
		}
	});
	$city = $("#city").val();
	if ($city == '') {
		$("#zip_hidden").val('');
		$("#city_hidden").val('');
		$("#zipcode").val('');
	}
}
/**
* fetch user city related schools when user try to type a school name
* @param    void
* @return   void
*/
function getSchoolAutocomplete() 
{
	var cityId;
	cityId  = $("#city_hidden").val();	
	$("#school").autocomplete(baseUrl+"/index/get-school/cityId/"+cityId, {
		width: 165,
		minChars: 2
	});
	$("#school").result(function(event, data, formatted) {
		if (data)
		$("#school_hidden").val(data[1]);
	});
}
/**
* fetch state and city related all zip code when user try to type a zip code
* @param    void
* @return   void
*/
function getZipCodeAutocomplete() 
{
	
	var stateId;
	var cityId;
	stateId = $("#state_hidden").val();	
	cityId  = $("#city_hidden").val();	
	$("#zipcode").autocomplete(baseUrl+"/index/get-zipcode/stateId/" +stateId+ "/cityId/"+cityId, {
		width: 335,
		minChars: 2,
		cacheLength: 0
	});
	$("#zipcode").result(function(event, data, formatted) {
		if (data)
		$("#zip_hidden").val(data[1]);
	});
}
/**
* fetch state and city related all zip code when user try to type a zip code
* @param    void
* @return   void
*/
function getProfileZipCodeAutocomplete() 
{
	
	var stateId;
	var cityId;
	stateId = $("#state_hidden").val();	
	cityId  = $("#city_hidden").val();	
	$("#zipCode").autocomplete(baseUrl+"/index/get-zipcode/stateId/" +stateId+ "/cityId/"+cityId, {
		width: 165,
		minChars: 2,
		cacheLength: 0
		
	});
	$("#zipCode").result(function(event, data, formatted) {
		if (data)
		$("#zip_hidden").val(data[1]);
	});
}


