
(function($){$.fn.getTwitter=function(options){$.fn.getTwitter.defaults={userName:null,numTweets:5,loaderText:"Loading tweets...",slideIn:true,slideDuration:750,showHeading:true,headingText:"Latest Tweets",showProfileLink:true,showTimestamp:true};var o=$.extend({},$.fn.getTwitter.defaults,options);return this.each(function(){var c=$(this);c.hide().empty().addClass("twitted");if(o.showHeading){c.append("<h4><a href='http://twitter.com/"+o.userName+"' target='_blank'>"+o.headingText+"</a></h4>");}
var twitterListHTML="<ul id=\"twitter_update_list\"><li></li></ul>";c.append(twitterListHTML);var tl=$("#twitter_update_list");tl.hide();var preLoaderHTML=$("<p class=\"preLoader\">"+o.loaderText+"</p>");c.append(preLoaderHTML);if(o.showProfileLink){var profileLinkHTML="<p class=\"profileLink\"><a href=\"http://twitter.com/"+o.userName+"\" target='_blank' >http://twitter.com/"+o.userName+"</a></p>";c.append(profileLinkHTML);}
c.show();$.getScript("http://twitter.com/javascripts/blogger.js");$.getScript("http://twitter.com/statuses/user_timeline/"+o.userName+".json?callback=twitterCallback2&count="+o.numTweets,function(){$(preLoaderHTML).remove();if(!o.showTimestamp){tl.find("li").each(function(){var timestampHTML=$(this).children("a");var timestamp=timestampHTML.html();timestampHTML.remove();$(this).attr("title",timestamp);});}
$("#twitter_update_list li").hide();$("#twitter_update_list").show();$("#twitter_update_list").append("<div id='btnMoreDiv' ></div>");var totalTweetShown=0;showMoreTweet();if(o.slideIn){var tlHeight=tl.data("originalHeight");if(!tlHeight){tlHeight=tl.show().height();tl.data("originalHeight",tlHeight);tl.hide().css({height:0});}
tl.show().animate({height:tlHeight},o.slideDuration);}
else{tl.show();}
$("#twitter_update_list li a:first-child").attr('target','_blank');$("#twitter_update_list li a").attr('target','_blank');function delayShowTweet(){setTimeout(showMoreTweet,2000);$("#btnMoreDiv").html("<img src='"+CURRENT_FRONT_THEME_PATH+"images/small_loading.gif'  />");}
function showMoreTweet(){if(totalTweetShown>=50){$("#btnMoreDiv").html("<a id='btnMoreTweet' href='http://twitter.com/tya_hongkong/' target='_blank' >Follow us @ Twitter</a>");return;}
totalTweetShown+=10;var _ath=0;for(var t=0;t<=totalTweetShown;t++){$("#twitter_update_list li:eq("+t+")").show();_ath+=$("#twitter_update_list li:eq("+t+")").height()+10;}
$("#btnMoreDiv").html("<a id='btnMoreTweet'>MORE</a>");$("#twitter_update_list").css("height",_ath+15+"px");$("#btnMoreTweet").click(delayShowTweet);}});});};})(jQuery);
