// JavaScript Document
/**
 * jQuery.Preload - Multifunctional preloader
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
 * Dual licensed under MIT and GPL.
 * Date: 3/25/2009
 * @author Ariel Flesler
 * @version 1.0.8
 */
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);

jQuery(document).ready(function($) {
	$("#slideshowFront > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[1]['image']);
	$("#slideshowFront > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[1]['text']);
	$("#slideshowFront > .slideshowText > img").attr("alt", slideshowItems[1]['alt']);
	$("#slideshowBack > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[2]['image']);
	$("#slideshowBack > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[2]['text']);
	$("#slideshowBack > .slideshowText > img").attr("alt", slideshowItems[2]['alt']);
	
	$("p.replay").children("a").click(function() {
		$("p.replay").hide();
		$("p.replay").addClass("noShow");	
		$("#slideshowBack").css('z-index', '25');
		$("#slideshowFront > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[1]['image']);
		$("#slideshowFront > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[1]['text']);
		$("#slideshowFront > .slideshowText > img").attr("alt", slideshowItems[1]['alt']);
		$("#slideshowFront").fadeTo(1000, 1.0, function() { 
			$("#slideshowBack > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[2]['image']);
			$("#slideshowBack > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[2]['text']);
			$("#slideshowBack > .slideshowText > img").attr("alt", slideshowItems[2]['alt']);
			slideshow();
		});
		return false;
	});
	
});
jQuery(function( $ ){		
	var urls = [ 'slide1Image', 'slide2Image', 'slide3Image', 'slide4Image', 'slide5Image', 'slide6Image' ];
	$.preload( urls, {
		base:'http://www.millermech.com/wordpress/wp-content/themes/millermech/imgs/home/',
		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'] = 'slide1Image.jpg';
slideshowItems[1]['text'] = 'slide1Text.png';
slideshowItems[1]['alt'] = 'As the preminent stainless steel contractor for a range of industries...';

slideshowItems[2] = new Array();
slideshowItems[2]['image'] = 'slide2Image.jpg';
slideshowItems[2]['text'] = 'slide2Text.png';
slideshowItems[2]['alt'] = 'with the man power to handle the job...';

slideshowItems[3] = new Array();
slideshowItems[3]['image'] = 'slide3Image.jpg';
slideshowItems[3]['text'] = 'slide3Text.png';
slideshowItems[3]['alt'] = 'the facilities to house and assemble many difficult projects both large and small...';

slideshowItems[4] = new Array();
slideshowItems[4]['image'] = 'slide4Image.jpg';
slideshowItems[4]['text'] = 'slide4Text.png';
slideshowItems[4]['alt'] = 'the tools to custom build what other fabricators may not...';

slideshowItems[5] = new Array();
slideshowItems[5]['image'] = 'slide5Image.jpg';
slideshowItems[5]['text'] = 'slide5Text.png';
slideshowItems[5]['alt'] = 'and a history of impeccable service...';

slideshowItems[6] = new Array();
slideshowItems[6]['image'] = 'slide6Image.jpg';
slideshowItems[6]['text'] = 'slide6Text.png';
slideshowItems[6]['alt'] = 'We get the job done!';
function slideshow() {
	jQuery("#slideshowFront").fadeTo(3500, 1.0, function() {
		jQuery("#slideshowFront").fadeTo(4000, 0.0, function() {
			jQuery("#slideshowFront > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[3]['image']);
			jQuery("#slideshowFront > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[3]['text']);
			jQuery("#slideshowFront > .slideshowText > img").attr("alt", slideshowItems[3]['alt']);
			jQuery("#slideshowFront > .slideshowText > .statusBar > span").attr("class", "statusSlide3");
			jQuery("#slideshowFront").fadeTo(2000, 0.0, function() {
				jQuery("#slideshowFront").fadeTo(4000, 1.0, function() {
					jQuery("#slideshowBack > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[4]['image']);
					jQuery("#slideshowBack > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[4]['text']);
					jQuery("#slideshowBack > .slideshowText > img").attr("alt", slideshowItems[4]['alt']);
					jQuery("#slideshowBack > .slideshowText > .statusBar > span").attr("class", "statusSlide4");
					jQuery("#slideshowFront").fadeTo(2000, 1.0, function() {
						jQuery("#slideshowFront").fadeTo(4000, 0.0, function() {
							jQuery("#slideshowFront > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[5]['image']);
							jQuery("#slideshowFront > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[5]['text']);
							jQuery("#slideshowFront > .slideshowText > img").attr("alt", slideshowItems[5]['alt']);
							jQuery("#slideshowFront > .slideshowText > .statusBar > span").attr("class", "statusSlide5");
							jQuery("#slideshowFront").fadeTo(2000, 0.0, function() {
								jQuery("#slideshowFront").fadeTo(4000, 1.0, function() {
									jQuery("#slideshowBack > .slideshowImage > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[6]['image']);
									jQuery("#slideshowBack > .slideshowText > img").attr("src", "/wordpress/wp-content/themes/millermech/imgs/home/"+slideshowItems[6]['text']);
									jQuery("#slideshowBack > .slideshowText > img").attr("alt", slideshowItems[6]['alt']);
									jQuery("#slideshowBack > .slideshowText > .statusBar > span").attr("class", "statusSlide6");
									jQuery("#slideshowFront").fadeTo(2000, 1.0, function() {
										jQuery("#slideshowFront").fadeTo(4000, 0.0, function() { 
											jQuery("#slideshowFront").fadeTo(5000, 0.0, function() { 
												jQuery("p.replayButton").hide();
												jQuery("p.replayButton").toggleClass("noShow");
												jQuery("p.replayButton").fadeIn();
												jQuery("#slideshowBack").css('z-index', '75');
											});
										});
									});
								});
							});
						});
					});
				});
			});
		});
	});
}
