$(document).ready(function() {
    $('input[type="text"], input[type="password"]').addClass("idleField");
	$(".tooltipViewport, .formInfo").hide();
	
	$('input[type="text"], input[type="password"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		$(".formInfo:visible").hide();
		$(".tooltipViewport").show();
		$(this).parent().prev(".formInfo").clone().appendTo(".tooltipViewport").fadeIn(800);
        if (this.value == this.defaultValue){
        	this.value = '';
    	}
        if(this.value != this.defaultValue){
	    	this.select();
        }
    });
	
    $('input[type="text"], input[type="password"]').blur(function() {
    	$(this).removeClass("focusField").addClass("idleField");
   		//$('.tooltipViewport .formInfo').hide();
        if ($.trim(this.value == '')){
        	this.value = (this.defaultValue ? this.defaultValue : '');
    	}
    });
});
