Ext.BLANK_IMAGE_URL="./ext-3.1/resources/images/default/s.gif";

chkStr = function(strs) { //
	if(strs.match( /[\/_\'\"\\<\>\=]+/ ) ) {
		return false;
	} else {
		return true;
	}
}

Ext.onReady(function(){

//****************************************************************
//	JSON
//****************************************************************	
	newsDetail = Ext.data.Record.create([
			{name: 'data0', type: 'int',sortable: true},
			{name: 'data1', type: 'string'},	//日付
			{name: 'data2', type: 'string'},	//内容	
			{name: 'data3', type: 'string'}		//URL
	]);
	
//****************************************************************
//	JSONデータのストア定義
//****************************************************************	

	newsStore = new Ext.data.JsonStore({
			url  : './mod/newsDisp.php',  //サーバー側school jsonデータ出力URL
			root : 'mt',
			remoteSort: true,
			listeners: {
				exception : function(proxy,type,action,o,responce,args){
					if(type !== 'remote'){
						Ext.getDom('infomationBody').innerHTML = '<p style="text-align:left;padding-left:10px;">現在お知らせはございません</p>';
					}
				}
			},			
			autoLoad: {params:{method:'POST'}},
			sortInfo: {field:'data0', direction:'DESC'},
			fields:newsDetail
	});

	newsStore.on('load',function(){
		if(newsStore.data.items[0].data.data1 == 'err'){
			var msgTxt = '<p style="text-align:left;padding-left:10px;">現在表示ができません</p>';
		} else {
			var ns = newsStore.data.items.length;
		}
		
		if(newsStore.data.items[0].data.data2.length == 0) {
			var msgTxt = '<p style="text-align:left;padding-left:10px;">現在お知らせはございません</p>';
		} else {
			var msgTxt = '';
			msgTxt = '<table width="460" border="0" cellpadding="2" cellspacing="0" class="margin_10">';
			for(i = 0;i < ns;i++) {
				var conts = '';
				var strLength = newsStore.data.items[i].data.data3.length;
				if(strLength > 0){
					conts = '<a href="'+newsStore.data.items[i].data.data3+'" target=_self>'+decodeURIComponent(newsStore.data.items[i].data.data2)+'</a>';
				} else {
					conts = decodeURIComponent(newsStore.data.items[i].data.data2);
				}
				msgTxt += '<tr>';
				msgTxt += '<td width="100" align="left" valign="top">'+newsStore.data.items[i].data.data1+'</td>';
				msgTxt += '<td align="left"><p style="margin-top: 0">'+conts+'</td>';
				msgTxt += '</tr>';
			}
			msgTxt += '</table>';
		}
		Ext.getDom('infomationBody').innerHTML = msgTxt;
	});
   	
});