function subscr_form() {
	var box = $('#sec_rub');
	if ( $(box).attr('ref') == 'sbcr_view' ) {
		$('#f_sbcr').fadeOut(500, function() {
			$(box).attr('ref', '');
			$('ul', box).removeClass('sbcr_view');
			if ($(box).attr('rel') == 'short_view') {
				$('ul li:not(.on)', box).addClass('none');
			}
			$('ul input', box).remove();
			$('ul label', box).wrapInner(function() {
				'<a href="'+ $(this).attr('ref') +'" class="pink" rel="'+ $(this).attr('rel') +'" />';
			});
			$('ul label', box).wrapInner(function() {
				return '<a href="'+ $(this).attr('ref') +'" class="pink" rel="'+ $(this).attr('rel') +'" />';
			});
			$('ul a', box).unwrap();
			$('a[name=sbcr_link] span, a[name=toggle_rubs] span').toggleClass('none');
		})
	} else {
		$(box).attr('ref', 'sbcr_view');
		$('ul', box).addClass('sbcr_view');
		$('ul li', box).removeClass('none');
		$('ul a', box).wrapInner(function(i) {
			return '<label for="sbcr_view_'+ i +'" ref="'+ $(this).attr('href') +'" rel="'+ $(this).attr('rel') +'" />';
		});
		$('ul label', box).unwrap().before(function(){
			return '<input type="checkbox" class="mid mr5" id="'+ $(this).attr('for') +'" name="list_id" value="'+ $(this).attr('rel') +'" />';
		});
		$('a[name=sbcr_link] span, a[name=toggle_rubs] span').toggleClass('none');
		$('#f_sbcr').fadeIn(600);
	}
	return false;
}

if(!-[1,]){ /* only IE hack for proper rendering */
	$(function(){
		$('div[ref=ie_zm]').wrap('<div class="ie_zm" />');
	});
}

function subscribeIt(form, logged) {
	var list_id_checked = $('input[type=checkbox]:checked', $(form)).length;
	if (list_id_checked > 0) {
		if (logged == 0) {
			$(form).submit();
			return false;
		} else {
			var list_id_data = '';
			list_id_checked.each(function(i) {
				if (i > 0) {
					list_id_data += ',' + $(this).attr('value');
				} else {
					list_id_data += $(this).attr('value');
				}
				i++;
			});
			$.getScript('http://content.mail.ru/subscribe/jsonp/subscribe/?list_id='+list_id_data+'&jsonp=subscribed', function(){
				$('#f_sbcr', $(form)).prepend('<div class="goodInfo">Вы подписались на рассылки');
			});
		}
	} else {
		alert('Вы не выбрали ни одной рубрики');
	}
	return false;
}
