Ext.onReady(function() {

			initExt();

			if (typeof(publicInit) != "undefined") {
				publicInit();
			}
			if (typeof(showMainPanel) != "undefined") {
				showMainPanel();
			} else {
				new Ext.Panel({
							height : 200,
							frame : true,
							title : '区域无内容',
							html : '区域内容显示尚未实现。。。'
						}).render('bd');
			}

			var activeMenu;

			function createMenu(name) {
				var el = Ext.get(name + '-link');
				var tid = 0, menu, doc = Ext.getDoc();

				var handleOver = function(e, t) {
					if (t != el.dom && t != menu.dom && !e.within(el) && !e.within(menu)) {
						hideMenu();
					}
				};

				var hideMenu = function() {
					if (menu) {
						menu.hide();
						el.setStyle('text-decoration', '');
						doc.un('mouseover', handleOver);
						doc.un('mousedown', handleDown);
					}
				}

				var handleDown = function(e) {
					if (!e.within(menu)) {
						hideMenu();
					}
				}

				var showMenu = function() {
					clearTimeout(tid);
					tid = 0;

					if (!menu) {
						menu = new Ext.Layer({
									shadow : 'sides',
									hideMode : 'display'
								}, name + '-menu');
					}
					menu.hideMenu = hideMenu;

					menu.el = el;
					if (activeMenu && menu != activeMenu) {
						activeMenu.hideMenu();
					}
					activeMenu = menu;

					if (!menu.isVisible()) {
						menu.show();
						menu.alignTo(el, 'tl-bl?');
						menu.sync();
						// el.setStyle('text-decoration', 'underline');
						var viewportEl = Ext.get("viewport");
						var viewportLeft = viewportEl.getLeft();
						var viewportWidth = viewportEl.getWidth()
						var menuLeft = menu.getLeft();
						var menuWidth = menu.getWidth();
						if (menuLeft + menuWidth > viewportLeft + viewportWidth) {
							// var activeMenuLeft = el.getLeft();
							// var activeMenuWidth = el.getWidth();
							// menu.setLeft(activeMenuLeft + activeMenuWidth - menuWidth);
							var activeMenuLeft = viewportLeft + viewportWidth - menuWidth;
							var activeMenuWidth = el.getWidth();
							menu.setLeft(activeMenuLeft);
						}

						doc.on('mouseover', handleOver, null, {
									buffer : 150
								});
						doc.on('mousedown', handleDown);
					}
				}

				el.on('mouseover', function(e) {
							if (!tid) {
								tid = showMenu.defer(150);
							}
						});

				el.on('mouseout', function(e) {
							if (tid && !e.within(el, true)) {
								clearTimeout(tid);
								tid = 0;
							}
						});
			}

			for (var i = 0; i < submenus.length; i++) {
				createMenu(submenus[i]);

			}

			// expanders
			Ext.getBody().on('click', function(e, t) {
						t = Ext.get(t);
						e.stopEvent();

						var bd = t.next('div.expandable-body');
						bd.enableDisplayMode();
						var bdi = bd.first();
						var expanded = bd.isVisible();

						if (expanded) {
							bd.hide();
						} else {
							bdi.hide();
							bd.show();
							bdi.slideIn('l', {
										duration : .2,
										stopFx : true,
										easing : 'easeOut'
									});
						}

						t.update(!expanded ? 'Hide details' : 'Show details');

					}, null, {
						delegate : 'a.expander'
					});

		});

function getContentListPanel(config) {

	var target = config.target || "_self";

	var start = config.start || 0;

	var pageSize = config.pageSize || 10;

	var store = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : UBA.url
						}),
				baseParams : {
					start : start,
					limit : pageSize
				},
				reader : new Ext.data.JsonReader(UBA.readerConfig, ["recordDesc", "recordTitle", "id", "content", "icon", "title", "status", "subject", "name", "path", "params"])
			});

	var bbar = [];
	bbar.push("->");
	if (config.showAll) {
		bbar.push(new Ext.Button({
					text : getword('showAll'),
					handler : function() {
						var url = location.protocol + '//' + location.host + location.pathname + '?screen=menu5.sub2';
						window.location.replace(url);
					}
				}));
	}
	if (config.prePage) {
		bbar.push(new Ext.Button({
					id : 'prePageButton',
					text : getword('prePage'),
					handler : function() {
						var start = store.baseParams.start - store.baseParams.limit;
						if (start >= 0) {
							store.baseParams.start = store.baseParams.start - store.baseParams.limit;
							panel.removeAll();
							store.reload();
						}
					}
				}));
	}
	if (config.nextPage) {
		bbar.push(new Ext.Button({
					id : 'nextPageButton',
					text : getword('nextPage'),
					handler : function() {
						store.baseParams.start = store.baseParams.start + store.baseParams.limit;
						panel.removeAll();
						store.reload();
					}
				}));
	}
	var panel = new Ext.Panel({
				layout : 'accordion',
				border : false,
				bbar : bbar,
				layoutConfig : {
					animate : true,
					collapseFirst : true,
					fill : true
				},
				items : []
			});

	store.on("load", function(store, records, options) {

				if (panel) {
					var nextPageButton = Ext.getCmp('nextPageButton');
					if (nextPageButton) {
						var nextPage_start = store.baseParams.start + store.baseParams.limit;
						if (nextPage_start < store.totalLength) {
							nextPageButton.show();

						} else {
							nextPageButton.hide();
						}
					}

					var prePageButton = Ext.getCmp('prePageButton');
					if (prePageButton) {
						var prePage_start = store.baseParams.start - store.baseParams.limit;
						if (prePage_start >= 0) {
							prePageButton.show();
						} else {
							prePageButton.hide();
						}
					}
				}

				for (var i = 0; i < records.length; i++) {
					var title = records[i].get("title");
					// var herf = location.pathname + '?screen=' + cur_screen + "&c=" + records[i].get("id");
					var herf = location.protocol + '//' + location.host + location.pathname + '?screen=' + (config.screen ? config.screen : 'menu5.sub2') + '&c='
							+ records[i].get("id");
					var subject = records[i].get("subject");
					var p = new Ext.Panel({
								title : title,
								contentUrl : herf,
								border : true,
								cls : 'news_record',
								autoHeight : true,
								hideCollapseTool : true,
								html : '<div style="padding: 10px;">' + '<a class="news_record_title" target="_self" href="' + herf + '">' + title + '</a>'
										// + '&nbsp;&nbsp;&nbsp;' +
										// '<a href="' + herf + '"><img border="0" src="front.gif" width="13" height="22" align="right"></a>'
										+ '<p>' + subject + '</div>',
								tools : [{
											id : 'right',
											handler : function(event, toolEl, panel) {
												if (target == "_self") {
													window.location.replace(panel.contentUrl);
												} else {
													window.open(panel.contentUrl);
												}
											}
										}]
							})
					panel.add(p);
				}
				panel.doLayout();
			});

	store.load({
				params : {
					module : 'cms_content_v',
					orderby : 'order by pubdate desc, pubtime desc',
					fields : config.fields,
					query : config.query,
					action : 'list'
				}
			});

	return panel;
}

