var obscureScale   ;
var seriousScale   ; 
var fantasticScalse ; 
var fastScale ; 

var thinSliderArray = new Array();

function addThinSlider(slider){
	thinSliderArray.push(slider);
}

function initThinSliders(parentDiv){
	 for(var i=0; i<thinSliderArray.length; i++) {
    	thinSliderArray[i].init(thinSliderArray[i] , parentDiv) ;
    }
}

function showThinSliderValues(){
	alert(seriousScale);
	alert(fantasticScalse);
	alert(fastScale);
}

function thinSlider(id){

	this.sliderLeft = 0 ;
	this.sliderUnit = 0 ;
	this.sliderValue = 0 ;
	this.initialValue = -1;
	//this.initialValue = 2;
	
	var knobCenter = 7;
	this.slider = document.getElementById('thinSliderKnob'+id);
	this.bar = document.getElementById('thinSliderBar'+id) ;
	if( document.getElementById('thinSliderEnabled'+id).value == 'false' ){
		this.sliderEnabled = false ;
	}else{
		this.sliderEnabled = true ;
	}

	this.initialize = false ;
	this.init = function( thisSlider, parentDiv ){
	
		if(this.initialize) return ;
		this.initialize = true ;
		var sliderTop = (getPosY( this.bar ) + 8 ) - getPosY(parentDiv) ;
		this.slider.style.top = sliderTop + "px" ;
		
		this.sliderLeft = (knobCenter +  getPosX( this.bar ) + 10) - getPosX(parentDiv) ;
		this.sliderWidth = parseInt( this.bar.style.width ) - 28 ;
		var sliderRight = this.sliderLeft + this.sliderWidth ;
		this.sliderUnit = 100 / this.sliderWidth ;
		
		this.sliderValue = parseInt(document.getElementById('thinSliderInitialValue'+id).value) ;
		//var initialOffset = 4 +  this.sliderUnit * this.sliderValue ;
		//this.slider.style.left = ( this.sliderLeft + initialOffset ) + "px";		
		//this.slider.style.visibility = "visible";

		Drag.init(this.slider, null, this.sliderLeft , sliderRight , sliderTop  ,sliderTop  );
		
		this.slider.onDrag = function (x,y){
			var offset = x - thisSlider.sliderLeft;
			thisSlider.sliderValue = offset *  thisSlider.sliderUnit ;
		}
		
		this.slider.onDragEnd = function (x,y){
			thisSlider.onDragEnd();
		}
		
		this.bar.onclick = function (event){
			if (!event) event = window.event;
			var offset = thisSlider.sliderLeft + getPosX(parentDiv) ;
			var pos_x = event.offsetX?(event.offsetX):event.pageX - offset ;

			if( thisSlider.sliderEnabled ) {
				if ( document.all )
				{
					if( pos_x > 16 ) return;
				}
				else
				{
					if( pos_x > 0 ) return;
				}
				//disable slider
				thisSlider.bar.src = imagePath + 'taste_scale_off.png';
				thisSlider.slider.style.display = 'none' ;
				thisSlider.sliderEnabled = false ;
			}else{
				//enbable slider
				thisSlider.bar.src = imagePath + 'taste_scale_on.png';
				thisSlider.slider.style.display = 'block' ;
				thisSlider.sliderEnabled = true ;
			}
		}
		this.setState();
	}
	
	this.setState = function(  ){
		//var initialOffset = 4 +  this.sliderUnit * this.sliderValue ;
		var initialOffset = 0;
		if( this.initialValue != -1 )
			initialOffset = 4 +  this.sliderUnit * this.initialValue*(100/4) ;
		else
			initialOffset = 4 +  this.sliderUnit * this.sliderValue ;
		
		this.slider.style.left = ( this.sliderLeft + initialOffset ) + "px";
		this.slider.style.visibility = "visible";
		if( this.sliderEnabled ) {
			//enbable slider
			this.bar.src = imagePath + 'taste_scale_on.png';
			this.slider.style.display = 'block' ;
			this.sliderEnabled = true ;
		}else{
			//disable slider
			this.bar.src = imagePath + 'taste_scale_off.png';
			this.slider.style.display = 'none' ;
			this.sliderEnabled = false ;
		}
	}
//	if( this.sliderEnabled == false ){
//		this.bar.src = imagePath + 'taste_scale_off.png';
//		this.slider.style.display = 'none' ;
//	}
}


