$(function(){
	$('.hashtag').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	);

	$('.task').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	);
	
	$('.note').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	);

	// Resetting password

	$('#pswd-recover-go').click(function(){
		$('#login-regular').hide();
		$('#login-recover').show();
	});

	$('#pswd-recover-cancel').click(function(){
		$('#login-regular').show();
		$('#login-recover').hide();
	});
	
	// Login and password check
	$('#login-submit').click(function(){
		$(this).attr('class', 'status-wait').attr('disable','disable'); // disabling submit button
		
		$.get( // checking password through AJAX
			'ok.htm', // url for checking login information
			
			{
				login:$('#email'), // parameters -- login and password (smth else, if necessary)
				psswd:$('#psswd')
			}, 
			
			function(data){ // collback function
				if(data!='ok'){
					document.location.href='taskly-today.html'; // redirecting to main page if login is sucessful
				} else {
					throwNotify('error','Email and password did not match'); // showing error otherwise
					$('#login-submit').attr('class', 'status-gogo').removeAttr('disable'); // enabling submit button
				}
			}
		);
	});
	
	$('#addform').submit(function(){
		if ($('#email').val()!='' && $('#email').val()!='your e-mail address') {
		$(this).attr('class', 'status-wait').attr('disable','disable'); 
		$('#email').attr('disabled','disabled');

		$.post( 
			'signup.php', 

			{
				email:$('#email').val()
			},

			function(data){ 
				if(jQuery.trim(data)=='ok'){
					$('#subscribe').attr('class', 'submited');
					$('#email').val("thanks!").css({'color': 'rgb(163, 163, 163)'});
					
				} else {
					$('#subscribe').attr('class', '').removeAttr('disable');
					$('#email').removeAttr('disable');
				}
			}
		);
		}
		return false;
	});
});
