/* 
 akiko twitter
*/ 
$(function(){
$.ajax({
    type:"GET",
    url:"/common/json/twitter.txt",
    //dataType:"json",
    error:function() {
            return false;
        },
    complete :function(){
    $('div.twtr-tweet').hover(
        function () {
        $("a.twtr-reply:eq("+$('div.twtr-tweet').index(this)+")").show();
        },
        function () {
        $("a.twtr-reply:eq("+$('div.twtr-tweet').index(this)+")").hide();
        }
  );
  $("a.twtr-reply").hide();
    },
    success:function(result,t) {
            var obj = eval("("+result+")");
            if( obj){
                var statusobj = obj['statuses'];
                var userobj = obj['user'];
                var twimg = new Image();
                twimg.src = userobj.profile_image;
                twimg.onload = function() {
                   $('#twitterTtl img:eq(0)').attr('src',  userobj.profile_image);
               };
                if(statusobj.length > 0){
                    for (var j=0; j<statusobj.length; j++ ){
			var idx = 20-j;
			$('#akiko-twtr').append('<div class="twtr-tweet" id="tweet-id-' + idx + '"><div class="twtr-tweet-wrap"></div></div>');
			$('#tweet-id-' + idx + ' .twtr-tweet-wrap').html('<div class="twtr-avatar"><div class="twtr-img"><a target="_blank" href="http://twitter.com/akiko_lawson"><img alt="akiko_lawson profile" src="http://a3.twimg.com/profile_images/771611507/icon_akiko_normal.gif"></a></div></div><div class="twtr-tweet-text"><p>' + statusobj[j]['html'] + '<i><a target="_blank" class="twtr-timestamp" href="http://twitter.com/akiko_lawson/status/'+ statusobj[j]['id']+'">'+statusobj[j]['create']+'</a> <a target="_blank" class="twtr-reply" href="http://twitter.com/?status=@akiko_lawson%20&amp;in_reply_to_status_id='+ statusobj[j]['id']+'&amp;in_reply_to=akiko_lawson">reply</a></i></p></div> ');
                   }
                }
             }
        }
});
});

