swfobject.embedSWF("images/main.swf", "topimage", "100%", "336", "9.0.0", "images/expressInstall.swf", {}, {menu:"false",wmode:"opaque"});

$(function(){
	$.ajax({
		url: "http://law.meijo-u.ac.jp/info/xml-rss2.php",
		async: true,
		cache: false,
		dataType:"xml",
		success: function(xml){
			$('#feedlist').html('');
			$(xml).find('item').each(function(i){
                if ( i > 6 ) {
                    return false;
                }
				var title = $(this).find('title').text();
				var url = $(this).find('link').text();
				var thum = $(this).find('thum').text();
				var description = remove_newline($(this).find('description').text()).substr(0,32);
				if(description.length >= 32) description=description+'...';
				var date = dateParse($(this).find('pubDate').text());
				$('#feedlist').append('<li class="clr"><div class="thum">'+thum+'</div><span class="date">'+date[0]+'</span>&nbsp;&nbsp;<a href="'+url+'">'+title+'</a>'+date[1]+'<div class="item">'+description+'</div></li>');
    		});
		}
	});
});
function dateParse(str){
    var objDate = new Date(str);
    var nowDate = new Date();
    myDay = Math.floor((nowDate.getTime()-objDate.getTime()) / (1000*60*60*24)) + 1;
    if (myDay < 15 ){
        var newMsg = '&nbsp;<img src="./images/new.gif" />';
    } else {
        var newMsg = '';
    }
    var year = objDate.getFullYear();
    var month = objDate.getMonth() + 1;
    var date = objDate.getDate();
    if ( month < 10 ) { month = "0" + month; }
    if ( date < 10 ) { date = "0" + date; }
    str = year + '.' + month + '.' + date;
    rtnValue = new Array(2);
    rtnValue[0] = str;
    rtnValue[1] = newMsg;
    return rtnValue;
}
function remove_newline(text){
	text = text.replace(/\r\n|\n|\<br \/\>|\<div(.+?)\>|\<\/div\>|\<a(.+?)\<\/a\>/g, "");
	return text;
} 