$(function(){	
	//Настройки аякса
	$.ajaxSetup({
		type: 'POST',
		timeout: 50000,
		dataType:'json',
		error: function(xhr)
		{
			$('#xDebug').html('Ajax Error: '+xhr.status+' '+xhr.statusText+' '+xhr.responseText);
			$('#xDebug').show();
		}
	})

	$('#xForm a.send').livequery('click',function(){
		$('#xForm').ajaxSubmit({
			url:'?_mod=main&_app=default&_task=sendMail',
			success:function(result){
				fnd_main_gui.hideLoading();
				if(result.err){
					fnd_main_gui.showBgr();
					$('#xForm').show();
					alert(result.err);				
				}else{
					alert("Ваше письмо отправлено!")
				}

			},
			beforeSend:function(){
				fnd_main_gui.hideBgr();
				$('#xForm').hide();
				fnd_main_gui.showLoading();
			}
		})
		return false;
	})

	$('#xMail').click(function(){
		fnd_main_gui.showBgr();
		$('#xForm').show();
	})

	$('#xForm a.close').livequery('click',function(){
		fnd_main_gui.hideBgr();
		$('#xForm').hide();
	})
	
	$(document).snowfall({round:true,minSize:1,maxSize:5,flakeCount : 35});
	
});
