// ###################################################################################
// # + IMAGE SLIDING SCRIPT
// ###################################################################################
/* Global settings */
var pause = 4000;				// Set the slide-interval (1000 = 1 seconde)
var slidebgcolor = "#e4e4e4";	// The background-color of the pictures

/* The images in the slide show */
/*
var dropimages = new Array();
dropimages[0]="5.jpg"
dropimages[1]="6.jpg"
dropimages[2]="7.jpg"
*/

/* Preloading the images */
var preloadedimages = new Array();
for(var i=0;i<dropimages.length;i++) {
	preloadedimages[i] = new Image();
	preloadedimages[i].src = dropimages[i];
}

/* Browser Check */
var ie4 = document.all;
var dom = document.getElementById;

/* Script settings */
var curpos = parseInt(260)*(-1);// Current position
var degree = 10;				// Speed of insliding
var curcanvas = "canvas0";		// The canvas of the first picture
var curimageindex = 1;			// The current picture
var nextimageindex = 2;			// The next picture

var tempobj, dropslide, startInterval, nextcanvas;

function startit(){
	clearInterval(startInterval);	// We have started, stop starting
	var crossobj = ie4 ? eval("document.all."+curcanvas) : document.getElementById(curcanvas); // Browser-check + take next canvas
	crossobj.innerHTML = '<img src="'+dropimages[curimageindex]+'" alt="" />'; // Show the immage
	rotateimage();	// Show the next image
}

function rotateimage() {
	if(ie4||dom) {
		// Resetting
		curpos = parseInt(260)*(-1);
		var crossobj = tempobj = ie4 ? eval("document.all."+curcanvas) : document.getElementById(curcanvas); // Browser-check + take next canvas
		crossobj.style.right = curpos+"px"; // Move it to the right out of the visible area
		crossobj.style.zIndex++; // Show it above the other canvas
		dropslide = setInterval("movepic()",10); // Start movin' it
		curcanvas = (curcanvas=="canvas0") ? "canvas1" : "canvas0"; // We now have a new active canvas
	} else {
		document.images.defaultslide.src=dropimages[curimageindex]; // Old browsers need different commands
	}
	curimageindex = (curimageindex<dropimages.length-1) ? curimageindex+1 : 0; // If were at the end of the cycle, we start all over again
}


function movepic() {
	if(curpos<0) { // If were still sliding
		if(curpos>-20) {
			curpos = Math.min(curpos+1,0);
		} else if(curpos>-35) {
			curpos = Math.min(curpos+2,0);
		} else if(curpos>-60) {
			curpos = Math.min(curpos+3,0);
		} else {
			curpos = Math.min(curpos+degree,0);
		}
		tempobj.style.right = curpos+"px";
	} else { // If we have arrived
		clearInterval(dropslide); // Stop sliding
		nextcanvas = curcanvas;
		tempobj = ie4 ? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas); // Browser-check + take next canvas
		tempobj.innerHTML = '<img src="'+dropimages[curimageindex]+'" alt="" />'; // Prepare the next image
		nextimageindex = (nextimageindex<dropimages.length-1) ? nextimageindex+1 : 0;
		setTimeout("rotateimage()",pause); // Show the next one in a bit
	}
}

if(ie4||dom) {
	startInterval = setInterval("startit()",pause);
} else {
	setInterval("rotateimage()",pause);
}