
var flag1 = true;
function fn_editHits(id) {
	if(flag1){
		$.post("articleAction!editHits.action", {id:id}, function (data) {
			if (data != null && typeof (data) != "undefined") {
				$("#" + id).html(data);
			}
		});
		flag1 =false;
	}
	setTimeout('flag=true',300000);
}

//��ȡ֧�ַ�����
$(document).ready(function () {
	weatherLoad();
});
function weatherLoad(){
	jQuery.ajaxSetup({cache:false});
	$.getJSON("jsonArticleAction!weatherHits.action", {}, function (json) {
		var supportNum = json.article0.hits;
		var oppositionNum = json.article1.hits;
		var supportNum1 = json.article2.hits;
		var oppositionNum1 = json.article3.hits;
		$("#supportNum").html("支持:"+supportNum);
		$("#oppositionNum").html("反对:"+oppositionNum);
		$("#supportNum1").html("支持:"+supportNum1);
		$("#oppositionNum1").html("反对:"+oppositionNum1);
		$("#vote0").val(json.article0.id);
		$("#vote1").val(json.article1.id);
		$("#vote2").val(json.article2.id);
		$("#vote3").val(json.article3.id);
		setCss(supportNum,oppositionNum,"0");
		setCss(supportNum1,oppositionNum1,"1");
	});
}
function setCss(supportNum,oppositionNum,type){
	var total = supportNum+oppositionNum;
	var totalHeight = 72;
	var height =totalHeight*(supportNum/total);
	$("#weatherImg"+type).removeClass();
	if(fn_compare(height,36)){
		$("#weatherImg"+type).toggleClass("qt",true);
		$("#weatherText"+type).html("晴天");
	}else{
		$("#weatherImg"+type).toggleClass("dy",true);
		$("#weatherText"+type).html("多云");
	}
	$("#schedule"+type).height(height);
}

function fn_compare(i,j){
	if(i<j){
		return false;
	}else{
		return true;
	}
}
var flag = true;
function weatherVote(id,name){
	if(flag){
		$("#anum"+name).animate({top:20,opacity:"show"},400).animate({top:-10,opacity:0},400);
		$.post("articleAction!editHits.action", {id:id}, function (data) {
			if (data != null && typeof(data) != "undefined") {
				weatherLoad();
			}
		});
		flag = false;
	}else{
		$("#alerttip").stop().removeAttr("style").animate({top:-8,opacity:"show"},0).delay(2000).animate({top:-60,opacity:0},200);
	}
	setTimeout('flag=true',300000);
}

