// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007

// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs 
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/

function K2Slider(handle, track, options) {
	var self = this;

	this.handle  = jQuery(handle);
    this.track   = jQuery(track);
    this.options = options || {};

    this.value     = this.options.value || 0;

    this.maximum   = this.options.maximum || 1;
    this.minimum   = this.options.minimum || 0;

    this.trackLength  = this.track.width();
    this.handleLength = this.handle.width();
	this.handle.css('position', 'absolute');

    this.active   = false;
    this.dragging = false;

    this.setValue(this.value);
   
    this.handle.mousedown(function(event) {
		self.active = true;

        var pointer	= self.pointerX(event);
		var offset	= self.track.offset();

		self.setValue(
			self.translateToValue(
				pointer-offset.left-(self.handleLength/2)
          	)
		);

		var offset = self.handle.offset();
		self.offsetX = (pointer - offset.left);
	});

	this.track.mousedown(function(event) {
		var offset	= self.track.offset();
        var pointer	= self.pointerX(event);

		self.setValue(
			self.translateToValue(
				pointer-offset.left-(self.handleLength/2)
          	)
		);
	});