var currObj;              // stores the current object being manipulated (leftSlider or rightSlider object)
var leftPos = 0;          // the current left position after mouse is released
var rightPos = 25000;     // the current right position after mouse is released
var sliderWidth = 0.075;      // the width of the sliders (includes borders)
var sliderBarWidth = 175; // the width of the slider bar (does not include borders)
var mouseStart = -99999   // an arbitrary number used to show that it is the first time we are hitting the moveSlider1 function.
var pos;                  // position with offset used during the move
var min = 0;              // minimum value of the data
var max = 3000000;          // maximum value of the data


/* funciton moveSlider(obj)
parameter obj - object reference to the calling object
This function sets the resets the starting mouse position and sets the document methods used to watch for mouse events.
*/
function moveSlider(obj) {
mouseStart = -99999;   // set the beginning mouse position to an unlikely number.
currObj = obj;         // set the currObj variable to the object that was clicked
document.onmousemove = moveSlider1; // set the onmousemove method to the function that moves the slider
document.onmouseup = moveDone;   // set the onmouseup method to the function that stops listening for the mousemove and reclaculates the data
}

/* function moveslider1
 This function is called by the mousemove event checks the current mouse position and compares it to the mouse position when the move was started. uses the difference as an offset from the slider's staring position to move the slider with the mouse
*/
function moveSlider1(e){

if (!e) var e = window.event;  // if IE, then we need to assign e
if (e.pageX) posX = e.pageX;   // FF, opera, netscape
else if (e.clientX) {          // IE
  posX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;  
}
if (mouseStart == -99999) mouseStart = posX;  // -99999 is an arbitrary number.  It is unlikely to be hit
var offset = posX - mouseStart; // determine the difference from where the mouse started to where it is now
if (currObj.id=="sliderLeft") {  // If we are moving the left slider
  pos = leftPos + offset;        // the new position should be the current left position + the offset
  if (pos < 0) pos = 0;          // if this makes the left position less than 0 then use 0
  if (pos > rightPos - sliderWidth) pos = rightPos - sliderWidth; // if the position would put us past the right slider then move up to the right slider
  var number;
  number =  Math.round(pos/sliderBarWidth*50)%50/50 * (max-min) + min; // put the new left position in a text box to be viewed. (this is not required)
 
	document.getElementById('leftX').innerHTML = Math.round(number);
 
}else {
  pos = rightPos + offset   // the new position should be the current right position + the offset
  if (pos < leftPos + sliderWidth) pos = leftPos + sliderWidth;  // if the new position would take us past the left slider then move next to the left slider
  if (pos > sliderBarWidth ) pos = sliderBarWidth ;  // if the new position is past the end of the bar, position at the end of the bar.
  var number;
  //find the end. by comparison and put the final number in the rightX box
  if (pos==sliderBarWidth){
	number =  max;
  }else{
	number =  Math.round(pos/sliderBarWidth*50)%50/50 * (max-min); // put the new right position in a text box to be viewed. (this is not required)
  }
  
	document.getElementById('rightX').innerHTML = Math.round(number);

}        
currObj.style.left = pos + "px";  // move the slider to the new position

}

// function moveDone()
// sets the current left/right position memory variable.
//  clears the mouse monitoring methods.
//  Calls the function to recaculate the data

function moveDone(e) {
if (currObj.id == "sliderLeft") leftPos = pos;    // set the current left position to the value of pos
else rightPos = pos;                              // set the current right position to the value of pos
document.onmousemove = function() {};             // stop listening for a mousemove event
document.onmouseup = function() {};               // stop listening for a mouseup event
//print ("value" + LeftX);
}