//JavaScript WIRTEL*(:)* 2009
var arr = new Array();
$.postJSON = function(url, data, callback){$.post(url, data, callback, "json");};
function bp(x){
	o = $(x);
	if (!arr[x] || arr[x] == 0){
		o.show('fast');
		arr[x] = 1;
	} else {
		o.hide('normal');
		arr[x] = 0;
	}
}

function bag(){
	var s = $('#txtreport');
	if ($.trim(s.attr('value'))){
		s.attr('disable','disable'); 
		s.css('background','#fff url(/img/re.gif) no-repeat center center');
		$.postJSON('/ajax/1/1',{s:s.attr('value')},function(data){
			s.css('background','#fff');
			if (data.stat == '1') { 
				s.attr('value','');
				alert('Сообщение доставлено, спасибо!');
				bp('#bag-report','');
			}
			if (data.stat == '0') {
				alert(data.err);
			}
		});
	} else alert('Введите сообщение.');
}
