(function($) {
	$.fn.overlabel = function() {
		this.each(function() {
			var label = $(this);
			var field = label.find('input.field');
			
			// make clicking label focus element in safari
			if($.browser.safari){
				label.bind('click',function(){
					$('input.field',this).get(0).focus();
				});
			}
			if(!field.val()){
				label.addClass('show');
			}
			
			field.focus(function(){
				$(this).parents('label').removeClass('show');
			})
			.blur(function(){
				if(!$(this).val()){
					$(this).parents('label').addClass('show');
				}
			}).end();
		});
		return this;
	};
})(jQuery);


// Adds class of 'focus' when element is focussed 
// Adds class of 'changed' if non-empty
(function($) {
	$.fn.fieldfocus = function() {
		this.each(function() {
			// works on text fields and select
			var field = $('input.field,select',this);
			field.focus(function(){
				$(this).addClass('focus');
			})
			.blur(function(){
				$(this).removeClass('focus');
				if($(this).val())
					$(this).addClass('changed');
				else
					$(this).removeClass('changed');
			});
		});
		return this;
	};
})(jQuery);




// Set value of text input to title attribute of input
// Sets to none when field is focused

/*
(function($) {
	$.fn.titleasvalue = function() {
		this.each(function() {
			var field = $(this);
			field.focus(function(){
				if(this.value == this.title){this.value = '';}
			})
			.blur(function(){
				if($(this).val() == '' || $(this).val() == undefined){
					this.value = this.title;
				}
			}).val(field.attr('title'));
		});
		return this;
	};
})(jQuery);

*/
