	$(document).ready(function () {
		function Slider() {
			this.num = 0;
			this.numSlides = 5;
			this.totalWidth = this.numSlides * 866;
			
			this.addGraphics();
			this.setCss();
			this.trackButton(0);
			var inter = this.startLoop();
		}
		
		Slider.prototype.addGraphics = function() {
			$('#slider_whole').append('\
				<div id="buttons_wrapper">\
					<div id="buttons">\
						<a href="#"><span class="box box1"></span></a>\
						<a href="#"><span class="box box2"></span></a>\
						<a href="#"><span class="box box3"></span></a>\
						<a href="#"><span class="box box4"></span></a>\
						<a href="#"><span class="box box5"></span></a>\
					</div>\
				</div>');
		}
		
		Slider.prototype.detectNext = function(num) {
			if (num < 4) {
				num++;
			} else {
				num = 0;
			}
			return num;
		}
		
		Slider.prototype.trackButton = function(num) {
			if ($('.box1').css('background-color') != 'rgb(154, 190, 210)') {
				$('.box1').css({ 'background' : 'white' });
			}
			if ($('.box2').css('background-color') != 'rgb(154, 190, 210)') {
				$('.box2').css({ 'background' : 'white' });
			}
			if ($('.box3').css('background-color') != 'rgb(154, 190, 210)') {
				$('.box3').css({ 'background' : 'white' });
			}
			if ($('.box4').css('background-color') != 'rgb(154, 190, 210)') {
				$('.box4').css({ 'background' : 'white' });
			}
			if ($('.box5').css('background-color') != 'rgb(154, 190, 210)') {
				$('.box5').css({ 'background' : 'white' });
			}
			
			if (num == 0) {
				$('.box1').css({ 'background' : '#114695' });
			} else if (num == 1) {
				$('.box2').css({ 'background' : '#114695' });
			} else if (num == 2) {
				$('.box3').css({ 'background' : '#114695' });
			} else if (num == 3) {
				$('.box4').css({ 'background' : '#114695' });
			} else if (num == 4) {
				$('.box5').css({ 'background' : '#114695' });
			} else {
				$('.box1').css({ 'background' : '#114695' });
			}
		}
		
		Slider.prototype.setCss = function() {
			$('#slides').css({
				'float' : 'left',
				'width' : this.totalWidth
			});
		}
		
		Slider.prototype.animateSlide = function(num) {
			num = this.detectNext(num);
			
			$('#slides').animate({
				'marginLeft' : (-866 * num) + 'px'
			}, 'slow', function() {
				Slider.prototype.trackButton(num);
			});
			
			return num;
		}
		
		Slider.prototype.startLoop = function() {
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
		}
		
		var slider = new Slider();
		
		$('.box1').bind('click', function(e) {
			e.preventDefault();
			clearInterval(Slider.prototype.inter);
			slider.num = slider.animateSlide(4); //SHIT CODE
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
			
		});
		
		$('.box2').bind('click', function(e) {
			e.preventDefault();
			clearInterval(Slider.prototype.inter);
			slider.num = slider.animateSlide(0); //SHIT CODE
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
		});
		
		$('.box3').bind('click', function(e) {
			e.preventDefault();
			clearInterval(Slider.prototype.inter);
			slider.num = slider.animateSlide(1); //SHIT CODE
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
		});
		
		$('.box4').bind('click', function(e) {
			e.preventDefault();
			clearInterval(Slider.prototype.inter);
			slider.num = slider.animateSlide(2); //SHIT CODE
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
		});
		
		$('.box5').bind('click', function(e) {
			e.preventDefault();
			clearInterval(Slider.prototype.inter);
			slider.num = slider.animateSlide(3); //SHIT CODE
			Slider.prototype.inter = setInterval(function() {
				slider.num = Slider.prototype.animateSlide(slider.num); //SHIT CODE
			}, 5000);
		});
		
		$('.box1').mouseenter(function() {
			if (slider.num != 0) {
				$('.box1').css({ 'background' : '#9abed2' });
			}
		}).mouseleave(function() {
			if (slider.num != 0) {
				$('.box1').css({ 'background' : 'white' });
			}
		});
		
		$('.box2').mouseenter(function() {
			if (slider.num != 1) {
				$('.box2').css({ 'background' : '#9abed2' });
			}
		}).mouseleave(function() {
			if (slider.num != 1) {
				$('.box2').css({ 'background' : 'white' });
			}
		});
		
		$('.box3').mouseenter(function() {
			if (slider.num != 2) {
				$('.box3').css({ 'background' : '#9abed2' });
			}
		}).mouseleave(function() {
			if (slider.num != 2) {
				$('.box3').css({ 'background' : 'white' });
			}
		});
		
		$('.box4').mouseenter(function() {
			if (slider.num != 3) {
				$('.box4').css({ 'background' : '#9abed2' });
			}
		}).mouseleave(function() {
			if (slider.num != 3) {
				$('.box4').css({ 'background' : 'white' });
			}
		});
		
		$('.box5').mouseenter(function() {
			if (slider.num != 4) {
				$('.box5').css({ 'background' : '#9abed2' });
			}
		}).mouseleave(function() {
			if (slider.num != 4) {
				$('.box5').css({ 'background' : 'white' });
			}
		});
	});
