﻿Ext.BLANK_IMAGE_URL = '/Js/s.gif';
var tday = new Date();
var matinpanelitemsattrs = { iconCls: 'icon-docs', autoScroll: true, autoLoad: { mode: 'iframe'} }; //, scope: this
var MainPanel = function (attrs, item) {
	var items = Ext.copy({ closable: false, autoLoad: { showMask: true, maskMsg: '正在加载', scope: this} }, item);
	var defattrs = { margins: '0 5 5 0', resizeTabs: true, minTabWidth: 135, tabWidth: 135, xtype: "tabpanel", enableTabScroll: true, activeTab: 0,
		items: Ext.copy(items, matinpanelitemsattrs)
	};
	var attrs = Ext.copy(attrs, defattrs)
	MainPanel.superclass.constructor.call(this, attrs);
};
Ext.extend(MainPanel, Ext.TabPanel, {
	initEvents: function () { MainPanel.superclass.initEvents.call(this); },
	loadTab: function (href, tabid, title, onactive) {
		var tab = this.getComponent(tabid);
		if (tab) {
			if (onactive) this.setActiveTab(tab);
			this.setTitle(title);
			tab.load({ url: href, showMask: true, maskMsg: '正在加载' });
		} else {
			tab = this.add(Ext.copy({ id: tabid, title: title, closable: true, autoLoad:{ url: href, showMask: true, maskMsg: '正在加载', scope: this} }, matinpanelitemsattrs));
			if (onactive) this.setActiveTab(tab);
		}
	}
});
function makeArrOption(p1, p2, p3, p4) {
	var res = [], i = 0;
	for (; p1 <= p2; p1 += p3, i++) { res[i] = { id: p1, title: p1 + p4 }; }
	return res;
}
function cityOptions(p) {
	var tmp = [];
	for (var i = 0; i < p.length; i++) tmp[i] = [p[i][1], p[i][0]];
	return tmp;
}
function provinceOptions(pv) {
	var _tmp = [];
	for (var i = 0; i < pv.length; i++) _tmp[i] = [i, pv[i]];
	return _tmp;
}
function onmessage(s) { Ext.MessageBox.alert('提示：', s); return false; }


var trigattrs = { triggersConfig: [{ iconCls: "x-form-clear-trigger", hideTrigger: true}], valueField: 'id', displayField: 'title', triggerAction: "all", queryDelay: 10, mode: "local", minChars: 0 }
var comboattrs = { typeAhead: true, triggerAction: 'all', forceSelection: true, editable: false, lazyRender: true, mode: 'local', valueField: 'id', displayField: 'title' };

var datArea1, datArea2 = new Ext.data.SimpleStore({ fields: ['id', 'title'], data: [[53, '请选择']] });
var datCommer = new Ext.data.SimpleStore({ fields: ['id', 'title'], data: [[0, '请选择']] });
var datChain = new Ext.data.SimpleStore({ fields: ['id', 'title'], data: [[0, '请选择']] });
var datPrice1 = new Ext.data.JsonStore({ autoLoad: true, root: 'root', fields: ['id', 'title'], data: { root: makeArrOption(50, 4950, 50, '元')} });
var datPrice2 = new Ext.data.JsonStore({ autoLoad: true, root: 'root', fields: ['id', 'title'], data: { root: makeArrOption(100, 5000, 50, '元')} });
var datStar = new Ext.data.JsonStore({ autoLoad: true, root: 'root', fields: ['id', 'title'], data: { root: makeArrOption(2, 5, 1, '星级')} });
var datPx = new Ext.data.SimpleStore({ fields: ['id', 'title'], data: [[1, '网站默认'], [2, '价格由低到高'], [3, '星级由低到高'], [4, '客户评价由高到低']] });

function binderChainAndCommercial(c1,c2,pas) {
	c1.clearValue();
	c2.clearValue();
	Ext.Ajax.request({
		url: '/js/GetCityInfo.ashx',
		success: function (result) {
			var data = eval('(' + result.responseText + ')');
			c1.store.loadData(data.commer);
			c2.store.loadData(data.chain);
		},
		failure: function (err, response) { },
		params: pas
	});
}

