jQuery.fn.DefaultValue = function(){
	var defcolor = '#999999', actcolor = '#000000';
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if( this.type != 'text' && this.type != 'password' && this.type != 'textarea' || $(this).attr('defaultvalue') == null )
			return;

		$(this).attr('realtype', this.type); // used for passwords


		//Set value initially if none are specified
        if( this.value == '' ) {
        	if( this.type == 'password' ) {
        		// todo: solve for IE
        		if (!$.browser.msie)
        		this.type = 'text';
        	}
			this.value = $(this).attr('defaultvalue');
			$(this).css('color', defcolor);
		}

		$(this)
		.focus(function() {
			if( this.value == $(this).attr('defaultvalue')){
				this.value = '';
				if ($(this).attr('realtype') == 'password') {
					// todo: solve for IE
        			if (!$.browser.msie)
					this.type = 'password';
				}
				$(this).css('color', actcolor);
			}
		})
		.blur(function() {
			if( this.value == '' ){
				if( this.type == 'password' ) {
					// todo: solve for IE
        			if (!$.browser.msie)
					this.type = 'text';
				}
				this.value = $(this).attr('defaultvalue');
				$(this).css('color', defcolor);
			}
		});

		//Capture parent form submission
		//Remove field values that are still default
		var that = this;
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if( that.value == $(that).attr('defaultvalue')) {
					that.value = '';
				}
			});
		});
    });
};
