var blogMax = 4;

function bindNewsData(data_array) {
	if(!data_array) return;
	if(data_array.length <= 0) return;

	function getBlogDate(_str){
		return new Date(
			_str.substring(0,4),
			_str.substring(4,6) - 1, // Jan = 0
			_str.substring(6,8),
			_str.substring(8,10),
			_str.substring(10,12),
			_str.substring(12,14)
		);
	}

	var listItem = $('<li><p class="category"></p><p class="title"><a href=""></a></p><p class="pubDate"></p></li>');
	var listBody = $('<ul class="blog-feeds link"></ul>')
	var count = 0;

	jQuery.each(data_array, function(){
		var itemPubDate = getBlogDate(this.pubDate);
		listItem.clone()
		.find('p.category')
			.text(this.category || '')
		.end()
		.find('p.title a')
			.attr('href', this.link)
			.text(this.title)
		.end()
		.find('p.pubDate')
			.text(formatDate(itemPubDate))
		.end()
		.appendTo(listBody);
		return (++count < blogMax) ;
	});
	$('#cyber-showcase-blog')
		.find('ul.link')
			.attr('class', 'link read-more')
			.find('a')
				.text(blog_read_more)
			.end()
		.end()
		.prepend(listBody);
}


$(function(){
	$.ajax({
		url: blog_json_url,
		dataType: 'script'
	});
});




