$(document).ready(function(){
	$('#feedback, a#close').hide();
	$('a#close').click(function () { $("#feedback, a#close").fadeOut();});
	
	$('#sendmail').click(function() {
		$('#feedback').fadeIn();
		$('#preloader').show();
		$.post("../mail/contact.php", {
			name: $('#name').val(), email: $('#email').val(), subject: $('#subject').val(), message: $('#message').val(), chk: $('#chk').val()
		}, function(response){
			$('a#close').stop().fadeIn();
			$('#preloader').stop().fadeOut();
			setTimeout("finishAjax('feedback', '"+escape(response)+"')", "400");
			$(this).delay(6000, function(){ $('#feedback, a#close').fadeOut(); });
			
		});
		
		return false;
	});
	$('#contact').blur(function(){
		$('#preloader').fadeOut();
	  	return false;
	});
	$("#contact").bind("keypress", function(e) {
		if (e.keyCode == 13) return false;
	});	
});
function finishAjax(id, response) {
  $('#preloader').hide();
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
}
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});	
	return this;
};
