(function($) { 

$(function(){
	//dType= ($.browser.msie) ? "text" : "xml";
	dType= "xml";
	
	xmlProduct = $.ajax({
		url: "productinfo/atom.xml",
		dataType: dType,
		timeout: 10000,
		async: true,
		cache: false,
		success: parserXML
	});

	function parserXML(xml){
		output = "#box_"+$(xml).find("feed > category").attr("term");
		viewlength = Math.min($(xml).find("entry").length, 5);

		$(output).append("<ul></ul>");
		
		for(i=0; i<viewlength; i++){
			xmlItem = $(xml).find("entry").eq(i);

			date = $(xmlItem).find("title").text();
			icon = $(xmlItem).find("category").attr("term")||"none";
			title = $(xmlItem).find("content").text();
			link = $(xmlItem).find('link[rel="alternate"]').attr("href")||"none";
			pdf = $(xmlItem).find('link[rel="via"]').attr("href")||"none";
			
			date_array = date.split(",");
			
			$(output + " ul")
			.append('<li><p class="date">'+date_array[0]+'</p><p class="headline">'+title+'</p></li>');
			
			if(icon != "none"){
				$(output + " ul p.date:last").addClass(icon);
			}
			if(link != "none"){
				$(output + " ul p.headline:last").wrapInner('<a href="'+link+'"></a>');
			}
			if(pdf != "none"){
				size = "("+$(xmlItem).find('link[rel="via"]').attr("length")+")";
				$(output + " ul p.headline:last").append(pdfHTML);
				$(output + " ul p.headline:last span a").attr("href",pdf).append(size);
			}
		}
		$(output + " ul li:last").addClass("lastChild");
	}
	
	pdfHTML = '<span class="pdf"><a target="_blank"><img src="images/common/icon_pdf.gif" alt="PDF" width="17" height="17" /></a></span>'

});



})(jQuery);




