var pkid=3;
var isLogin=false;
function CheckLogin()
{
if (isLogin==true) return;
$.ajax({
url: "pkajax.asp",
cache: false,
data: "action=checklogin&id=" + pkid,
success: function(r){
r=unescape(r);
var arrobj=r.split('|');
if (arrobj[0]!="success")
{
if (arrobj[0]=="login")
{
showlogin();
}else{
Alert(arrobj[0],arrobj[1],arrobj[2]);
}
}else{
isLogin=true;
}
}
});
}
function showlogin(){
ShowLogin();
}
function submitCheck(role){
var content=''
if (role==1)
{
if (jQuery("#agreeContent").val()==''||jQuery("#agreeContent").val()=='支持观点A请在这里发表自己的观点!')
{
KesionJS.Alert("请发表A观点!",'jQuery("#agreeContent").focus();');
return;
}
content=jQuery("#agreeContent").val();
}else if(role==2){
if (jQuery("#argueContent").val()==''||jQuery("#argueContent").val()=='支持观点B请在这里发表自己的观点!')
{
KesionJS.Alert("请发表B观点!",'jQuery("#argueContent").focus()');
return;
}
content=jQuery("#argueContent").val();
}else{
if (jQuery("#otherContent").val()==''||jQuery("#otherContent").val()=='我要发表其它观点...')
{
KesionJS.Alert("请输入其它观点!",'jQuery("#otherContent").focus()');
return;
}
content=jQuery("#otherContent").val();
}
$.post("pkajax.asp",{action:'savepost',id:pkid,content:escape(content),role:role}, function(r){
r=unescape(r);
var arrobj=r.split('|');
if (arrobj[0]!="success")
{
if (arrobj[0]=="login")
{
showlogin();
}else{
Alert(arrobj[0],arrobj[1],arrobj[2]);
}
}else{
KesionJS.Alert("恭喜,您的观点提交成功!","");
setpkimg();
setpkgdlist();
jQuery("#agreeContent").val('支持观点A请在这里发表自己的观点!');
jQuery("#argueContent").val('支持观点B请在这里发表自己的观点!');
jQuery("#otherContent").val('我要发表其它观点...');
}
}
);
}
//设置PK图片显示
function setpkimg() {
var agreeNum = 0;
var argueNum = 0;
$.ajax({
url: "pkajax.asp",
cache: false,
data: "action=getvotes&id=" + pkid,
success: function(r){
r=unescape(r)
var arr=r.split('|');
agreeNum=parseInt(arr[0]);
argueNum=parseInt(arr[1]);
$("#agreenum").html(agreeNum+"人支持");
$("#arguenum").html(argueNum+"人支持");
var total = agreeNum + argueNum;
var h3Width = 70;
var imgAgreeSpan = imgArgueSpan = 300;
var imgAgree = imgArgue = imgAgreeSpan + h3Width;
if (total != 0) {
var totalSpan = imgAgreeSpan * 2;
imgAgreeSpan = Math.round(agreeNum / total * totalSpan);
imgAgree = imgAgreeSpan + h3Width;
imgArgueSpan = totalSpan - imgAgreeSpan;
imgArgue = imgArgueSpan + h3Width;
}
$("#pk_yes").css("width", imgAgree);
$("#pk_no").css("width", imgArgue);
$("#img_agree").css("width", imgAgreeSpan);
$("#img_argue").css("width", imgArgueSpan);
}
});
}
function setpkgdlist()
{
$.getScript("pkajax.asp?action=getgdlist&role=1&id="+pkid);
$.getScript("pkajax.asp?action=getgdlist&role=2&id="+pkid);
$.getScript("pkajax.asp?action=getgdlist&role=3&id="+pkid);
}
function showagree(commentJsonVarStr___){
data=formattime(commentJsonVarStr___);
if (data.comments != null) {
//绑定模板
var node = $($(".agreetpl").html()).bindTo(data);
//显示
$("#agreecomm").html(node);
}
}
function showargue(commentJsonVarStr___){
data=formattime(commentJsonVarStr___);
if (data.comments != null) {
//绑定模板
var node = $($(".arguetpl").html()).bindTo(data);
//显示
$("#arguecomm").html(node);
}
}
function showother(commentJsonVarStr___){
data=formattime(commentJsonVarStr___);
if (data.comments != null) {
//绑定模板
var node = $($(".othertpl").html()).bindTo(data);
//显示
$("#othercomm").html(node);
}
}
//格式化时间
function formattime(data){
var str = null;
if (data.comments != null) {
for(i=0; i广告