var pradio = [];
var pmagazine = [];
var ptv = [];
var pweb = [];

$(function(){
	$.ajax({
    url: 'atom.xml',
    type: 'GET',
    dataType: 'xml',
    timeout: 1000,
    error: function(){
        //$('#new dl').html('<dd>最新記事が取得できませんでした</dd>');
    },
    success: function(xml){
			var pradio = [];
			var pmagazine = [];
			var ptv = [];
			var pweb = [];
			
			$(xml).find("entry").each(function(){
				var published = $('published',this).text();
				published = published.split('T')[0].split('-');
				published = published[0] + published[1] + published[2];
				
				var cat = $('category',this).attr('term');
				
				if(cat == 'RADIO'){
					pradio.push(published);
				}
				else if(cat == 'MAGAZINE'){
					pmagazine.push(published);
				}
				else if(cat == 'TV'){
					ptv.push(published);
				}
				else if(cat == 'WEB'){
					pweb.push(published);
				}
			});
			
			pradio.sort();
			pmagazine.sort();
			ptv.sort();
			pweb.sort();
			
			pradio.reverse();
			pmagazine.reverse();
			ptv.reverse();
			pweb.reverse();
			
			pradio = pradio[0];
			pmagazine = pmagazine[0];
			ptv = ptv[0];
			pweb = pweb[0];
			
			var a=1;
			
			$.get('date_get.php',function(udate){
				if(pradio > udate){
					newIconView('sRadio');
				}
				if(pmagazine > udate){
					newIconView('sMagazine');
				}
				if(ptv > udate){
					newIconView('sTV');
				}
				if(pweb > udate){
					newIconView('sWeb');
				}
			});
			
    }
    });
});

function newIconView(id){
	id = '#' + id;
	var str = $(id).html();
	$(id).html(str+'&nbsp;<strong>[NEW]</strong>');
}





