function callback(tweets) {
  var html = "";
  var maxLength =  50; //省略文字数

  for (var i=0; i<tweets.length; i++) {
    var tweet = tweets[i];

    var body = tweet.text.slice(0, maxLength);
    if(tweet.text.length > maxLength)  body += " ...";

    var time = niceTime(parseDate(tweet.created_at));
    var owner = tweet.user.screen_name;

    html += '<div class="tweet" '
      + 'onmouseover="$(\'#reply_' + tweet.id + '\').css(\'visibility\', \'visible\')"'
      + 'onmouseout="$(\'#reply_' + tweet.id + '\').css(\'visibility\', \'hidden\')"'
      + '>'
      + '<a href="http://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id + '">'
      + body
      + '</a><br />'
      + '<span class="time">' + time + '</span>'
      + '<a href="http://twitter.com/?status=@' + owner + '%20'
      + '&in_reply_to_status_id=' + tweet.id + '&in_reply_to=' + owner + '" '
      + 'class="reply" id="reply_' + tweet.id + '">'
      + 'reply'
      + '</a>'
      + '</div>';
  }
  $("#tweets").html(html);
}



  window.onload = function getTl() {
//    var id = "Junji_Inagawa";

    var id = "pmb_news";
    var param = "count=20";
    TwitterAPI.statuses.user_timeline(callback, id, param);
  }

