function DropDown(te){
	this.showElement = te;
	this.container = te.parentNode;
	this.container.style.position = 'relative';
	this.scaleFactor = 1.5;
	
	//this.anim = new YAHOO.util.Scroll(); 
	//this.scrollStep = this.showElement.offsetHeight-10;
}

DropDown.prototype.render = function(){
	if(!this.isNeedDD()){
		return;
	}
	this.showElement.style.overflowY='hidden';
	this.showElement.style.overflowX='auto';
	this.showElement.style.width = '607px';
	this.container.style.textAlign='left';
	
	this.createDU();
	this.createSlider();
	this.createDD();
	this.initSlider();
}


DropDown.prototype.createDU = function(){
	this.du = document.createElement('div');
	this.du.className="du";
	
	var DD = this;
	this.du.onclick = function(){
		DD.dropUp();
	}
	
	this.container.appendChild(this.du);
}



DropDown.prototype.createSlider = function(){
	this.sliderEl = document.createElement('div');
	this.sliderEl.id="slider-bg";
	
	this.sliderThumb = document.createElement('div');
	this.sliderThumb.id="slider-thumb";
	
	this.sliderThumb.innerHTML = "<img src='images/xt_green/thumb-bar.png'>";
	this.sliderEl.appendChild(this.sliderThumb);
	
	
	var offsetHeight = this.container.offsetHeight;
	var arrowHeight = this.du.offsetHeight;
	
	
	var height = offsetHeight-arrowHeight*2 ;
	this.bottomConstraint = height- 42;
	
	this.keyIncrement  = this.bottomConstraint/5;
	
	
	this.scaleFactor = ((this.showElement.scrollHeight-this.showElement.clientHeight)/this.bottomConstraint).toFixed(3);
	
	this.sliderEl.style.height = height+"px";
	this.sliderEl.style.top = ( arrowHeight) +'px';
	
	
	this.container.appendChild(this.sliderEl);
	
}




DropDown.prototype.createDD = function(){
	this.dd = document.createElement('div');
	this.dd.className="dd";
	
	var DD = this;
	
	this.dd.onclick = function(){
		DD.dropDwon();
	}
	
	this.container.appendChild(this.dd);
	
}

//向下
DropDown.prototype.dropDwon = function(h){
	/*var scrollHeight = this.showElement.scrollHeight;
	var top =  this.showElement.scrollTop;
	
	h = h || this.scrollStep
	
	if(top+h >= scrollHeight){
		return;
	}
	
	top += h;
	
	if(top>scrollHeight){
		top = scrollHeight;
	}

	var attributes = {   
 		scroll: { to: [0, top] }
	};   
	this.anim.init(this.showElement,attributes);
	this.anim.animate();  */
	
	var value = this.slider.getValue() + this.keyIncrement;
	
	if(value > this.bottomConstraint){
		value = this.bottomConstraint;
	}
	this.slider.setValue(value,false);
	this.dudd(this.slider.getRealValue());
}
//向上
DropDown.prototype.dropUp = function(h){
	/*var top =  this.showElement.scrollTop;
	if(top <= 0){
		return;
	}
	h = h || this.scrollStep
	top -=   h;
	
	if(top<0){
		top = 0;
	}

	var attributes = {   
 		scroll: { to: [0, top] }
	};   
	this.anim.init(this.showElement,attributes);
	this.anim.animate();  */
	
	var value = this.slider.getValue() - this.keyIncrement;
	if(value <= 0){
		value = 0;
	}
	this.slider.setValue(value,false);
	this.dudd(this.slider.getRealValue());
}

DropDown.prototype.dudd = function(value){
	this.showElement.scrollTop = value;
}

DropDown.prototype.isNeedDD = function(){
	var offsetHeight = this.showElement.offsetHeight;
	var scrollHeight = this.showElement.scrollHeight;
	
	if(scrollHeight>offsetHeight){
		return true;
	}
	return false;
}


DropDown.prototype.initSlider = function(topConstraint){
	topConstraint = topConstraint || 0;
	bottomConstraint = this.bottomConstraint || this.sliderEl.offsetHeight;
	this.slider = YAHOO.widget.Slider.getVertSlider(this.sliderEl,this.sliderThumb, topConstraint, bottomConstraint);
	var DD = this;
    this.slider.getRealValue = function() {
        return Math.round(this.getValue() * DD.scaleFactor);
    }
	
    this.slider.subscribe("change", function(offsetFromStart) {

        var actualValue = this.getRealValue();
       
        //DD.sliderThumb.title = offsetFromStart+"/"+actualValue+"/"+DD.scaleFactor;
		DD.dudd(actualValue);
    });
}

