/**function processSlideshow(elem, imageList, imageDuration, fadeSpeed, current) 
{
    var listSize = imageList.length;
    if (!current || current >= listSize) current = 0;
    if (!imageDuration) imageDuration = 3000;
    if (!fadeSpeed) fadeSpeed = 1000;
    
	$j(elem + " img").attr("src", imageList[current]);
    if (current == (listSize - 1)){
		$j(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
    }else{
        $j(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
    }
	
    $j(elem + " img").animate({ opacity: "1" }, imageDuration)
		.animate({ opacity: "0.01" }, fadeSpeed, function(){ 
        	$j(this).css("opacity", "1"); 
			processSlideshow(elem, imageList, imageDuration, fadeSpeed, current + 1) ;
        });
} 

	
	   //define a javascript array that contains your images
		var slideShow = new Array()
		slideShow[0] = "/sites/teanaubackpackers.co.nz/themes/backpackers/images/header-photo.jpg";
		slideShow[1] = "/sites/teanaubackpackers.co.nz/themes/backpackers/images/header-photo2.jpg";
		slideShow[2] = "/sites/teanaubackpackers.co.nz/themes/backpackers/images/header-photo3.jpg";
		slideShow[3] = "/sites/teanaubackpackers.co.nz/themes/backpackers/images/header-photo4.jpg";
		slideShow[4] = "/sites/teanaubackpackers.co.nz/themes/backpackers/images/header-photo5.jpg";
		
		function startSlideshow()
		{
      	processSlideshow("#head-image", slideShow);
    }
**/



/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $jactive = $j('#head-image IMG.active');

    if ( $jactive.length == 0 ) $active = $j('#head-image IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $jnext =  $jactive.next().length ? $jactive.next()
        : $j('#head-image IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $jactive.addClass('last-active');

    $jnext.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $jactive.removeClass('active last-active');
        });
}

$j(function() {
    setInterval( "slideSwitch()", 3000 );
});
