function FontSlider() {

	var me=this;
	this.baseUrl = 'http://sampler.linotype.com/sam';
	this.fontId = '610709';
	this.sampleText = 'Test ITC Chino!';
	this.sampleWidth = '772';
	this.sampleColor = '&fg_r=51&fg_g=51&fg_b=51&bg_r=240&bg_g=240&bg_b=240';
	this.minFontSize = 8;
	this.steps = 20;
	this.range = 200;
	this.showing = 0;
	this.imgs;
	this.activator = null;
	
	this.init = function() {
		this.fontSize = document.getElementById('fontSize');
		this.container = document.getElementById('fontTester');
		this.slider = YAHOO.widget.Slider.getHorizSlider("slider", "sliderthumb", 0, this.range);
	    this.slider.subscribe('change', this.chgInterval);
	    this.preloadImages()
		YAHOO.util.Event.on(this.fontSize, "blur", this.checkValue);
		YAHOO.util.Event.on(this.fontSize, "keydown", this.keyDown);
		this.checkValue();
	}

	this.preloadImages = function() {
	    while ( this.container.childNodes.length >= 1 ) {
	        this.container.removeChild( this.container.firstChild );
	    } 
	    this.imgs = new Array();
	    for (var g = 0; g <= this.steps; g++) {
	        var i = new Image();
	        i.src = this.baseUrl + '?ID=' + this.fontId + this.sampleColor + '&text=' + this.sampleText + '&sizex=' + this.sampleWidth + '&fontsize=' + ((g * (this.range / this.steps)) + this.minFontSize);
	        i.style.position = 'absolute';
	        i.style.visibility = 'hidden';
	        this.container.appendChild(i);
	        this.imgs.push(i);
	    }
	}
	// Changes the text field value
	this.chgValue = function(x) {
	    this.fontSize.value = x + this.minFontSize;
	}
	
	//Hide currently shown image
	this.hideShowing = function() {
	    this.imgs[this.showing].style.visibility = 'hidden';
	}
	
	// Changes the shown img tag
	this.chgInterval = function(x) {
		var shownum = Math.round(x / (me.range / me.steps));
	    if (shownum != me.showing) {
	        me.hideShowing();
	        me.showing = shownum;
	        me.imgs[me.showing].style.visibility = 'visible';
	    }
	    me.chgValue(x);
	}
	
	// Checks the value of the text field, and sets the slider to that value
	this.checkValue = function() {
	    i = parseInt(this.fontSize.value-this.minFontSize);
	    if (isNaN(i)) {
	        i = this.slider.getValue();
	    }
	    this.slider.setValue(i, false);
	}
	
	// Used to determine if the enter key has been pressed
	this.keyDown = function(k) {
	    if (k.keyCode == 13) {
	        this.checkValue();
	        return false;
	    }
	}
	
	// Change font and displayed text
	this.changeFont = function (caller,id,text) {
		if(caller!=null) {
			if(this.activator!=null) {
				this.activator.style.fontWeight = 'normal';
				this.activator.style.color = '#333';
			}
			caller.style.fontWeight = 'bold';
			caller.style.color = '#39f';
			this.activator = caller;
		}
		this.fontId = id;
		if(text!='') {
			this.sampleText = text;
		}
		this.preloadImages();
		this.imgs[this.showing].style.visibility = 'visible';
	}

	// Change font and displayed text
	this.changeText = function (text) {
		this.changeFont(null,this.fontId, text);
		this.imgs[this.showing].style.visibility = 'visible';
	}
	
}