(function($)
			{
				
				var opts = {};
				
			  
				//
				// Main Plugin Entry Point
				//
				$.fn.passwordMask = function(  options )
				{
					opts = $.extend( {}, $.fn.passwordMask.defaults, options );
					
					// Loop through all the objects in the selector
					this.each( function() {
						var $this = $(this);
						
						if ( opts.mode == 'div' )
						{
							// wrap the div in the container
							$this.wrap("<div class=\"fillin_txt_wrapper\"></div>");
							
							// create a div after the input
							var fillin_div = $("<div class=\"fillin_div\">" + opts.caption + "</div>");
							
							fillin_div.data('fillin_txt', $this);
							
							fillin_div.bind( "click focus", function(e) {
								$(this).data('fillin_txt').focus();
							});
							
							$this.after(fillin_div);
							$this.data('fillin_div', fillin_div	);
							fillin_div.hide();
						}
						
						
						// Initialise the masks
						window.setTimeout( function(){
							if ( $this.val() == '' )
							{
								switch( opts.mode )
								{
									case 'image':
										$this.css('background-image', "url(" + opts.image + ")");		
									break;
									
									case 'class':
										$this.addClass(opts.className);
									break;
									
									case 'div':
										$this.data('fillin_div').show();
									break;
								}
							}
						}, 500);
						
						// When it's clicked on
						$this.focus(function(){
							
							var $this = $(this);
							
							switch( opts.mode )
							{
								case 'image':
									$this.css('background-image', 'none');
								break;
								
								case 'class':
									$this.removeClass(opts.className);
								break;
								
								case 'div':
									$this.data('fillin_div').hide();
								break;
							}
							
							
			
						});
						
						// When it's clicked off
						$this.blur(function(){
							var $this = $(this);
							if ( $this.val() == '' )
							{
								switch( opts.mode )
								{
									case 'image':
										$this.css('background-image', "url(" + opts.image + ")");
									break;
									
									case 'class':
										$this.addClass(opts.className);
									break;
									
									case 'div':
										$this.data('fillin_div').show();
									break;
								break; 
								
								}
								
							}
						
						});
												
						$this.bind('propertychange', function(e){
							var $this = $(this);
							if ( e.originalEvent.propertyName == "value" )
							{
								$this.triggerHandler('focus');
							}
							
						});
						
					});
					
					return this;
			
				};
				
				//
				// Default Options
				//
				$.fn.passwordMask.defaults = {
					mode:'class',
					className: 'label-on',
					caption: 'Password',
					image:''
				};
			})(jQuery);
