// background setup
var backgrounds = new Array(
	"/images/background4.jpg",
	"/images/background3.jpg",
	"/images/background5.jpg",
	"/images/background1.jpg",
	"/images/background6.jpg",
	"/images/background2.jpg",
	"/images/thehorrors2000.jpg"
);
backgrounds.sort(function() {return 0.5 - Math.random()});
var count = 0;

//timings
var fadeTime = 15000;
var waitTime = 5000;

$(document).ready(function() {
	
	//setTimeout('$("#mainimage2").fadeOut(fadeTime, function(){ switchOne(); })',waitTime);
	
});

function switchOne() {
	
	$("#mainimage2").attr({src: backgrounds[count]});
	
	count++;
	
	if(count > backgrounds.length) { count = 0; }
	
	setTimeout('$("#mainimage2").fadeIn(fadeTime, function(){ switchTwo(); })',waitTime);
	
}

function switchTwo() {
	
	$("#mainimage").attr({src: backgrounds[count]});
	
	count++;
	
	if(count > backgrounds.length) { count = 0; }
	
	setTimeout('$("#mainimage2").fadeOut(fadeTime, function(){ switchOne(); })',waitTime);
	
}
