Cufon.replace('.felt');

$(document).ready(function() {	

	$.fn.clear = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				if (this.id == 'formfield-login-email') {
					this.value = this.defaultValue;
					$(this).removeClass('filled');
				} else {
					$('#login-password-overlay').show();
				}
			} else {
				$(this).addClass('filled');
				$('#login-password-overlay').hide();				
			}
		});
	};
	
	$.fn.regclear = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				if (this.id == 'formfield-register-email') {
					this.value = this.defaultValue;
					$(this).removeClass('filled');
				} else {
					$('#register-password-overlay').show();
				}
			} else {
				$(this).addClass('filled');
				$('#register-password-overlay').hide();				
			}
		});
	};
		
	$('#login-password-overlay').click(function(){
		$('#formfield-login-password').focus();
	});
	
	$('#formfield-login-password').focus(function(){
		$('#login-password-overlay').hide();
	});
	
	$('#formfield-register-password').focus(function(){
		$('#register-password-overlay').hide();
	});
	
	$('#register-password-overlay').click(function(){
		$('#formfield-register-password').focus();
	});
	
	$('#formfield-login-email, #formfield-login-password').clear();
	$('#formfield-register-email, #formfield-register-password').clear();
	
	
	$('#group-header #unit-login form').hover(function(){
		$('#tip-password').fadeIn();
	}, function(){
		$('#tip-password').fadeOut();
	});
	
	$('.link-register').hover(function(){
		$('#tip-registration').fadeIn();
	}, function(){
		$('#tip-registration').fadeOut();
	});
	
	$('#tip-registration').hover(function(){
		$('#tip-registration').fadeIn().stop();
	}, function(){
		$('#tip-registration').fadeOut();
	});
	
	$('#tip-password').hover(function(){
		$('#tip-password').fadeIn().stop();
	}, function(){
		$('#tip-password').fadeOut();
	});
	
	
});
