function SliderDirector(
	oSliderId,
	oMinPriceSlider,
	oMaxPriceSlider,
	oMinPriceInput,
	oMaxPriceInput,
	iMinValue,
	iMaxValue
	) {	
	
	this.oSliderId = oSliderId;
	this.oMinPriceSlider = oMinPriceSlider;
	this.oMaxPriceSlider = oMaxPriceSlider;
	this.oMinPriceInput = oMinPriceInput;
	this.oMaxPriceInput = oMaxPriceInput;
	this.iMinValue = iMinValue;
	this.iMaxValue = iMaxValue;
	this.iCurrentMinValue = parseInt(oMinPriceInput.value);
	this.iCurrentMaxValue = parseInt(oMaxPriceInput.value);	
		
	var oThis = this;
			
	this.oMinPriceSlider.onchange = this.oMaxPriceSlider.onchange = function() {
						
		oThis.synchronizeFromSlider();			
		
	};
		
	this.oMinPriceInput.onkeypress = this.oMaxPriceInput.onkeypress = function(oEvent) {
						
		var
			oEvent = oEvent || window.event,
			iKeyCode = oEvent.keyCode? oEvent.keyCode : (oEvent.which? oEvent.which : null)
			;
							
		if(!(oThis.isDigit(iKeyCode) || oThis.isSystem(iKeyCode))) {
			return false;
		}						
		
	};

	this.oMinPriceInput.onkeyup = this.oMaxPriceInput.onkeyup = function() {					
				
		oThis.updateValuesFromInputs();			
		oThis.synchronizeToSlider();			
			
	};
	
}
		
SliderDirector.prototype = {
	
	synchronizeFromSlider : function() {			
		
		this.iCurrentMinValue = parseInt(this.oMinPriceSlider.value);
		this.iCurrentMaxValue = parseInt(this.oMaxPriceSlider.value);				
		
		if(this.oMinPriceInput.value != this.iCurrentMinValue) {
			this.oMinPriceInput.value = this.iCurrentMinValue > -1? this.iCurrentMinValue : '';
		}
		
		if(this.oMaxPriceInput.value != this.iCurrentMaxValue) {
			this.oMaxPriceInput.value = this.iCurrentMaxValue > -1? this.iCurrentMaxValue : '';	
		}
	
	},
	
	synchronizeToSlider : function() {							
		
		if(aSliders[this.oSliderId]) {
		
			aSliders[this.oSliderId].aPointers[0].iValue = this.iCurrentMinValue;
			aSliders[this.oSliderId].aPointers[1].iValue = this.iCurrentMaxValue;
		
			aSliders[this.oSliderId].aPointers[0].recalcPositionFromValue();
			aSliders[this.oSliderId].aPointers[0].movePointer();				
				
			aSliders[this.oSliderId].aPointers[1].recalcPositionFromValue();
			aSliders[this.oSliderId].aPointers[1].movePointer();
			
		}
	
	},
	
	updateValuesFromInputs : function() {
	
		this.iCurrentMinValue = parseInt(this.oMinPriceInput.value.length > 0? this.oMinPriceInput.value : -1);
		this.iCurrentMaxValue = parseInt(this.oMaxPriceInput.value.length > 0? this.oMaxPriceInput.value : -1);
		
		if(this.iCurrentMinValue > this.iMaxValue) {
			this.iCurrentMinValue = this.iMaxValue - 2;
		}
		
		if(this.iCurrentMaxValue > this.iMaxValue) {
			this.iCurrentMaxValue = this.iMaxValue - 1;
		}
		
		if(this.iCurrentMinValue > this.iCurrentMaxValue) {
			this.iCurrentMinValue = this.iCurrentMaxValue - 1;
		}		
		
	},
	
	isSystem : function(iKeyCode) {
	
		return iKeyCode < 48;
	
	},
	
	isDigit : function(iKeyCode) {
	
		return !(iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57));
	
	}

};