/**
 * jQuery (LabelInsideInput) 1.0
 *  
 * Instead of showing a label next to that text field, show it as a pre-filled value inside the text field.
 *
 * Copyright (c) 2010  Draško Gomboc - Mrežni Sistemi 
 * 
 * Requirements:
 * 	jquery-1.3.2.min.js
 * 	 
 * 
 */
;(function(jQuery) {
	
	jQuery.fn.labelInsideInput = function(options) {

		function showHideLabel(container)
		{
			if(jQuery("#password", container).val().length > 0) {
				jQuery(".passwordLabel", container).addClass('hidden');
			}else {
				jQuery(".passwordLabel", container).removeClass('hidden');
			}
		}
		
		return this.each(function() {  
			
			var container = jQuery(this);

			jQuery("#username", container)		
			.focus(function(){
				jQuery(".usernameLabel", container).css({opacity: "0.5"});
			})
			.blur(function(){
				jQuery(".usernameLabel", container).css({opacity: "1"});
			})
			.keyup(function(){
				showHideLabel(container)
			})
			.change(function(){
				showHideLabel(container)
			});
	
			jQuery("#password", container)
				.focus(function(){
					jQuery(".passwordLabel", container).css({opacity: "0.0"});
	
				})
				.blur(function(){
					jQuery(".passwordLabel", container).css({opacity: "1"});
				})
				.keyup(function(){
					showHideLabel(container)
				})
				.change(function(){
					showHideLabel(container)
				});
			
		});
	}

})(jQuery);
