// Copyright (c) 2006-2007, Powermand Inc. All Rights Reserved.

// JavaScript for a slider input device
// "lever class=draggable" defines the draggable control peg, and "line" defines the track it moves on
// Requires js.toolbox.js, js.toolbox.draggable.js, and window.onload draggable_init() & Slider.init()

var SliderTimeout='';
function Slider() {
	this.lvr= '';
	this.ln= '';
	this.lvrW=0;
	this.firstTest=0;
	this.init=function(lvr,ln){ 
						this.lvr=lvr;
						this.ln=ln;
						this.lvrW=width(lvr);
						Constraint(lvr,leftCoord(ln),rightCoord(ln),'off');
					}; 
	//returns the current value of the slider
	this.Percent=function(){
						pos=leftCoord(this.lvr)-leftCoord(this.ln);
						Amt=  parseInt((pos/(rightCoord(this.ln)-this.lvrW-leftCoord(this.ln)))*100);
						if(Amt<0) Amt=0;
						if(Amt>100) Amt=100;
						return Amt;
	 				};
	//set current value
	this.setPos=function(Amt){
						//alert('Amt'+Amt);
						Amt=parseInt(Amt);
						if(Amt<0) Amt=0;
						if(Amt>100) Amt=100;
						Amt=Amt/100; 
						$TB(this.lvr).style.left=(leftCoord(this.ln)+((width(this.ln)-width(this.lvr))*Amt))+'px';
						//alert('left'+(leftCoord(this.ln)+((width(this.ln)-width(this.lvr))*Amt))+'px' );
						//$TB(this.lvr).style.left=60+'px'; 
	 				};						
}
