function switchTabs(obj) {
	$('ul.action-menu a').removeClass('a');
	$('a#'+obj.id).addClass('a');
	$('div.inner').hide();
	$('div#tab-'+obj.id).show();
}
function postRating(id, val) {
	$.ajax({type:"POST",
	        url: '/com/'+id+'/rating.html',
			  data: 'rating='+val, 
			  beforeSend: function(obj) {
			  	   $('#rating-value div').show();
			  },
			  error: function(){
			      $('#rating-value div').hide();
			  }, 
			  success: function(text) {
					$('#rating-value').html(text);
				}			  
			}); 
	return 0;
}

function login(form) {
   if (document.getElementById('comment-name'))
		if ($('#comment-name').val().length == 0) {
			alert('Подпишитесь, пожалуйста...');
			$('#comment-name').focus();
			return 0;
		}
	
/*
	if ($F('comment-captcha').length < 5) {
	   alert('Пожалуйста, укажите текст, изображенный на картинке...');
		$('comment-captcha').focus();
		return 0;
	}
*/
	// Email
   var Format = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (document.getElementById('comment-email'))
		if ($('#comment-email').val().length == 0 || !$('#comment-email').val().match(Format)) {
			alert('Пожалуйста, укажите корректное значение поля Email');
			$('#comment-email').focus();
			return false;
		}
   if ($('#comment-comment').val().length == 0) {
	   alert('Пустые отзывы не будут опубликованы');
		$('#comment-comment').focus();
		return 0;
	}
   $.ajax({
		url: form.action,
	   type: 'POST',
		data: 'action=login&'+$(form).serialize(),
		dataType: "script",
		error: function(){alert('Ajax error: loginComment');}, 
		success:function(req) {
			$('tr.commentpasw').remove();
			if ($('#comment-info')) $('#comment-info').after(req);
		 }
		});
	return false;
}

// Отправляем фидбек об изменениях
function sendChange(form) {
	//alert('postComment - ' + form.id); return;
   $.ajax({
		url: undefined,
	   type: 'POST',
		data: $(form).serialize(),
		error: function(){alert('Ajax error: sendChange');}, 
		success:function(req) {
			name = form.id.replace(/\-form/g, '');
			$('#'+name).html(req);
		 }
		});
	return false;
}

// Постим комментарии
function postComment(form) {
	//alert('postComment - ' + form.action); //return;
   $.ajax({
		url: form.action,
	   type: 'POST',
		data: 'action=post&'+$(form).serialize(),
		error: function(){alert('Ajax error: postComment');}, 
		success:function(req) {
			if ($('dl#comments')) $('dl#comments').append(req);
			if ($('#commentform')) $('#commentform').hide();
			//if ($('#newcomment')) $('#newcomment').hide();
			if ($('#tab-comment')) $('#tab-comment').append(req);
			if ($('#commentform')) document.getElementById('commentform').reset();
			if ($('#comment-on')) $('#comment-on').show();
		 }
		});
	return false;
}
/*
function refreshCaptcha() {
   var new_c = captcha_url + "&anticache="+(new Date()).getTime();
	$('captcha-img').src = new_c;
}
*/
