window.addEvent('load', function () {
$$('.slider label').each(function(milabel){	
	var labelColor = '#999';
	var restingPosition = '5px';
	
	// style the label with JS for progressive enhancement
	milabel.setStyles({
		'color' : labelColor,
		'position' : 'absolute',
	 	'top' : '6px',
		'left' : restingPosition,
		'display' : 'inline',
    	'z-index' : 99
	});
	
	// grab the input value
	var miinput = milabel.getNext('input');
	var inputval = miinput.get('value');
	
	// grab the label width, then add 5 pixels to it
	var labelwidth = milabel.getStyle('width').toInt();
	var labelmove = labelwidth + 5;
	
	//onload, check if a field is filled out, if so, move the label out of the way
	if(inputval !== ''){
		var myFx = new Fx.Tween(milabel);
		myFx.start('left',-(labelmove));		
	}    	
	
	// if the input is empty on focus move the label to the left
	// if it's empty on blur, move it back
	miinput.addEvents({
		'focus':function(){
			var label = milabel;			
			var width = label.getStyle('width').toInt();
			var adjust = width + 5;
			var value = this.get('value');
			
			if(value == ''){
				var myFx = new Fx.Tween(label,{
					duration:300
				});				
				myFx.start('left',-(adjust));
			} else {				
				label.setStyle('left',-(adjust));				
			}
			
		},
		'blur':function(){
			var label = milabel;
			var value = this.get('value');
			if(value == ''){
				var myFx = new Fx.Tween(label,{
					duration:'normal'
				});
				myFx.start('left',restingPosition);				
			}	
		}
	
	});

	
})
});
