/* Author: Widgeon Web Design

*/

var slideshowImgs;
var cur;
var next;


function showNext(){
	

	$(slideshowImgs).each(function(index, element) {
        if($(element).hasClass('currentlyShowing')){
			next = index+1;
			if(next >= slideshowImgs.length){
				next = 0;
				}
			cur = element;	
			return(false);
			}
    });
	
			$(cur).fadeOut(800, 'linear');
			$(cur).removeClass('currentlyShowing');
			$(slideshowImgs[next]).addClass('currentlyShowing');
			$(slideshowImgs[next]).delay(1000).fadeIn(800, 'linear');
			
			
			setTimeout('prepareNext();', 2600);
	}


$(window).load(function(e) {
	slideshowImgs = $('#homepage-slideshow ul li');
	$('#homepage-slideshow ul .first').addClass('currentlyShowing');
	for(var i = 0; i< slideshowImgs.length; i++){
		cur = $(slideshowImgs[i]);
		if(!$(cur).hasClass('currentlyShowing')){
			$(cur).hide();
			}
		}
	setTimeout('showNext();', 3000);
	
});


function prepareNext(){
	setTimeout('showNext();', 3000);
	}