/**
 * PRETTY-DATE by James Padsley
 * http://james.padolsey.com/javascript/recursive-pretty-date/
 */
 var niceTime = (function() {
   
   var ints = {
     second: 1,
     minute: 60,
     hour: 3600,
     day: 86400,
     week: 604800,
     month: 2592000,
     year: 31536000
   };
   
   return function(time) {
     
     time = +new Date(time);
     var gap = ((+new Date()) - time) / 1000,
       amount, measure;
     
     for (var i in ints) {
       if (gap > ints[i]) { measure = i; }
     }
     
     amount = gap / ints[measure];
     amount = gap > ints.day ? (Math.round(amount * 100 / 100)) : Math.round(amount);
     amount += ' ' + measure + (amount > 1 ? 's' : '') + ' ago';
     
     return amount;
   };
   
 })();


 var parseDate = (function() {
   var months = {
     "Jan":1,
     "Feb":2,
     "Mar":3,
     "Apr":4,
     "May":5,
     "Jun":6,
     "Jul":7,
     "Aug":8,
     "Sep":9,
     "Oct":10,
     "Nov":11,
     "Dec":12
   };

   return function(dateStr) {
     var matches = dateStr.match(/^[a-zA-Z]{3} ([a-zA-Z]{3}) ([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) \+([0-9]{4}) ([0-9]{4})$/);
     var dateFormatted = matches[7] + "-" + months[matches[1]] + "-" + matches[2] + "T" + matches[3] + ":" + matches[4] + ":" + matches[5] + "Z";

	var d = dateFormatted.split(/\D/);
	--d[1];
	var time = Date.UTC.apply(null, d);

     return new Date(time);
   };
 })();
 
 
 
// twitterapi
 
 /*
 * Copyright (c) 2009 Otchy
 * This source file is subject to the MIT license.
 * http://www.otchy.net
 */
var TwitterAPI = {
version:'0.9.3',
w:window,
d:document,
e:function(id){return this.d.getElementById(id);},
ce:function(el){return this.d.createElement(el);},
ac:function(e){this.d.body.appendChild(e);},
rc:function(e){try{this.d.body.removeChild(e);}catch(e){}},
ae:function(e,t,f){if(e.attachEvent){e.attachEvent('on'+t,f);}else{e.addEventListener(t,f,false);}},
b:'https://twitter.com/',
lout:'https://other:a@twitter.com/',
cnt:0,
tid:function(){return 'TwitterApiID'+(++this.cnt)},
cm:function(c,m,i) {return c+(m&&m.length>0?'/'+m:'')+(i?'/'+i:'');},
isFx:(/a/[-1]=='a'),
isIE:(/*@cc_on!@*/false),
isOp:window.opera,
get:function(c,f,p) {
	var t=this;t._get(t.b,c,f,p);
},
_get:function(b,cm,func,param) {
	var t=this;
	var tid=t.tid();
	var s=t.ce('script');
	t.w[tid]=function(obj){
		if(func){func(obj);}
		var t=TwitterAPI;
		setTimeout(function() {
			try{delete t.w[tid];}catch(e){t.w[tid]=null;}
			t.rc(s);
		},100);
	};
	s.src=b+cm+'.json?callback='+tid+((param)?'&'+param:'');
	t.ac(s);
},
post:function(cm,func,vals) {
	var t=this;
	var i1=t.ce('iframe');
	i1.style.display='none';
	t.ac(i1);
	var tid;
	if(t.isIE){
		tid='_self';
		setTimeout(function() {
			t.rc(i1);
		},5000);
	}else{
		tid=t.tid();
		var i2=t.ce('iframe');
		i2.name=tid;
		i2.style.display='none';
		t.ac(i2);
		if(t.isFx){t.w[tid+'flg']=true};
		t.ae(i2.contentWindow,'unload',function(){
			var t=TwitterAPI;
			if(t.w[tid+'flg']){delete t.w[tid+'flg'];return;}
			if(func){func();}
			setTimeout(function() {
				t.rc(i1);
				t.rc(i2);
			},100);
		});
	}
	var d=i1.contentWindow.document;
	d.open();
	d.write('<form method="POST" action="'+t.b+cm+'.xml" target="'+tid+'">');
	if (vals) {
		for(var n in vals) {
			var val=vals[n].replace(/&/g,'&').replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>');
			d.write('<input type="hidden" name="'+n+'" value="'+val+'">');
		}
	}
	d.write('</form>');
	d.write('<script>window.onload=function(){document.forms[0].submit();}</script>');
	d.close();
},
relogin:function(f) {
	var t=this;
	var e=false;
	if(t.isOp){
		e=true;
	}else{
		try{t._get(t.lout,t.cm('statuses','user_timeline'),f);}catch(e){e=true;}
	}
	if(e){alert('Not supported relogin.');}
},
search:function(f,i,p){var t=TwitterAPI;t.get(t.cm('search'),f,p);},
statuses:{
	public_timeline:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','public_timeline'),f,p);},
	friends_timeline:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','friends_timeline',i),f,p);},
	user_timeline:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','user_timeline',i),f,p);},
	show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','show',i),f,p);},
	update:function(s,f) {var t=TwitterAPI;t.post(t.cm('statuses','update'),f,{'status':s});},
	mentions:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','mentions'),f,p);},
	destroy:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','destroy',i),f);},
	friends:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','friends',i),f,p);},
	followers:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','followers',i),f,p);},
	featured:function(f,i,p){var t=TwitterAPI;t.get(t.cm('statuses','featured'),f);}
},
users:{
	show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('users','show',i),f,p);},
	own:function(f) {
		TwitterAPI.statuses.user_timeline(function(r) {
			if (r&&r.length&&r.length>0) {f(r[0].user);}
		},null,'count=1');
	}
},
direct_messages:{
	show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('direct_messages'),f,p);},
	sent:function(f,i,p){var t=TwitterAPI;t.get(t.cm('direct_messages','sent'),f,p);},
	create:function(u,x,f) {var t=TwitterAPI;t.post(t.cm('direct_messages','new'),f,{'user':u,'text':x});},
	destroy:function(f,i,p){var t=TwitterAPI;t.get(t.cm('direct_messages','destroy',i),f,p);}
},
friendships:{
	create:function(f,i,p){var t=TwitterAPI;t.post(t.cm('friendships','create',i),f,p);},
	destroy:function(f,i,p){var t=TwitterAPI;t.post(t.cm('friendships','destroy',i),f,p);},
	exists:function(f,i,p){var t=TwitterAPI;t.get(t.cm('friendships','exists'),f,p);},
	show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('friendships','show'),f,p);}
},
friends:{
	ids:function(f,i,p){var t=TwitterAPI;t.get(t.cm('friends','ids'),f,p);}
},
followers:{
	ids:function(f,i,p){var t=TwitterAPI;t.get(t.cm('followers','ids'),f,p);}
},
account:{
	verify_credentials:function(f,i,p){var t=TwitterAPI;t.get(t.cm('account','verify_credentials'),f);},
	rate_limit_status:function(f,i,p){var t=TwitterAPI;t.get(t.cm('account','rate_limit_status'),f);},
	end_session:function(f,i,p){var t=TwitterAPI;t.get(t.cm('account','end_session'),f);},
	update_delivery_device:function(f,i,p){var t=TwitterAPI;t.get(t.cm('account','update_delivery_device'),f,p);},
	update_profile_colors:function(f,i,p){var t=TwitterAPI;t.post(t.cm('account','update_profile_colors',i),f,p);},
	update_profile_image:function(f,i,p){var t=TwitterAPI;t.post(t.cm('account','update_profile_image',i),f,p);},
	update_profile_background_image:function(f,i,p){var t=TwitterAPI;t.post(t.cm('account','update_profile_background_image',i),f,p);},
	update_profile:function(f,i,p){var t=TwitterAPI;t.post(t.cm('account','update_profile',i),f,p);}
},
favorites:{
	show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('favorites','',i),f,p);},
	create:function(f,i,p){var t=TwitterAPI;t.post(t.cm('favorites','create',i),f,p);},
	destroy:function(f,i,p){var t=TwitterAPI;t.post(t.cm('favorites','destroy',i),f,p);}
},
notifications:{
	follow:function(f,i,p){var t=TwitterAPI;t.get(t.cm('notifications','follow',i));},
	leave:function(f,i,p){var t=TwitterAPI;t.get(t.cm('notifications','leave',i));}
},
blocks:{
	create:function(f,i,p){var t=TwitterAPI;t.post(t.cm('blocks','create',i),f,p);},
	destroy:function(f,i,p){var t=TwitterAPI;t.post(t.cm('blocks','destroy',i),f,p);},
	exists:function(f,i,p){var t=TwitterAPI;t.get(t.cm('blocks','exists',i),f,p);},
	blocking:{
		show:function(f,i,p){var t=TwitterAPI;t.get(t.cm('blocks','blocking',i),f,p);},
		ids:function(f,i,p){var t=TwitterAPI;t.get(t.cm('blocks','blocking','ids'),f,p);}
	}
},
report_spam:{
},
help:{
	test:function(f,i,p){var t=TwitterAPI;t.get(t.cm('help','test'));},
	downtime_schedule:function(f,i,p){var t=TwitterAPI;t.get(t.cm('help','downtime_schedule'));}
}
}


