﻿$(document).ready(function(){
	var out = function(data){
		var xmlData = data.data.news;
		var tmpList;
		if(xmlData.length){
			tmpList = xmlData;
		}else{
			tmpList = [xmlData];
		}
		
		var output = '';
		for(var i = 0; i < tmpList.length; i++){
			var tmpItem = tmpList[i];
			var tmpUrl = tmpItem.url['#cdata-section'];
			var target = tmpItem.url.target;
			target = (target == '' || !target) ? '_self' : target;
			var anchor = '<a href="' + tmpUrl + '" target="' + target + '">';
			
			var tmpDescription;
			if(!tmpUrl || tmpUrl == ''){
				tmpDescription = tmpItem.description;
			}else{
				tmpDescription = anchor + tmpItem.description + '</a>';
			}
			
			
			output += '<div class="news-article">';
			output += '<dl>';
			output += '<dt>' + tmpItem.date + '</dt>'
			output += '<dd class="clearfix">' + tmpDescription + '</dd>';
			output += '</dl>';
			output += '</div>';
		}
		$('#news-div-list').html(output);
	}
	
	var http = new JKL.ParseXML('index/xml/news.xml');
	http.async(out);
	http.parse();
});