var fbclick = 0;
$('#fbbut').click(function(){
	if (fbclick == 0) {
		$(this).animate({left: '+=201px'}, "slow");
		$('#fbform').animate({left: '+=201px'}, "slow");
		$('#fbmessage').focus();
		fbclick = 1;
	} else {
		$(this).animate({left: '-=201px'}, "slow");
		$('#fbform').animate({left: '-=201px'}, "slow");
		$('#fbmessage').blur();
		fbclick = 0;
	}
});

function sendfeedback() {
	fbemail = document.getElementById('email').value;
	fbmes = document.getElementById('fbmessage').value;
	$('#fbform .load').css({display: 'block'});
	$('#fbform .but').css({display: 'none'});
	if (fbemail == '' || fbmes == '') {
		$('#fbform .load').css({display: 'none'});
		$('#fbform .but').css({display: 'block'});
		alert('Fill in the fields.');
	} else if (fbemail == 'enter your e-mail') {
		$('#fbform .load').css({display: 'none'});
		$('#fbform .but').css({display: 'block'});
		alert('Enter your e-mail in the field above message.');
	} else {
		$.ajax({
			url: '/feedback.php',
			type: 'POST',
			cache: false,
			data: 'email=' + fbemail + '&message=' + fbmes,
			dataType: 'html',
			success: function(html, stat) {
				$('#fbform .load').css({display: 'none'});
				$('#fbform .but').css({display: 'block'});
				$('#fbform').html('Thanks for your message.');
			},
			error: function() {
				$('#fbform .load').css({display: 'none'});
				$('#fbform .but').css({display: 'block'});
				alert('Error. Try again.');
			},
			timeout: 5000
		});
	}
}
