if(!BMObjs){var BMObjs=[];};
if(!BMObjs["hotcity"]) BMObjs["hotcity"]=[];
var HotCity = Class.eventClass();

Object.extend (HotCity.prototype, {
	hotCityList: false,
	hotCityTemplate: false,
	templateObj: "",
	f_aG: false,
	initialize: function() {
		this.objType = "hotcity";
		BMObjs["hotcity"].push(this);
	},
	attach: function(f_c, f_cv) {
		this.f_c = $(f_c);
		this.f_cv = $(f_cv);
		this.f_cT = this.f_c.extendBox;
		this.hotCityList.hotCityCount = this.hotCityList.cityList.length;
		if (!this.f_aG) {
			if (this.hotCityTemplate) this.f_aG = TrimPath.parseTemplate(this.hotCityTemplate);
			else this.f_aG = TrimPath.parseTemplate (this.templateObj);
		}
		Event.observe(this.f_cv, "click", this.f_fc.bind(this));
		Event.observe(this.f_cv, "blur", this.f_bE.bindAsEventListener(this,false));

	},
	f_bE: function (event, f_bv, f_aR) {
		Event.stop(event);
		if (Prototype.Browser.IE && document.activeElement.tagName.toUpperCase()=="IFRAME") {
			this.f_c.f_ap = true;
      this.f_cv.focus();
			return;
		}
		if (f_bv) {
			this.f_c.country = f_aR.readAttribute("country");
			this.f_c.setValue(f_aR.readAttribute("key"));
			this.f_c.setValidate(true);
			this.f_c.fillExtendBox();
		} else {
			window.setTimeout(this.f_c.fillExtendBox.bind(this.f_c),200);
		}
	},
	f_fc: function() {
		if (!this.f_bA || !this.f_c.isShownInExtendBox(this.f_bA)) {
			//this.fireEvent("cityshow");
			var f_A = this.f_aG.process(this.hotCityList);
			this.f_bA = $E(f_A);
			this.f_bA.getElementsBySelector("li").each(function (f_aX) {				
			  Event.observe(f_aX, "click" , this.f_bE.bindAsEventListener(this,true,f_aX));
			  Event.observe(f_aX, "click" , function() {
			  	//this.fireEvent("cityselect",f_aX.innerHTML.stripTags());	
			  }.bind(this));
			}.bind(this));
			this.f_bA.getElementsBySelector("img.closeImg").each(function (f_hd) {				
			  Event.observe(f_hd, "click" , this.f_bE.bindAsEventListener(this,false));
			}.bind(this));
		} else  {
			this.f_bA = false;
		}
		this.f_c.fillExtendBox(this.f_bA);
	}
});
