// JavaScript Document
$(document).ready(function() {
	$("#slideshowFront").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[1]['image']);
	$("#slideshowFront").children("img").attr("alt", slideshowItems[1]['alt']);
	$("#slideshowBack").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[2]['image']);
	$("#slideshowBack").children("img").attr("alt", slideshowItems[2]['alt']);
	
	$("p.replay").children("a").click(function() {
		$("p.replay").hide();
		$("p.replay").addClass("noShow");
		$("#slideshowFront").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[1]['image']);
		$("#slideshowFront").children("img").attr("alt", slideshowItems[1]['alt']);
		$("#slideshowFront").fadeTo(1000, 1.0, function() { 
			$("#slideshowBack").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[2]['image']);
			$("#slideshowBack").children("img").attr("alt", slideshowItems[2]['alt']);
			slideshow();
		});
		return false;
	});
	
});
jQuery(function( $ ){		
	var urls = [ 'slideshow1', 'slideshow2', 'slideshow3', 'slideshow4', 'slideshow5', 'slideshow6' ];
	$.preload( urls, {
		base:'http://www.millermech.com/imgs/slideshow/',
		ext:'.jpg',
		onComplete:function( data ){
			var img = new Image();
			img.src = data.image;
		},
		onFinish:function(){
			slideshow();
		}
	});
});
var slideshowItems = new Array();

slideshowItems[1] = new Array();
slideshowItems[1]['image'] = 'slideshow1.jpg';
slideshowItems[1]['alt'] = 'As the preeminent stainless steel contractor for a range of industries';

slideshowItems[2] = new Array();
slideshowItems[2]['image'] = 'slideshow2.jpg';
slideshowItems[2]['alt'] = 'With the man power to handle the job';

slideshowItems[3] = new Array();
slideshowItems[3]['image'] = 'slideshow3.jpg';
slideshowItems[3]['alt'] = 'The facilities to house and assemble many difficult projects both large and small';

slideshowItems[4] = new Array();
slideshowItems[4]['image'] = 'slideshow4.jpg';
slideshowItems[4]['alt'] = 'The tools to custom build what other fabricators may not';

slideshowItems[5] = new Array();
slideshowItems[5]['image'] = 'slideshow5.jpg';
slideshowItems[5]['alt'] = 'And a history of impeccable service';

slideshowItems[6] = new Array();
slideshowItems[6]['image'] = 'slideshow6.jpg';
slideshowItems[6]['alt'] = 'We get the job done.';
function slideshow() {
	$("#slideshowFront").fadeTo(3500, 1.0, function() {
		$("#slideshowFront").fadeTo(4000, 0.0, function() {
			$("#slideshowFront").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[3]['image']);
			$("#slideshowFront").children("img").attr("alt", slideshowItems[3]['alt']);
			$("#slideshowFront").fadeTo(2000, 0.0, function() {
				$("#slideshowFront").fadeTo(4000, 1.0, function() {
					$("#slideshowBack").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[4]['image']);
					$("#slideshowBack").children("img").attr("alt", slideshowItems[4]['alt']);
					$("#slideshowFront").fadeTo(2000, 1.0, function() {
						$("#slideshowFront").fadeTo(4000, 0.0, function() {
							$("#slideshowFront").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[5]['image']);
							$("#slideshowFront").children("img").attr("alt", slideshowItems[5]['alt']);
							$("#slideshowFront").fadeTo(2000, 0.0, function() {
								$("#slideshowFront").fadeTo(4000, 1.0, function() {
									$("#slideshowBack").children("img").attr("src", "/imgs/slideshow/"+slideshowItems[6]['image']);
									$("#slideshowBack").children("img").attr("alt", slideshowItems[6]['alt']);
									$("#slideshowFront").fadeTo(2000, 1.0, function() {
										$("#slideshowFront").fadeTo(4000, 0.0, function() { 
											$("#slideshowFront").fadeTo(5000, 0.0, function() { 
												$("p.replay").hide();
												$("p.replay").toggleClass("noShow");
												$("p.replay").fadeIn(); 
											});
										});
									});
								});
							});
						});
					});
				});
			});
		});
	});
}