// open event profile
$(function(){
   $(".more a")
     .click(function () {
       $(".more_text").slideToggle("normal",function(){
           if ($(this).is(":hidden")){
             $(".more_delimiter").css("visibility", "visible");
              $(".more a").html("<span class=\"arrow_bottom\"></span>続きを読む");
           }else{
             $(".more_delimiter").css("visibility", "hidden");
              $(".more a").html("<span class=\"arrow_top\"></span>閉じる");
           }
         });
     })
 });
 
$(document).ready(function(){ 
 $(".main_logo").pngfix();

});


 
 
 // png fix
 /**
 * jQuery (PNG Fix) v1.2
 * Microsoft Internet Explorer 24bit PNG Fix
 *
 * The MIT License
 * 
 * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @param		Object
 * @return		Array
 */
(function($) {
	
	$.fn.pngfix = function(options) {
		
		// Review the Microsoft IE developer library for AlphaImageLoader reference 
		// http://msdn2.microsoft.com/en-us/library/ms532969(VS.85).aspx
		
		// ECMA scope fix
		var elements 	= this;
		var settings 	= $.extend({
			imageFixSrc: 	false,
			sizingMethod: 	false 
		}, options);
		
		if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) {
			return(elements);
		}

		function setFilter(el, path, mode) {
			var fs = el.attr("filters");
			var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";
			if (fs[alpha]) {
				fs[alpha].enabled = true;
				fs[alpha].src = path; 
				fs[alpha].sizingMethod = mode;
			} else {
				el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');			
			}
		}
		
		function setDOMElementWidth(el) {
			if(el.css("width") == "auto" & el.css("height") == "auto") {
				el.css("width", el.attr("offsetWidth") + "px");
			}
		}

		return(
			elements.each(function() {
				
				// Scope
				var el = $(this);
				
				if(el.attr("tagName").toUpperCase() == "IMG" && (/\.png/i).test(el.attr("src"))) {
					if(!settings.imageFixSrc) {
						
						// Wrap the <img> in a <span> then apply style/filters, 
						// removing the <img> tag from the final render 
						el.wrap("<span></span>");
						var par = el.parent();
						par.css({
							height: 	el.height(),
							width: 		el.width(),
							display: 	"inline-block"
						});
						setFilter(par, el.attr("src"), "scale");
						el.remove();
					} else if((/\.gif/i).test(settings.imageFixSrc)) {
						
						// Replace the current image with a transparent GIF
						// and apply the filter to the background of the 
						// <img> tag (not the preferred route)
						setDOMElementWidth(el);
						setFilter(el, el.attr("src"), "image");
						el.attr("src", settings.imageFixSrc);
					}
					
				} else {
					var bg = new String(el.css("backgroundImage"));
					var matches = bg.match(/^url\("(.*)"\)$/);
					if(matches && matches.length) {
						
						// Elements with a PNG as a backgroundImage have the
						// filter applied with a sizing method relevant to the 
						// background repeat type
						setDOMElementWidth(el);
						el.css("backgroundImage", "none");
						
						// Restrict scaling methods to valid MSDN defintions (or one custom)
						var sc = "crop";
						if(settings.sizingMethod) {
							sc = settings.sizingMethod;
						} 
						setFilter(el, matches[1], sc);
						
						// Fix IE peek-a-boo bug for internal links
						// within that DOM element
						el.find("a").each(function() {
							$(this).css("position", "relative");
						});
					}
				}
				
			})
		);
	}

})(jQuery)