// "Slideshow" script for home page

<!-- Original:  Ricocheting (ricocheting@hotmail.com) -->
<!-- Web Site:  http://www.ricocheting.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var rotate_delay = 3000; // delay in milliseconds (5000 = 5 secs)
var current = 0;
var playing = false;
var rotate_interval;

function showImage(ImgName,ImageSrc) {
	document.images[ImgName].src = ImageSrc;
}

function rotate() {
	current = (current == document.mainImages.length-1) ? 0 : current+1;
	blendimage('blenddiv','blendimage', document.mainImages[current].src)
}

function blendimage(divid, imageid, imagefile, millisec) { 
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 

    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')", i* 10); 
    } 
} 
//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 101); 
    object.MozOpacity = (opacity / 101); 
    object.KhtmlOpacity = (opacity / 101); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function setupImages() {
  var d=document;
  if(d.images){ if(!d.mainImages) { d.mainImages=new Array();}
    var i,j=d.mainImages.length,a=setupImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.mainImages[j]=new Image; d.mainImages[j++].src="Images/"+a[i];}}
}

function showCustomerLogos() {

	setupImages(
	"broken-heart-plate.jpg",
	"IMG_3686 handmade jug.jpg",
	"white-plate-with-fish.jpg",
	"hand-impression-in-clay.jpg",
	"handprint-on-plate.jpg",
	"clay-beads.jpg",
	"bowl-with-twisted-lid.jpg",
	"paisley-relief-platter.jpg",
	"hedgehog-painted-bowl.jpg",
	"painted-ceramic-fish.jpg"
	);

	current = Math.floor(Math.random()*10);
	showImage('blendimage', document.mainImages[current].src);
	rotate_interval = window.setInterval("rotate()", rotate_delay);
}
function showHandPrints() {

	setupImages(
	"handprint-clay-1.jpg",
	"handprint-clay-2.jpg",
	"handprint-clay-3.jpg",
	"handprint-clay-4.jpg",
	"handprint-clay-5.jpg",
	"handprint-clay-6.jpg",
	"handprint-clay-7.jpg"
	);

	showImage('blendimage', document.mainImages[0].src);
	rotate_interval = window.setInterval("rotate()", rotate_delay);
}
