//<![CDATA[
$(document).ready(function () {
	headline_init();
});

(function($){
$.fn.vTicker = function(options) {
	var defaults = {
		speed: 100,
		pause: 3000,
		showItems: 1
	};

	var options = $.extend(defaults, options);

	moveUp = function(obj, height){
    	first = obj.children('ul').children('li:first').clone(true);
    	obj.children('ul')
    	.animate({top: '-=' + height + 'px'}, options.speed, function() {
        	$(this).children('li:first').remove();
        	$(this).css('top', '0px');
        });

    	first.appendTo(obj.children('ul'));
	};

	return this.each(function() {
		obj = $(this);
		maxHeight = 0;

		obj.css({overflow: 'hidden', position: 'relative'})
			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
			.children('li').css({margin: 0, padding: 0});

		obj.children('ul').children('li').each(function(){
			if($(this).height() > maxHeight)
			{
				maxHeight = $(this).height();
			}
		});

		obj.children('ul').children('li').each(function(){
			$(this).height(maxHeight);
		});

		obj.height(maxHeight * options.showItems);

		interval = setInterval('moveUp(obj, maxHeight)', options.pause);

		obj.hover(
			function() {
				clearInterval(interval);
			},
			function() {
				interval = setInterval('moveUp(obj, maxHeight)', options.pause);
			}
		);

	});
};
})(jQuery);

function headline_init(){

	var url		= "/file/LX_GalleryRealtimeComment.xml";
	var html	= "";

	$.ajax({
		type:"GET",
		url:url,
		dataType: "xml",
		error: function(error){
	       // alert('Ajax Data load errer : '+error);
	    },
		success: function(_xml){

	    	$(_xml).find("entry").each(function(){

	    		html += "<li class='headline'>";
    			html += "<a href='"+$(this).find("link").text()+"'>"+$(this).find("content").text()+" "+$(this).find("date").text()+"</a>";
				html += "</li>";

	    	})

	    	$("#rolling_comment > UL").html(html);
		},

		complete: function(_xml){
			$('#rolling_comment').vTicker();
		}
	})
}
//]]>