function news_home_list(id_categoria, pagina)
{
	if (!document.sending) {
		document.sending = true;
		//$('#div_news_home_list').html(MSG_LOADING);
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/news_home_list.php",
			data: { id_cat: id_categoria, p: pagina },
			success: function(response) {
				document.sending = false;
				$('#div_news_home_list').html(response);
			},
			error: function(obj, what_happen, other_obj) {
			}
		});
	}
}
function news_comment_save(id_news)
{
	if (!document.sending && news_comment_valid()) {
		document.sending = true;
		show_div('news_comment_msg', MSG_SENDING);
		var data = {id_news : id_news,
					name: $('#news_comment_name').val().trim(),
					email: $('#news_comment_email').val().trim(),
					comment: $('#news_comment_comment').val().trim() };
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/news_comment_save.php",
			data: data,
			success: function(response) {
				document.sending = false;
				if (response == '0') {
					show_div('news_comment_msg', MSG_DATA_SENT_OK);
					$('#news_comment_comment').val('');
					news_comment_list(id_news); // recargar comentarios
				} else {
					show_div('news_comment_msg', MSG_DATA_SENT_ERROR);
				}
			},
			error: function(obj, what_happen, other_obj) {
			}
		});
	}
}
function news_comment_valid()
{
	var valid = true;
	if ($('#news_comment_name').val().trim() == '') {
		valid = false;
		show_div('news_comment_msg', MSG_YOURNAME_MISSING);
	} else if ($('#news_comment_email').val().trim() == '') {
		valid = false;
		show_div('news_comment_msg', MSG_YOUREMAIL_MISSING);
	} else if (!is_email($('#news_comment_email').val())) {
		valid = false;
		show_div('news_comment_msg', MSG_EMAIL_NOT_VALID);
	} else if ($('#news_comment_comment').val().trim() == '') {
		valid = false;
		show_div('news_comment_msg', MSG_YOURCOMMENT_MISSING);
	}
	return valid;
}
function news_comment_list(id_news)
{
	$.ajax({
		type: "POST",
		url: WEB_PATH + "app/ajax/news_comment_list.php",
		data: { id_news: id_news },
		success: function(response) {
			$('#div_news_comment_list').html(response);
		},
		error: function(obj, what_happen, other_obj) {
		}
	});
}
function news_polo_tips_list(page){
  	if (!document.sending) {
		document.sending = true;
		//$('#div_news_home_list').html(MSG_LOADING);
		$.ajax({
			type: "POST",
			url: WEB_PATH + "app/ajax/news_polo_tips_list.php",
			data: { p: page },
			success: function(response) {
				document.sending = false;
				$('#div_polo_tips_block').html(response);
			},
			error: function(obj, what_happen, other_obj) {
                document.sending=false;
			}
		});
	}
}
