﻿function showHits(id){
	var box = $I('news_hits');
	if( !box ) return;
	$.ajax({
		type : 'get',
		url : '../../club/control?do=news-hits&id='+id,
		cache : false,
		dataType : 'text',
		timeout : 20000,
		success: function(text){
			box.innerHTML = text;
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			box.innerHTML = 'err';
		}
	});
}

function showComment(id,page,flag){
	if ( flag ){ //评论列表
		var box_show = $I('news_comment');
		if( !box_show ) return;
		$.ajax({
			type : 'get',
			url : '../../club/control?do=news-comment-show&id='+id+'&page='+(page?page:1),
			cache : false,
			dataType : 'text',
			timeout : 20000,
			success: function(text){
				box_show.innerHTML = text;
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				box_show.innerHTML = '评论载入失败。';
			}
		});
	}else{ //评论数量
		var box_count_1 = $I('news_comment_count_1');
		var box_count_2 = $I('news_comment_count_2');
		if( !box_count_1 && !box_count_2 ) return;
		$.ajax({
			type : 'get',
			url : '../../club/control?do=news-comment-count&id='+id,
			cache : false,
			dataType : 'text',
			timeout : 20000,
			success: function(text){
				if( box_count_1 ) box_count_1.innerHTML = text;
				if( box_count_2 ) box_count_2.innerHTML = text;
			}
		});
	}
}

function saveComment(id){
	loading(1);
	var url = '../../club/control/'+post_handle+'?do=news-comment-save&id='+id;
	var data =  $('#form_comment').serialize();
	post(url,data,'您的评论已成功提交！',null,5,'$I("form_comment").reset();$I("safecode_box").innerHTML="";showComment('+id+');');
}

function showHots(){
	var box = $I('RBOX');
	if( !box ) return;
	$.ajax({
		type : 'get',
		url : '../../club/control?do=news-hot-show',
		cache : false,
		dataType : 'text',
		timeout : 20000,
		success: function(text){
			box.innerHTML = text;
		}
	});
}
