/* Weather Box */

Sppc.Landing.WeatherWeatherComBox$Class = {
	constructor: function(data) {
		Sppc.Core.extendSuper(this, Sppc.Landing.AbstractBox, Sppc.Landing.WeatherWeatherComBox$Class, data);
	},

	_settingsLoaded: function() {
		this.__super._settingsLoaded();
		
		var thisObj = this;
		jQuery('#weatherComLocation_'+this._id).change(function(){
			jQuery('#searchWeatherComLocation_'+thisObj._id).val('');
		});
		
		var autocompleater = jQuery('#searchWeatherComLocation_'+this._id).autocomplete(site_url+"box/weather_weathercom/search", {
			autoFill: false,
			width: 320,
			max: 4,
			highlight: false,
			scroll: true,
			scrollHeight: 300,
			extraParams: { 'id': this._id },			
			formatItem: function(data, i, n, value) {
				return value.split(";")[1];
			},
			formatResult: function(data, value) {
				return value.split(";")[1];
			}
			
		});
		autocompleater.result(function(event, data, formatted) {
			var code = formatted.split(";")[0]; 
			var title = formatted.split(";")[1]; 
			jQuery('#displayTitle_'+thisObj._id).val(title);
			jQuery('#weatherComLocation_'+thisObj._id).val(code);
			return code; 
		});

	}
};
Sppc.Landing.WeatherWeatherComBox = Sppc.Landing.WeatherWeatherComBox$Class.constructor;
