var slideshow_width = 400;		// Slideshow width
var slideshow_height = 140;		// Slideshow height
var pause = 5000;			// Pause in ms


// Store image and link details (ISBN, [target,] title, text, price)
// fadeimages[0] is the default image
var fadeimages = new Array();


fadeimages[0] = ["9781844744046", "new", "Inside Story", "A new biography of John Stott, once namesd as one of the 100 most influential people on the world.", "12.99"];
fadeimages[1] = ["9780310275039", "new", "Drops Like Stars HB", "An exploration of the complex relationship between suffering and creativity, driven by the belief that there is art in the agony.", "19.99"];
fadeimages[2] = ["9780736920865", "new", "Power of Praying for Your Adult Children", "Stormie Omartian addresses the areas of concern parents have for their grown children and shares how to lift them up to God.", "9.49"];
fadeimages[3] = ["9781844743735", "new", "Signposts", "<b>Signposts</b> provides a map to help readers chart their way through the Psalms, watch out for points of interest, and make connections between one place and another.", "9.99"];
fadeimages[4] = ["9781434799791", "new", "So Beautiful", "Just as DNA's three strands make life possible, three other elements work in harmony to make life not just pretty, but beautiful. And it's in the church where we find the greatest expression, and ultimate fulfillment, of these three components.", "9.99"];
fadeimages[5] = ["9781844743773", "new", "The Ordinary Hero", "A hard-hitting book showing how the cross and resurrection provide the pattern for Christian discipleship today. Allowing the cross and resurrection to shape our lives enables us to become exceptional, special, heroic.", "8.99"];
fadeimages[6] = ["9780310291541", "new", "Apprentice", "<b>Apprentice</b> is the official Spring Harvest Book 2009/10.", "9.99"];
fadeimages[7] = ["9781850788140", "new", "Looking Good, Being Bad", "Adrian Plass gently and humorously challenges the Churchman or woman in us all, as we treat the church as if it should be made in our own image.", "£9.99"];
fadeimages[8] = ["9780310275633", "new", "Jesus Wants to Save Christians", "'There is a church in our area that recently added an extension to their building which cost more than $20 million. Our local newspaper ran a front-page story not too long ago revealing that one in five people in our city lives in poverty.' This is a book about those two numbers.", "9.50"];


// Preload images
var preloadedimages = new Array();
for (p = 0; p < fadeimages.length; p++)
{
	preloadedimages[p] = new Image();
	preloadedimages[p].src = fadeimages[p][0];
}

var ie4 = document.all;
var dom = document.getElementById;

if (ie4 || dom)
{
	document.write ('<div style = "position:relative; width: ' + slideshow_width + '; height: ' + slideshow_height + '; overflow:hidden">');
	document.write ('<div id = "canvas0" style = "position:absolute; width: ' + slideshow_width + '; height: ' + slideshow_height + '; top: 0; left: 0; filter: alpha(opacity = 10); -moz-opacity: 10"></div>');
	document.write ('<div id = "canvas1" style = "position:absolute; width: ' + slideshow_width + '; height: ' + slideshow_height + '; top: 0; left: 0; filter: alpha(opacity = 10); -moz-opacity: 10; visibility: hidden"></div>');
	document.write ('</div>');
}

else
{
	document.write('<img name = "defaultslide" src = "http://www.keithjones.co.uk/shop/store/default/product_images/' + fadeimages[0][0] + '.jpg" alt = "' + fadeimages[0][2] + '">');
}

var curpos = 1;
var degree = 5;
var curcanvas = "canvas0";
var curimageindex = 0;
var nextimageindex = 1;

function fadepic()
{
	if (curpos < 100)
	{
		curpos += degree;
		if (tempobj.filters) tempobj.filters.alpha.opacity = curpos;
		else if (tempobj.style.MozOpacity) tempobj.style.MozOpacity = curpos / 101;
	}

	else
	{
		clearInterval (dropslide);
		nextcanvas = (curcanvas == "canvas0") ? "canvas0" : "canvas1";
		tempobj = ie4 ? eval ("document.all." + nextcanvas) : document.getElementById (nextcanvas);
		tempobj.innerHTML = insertimage (nextimageindex);
		nextimageindex = (nextimageindex < fadeimages.length - 1) ? nextimageindex + 1 : 0;
		var tempobj2 = ie4 ? eval ("document.all." + nextcanvas) : document.getElementById (nextcanvas);
		tempobj2.style.visibility = "hidden";
		setTimeout ("rotateimage()", pause);
	}
}

function insertimage(i)
{
	var tempcontainer = '<a href = "http://www.keithjones.co.uk/shop/eshop/exec/search.php?s=default&q=' + fadeimages[i][0] + '" target = "' + fadeimages[i][1] + '">';
	tempcontainer += '<img src = "http://www.keithjones.co.uk/shop/store/default/product_images/' + fadeimages[i][0] + '.jpg" border = "0" width = "90" height = "' + slideshow_height + '" alt = "' + fadeimages[i][2] + '" align = "left">';
	tempcontainer += '</a>';
	tempcontainer += '<a href = "http://www.keithjones.co.uk/shop/eshop/exec/search.php?s=default&q=' + fadeimages[i][0] + '" target = "' + fadeimages[i][1] + '"><b>' + fadeimages[i][2] + '</b></a>';
	tempcontainer += '<p>' + fadeimages[i][3] + '</p>';
	tempcontainer += 'Our price: <b>£' + fadeimages[i][4] + '</b>';
	tempcontainer += '<br><br><a href = "pg_newbooks.php">More information...</a>';
	return tempcontainer;
}

function rotateimage()
{
	if (ie4 || dom)
	{
		resetit (curcanvas);
		var crossobj = tempobj = ie4 ? eval ("document.all." + curcanvas) : document.getElementById (curcanvas);
		crossobj.style.zIndex++;
		tempobj.style.visibility = "visible";
		var temp = 'setInterval ("fadepic()", 50)';
		dropslide = eval (temp);
		curcanvas = (curcanvas == "canvas0") ? "canvas1" : "canvas0";
	}

	else document.images.defaultslide.src = fadeimages[curimageindex][0];
	curimageindex = (curimageindex < fadeimages.length - 1) ? curimageindex + 1 : 0;
}

function resetit(what)
{
	curpos = 10;
	var crossobj = ie4 ? eval ("document.all." + what) : document.getElementById (what);
	if (crossobj.filters) crossobj.filters.alpha.opacity = curpos;
	else if (crossobj.style.MozOpacity) crossobj.style.MozOpacity = curpos / 101;
}

function startit()
{
	var crossobj = ie4 ? eval ("document.all." + curcanvas) : document.getElementById (curcanvas);
	crossobj.innerHTML = insertimage (curimageindex);
	rotateimage();
}

if (ie4 || dom) window.onload = startit;
else setInterval ("rotateimage()", pause);