$(function() {
	$.ajax({
		type: "GET",
		url: "/y150/data/tvknews.xml",
		dataType: "xml",
		success: function(xml) { parsecxml(xml); },
		error: function(xml) {}
	});
});

function parsecxml(xml) {
	var count = 0;
	$('item', xml).each(function() {
		var title = $(this).find('title').text();
		var dscp = $(this).find('description').text();
		var date = new Date($(this).find('pubDate').text());
		dscp = dscp.replace(/\r\n/g, "<br />");
		dscp = dscp.replace(/(\n|\r)/g, "<br />");
		$("#news-item_" + count).append("<p class=\"pnt\"><a href=\"#news-dscp_" + count +"\" rel=\"shadowbox\" class=\"news-link\" title=\"" + title + "\">" + title +"</a></p>");
		yy = date.getFullYear();
		mm = date.getMonth() + 1;
		dd = date.getDate();
		hh = date.getHours();
		mi = date.getMinutes();
		if (mm < 10) { mm = "0" + mm; }
		if (dd < 10) { dd = "0" + dd; }
		var date_text =  yy + "/" +mm + "/" + dd + " "+ hh + ":" + mi;
		$("#news-item_" + count).css("display","block");
		$("#news-item_" + count).append("<p class=\"side-date\">" + date_text + "</p>");
		Shadowbox.setup($("#news-item_" + count + " p a"));
		$("#news-item_" + count).append("<div id=\"news-dscp_" + count +"\"><p style=\"padding:10px;color:#FFF;\"><span style=\"display:inline; float:right; margin-top:-5px;\">" + date_text + "</span><br />" + dscp + "</p></div>");
		count++;
		if(count>3) return false;
	});
}

