(function( $ ){

  $.fn.snappyPlaceholder = function(options) {
	  
	  	if(!options) var options = {};
	  
	  	var settings = {
			'placeholderClass': 'snappy-placeholder'
		}
		
		$.extend(options,settings);

		this.each(function(){
	
			if($(this).find("[placeholder]").length) {
				
				var placeholders = $(this).find("[placeholder]");
				
				$(placeholders).each(function(){
					var placeholderText = $(this).attr('placeholder');
					
					if($(this).val()=="") $(this).val(placeholderText).addClass(settings.placeholderClass);
					
					$(this).bind('focus',function(){
						var inputText = $(this).val();
						if(inputText==placeholderText) {
							$(this).val("").removeClass(settings.placeholderClass);	
						}
					});
					$(this).bind('blur',function(){
						var inputText = $(this).val();
						if(inputText=="") {
							$(this).val(placeholderText).addClass(settings.placeholderClass);	
						}
					});
				});
				
				if($("form").length) {
					$("form").bind('submit',function(){
						$(placeholders).each(function(){
							var placeholderText = $(this).attr('placeholder');	
							var inputText = $(this).val();
							if(inputText==placeholderText) $(this).val("");
						});							   
					});
				}
				
			}
		
		});
	
  };
})( jQuery );
