var SlideShow = {
	duration : 10000,
	speed : 800,
	
	current : 0,
	old : -1,
	timeout : -1,
	
	next : function() {
		if ($(".slide").eq(this.current).is(":animated")) {
			return;
		}
		var numOfSlides = $(".slide").length;
		this.old = this.current;
		this.current = this.current < numOfSlides-1 ? this.current+1 : 0;
		this.show('next');
	},
	
	prev : function() {
		if ($(".slide").eq(this.current).is(":animated")) {
			return;
		}
		$(".slide").length
		var numOfSlides = $(".slide").length;
		this.old = this.current;
		this.current = this.current > 0 ? this.current-1 : numOfSlides-1;
		this.show('prev');
	},
	
	show : function(dir) {
		clearTimeout(this.timeout);
		
		hideDir = dir == 'next' ? 'left' : 'right';
		showDir = dir == 'next' ? 'right' : 'left';
				
		var that = this;
		$(".slide").eq(this.old).hide('slide', { direction: hideDir }, this.speed, function() {});			
		$(".slide").eq(this.current).show('slide', { direction: showDir }, this.speed, function() {
			that.timeout = setTimeout("SlideShow.next()", that.duration);
		});
	},
	
	init : function() {
		this.timeout = setTimeout("SlideShow.next()", this.duration);

		if ($.browser.msie && $.browser.version == '6.0') {
			$('.screenshot').each(function(index, elm) {
				var img = $(this).css('background-image');
				if (img.indexOf('.png') != -1) {
					var start = img.indexOf('url("') + 5;
					var end = img.indexOf('")');
	
					img = img.substring(start, end);
					
					$(this).css({
						'background-image' : 'none',
						'filter' : 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + img + ', sizingMethod="image")'
					});
				}
			});
		}
	}
};

$(document).ready(function() { SlideShow.init(); });