function formatPage() {
  var jqFirstArticle = $(".newsheadline:eq(0)");
  var jqSecondArticle = $(".newsheadline:eq(1)");
  // replace top left image with the image in the first article
  // var jqSlideshowImage = jqFirstArticle.find("img");
  //if (jqSlideshowImage.size() > 0) {
  //  $("#slideshow_image").replaceWith(jqSlideshowImage).addClass("rounded").attr("id","slideshow_image");
  //c}
  // set text over top left image
  $("#slideshow_caption").html(jqFirstArticle);
  // move second article to top right
  $("#video").html(jqSecondArticle);
  // tidy up link separators
  $("img.section_separator").last().remove();
  // bottom section: remove columns if necessary
  if($("#bottom_half").find("iframe").size() > 0) {
    $("#bottom_half").css("column-count","1").css("-moz-column-count","1").css("-webkit-column-count","1");
  }
}

function fYouTube() {
	$('a').each(
			function() {
				var sHref = this.getAttribute('href');
				if ((sHref.indexOf('youtube.com') > -1)
						|| (sHref.indexOf('vimeo.com') > -1)) {
					var oContainer = document.createElement('div');
					oContainer = $(oContainer);
					oContainer.addClass('gtpb_youtube');
					$(this).replaceWith(oContainer);
					oContainer.oembed(sHref, 
					  {
					  	youtube: { maxWidth: 390 }
					  }
					);
				}
				// oContainer.find('embed').attr('rel',0);
			});
}

var gtwm_image_number = 0;

function next_slide() {
  var imgSrc = $($('.slideshow_item').get(gtwm_image_number+1)).find("img").attr("src");
  $('#slideshow').css('background','url(' + imgSrc + ')');
  $('.slideshow_item').fadeOut(2000);
  $($('.slideshow_item').get(gtwm_image_number+1)).fadeIn(2000);
  if (gtwm_image_number >= ($('.slideshow_item').size() - 2)) {
  	gtwm_image_number = -1;
  } else {
  	gtwm_image_number++;
  }
}


