jQuery(document).ready(function($) {
	$('.estekhare-ajax').hide();
	$('#estekhare').on('click', '.estekhare-get', function() {
		var estekhare_ajax = $('.estekhare-ajax');
		var estekhare_result = $('#estekhare-result');
		estekhare_ajax.slideDown().css('display', 'block');
		$.ajax({
				url: estekhare.ajaxurl,
				type: 'POST',
				dataType: 'json',
				data: {
					action: 'estekhareAction'
				},
			})
			.done(function(data) {
				estekhare_ajax.slideUp();
				if (data.ok == 'yes') {
					estekhare_result.html(data.e);
					$('html , body').animate({
							scrollTop: estekhare_result.offset().top - 100
						},
						1000,
						function() {
							/* stuff to do after animation is complete */
						});
				} else {
					alert(data.msg);
				}
				console.log("success");
			})
			.fail(function() {
				estekhare_ajax.slideUp();
				console.log("error");
			})
			.always(function() {
				estekhare_ajax.slideUp();
				console.log("complete");
			});
	})
});