$(function() {
  var containerWidth = '410px';
  $('#navLinks')
    .css({width:containerWidth,'text-align':'center',margin:'0px 0 0px 0'})
    .append("[ <a href='#'><span id='prev'>&lt; Previous</span></a>"
    + " | <a id='pause-play' href='#'>Pause</a>"
    + " | <a href='#'><span id='next'>Next &gt;</span></a> ]"    
  );
// <div> container holding all the news stories
  var $newsStories = $('#newsStories');
/* dynamically style:
 * [1] container itself
 * [2] each paragraph in the summary 
 */
  $newsStories.css({
    width:containerWidth,height:'340px',
    margin:'0px 0px 5px 0',border:'0px solid gray'
  }).find('div div').css({padding:'5px 0px 10px 0px'});
// call the plugin and set the options  
  $newsStories.cycle({
    timeout: 9000, cleartype: 1, speed: 400,
    prev:'#prev',next:'#next',
    after:function(currSlideElement, nextSlideElement, options, forwardFlag){
      $('#newsInfo').html('<strong>'
        + 'Article ' + (options.currSlide + 1) + ' of ' + options.slideCount 
        + '</strong>'
      );
    }
  });
  $('#pause-play').click(function() { 
    var pause = 'Pause';
    var text = $(this).text();
    if (pause == text) {
      $newsStories.cycle('pause');
      $(this).text('Play');
    }
    else {
      $newsStories.cycle('resume', true);
      $(this).text(pause);
    }
    return false;
  });
  $('img.newsPic').css({float:'left',padding:'0px 0px 5px 0px', margin:'0px 0 0 0px',overflow:'hidden' });
  $('a.msgAlert').click(function(){
    alert('Hyperlink disabled for this example; News Article does not exist.');
    return false;
  });
});