function getSpecialAlertPanel(config) {

	var target = config.target || "_self";

	var start = config.start || 0;

	var pageSize = config.pageSize || 10;

	var store = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : UBA.url
						}),
				baseParams : {
					start : start,
					limit : pageSize
				},
				reader : new Ext.data.JsonReader(UBA.readerConfig, ["recordDesc", "recordTitle", "id", "content", "icon", "title", "status", "subject", "name", "path", "params"])
			});

	var bbar = [];
	bbar.push("->");
	if (config.showAll) {
		bbar.push(new Ext.Button({
					text : getword('showAll'),
					handler : function() {
						var url = location.protocol + '//' + location.host + location.pathname + '?screen=menu5.sub3';
						window.location.replace(url);
					}
				}));
	}
	if (config.prePage) {
		bbar.push(new Ext.Button({
					id : 'siPrePageButton',
					text : getword('prePage'),
					handler : function() {
						var start = store.baseParams.start - store.baseParams.limit;
						if (start >= 0) {
							store.baseParams.start = store.baseParams.start - store.baseParams.limit;
							panel.removeAll();
							store.reload();
						}
					}
				}));
	}
	if (config.nextPage) {
		bbar.push(new Ext.Button({
					id : 'siNextPageButton',
					text : getword('nextPage'),
					handler : function() {
						store.baseParams.start = store.baseParams.start + store.baseParams.limit;
						panel.removeAll();
						store.reload();
					}
				}));
	}
	var panel = new Ext.Panel({
				layout : 'column',
				border : false,
				bbar : bbar,
				layoutConfig : {
					animate : true,
					collapseFirst : true,
					fill : true
				},
				items : []
			});

	store.on("load", function(store, records, options) {

		if (panel) {
			var nextPageButton = Ext.getCmp('siNextPageButton');
			if (nextPageButton) {
				var nextPage_start = store.baseParams.start + store.baseParams.limit;
				if (nextPage_start < store.totalLength) {
					nextPageButton.show();

				} else {
					nextPageButton.hide();
				}
			}

			var prePageButton = Ext.getCmp('siPrePageButton');
			if (prePageButton) {
				var prePage_start = store.baseParams.start - store.baseParams.limit;
				if (prePage_start >= 0) {
					prePageButton.show();
				} else {
					prePageButton.hide();
				}
			}
		}

		for (var i = 0; i < records.length; i++) {
		
			var qlan ;
			if( config.query ){
				var qParts = config.query.split( "_" );
				if( qParts.length>=2 ){
					qlan = qParts[1];
				}
			}
			
			var title = records[i].get("title");
			if (title.length > 12) {
				var len = 14 ;
				if( qlan && qlan=="en" ){
					len = title.length>25?25:title.length ;
				}
				title = title.substr(0, len) + "...";
			}
			var herf = location.protocol + '//' + location.host + location.pathname + '?screen=' + (config.screen ? config.screen : 'menu5.sub3') + '&c=' + records[i].get("id");
			var subject = records[i].get("subject");
			var iconPaddTop = qlan=='en'?4:2;

			var p = new Ext.Panel({
						columnWidth : 1,
						height : 23,
						autoHeight : false,
						border : false,
						html : "<div style='width:100%;height:20px;margin-top:2px;padding-bottom:2px;overflow:hidden'>"
								+ "<div style='float:left;padding-left:5px;padding-top:"+iconPaddTop+"px;'><img src='cms/apps/icbc_ca/images/round_icon.jpg' /></div>"
								+ "<div style='padding-left:20px;'><a href='"
								+ herf
								+ "' style='color:black;' onmouseover='javascript:this.style.textDecoration=\"underline\"' onmouseout='javascript:this.style.textDecoration=\"none\"'>"
								+ title + "</a></div></div>"

					});
			panel.add(p);

		}
		panel.doLayout();
	});

	store.load({
				params : {
					module : 'cms_content_v',
					orderby : 'order by pubdate desc, pubtime desc',
					fields : config.fields,
					query : config.query,
					action : 'list'
				}
			});

	return panel;
}

