// Author: Kris Khoury, DUO Consulting

(function($){
	$.fn.hideandtype = function(options) {
		var defaults = {
			default_value: 		null,
			active_color:		"#000",
			inactive_color:			"#666"
		};
		var options = $.extend(defaults, options);
		return this.each(function(){
			var _sel = "input[rel='hideandtype']";
			$(this)
				.hover(
					function(){
						if(!$(this).next(_sel).length > 0){
							var input = $("<input type=hidden>");
							input.attr({"value":$(this).val(),"rel":"hideandtype"});
							$(this).after(input)
						}
					},
					function(){
						
					}
				)
				.focus(function(){
					if($(this).val() == $(this).next(_sel).val()){
						$(this)
							.val("")
							.css({"color":options.active_color})
					}
				})
				.blur(function(){
					if($(this).val() == ""){
						$(this)
							.val($(this).next(_sel).val())
							.css({"color":options.inactive_color})
					}
				})
				.css({"color":options.inactive_color})
		});
	};
})(jQuery);

$(document).ready(function() {
	$(".hideandtype").hideandtype();
});
