	var speed = 30;
	var pic, numImgs, arrLeft, i, totalWidth, n, myInterval; 

	
	
	
$(window).load(function(){
	pic = $("#slider").children("img");
	numImgs = pic.length;
	arrLeft = new Array(numImgs);

	for (i=0;i<numImgs;i++){

		totalWidth=0;
		for(n=0;n<i;n++){
			totalWidth += $(pic[n]).width();
		}

		arrLeft[i] = totalWidth;
		$(pic[i]).css("left",totalWidth);
	}

	myInterval = setInterval("flexiScroll()",speed);
	$('#imageloader').hide();
	$(pic).show();
	
	/* Set up click thrus*/
	$("#slider img.customerlogo").click(function() {
		var url_stem='/'; /* Change this if you want to redirect to a subdirectory,
		eg. /customers/coca-cola.html
		*/
		var alt_text=$(this).attr('alt');
		window.location=url_stem+alt_text+".html";
	});
	
	
	/* Set up hover ability */
	
	/* First cache colour images for highlights by duplicating existing slider DOM and changing filenames*/
	$("#slider").clone().attr('id','slider-colourclone').css('display','none').appendTo("#customer-marquee");
	$("#slider-colourclone").find('img.customerlogo').each(function(){
		var imgfilename = $(this).attr('src');
		var newfilename = imgfilename.replace ('grey','colour');
		$(this).attr('src',newfilename);
	});
	
	
	$("#slider img.customerlogo").hover(function() {
		var imgfilename = $(this).attr('src');
		var newfilename = imgfilename.replace ('grey','colour');
		$(this).attr('src',newfilename);
	}, function () {
		var imgfilename = $(this).attr('src');
		var newfilename = imgfilename.replace ('colour','grey');
		$(this).attr('src',newfilename);
	}
	);
	
});

function flexiScroll(){

	for (i=0;i<numImgs;i++){
		arrLeft[i] -= 1;		

		if (arrLeft[i] == -($(pic[i]).width())){
			totalWidth = 0;
			for (n=0;n<numImgs;n++){
				if (n!=i){
					totalWidth += $(pic[n]).width();
				}
			}
			arrLeft[i] =  totalWidth;
		}
		$(pic[i]).css("left",arrLeft[i]);
	}
}

