﻿var adSlider = {
	init: function() {
		var 
		timer,
		slider = $('#slideshow'),
		reset = function() {
			$('li', slider).css({
				display: 'block',
				opacity: null
			});
		},
		hide = function() {
			$(this).css({ display: 'none' });
		},
		rotate = function() {
			if ($('li:visible', slider).length == 1)
				$('li:last', slider).css({ display: 'block' }).animate({ opacity: 1.0 }, 1000, reset);
			else
				$('li:visible:last', slider).animate({ opacity: 0.0 }, 1000, hide);
		};

		timer = setInterval(rotate, 5000);

		this.dispose = function() {
			clearInterval(timer);
		};
	}
};

$(document).ready(function() {
	adSlider.init();});

$(window).unload(function() {
	adSlider.dispose();
});
