jQuery(document).ready(function() {

    // satisfy the requirement of the Cycle plugin to have at least 2 images in the div
    jQuery('#banner_slideshow').append('<img src="img/banner/energy2.jpg" width="840" height="210" class="other_pics"/>');

    var stack = [];

var img = new Image(840, 210);
img.src = 'img/banner/aerospace.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/agriculture.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/architecture.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/arms.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/construction.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/energy.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/lumber.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/manufacturing2.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/manufacturing.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/stamping.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/technology.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/security.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/defence.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/finance.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/energy2.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/recording.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});
var img = new Image(840, 210);
img.src = 'img/banner/leisure.jpg';
jQuery(img).bind('load', function() {
  stack.push(this);
});


    // call the method to cycle through contents of div
    jQuery('#banner_slideshow').cycle({
      delay:   -2000, // additional delay (-5 secs) for first transition
      next:    '#banner_slideshow', // element to use as click trigger for next slide
      pause:   1,     // pause slideshow on mouse hover
      timeout: 5000,  // 10 secs between slide transitions
			speed: 2000,
      before: onBefore
    });

    // add images to slideshow
    function onBefore(curr, next, opts) {
        if (opts.addSlide) // <-- important!
            while(stack.length)
                opts.addSlide(stack.pop());
    };

});

