$(function(){
	
	jQuery('img.slide').maxImage({
		isBackground: true,
		slideShow: true,
		slideShowTitle: false,
		slideDelay: 9,
		slideFade: 2,
		maxFollows: 'width'
	});
	
	/*------------------------------------------------------------------*/
	
	$("#feed").height(parseInt(($(window).height()-550)));
	$('#feed').jScrollPane();
	$(window).resize(function() {
	　$("#feed").height(parseInt(($(window).height()-550)));
	　$('#feed').jScrollPane();
	});
	
	/*------------------------------------------------------------------*/
	
	$.getJSON(
	'http://www.marble-sud.com/js/twitter.proxy.php?user=mbsd_20110819&list=marble-sud',
		//http://api.twitter.com/1/mbsd_20110819/lists/marble-sud/statuses.json?callback=?',
	 //ok, let's join
	 function (json) {
		 //$("#scroller").hide();
//		 for(var i in json){
		 for(var i =0;i<7;i++){	//新着7件のみ表示
		 //console.log(i);
		 $("#scroller").append("<li>"+
		 '<a href="http://twitter.com/#!/'
		 +json[i].user.screen_name+'/status/'+json[i].id_str+'" target="_blank">'
		 +'<img src="'+ json[i].user.profile_image_url +'" width="22" height="22" />'
		 +"</a>"
		 +'<a href="http://twitter.com/#!/'
		 +json[i].user.screen_name+'/status/'+json[i].id_str+'" target="_blank">'
		 +json[i].user.name +"</a>"
		 + json[i].text + "</li>");
//		 if(i == json.length-1){
		 if(i == 7-1){
			//console.log($('#scroller'));
			$('#scroller').list_ticker({
				speed:9000,
				effect:'fade'
			});
		}
	 }
	});

	//ticker 

	/*!
	 * liScroll 1.0
	 * 2007-2010 Gian Carlo Mingati
	 * Version: 1.0.2.1 (22-APRIL-2011)
	 * Dual licensed under the MIT and GPL licenses:
	 * http://www.opensource.org/licenses/mit-license.php
	 * http://www.gnu.org/licenses/gpl.html
	 function ticker(){
			var $strip = $("#scroller");
			var stripWidth =0;
			
			$strip.find("li").each(function(i){
				stripWidth += jQuery($strip, i).outerWidth(true);
			});
			$strip.width(stripWidth);//tiwtter含むulの幅

			var containerWidth = parseInt(($(window).width()-137));//stripの全体幅。
			var totalTravel = stripWidth;
			var defTiming = (totalTravel-containerWidth)/.05;
			$strip.css("left", containerWidth).show();
			//console.log($strip.width())
			//console.log(totalTravel)
			
			
			function scrollnews(spazio, tempo){
				$strip.animate(
					{left: '-='+ spazio},
					tempo,
					"linear",
					function(){$strip.css("left", containerWidth);
						scrollnews(totalTravel, defTiming);
					}
				);
			}				
			scrollnews(totalTravel, defTiming);				
	};
	 */
});

/* List Ticker by Alex Fish 
// www.alexefish.com
//
// options:
//
// effect: fade/slide
// speed: milliseconds
*/

(function($){
  $.fn.list_ticker = function(options){
    
    var defaults = {
      speed:4000,
	  effect:'fade'
    };
    
    var options = $.extend(defaults, options);
    
    return this.each(function(){
      
      var obj = $(this);
      var list = obj.children();
      list.not(':first').hide();
      
      setInterval(function(){
        
        list = obj.children();
        list.not(':first').hide();
        
        var first_li = list.eq(0)
        var second_li = list.eq(1)
		
		if(options.effect == 'slide'){
			first_li.slideUp();
			second_li.slideDown(function(){
				first_li.remove().appendTo(obj);
			});
		} else if(options.effect == 'fade'){
			first_li.fadeOut(function(){
				second_li.fadeIn();
				first_li.remove().appendTo(obj);
			});
		}
      }, options.speed)
    });
  };
})(jQuery);


