$().ready(function(){

	function changePasswordFields() {
		$('#cpassword').hide();
		$('#password').show();
		$('#password').focus();
	}

	function reChangePasswordFields() {
		$('#password').hide();
		$('#cpassword').show();
		$('#cpassword').blur();
	}
	
	$('.signinfields').corner("round 5px");

	$('#cpassword').focus(function() {
		changePasswordFields();
	});

	$('#password').blur(function() {
		if ($(this).val()=='') reChangePasswordFields();
	});
		

	$('#forgottenpassword').click(function() {		
		$('#forgottensend').show();
		$('#fsubmit').hide();
		$('#secondbox, #forgottenpassword').fadeOut('slow', function(){$('#forgottenhelp').fadeIn('slow');});
	});

	$('#forgottencancel').click(function() {
		$('#forgottensend').hide();
		$('#fsubmit').show();		
		$('#forgottenhelp').fadeOut('slow', function(){$('#secondbox, #forgottenpassword').fadeIn('slow');});
	});

	$('#tryagainlink').click(function() {
		$('#myalert').fadeOut('slow', function(){
			$('#firstbox, #secondbox, #forgottenpassword').fadeIn('slow');
			$('#fsubmit').css({'opacity':'1', 'cursor':'pointer'}).removeClass('block');
		});
	});
	
	$('#tryagainlink2').click(function() {
		$('#forgottensend').css({'opacity':'1', 'cursor':'pointer'});
		$('#emailerror').fadeOut('slow', function(){$('#forgottenhelp').fadeIn('slow');});
	});

	$('#forgottensend').click(function() {
		var myemail = $('#email').val();   
        
        $(this).css({'opacity':'0.1', 'cursor':'default'});
        $.get('/auth/index/forgotten/email/'+myemail, '', function(data){ 
        	
        	var divToShow = '#passwordsent';
        	if (data=='ERROR') divToShow = '#emailerror'; 
        	$('#forgottenhelp').fadeOut('slow', function(){$(divToShow).fadeIn('slow');});
			
	    } );
	});
	
});

function myBlock(){
}