/*Rollover effect on different image script-
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/

/*
Script by FPMC at http://jsarchive.8m.com
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

var timerID = 0;
//set duration for each image
var duration = 6;


//set image paths
src = ["slideshow/001.jpg","slideshow/002.jpg","slideshow/003.jpg","slideshow/004.jpg","slideshow/005.jpg"]


//Please do not edit below
var ads=[], ct=0, myimages=[], i=0;

function switchAd() {
	var n=(ct+1)%src.length;
	if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
		$("#slideshow2").fadeOut("slow", function() {
			document["targetimage"].src = ads[ct=n].src;
		});
		$("#slideshow2").fadeIn("slow");
	}
	ads[n=(ct+1)%src.length] = new Image;
	ads[n].src = src[n];
	timerID=setTimeout("switchAd()",duration*1000);
}

onload = function(){
	if (document.images)
	switchAd();
}



function changeimage(towhat){
	if (document.images){
		document.images.targetimage.src=towhat.src;
		Stop();
	}
}


function preloadimages(){
	for (i=0;i<=src.length;i++){
		myimages[i]=new Image();
		myimages[i].src=src[i];
	}
}

function Start() {
	timerID=setTimeout("switchAd()",duration*1000);
}

function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;

   }
}


preloadimages();




/*
var timerID = 0;
//set duration for each image
var duration = 5*1000;

function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    timerID=setInterval( "slideSwitch()", duration );
});


src = ["slideshow/001.jpg","slideshow/002.jpg","slideshow/003.jpg","slideshow/004.jpg","slideshow/005.jpg"]

function changeimage(towhat){
	if (document.images){
		document.images.targetimage.src=towhat.src;
		Stop();
	}
}


var myimages=new Array()

function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}


function Start() {
	timerID=setInterval("slideSwitch()", duration );
}

function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }
}

preloadimages("slideshow/001.jpg","slideshow/002.jpg","slideshow/003.jpg","slideshow/004.jpg","slideshow/005.jpg")
*/
