$(document).ready(function() {
	$('#generate_btn').click(function() {
		$('#generate_btn').attr('disabled', 'disabled');
		var string = $('[name=string]').val();
		var isRadio = $('#is_radio').val();
		
		if (isRadio != undefined) {
			var type = $('[name=type]:checked').val();
		} else {
			var type = $('[name=type]').val();
		}
		
		$.post("/ajax/hash", {
			type : type,
			string : string
		}, function(data) {
			if (data == 'false') {
				alert('Błąd połaczenia z serwerem');
			} else {
				$('#hash_result').val(data);
				$('#hash_result_div').show(300);
				$('#generate_btn').removeAttr('disabled');
			}
		}, "text");
		return false;
	});
});