/*
* jQuery.fn.toggleValue();
*
* Toggle default value on focus/blur, works on:
* input:text, input:password and textarea
*
* $('.element').toggleValue();
*
* Version 0.6.0
* www.labs.skengdon.com/toggleValue
* www.labs.skengdon.com/toggleValue/js/toggleValue.min.js
*/
;(function($){
	$.fn.toggleValue = function() {
		return this.each(function() {
			var node = this.nodeName.toLowerCase();
			if( node == 'input' ) {
				
				if ( !this.type ) this.type = 'text';
				
				if ( ( this.type == 'text' ) || ( this.type == 'password' ) ) {
					this.edit = true;
				};	
				
			} else if( node == 'textarea' ) {
			
				this.edit = true;
				
			};
			
			if ( this.edit ) {
				$(this).wrap('<div style="position:relative;"></div>');
				$(this).clone().appendTo( $(this).parent() );
				var that = $(this).next().get(0);
				
				that.name = that.id = '';
				this.value = '';
				
				$(that).css( { position:'absolute', top:0, left:0 } );
				
				$(that).focus(function() {
					$(this).fadeOut();
					$(this).prev().focus();
				});
				
				$(this).blur(function() {
					if ( this.value == '' ) {
						$(this).next().fadeIn();
					}
				});
			}
		});
	};
})(jQuery);
