// Portions (c) 2000 www.CodeLifter.com
// http://www.codelifter.com
//
// Portions (c) BrainError
// http://www.brainerror.net/scripts_js_blendtrans.php
//
// Portions (c) Heston Liebowitz Design
// http://www.hestonliebowitz.com


// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 4000

// Duration of crossfade (milliseconds)
var crossFadeDuration = 1000

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = "pictures/" + Pic[i]
}

function runSlideShow(){
   blendimage(preLoad[j].src,crossFadeDuration)
   
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}



function blendimage(imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
     //set the current background as the image
     reg = /url\(([^\)]+)\)/
    bg = reg.exec(slideshow_var.style.backgroundImage)
    image_var.src = bg[1]
    
    //make image opaque 
    changeOpac(100);
    
    //set background to new image
    slideshow_var.style.backgroundImage = "url(" + imagefile + ")";
    
     //fade out image 
    for(i = 100; i >= 0; i--) {
       setTimeout("image_var.style.opacity = ("+i+" / 100)", (timer*speed))
   	   setTimeout("image_var.style.filter = \"alpha(opacity=" + i + ")\"", (timer*speed))
   	   timer++
    }
}

//change the opacity for different browsers 
function changeOpac(opacity) {
    image_var.style.opacity = (opacity / 100); 
    image_var.style.filter = "alpha(opacity=" + opacity + ")"; 
}

function pausecomp(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
}

window.onload = function () {
	slideshow_var = document.getElementById("slideshow_div")
	image_var = document.getElementById("slideshow_img")
	setTimeout("runSlideShow()", 500)
}
