function Tooltip() {
	this.mouseX = 0;
	this.mouseY = 0;
}

function Slider() {
	this.$slides = $('#slides div');
	this.current = 0;
	this.max = this.$slides.length;
	
	this.nextStyle = {left:800};
	this.prevStyle = {left:-800};
	this.currentStyle = {left:0};
	this.time = 300;
	
	this.initStyle();
	this.initEvents();
}

Slider.prototype.prev = function() {
	return (this.current-1 >= 0) ? this.current-1 : this.max-1;
}

Slider.prototype.next = function() {
	return (this.current+1 < this.max) ? this.current+1 : 0;
}

Slider.prototype.currentSlide = function() {
	return $(this.$slides[this.current]);
}

Slider.prototype.prevSlide = function() {
	return $(this.$slides[this.prev()]);
}

Slider.prototype.nextSlide = function() {
	return $(this.$slides[this.next()]);
}

Slider.prototype.goPrev = function() {
	this.currentSlide().stop().animate(this.nextStyle, this.time);
	this.prevSlide().stop().css(this.prevStyle).animate(this.currentStyle, this.time);
	this.current = this.prev();
}

Slider.prototype.goNext = function() {
	this.currentSlide().stop().animate(this.prevStyle, this.time);
	this.nextSlide().stop().css(this.nextStyle).animate(this.currentStyle, this.time);
	this.current = this.next();
}

Slider.prototype.initStyle = function() {
	this.$slides.css('left', 800);
	this.currentSlide().css('left', 0);
	this.$slides.css('position', 'absolute');
}

Slider.prototype.initEvents = function() {
	var slider = this;
	$('#slider-next').click(function() {
		slider.goNext();
	});
	$('#slider-prev').click(function() {
		slider.goPrev();
	});
}

var slider;

$(document).ready(function () {
	tooltip();
	slider = new Slider();
});
