var array1 = [];
var array2 = [];
var array3 = [];
var a = 0;
var b = 0;
var c = 0;


function slide1() {
	$(array1[a]).fadeOut("slow");

	if(a == array1.length - 1) {
		a = 0;
	} else {
		a++;
	}

	$(array1[a]).fadeIn("slow", function() {
			setTimeout("slide1()", Math.round((13000-7000) * Math.random() + 4000));
	});
}

function slide2() {
	$(array2[b]).fadeOut("slow");

	if(b == array2.length - 1) {
		b = 0;
	} else {
		b++;
	}

	$(array2[b]).fadeIn("slow", function() {
			setTimeout("slide2()", Math.round((8000-3000) * Math.random() + 9000));
	});
}

function slide3() {
	$(array3[c]).fadeOut("slow");

	if(c == array3.length - 1) {
		c = 0;
	} else {
		c++;
	}

	$(array3[c]).fadeIn("slow", function() {
			setTimeout("slide3()", Math.round((12000-4000) * Math.random() + 6000));
	});
}

$(document).ready(function() {
	$("#slideshow1 img").each(function(i) {
		array1.push(this);
	});

	$("#slideshow2 img").each(function(i) {
		array2.push(this);
	});

	$("#slideshow3 img").each(function(i) {
		array3.push(this);
	});

	setTimeout("slide1()", Math.round((7000-2500) * Math.random() + 5000));
	setTimeout("slide2()", Math.round((12000-6000) * Math.random() + 7000));
	setTimeout("slide3()", Math.round((8000-1000) * Math.random() + 3000));


});