$(function(){
$('form#contactForm .slider label').each(function(){
	var labelColor = '#999';
	var restingPosition = '5px';
	
	// style the label with JS for progressive enhancement
	$(this).css({
		'color' : labelColor,
		 	'position' : 'absolute',
	 		'top' : '6px',
			'left' : restingPosition,
			'display' : 'inline',
    		'z-index' : '99'
	});
	
	// grab the input value
	var inputval = $(this).next('input').val();
    var textareaval = $(this).next('textarea').text();
	
	// grab the label width, then add 5 pixels to it
	var labelwidth = $(this).width();
	var labelmove = labelwidth + 5;
	
	//onload, check if a field is filled out, if so, move the label out of the way
	if(inputval !== '' && textareaval !== ''){
		$(this).stop().animate({ 'left':'-'+labelmove }, 1);
	}    	
	
	// if the input is empty on focus move the label to the left
	// if it's empty on blur, move it back
	$('input').focus(function(){
		var label = $(this).prev('label');
		var width = $(label).width();
		var adjust = width + 5;
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':'-'+adjust }, 'fast');
		} else {
			label.css({ 'left':'-'+adjust });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();
		
		if(value == ''){
			label.stop().animate({ 'left':restingPosition }, 'fast');
		}

	});
	$('textarea').focus(function(){
		var label = $(this).prev('label');
		var width = $(label).width();
		var adjust = width + 5;
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':'-'+adjust }, 'fast');
		} else {
			label.css({ 'left':'-'+adjust });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':restingPosition }, 'fast');
		}

	});
})
});
