/*window.onload = function () {
    tssA = new timedSlideShow(
        $('slideshow_left'), 
        0,
        7000,
        [
            [ '/images/photos/index/1a.jpg', null, 'Photo Title Here', 'Description Here' ],
            [ '/images/photos/index/1b.jpg', null, 'Photo Title Here', 'Description Here' ],
            [ '/images/photos/index/1c.jpg', null, 'Photo Title Here', 'Description Here' ]
        ]  
    );
            
    tssB = new timedSlideShow(
        $('slideshow_right'),
        5000,
        6000,
        [
            [ '/images/photos/index/2a.jpg', null, 'Photo Title Here', 'Description Here' ],
            [ '/images/photos/index/2b.jpg', null, 'Photo Title Here', 'Description Here' ],
            [ '/images/photos/index/2c.jpg', null, 'Photo Title Here', 'Description Here' ]
        ]
    );
    

}
*/
var delay = 4000;
var start_frame = 0;

function init_left () {
	var lis_left = $('slide-images-left').getElementsByTagName('li');
	
	for( i=0; i < lis_left.length; i++){
		if(i!=0){
			lis_left[i].style.display = 'none';
		}
	}
	end_frame = lis_left.length -1;
	
	start_slideshow('slide-images-left',start_frame, end_frame, delay, lis_left);
}

function init_right () {
	var lis_right = $('slide-images-right').getElementsByTagName('li');
	
	for( i=0; i < lis_right.length; i++){
		if(i!=0){
			lis_right[i].style.display = 'none';
		}
	}
	end_frame = lis_right.length -1;
	
	start_slideshow('slide-images-right',start_frame, end_frame, delay, lis_right);
}

function init() {
    /** Left ***********/
    init_left();
	
    /** Right **********/
    setTimeout(init_right,delay/2);
}



function start_slideshow(id,start_frame, end_frame, delay, lis) {
	setTimeout(fadeInOut(id,start_frame,start_frame,end_frame, delay, lis), delay);
}


function fadeInOut(id,frame, start_frame, end_frame, delay, lis) {
	return (function() {
		lis = $(id).getElementsByTagName('li');
		Effect.Fade(lis[frame]);
		if (frame == end_frame) { frame = start_frame; } else { frame++; }
		lisAppear = lis[frame];
		setTimeout("Effect.Appear(lisAppear);", 0);
		setTimeout(fadeInOut(id,frame, start_frame, end_frame, delay), delay + 1850);
	})
	
}

Event.observe(window, 'load', init, false);
