
//image paths and navigation used in the slideshow
var imagePaths = new Array();
imagePaths[0] = new Array('images/frame_wirelessPTL.jpg', 'http://www.lightningpick.com/WirelessPickToLight.html', 'Wireless Pick to Light System on Totes');
imagePaths[1] = new Array('images/frame_mobile.jpg', 'http://www.lightningpick.com/MobileApp.html', 'Mobile Pick to Light App for Smartphones');
imagePaths[2] = new Array('images/frame_version6-1.jpg', 'http://www.lightningpick.com/InTheNews/LPVersion6-1.html', 'Advanced Pick to Light Order Fulfillment Execution Software GUI');
imagePaths[3] = new Array('images/frame_dashboard.jpg', 'http://www.lightningpick.com/LPDashboard.html', 'New enhanced Dashboard Productivity Screens');

//speed of the slideshow
var speed = 325;

//delay between slide
var delay = 2000;

$(document).ready(function () {
	//javascript is a go, kill the static image
	$('.static').remove();

	//show the loading bar
    	$("#loader").fadeIn('slow', function() {
		loadImages();
	});
	
	function loadImages() {
		for (var i = 0; i < imagePaths.length; i++) {
			var img = new Image();
   			var src = imagePaths[i][0]; 
			var dest = imagePaths[i][1];
			var alt = imagePaths[i][2];
  			$(img)
			.attr('class', 'slide')
			.attr('alt', alt)
    			.error(function () {
				alert('an error has occured');
    			})
			.attr('src',src);
			$('#bannerImages').append(img);
			$(img).wrap('<a href=' + dest + ' />');
		}
		//all images are loaded, start the slideshow
		//and remove the loading icon
		$('#loader').remove();
		//show the pager
		$('#pager').fadeIn();
		//set up hover buttons
		createHovers();		
		$('#bannerImages').cycle({ 
    			delay:  delay, 
    			speed:  speed,
			pause: 1,
			next: '#rightButton',
			prev: '#leftButton',
			pager:  '#pager'
		}); 
	}

	function createHovers() {
		//on hover show the 'next' and 'back' buttons	
		$('#cBanner').hover(function () 
			{
    				$("#rightButton").fadeIn('slow');
    				$("#leftButton").fadeIn('slow');
			}
			,
			function () 
			{
    				$("#rightButton").fadeOut('slow');
    				$("#leftButton").fadeOut('slow');
			}
    		);
	
		//hover behaviours for the 'next' and 'back' buttons
		$('#rightButton').hover(function () 
			{
    				$("#rightButton").fadeTo('fast', 0.5);
			}
			,
			function () 
			{
    				$("#rightButton").fadeTo('fast', 1);
			}
    		);

		$('#leftButton').hover(function () 
			{
    				$("#leftButton").fadeTo('fast', 0.5);
			}
			,
			function () 
			{
    				$("#leftButton").fadeTo('fast', 1);
			}
    		);
	
	}
});


