function writePanel() {
  $("body").append('<div class="panel"><div class="inner"><div id="tweets"></div></div></div><a class="closed panel-handle" href="#"><img src="/wp-content/themes/stanberry/css/img/handle.png" alt="Tweets" /></a>');
}
function showPanel() {
  $(".panel-handle").removeClass('closed');
  $(".panel-handle").addClass('open');
  $(".panel-handle").animate({right: "400px"}, 500);
  $(".panel").animate({right: "0px"}, 500);
}
function hidePanel() {
  $(".panel-handle").removeClass('open');
  $(".panel-handle").addClass('closed');
  $(".panel-handle").animate({right: "0px"}, 500);
  $(".panel").animate({right: "-400px"}, 500);
}
$(document).ready(function() {
  /* external links */
  /* http */
  $("a[href^='http:']:not([href*='" + window.location.host + "'][target='_blank'])").live('click', function(){
		$(this).attr('target','_blank');
	});
	/* https */
  $("a[href^='https:']:not([href*='" + window.location.host + "'][target='_blank'])").live('click', function(){
		$(this).attr('target','_blank');
	});
	
  /* Tweets panel */
  writePanel();
  hidePanel();
  $(".panel-handle").toggle(showPanel, hidePanel);
  $("#tweets").getTwitter({
    userName: "StanberryIns",
    numTweets: 8,
    loaderText: "Loading tweets...",
    slideIn: true,
    slideDuration: 750,
    showHeading: true,
    headingText: "Latest Tweets",
    showProfileLink: true,
    showTimestamp: true
  });
});
