var CityInput=Class.eventClass(); 
Object.extend (CityInput.prototype, {
	asyncValidate: true,
	useSuggest: false,
	useHotCity: false,
	useValidate: false,
	f_c: "",
	initialize: function (f_cJ, f_bn) {
		this.f_c = $(f_cJ);
		this.id=f_cJ + "_CI";
		if (!this.f_c) return false;
 		if (!this.f_c.name)  this.f_c.name = f_cJ;
		if (f_bn.useValidate && f_bn.validateURL) {
			this.f_bK = f_bn.validateURL;
	 		Object.extendAndInit(this.f_c,InputboxExtension,System.language._CITYINPUT_LANG,this.f_ed.bind(this));
		} else {
			Object.extendAndInit(this.f_c,InputboxExtension,System.language._CITYINPUT_LANG);
		}
			this.f_c.autoValidate = true;
			this.f_c.asyncValidate = true;
		if (f_bn.useSuggest) this.f_fG(f_bn);
		if (f_bn.useHotCity) this.f_fH(f_bn);
		this.f_bn = f_bn;
	},
	f_fG : function (f_bn) {
		var f_dq = new Suggest(this.id+"_SG");
		f_dq.showAirport = f_bn.showAirport;
		f_dq.suggestURL = System.constant.SUGGEST_URL;
		f_dq.templateObj = f_bn.suggestTemplateObj;
		f_dq.attach(this.f_c)
	},
	f_fH: function (f_bn) {
		this.hotcityObj = new HotCity();
		this.hotcityObj.templateObj = f_bn.hotCityTemplateObj;
		this.hotcityObj.hotCityList = f_bn.hotCityList;
		this.hotcityObj.attach(this.f_c, f_bn.hotCityImage);
	},

f_ed: function () {
		var f_l = "lang=" + this.f_bn.language + "&input=" + encodeURI(this.f_c.value);
		f_l += ("&sa=" + (this.f_bn.showAirport?"true":"false"));
		if (this.f_aS && this.f_aS.transport.readyState!=4 ) {
			try {
				this.f_aS.transport.abort();
			} catch (e) {
			}
		}
		this.f_aS = new Ajax.Request(
			this.f_bK,
			{
				method:	"get",
				crossSite : true,
				parameters: f_l+"&callback=window.ObjectPool."+this.id+".f_bV",

				onException: showError
		 	});
	    },
		f_bV : function(f_cs) {
			if (!f_cs) {
				this.f_c.setValidate(false);
			} else {
				if (f_cs[0].validate) {
					this.f_c.country = f_cs[0].country;
					this.f_c.setValue(f_cs[0].value, true);
				}	else {
				this.f_c.setValidate(false);
				}	
			}
			Event.fire(this.f_c, "validatecomplete");
		},
		isInterCity : function () {
			return this.f_c.country != null && this.f_c.country != this.f_bn.homeCountry;
		}
})
