//************************************************************************************************
// --  English NEWS  --
//************************************************************************************************


// NEWS write------------------------------------------------------------
// ['start', 'end', 'text']  !! NOT TOUCH last[] !!
// ★★★アポストロフィは直前に￥マークを付ける★★★
var ism_news = [

	['2012/01/01', '2222/01/01', '<a href="http://noe.ism.ac.jp/sml-center-en/">The website of the Research Center for Statistical Machine Learning launched</a>'],
	['2011/12/22', '2011/12/29', 'This website will be temporarily unavailable due to maintenance between Dec.28, 21:00 and Dec.29 9:00, JST.'],
	['2011/11/08', '2222/01/01', 'The Memorandum of Agreement with National Institute for Japanese Language and Linguistics has been signed.'],
	['2011/10/31', '2222/01/01', '<a href="editsec/aism/vol63.html#NO6">Annals of the Institute of Statistical Mathematics Vol.63, No.6 published. </a>'],
	['2011/10/24', '2222/01/01', '<a href="gaiyo-news/Gaiyou/2011en.pdf">Outline 2011-2012 (PDF: 3,869KB) published.</a>'],

	[]
];
// ------------------------------------------------------------


// NEWS program------------------------------------------------------------
function item_news(arr0, cnt) {
	if (cnt==undefined) { cnt=99999; }

	// for Opera
	arr = new Array();
	for (k in arr0) {
		if (arr0[k][0] != undefined) {
			arr[k] = arr0[k];
		}
	}

	// for IE
	for (j in arr) {
		//arr[j][99] = arr[j][0] + '_' + pad(j, 4);
		arr[j][99] = arr[j][0] + '_' + pad(9999-j, 4);
	}

	//arr = asort(arr, '0', '1');
	arr = asort(arr, '99', '1');

	var today = new Date();
	var new_days = 7;
	var new_text = '<img src="image/icon_new.gif" alt="new" width="27" height="11" />';

	var cnt2 = 0;
	for (var i=0; i<arr.length; i++) {
		var startday = new Date(arr[i][0] + ' 00:00:00');
		var endday = new Date(arr[i][1] + ' 23:59:59');

		if ((today >= startday) && (today <= endday)) {
			text1 = '<dt>' + arr[i][0] + '</dt>';
			if ((today - startday) / (24*60*60*1000) <= new_days) {
				text2 = new_text;
			} else {
				text2 = '';
			}
			text3 = '<dd>' + arr[i][2] + text2 + '</dd>';
			document.write(text1 + text3);
			cnt2++;
		}
		if (cnt2 >= cnt) { break; }
	}
}
function asort(arr, key, desc){
	if (desc == undefined) { desc = 0; }
	if (desc == 0) {
		arr.sort ( function (a, b) { return a[key] > b[key] ? 1 : -1; } );
	} else {
		arr.sort ( function (a, b) { return a[key] > b[key] ? -1 : 1; } );
	}
	return arr;
}
function pad(str, length) {
    while (str.length < length) str = '0' + str;
    return str;
}
// ------------------------------------------------------------

