﻿var cdate = p.getdate(), extcons, getCheckedDate = function (index) {
	var cdate = extcons[index].getValue();
	return cdate ? cdate.getFullYear() + '-' + (cdate.getMonth() + 1) + '-' + cdate.getDate() : null;
}, onsearch = function () {
	location.href = '/Hotel-search.html?t=1&provinceid=' + extcons[0].getValue() + '&cityid=' + extcons[1].getValue() +
									'&comedate=' + p.format(extcons[2].getValue()) + '&outdate=' + p.format(extcons[3].getValue()) + '&minprice=' + extcons[4].getValue() +
									'&maxprice=' + extcons[5].getValue() + '&hn=' + escape(extcons[6].getValue());
}
Ext.onReady(function () {
	datArea1 = new Ext.data.SimpleStore({ fields: ['id', 'title'], data: provinceOptions(Ap) });
	extcons = [
			new Ext.form.ComboBox(Ext.copy({ el: "conArea1", store: datArea1, width: 80 }, comboattrs)),
			new Ext.form.ComboBox(Ext.copy({ el: "conArea2", store: datArea2, width: 80 }, comboattrs)),
			new Ext.form.DateField({ format: "Y-m-d", el: "conDateStart", width: 100, enableKeyEvents: true, value: cdate.d1 }),
			new Ext.form.DateField({ format: "Y-m-d", el: "conDateFinish", width: 100, enableKeyEvents: true, value: cdate.d2 }),
			new Ext.TriggerComboBox({
				store: datPrice1, el: "conPriceStart", valueField: 'id', displayField: 'title', triggerAction: "all", width: 80, queryDelay: 10, mode: "local", minChars: 1,
				triggersConfig: [{ iconCls: "x-form-clear-trigger", hideTrigger: true}]
			}),
			new Ext.TriggerComboBox({
				store: datPrice2, el: "conPriceFinish", valueField: 'id', displayField: 'title', triggerAction: "all", width: 80, queryDelay: 10, mode: "local", minChars: 1,
				triggersConfig: [{ iconCls: "x-form-clear-trigger", hideTrigger: true}]
			}),
			new Ext.form.TextField({ el: "conKey", width: 100 })
		];
	for (var i = 0; i < extcons.length; i++) extcons[i].render();

	extcons[0].on("select", function (box, newvar, oldvar) {
		var i = Ac[extcons[0].getValue()];
		var tmpobj = extcons[1];
		tmpobj.clearValue();
		tmpobj.store.loadData(i);
	});
});

