$(document).ready(function() {
    $('a[rel=external]').click(function(e) {
        window.open(this.href, '', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,left = 20,top = 20');
        e.preventDefault();
    });
    
    var c=document.getElementById("mainContentWrapper");
    var s=document.getElementById("smallcontent");
    if (c && c.offsetHeight>400 && !s) {
    var link = document.createElement('a');
	    link.setAttribute('href', '#top');
	    link.setAttribute('class', 'maintoplink');
	    link.innerHTML = 'Back to top';
	    c.appendChild(link);
    }
    // Setup and rotate page quotes
    $('#pageQuotes blockquote').css({opacity:0.0});
    $('#pageQuotes blockquote').removeClass('mobile');
    $('#pageQuotes blockquote:first').css({opacity:1.0}).addClass('active');
     setInterval( "rotatePageQuotes()", 9000 );
});

function rotatePageQuotes() {
  var $active = $('#pageQuotes .active');
  var $next = ($active.next().length != 0) ? $active.next() : $('#pageQuotes blockquote:first');
  $active.addClass('last-active');
  $active.animate({opacity: 0.0}, 1000, function() {
	  $next.css({opacity: 0.0})
		  .addClass('active')
		  .animate({opacity: 1.0}, 1000, function() {
		      $active.removeClass('active last-active');
	  });
  });
}
