var GuestShowPerson=1;
$(document).ready(function(){
inputfocus();
cutWrap("*[cut='line']", "*[cut]");
cutByMaxChar();
});
function defineClick(){
if(!(jQuery.browser.msie)){
HTMLElement.prototype.click=function(){
var evt=this.ownerDocument.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
}
}
function inputfocus(){
if (jQuery.browser.msie){
$("input[type='text'], input[type='password'], textarea").focus(function(){$(this).addClass("iefocus")}).blur(function(){$(this).removeClass("iefocus")});
}
}
function G(id){return document.getElementById(id);}
function getCookie(aFolder,aName){
var sSearch=" "+aFolder+"=";
var acookie=" "+window.document.cookie+";";
if(acookie.length>0){
var iOffset=acookie.indexOf(sSearch);
if(iOffset!=-1){
iOffset+=sSearch.length;
var iEnd=acookie.indexOf(";",iOffset);
if(iEnd==-1){iEnd=acookie.length;}
acookie="&"+acookie.substring(iOffset,iEnd)+"&";
sSearch="&"+aName+"=";
iOffset=acookie.indexOf(sSearch);
if(iOffset!=-1){
iOffset+=sSearch.length;
iEnd=acookie.indexOf("&",iOffset);
if(iEnd==-1){iEnd=acookie.length;}
var s=acookie.substring(iOffset,iEnd);
if(IsNumeric(s)) return s;else return unescape(s);
}
}
}
return null;
}
var lastUID="ready";
var uidTimer=null;
function getUserID(){
var uid=getCookie("oASK", "UID");
if(!uid) return 0;
if(IsNumeric(uid)==false) return 0;
return uid.valueOf();
}
function IsLogined(){
if(getUserID()>0){return true;}else{return false;}
}
function oEditorCallback(){
if(IsLogined()==false){
alert("只有本站的注册用户才能使用本按钮的功能！");
return false;
}else{
return true;
}
}
function IsSender(){
var UID=getUserID();
if(UID==0){
var qqq=getCookie("oASK%5F0", "QQQ");
if(!qqq)return false;
qqq=","+qqq+",";
return (qqq.indexOf(","+qid+",")!=-1);
}else{
return (UID==senderid);
}
}
function IsReplyer(rid,replyerid){
var UID=getUserID();
if(UID==0){
var rrr=getCookie("oASK%5F0", "RRR");
if(!rrr)return false;
rrr=","+rrr+",";
return (rrr.indexOf(","+rid+",")!=-1);
}else{
return (UID==replyerid);
}
}
function check_loginform(f){
if(f.name.value==""||f.name.value.length<=0){alert("请输入用户名");f.name.focus();return false;}
if(f.pwd.value==""||f.pwd.value.length<=0){alert("请输入密码");f.pwd.focus();return false;}
if(f.vcode){if(f.vcode.value==""||f.vcode.value.length<=0){alert("请输入验证码");f.vcode.focus();return false;}}
}
function ShowLogin_New(msg,js){
var surl=weburl+"login.asp";
if(js)surl=surl+"?js="+js;
if(msg){msg="用户登陆 ("+msg+")";}else{msg="用户登陆"}
openWindow(surl,400,180,msg);
}
function ShowLogin(msg,js){
lastUID="ready";
if(msg){msg="用户登陆 -- "+msg;}else{msg="用户登陆"}
var surl="?TB_login=true&TB_vcode=1&height=130&width=320";
if(js)surl=surl+"&js="+js;
TB_show(msg,surl,false);
}
function openWindow(_sUrl,_sWidth,_sHeight,_sTitle){
if(!_sUrl)return false;
if(!_sTitle)_sTitle="oASK系统提示";
if(_sUrl.indexOf("?")>-1) {_sUrl=_sUrl+"&TB_iframe=true&height="+_sHeight+"&width="+_sWidth}else{_sUrl=_sUrl+"?TB_iframe=true&height="+_sHeight+"&width="+_sWidth}
try{window.top.TB_show(_sTitle,_sUrl,false);}catch(e){TB_show(_sTitle,_sUrl,false);}
return false;
}
function openWindow_Self(_sUrl,_sWidth,_sHeight,_sTitle){
if(!_sUrl)return false;
if(!_sTitle)_sTitle="oASK系统提示";
if(_sUrl.indexOf("?")>-1) {_sUrl=_sUrl+"&TB_iframe=true&height="+_sHeight+"&width="+_sWidth}else{_sUrl=_sUrl+"?TB_iframe=true&height="+_sHeight+"&width="+_sWidth}
TB_show(_sTitle,_sUrl,false);
}
function dlg(_sText,_sWidth,_sHeight,_sTitle){
if(!_sText)return false;
if(!_sTitle)_sTitle="oASK系统提示";
var surl="#TB_message?height="+_sHeight+"&width="+_sWidth+"&msgtext="+escape(_sText);
try{window.top.TB_show(_sTitle,surl,false);}catch(e){TB_show(_sTitle,surl,false);}
}
function closeWindow(){
try{
$.dialog.hide();
}catch(e){
try{
window.parent.G("dialogBoxClose").click();
}catch(e){
try{
window.top.G("dialogBoxClose").click();
}catch(e){}
}
}
}
function openWindow2(_sUrl,_sWidth,_sHeight,_sTitle){
openWindow(_sUrl,_sWidth,_sHeight,_sTitle);
return false;
}
function openScript(url,width,height){
window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );
}
function openScript2(url,width,height){
window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=no,menubar=no,status=no' );
}
function ReadSMS(id){
openWindow2(weburl+"sms.asp?act=read&smsid="+id, 610, 450, "站内短信");
}
function EditSMS(id){
openWindow2(weburl+"sms.asp?act=edit&smsid="+id, 610, 450, "站内短信");
}
function NewSMS(to,aTitle,aContent,ByAdmin){
if(IsLogined()==false && !ByAdmin){alert("登录后才能使用站内短信功能");return false;}
var u=weburl+"sms.asp?act=new";
if(to)u=u+"&touser="+to;
if(aTitle)u=u+"&title="+aTitle;
if(ByAdmin==1)u=u+"&byadmin=1";
if(aContent){
var re=/\n/g;
aContent=aContent.replace(re,"<br>");
u=u+"&content="+aContent;
}
openWindow2(u,610,500,"站内短信");
}
function ShowPerson(id){
if(GuestShowPerson==0 && getUserID()==0){
ShowLogin("登录后您才能查看别人的资料!");
}else{
openScript(weburl+"showperson.asp?id="+id+"", 600, 400, "用户信息中心");
}
}
function ShowPerson2(name){
if(!name)return false;
if(GuestShowPerson==0 && getUserID()==0){
ShowLogin("登录后您才能查看别人的资料!");
}else{
openScript(weburl+"showperson.asp?name="+name+"", 600, 400, "用户信息中心");
}
}
function ShowIP(IP){
openWindow(weburl+"ip.asp?ip="+IP, 400,200, "用户最后登陆的IP地址");
}
function ShowDealBtn(divid,replyerid){
if (IsSender()==true && jie==0 && replyerid!=senderid) {
show_hidden(divid,1);
}else{
show_hidden(divid,0);
}
return;
}
function ClickDeal(obj,qid,rid){
if(IsSender()==false){
ShowLogin("您尚未登录，或者此问题不是您提问的!");
}else{
if(confirm('确实要把这个回复选择为最佳答案吗? ')){
location.href=weburl+"modify.asp?act=deal&qid="+qid+"&rid="+rid;
return true;
}else{return false;}
}
}
function ShowAnswerBtn(){
if (IsSender()==true || jie==1) {
show_hidden("AnswerBtn",0);
}else{
show_hidden("AnswerBtn",1);
}
return;
}
function ShowModifyReBtn(divid,replyerid){
if (IsReplyer(rid,replyerid)==false || jie!=0) {
show_hidden(divid,0);
}else{
show_hidden(divid,1);
}
return;
}
var lastUID="ready";
function getUserID(){
if(lastUID=="ready") lastUID=getCookie("oASK", "UID");
if(!uidTimer)setInterval(function(){lastUID="ready";},5000);
if(!lastUID)lastUID=0;
return lastUID;
}
var loginTimer=null;
function ShowLoginDiv(divid,ReRunInTimer){
var UID=getUserID();
if (UID>0) {
show_hidden(divid,0);
clearTimeout(loginTimer);
if(ReRunInTimer){
var UserBar=$("#UserBar");
if(UserBar) UserBar.html("");
}
}else{
show_hidden(divid,1);
clearTimeout(loginTimer);
loginTimer=setTimeout(function(){ShowLoginDiv(divid,1);},3000);
}
return;
}
function show_hidden_new(idname,v)
{
var oObj=G(idname);
if (!oObj){return false;}
if(v==0) {
oObj.style.display="none";
return true;
}else{
oObj.style.display="";
return true;
}
return false;
}
function show_hidden(idname,v){
var oObj=$("#"+idname);
if(!oObj)return false;
if(v)oObj.css({display:""});else oObj.css({display:"none"});
return true;
}
function RefreshParent() {
if (window.top.dialogBoxClose) window.top.dialogBoxClose.click();
window.top.location=window.top.location;
}
function IsNumeric(s)
{
if(s=="")return false;
var r,re;
re=/\d*/i;
r=s.match(re);
return (r==s)?true:false;
}
function regInput(obj,reg,inputStr)
{
var docSel=document.selection.createRange();
if(docSel.parentElement().tagName !="INPUT") return false;
oSel=docSel.duplicate();
oSel.text="";
var srcRange=obj.createTextRange();
oSel.setEndPoint("StartToStart", srcRange);
var str=oSel.text+inputStr+srcRange.text.substr(oSel.text.length);
return reg.test(str);
}
function ShowErr(msg,act,aurl){
var re=/\n/g;
document.write("<center>"+msg.replace(re,"<br>")+"</center>");
if(act=="close"){
try{window.parent.dialogBoxClose.click();}catch(e){}
if(msg.length>0)alert(msg);
}else if(act=="refresh"){
try{window.parent.dialogBoxClose.click();}catch(e){}
top.location.reload();
}else if(act=="back"){
if(msg.length>0)alert(msg);
history.back();
}else if(act=="goto" && aurl.length>0){
if(msg.length>0)alert(msg);
window.top.location=aurl;
}else{
if(msg.length>0)alert(msg);
}
}
function enableReplyButton(){
try{top.document.hd.ok.disabled=false;}catch(e){}
}
function check_replyform(aform,MaxReplyLengh){
var uid=getUserID();
if(uid==0){
if(WhoCanAnswer==0){
var b=confirm("您还没有登陆，\n如果匿名回答，您将不能获得任何积分奖励，\n建议您先去注册一下。\n\n继续使用游客身份匿名回答吗？");
if(b==false){return false;}
}else{
ShowLogin("请登录后再回答","4");
return false;
}
}else if(WhoCanAnswer==2){
if(MasterC=="" || MasterC.indexOf(","+cid+",")==-1){
alert("只有专家用户才能回答本分类的问题！");
return false;
}
}
if(!MaxReplyLengh) MaxReplyLengh=4000;
if(aform==window){
aform=G("hd");
if(!aform)aform=G("replyForm");
}
var co=aform.co.value;
if(co)co=StripHtml(co);
if(!co){
alert("回答内容不能为空！");
return false;
}else if(co.length>MaxReplyLengh){
alert("回答内容的长度不能超过"+MaxReplyLengh+"个字");
return false;
}else{
if(EnableAntiSpam==1){
PrepareAntiSpam(aform,"RE");
if( NeedVCode(aform,"reply") ) return false;
}
try{aform.ok.disabled=true;}catch(e){}
showLoading(G('ok'),1);
return true;
}
}
function check_plform(aform){
var uid=getUserID();
if(uid==0 && EnableGuestPing==0){
ShowLogin('登录后您才能做出评价!','2');
return false;
}else if(!aform.ping.value){
alert('请输入评论内容');
return false;
}if(aform.ping.value.length>200){
alert('输入的评论内容请限制在200个文字以内!');
return false;
}else{
if(EnableAntiSpam==1) PrepareAntiSpam(aform,"PL");
showLoading(G('pl_submit'),1);
return true;
}
}
function getPxOf(obj,cssName){
try{
var css=$(obj).css(cssName);
if(!css) return 0;
css=trim(css.toLowerCase());
if(css.indexOf("px")==-1)return 0;
css=css.substring(0,css.length-2);
if(IsNumeric(css)) return new Number(css).valueOf();else return 0;
}catch(e){
return 0;
}
}
function getOffsetTop(obj){
return obj.offsetTop;//+getPxOf(obj,"marginTop") + getPxOf(obj,"borderTopWidth");
}
function getOffsetLeft(obj){
return obj.offsetLeft;//+getPxOf(obj,"marginLeft") + getPxOf(obj,"borderLeftWidth");
}
function showLoading(obj,visible){
if(visible){
var t=0,l=0,w=0,h=0;
try{
var offset=$(obj).offset();
t=offset.top;
l=offset.left;
w=$(obj).outerWidth();
h=$(obj).outerHeight();
if(!(t && l && w && h)){
t=0;
l=0;
}
}catch(e){}
if(!t || !l){
t=getOffsetTop(obj);
l=getOffsetLeft(obj);
w=obj.clientWidth;
h=obj.clientHeight;
while(obj=obj.offsetParent)
{
t+=getOffsetTop(obj);
l+=getOffsetLeft(obj);
}
}
var w2=$("#loadingSmall").width();
var h2=$("#loadingSmall").height();
$("#loadingSmall").css({top:(t+(h-h2)/2)+"px", left:(l+(w-w2)/2)+"px", display:"block"});
}else{
$("#loadingSmall").css({display:"none"});
if(document!=top.document) top.showLoading(null,0);
}
}
function ShowIMG(imgsrc,maxw,maxh){
try{
var img=new Image;
img.src=imgsrc;
var w=img.width;
var h=img.height;
img=null;
var r=parseInt(w)/parseInt(h);
if(!maxw)maxw=500;
if(!maxh)maxh=800;
if(w>maxw){w=maxw;h=maxw/r;}
if(h>maxh){h=maxh;w=maxh*r;}
if(w<1)w=100;if(h<1)h=100;
document.write("<a href='"+imgsrc+"' target='_blank'><img width="+w+" height="+h+" src='"+imgsrc+"' /></a>");
}catch(e){document.write("<a href='"+imgsrc+"' target='_blank'><img src='"+imgsrc+"' /></a>");}
}
function resizeme(aimg,maxw,maxh){
try{
var img=new Image();
img.src=aimg.src;
img.resized=true;
var w=img.width;
var h=img.height;
img=null;
var r=parseInt(w)/parseInt(h);
if(!maxw)maxw=500;
if(!maxh)maxh=800;
if(w>maxw){w=maxw;h=maxw/r;}
if(h>maxh){h=maxh;w=maxh*r;}
if(w<1)w=100;
if(h<1)h=100;
$(aimg).css({width:w});
$(aimg).css({height:h});
}catch(e){}
}
function trim(s){return s.replace(/(^\s*)|(\s*$)/g,"");}
function showit(id){$("#"+id).css({display:"block"});}
function hideit(id){$("#"+id).css({display:"none"});}
function hideifblank(id){var s=$("#"+id).text();if(!s || trim(s)==""){hideit(id);}}
function ShowEmot(p){
var o=G("emot");
if(!o)return;
var Emots='01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|';
Emots=Emots.split("|");
var ps=12;
var pc;
var ec=Emots.length-1;
if(ec%ps==0)pc=(ec)/ps;else pc=Math.floor((ec)/ps)+1;
p=parseInt(p);
if(p<1)p=1;
if(p>pc)p=pc;
var istr;
var s='&nbsp;';
var ep=weburl+'img/emot/em';
if(p!=1 && pc>1){s+='<img style="cursor: pointer;" onClick="ShowEmot('+(p-1)+');" src="'+weburl+'img/'+'Previous.gif" width="14" height="14" title="上一页">&nbsp;';}
for(i=(p-1)*ps;i<(p-1)*ps+ps;i++){
if(i==ec)break;
if(i<9)istr='em0'+(i+1); else istr='em'+(i+1);
s+='<img title="'+istr+'" style="cursor: pointer;" onClick=putEmot("'+istr+'"); src="'+ep+Emots[i]+'.gif">&nbsp;';
}
if(p!=pc){s+='<img style="cursor: pointer;" onClick="ShowEmot('+(p+1)+');" src="'+weburl+'img/'+'Next.gif" width="14" height="14" title="下一页">&nbsp;';}
s+='分页：<b>'+p+'</b>/<b>'+pc+'</b>，共<b>'+(ec)+'</b>个';
s+="<select id=emotpage onchange=\"ShowEmot(this.value);\">";
for(i=1;i<=pc;i++) s+="<option value=\""+i+"\">"+i;
s+="<\/select>";
o.innerHTML=s;
G('emotpage').options[p-1].selected=true;
}
function putEmot(thenNo)
{
var ToAdd='['+thenNo+']';
var co=G("co_emot");
try{if(!co)co=hd.co;}catch(e){}
if(co) co.value=co.value+ToAdd;
}
function reset_vcd(){try{var obj=G("oask_vcdimg");obj.src=obj.src;}catch(e){}}
function SearchBar(key,searchword){
document.write("<form action='search.asp' method='get'>");
document.write("<input type='hidden' name='spage' value='2' />");
document.write("<input type='hidden' name='isword' value='0' />");
document.write("<img src='img\/search.gif' width='85' height='32' border='0' align='middle'\/>");
document.write("<input type='text' value='" +key+ "' maxlength='100' size='40' name='q' id='otherQjs' style='padding:0;height:24px;line-height:24px;' \/> ");
document.write("<input name='submit' type='submit' class='btn4' onClick=\"if(this.form.q.value)this.form.action='search.asp'; else{alert('请输入要搜索的内容');return false;}\" value='搜索答案'\/>&nbsp;");
document.write("<input type='button' class='btn4' onClick=\"if(this.form.q.value)top.location='ask.asp?q='+this.form.q.value;else{alert('请输入要提问的标题');return false;}\" value='我要提问'\/>&nbsp;");
if(searchword){
document.write("<input type='submit' class='btn4' onClick=\"if(this.form.q.value)this.form.isword.value=1;else{alert('请输入要搜索的内容');return false;}\" value='搜索词条'\/>&nbsp;");
document.write("<input type='button' class='btn4' onClick=\"if(this.form.q.value)top.location='wordadd.asp?wordname='+this.form.q.value;else{alert('请先输入词条名称');return false;}\" value='添加词条'\/>&nbsp;");
}
document.write("<\/form>");
}
function SearchBar_google(keyword){
document.write("<form method='get' action='http://www.google.cn/custom' target='_top'><table><tr><td nowrap='nowrap' valign='middle' align='left' height='32'><img src='"+weburl+"img/search.gif' border='0' align='middle'></img><input type='text' name='q' size='25' maxlength='255' value='"+keyword+"' id='sbi'></input> ");
document.write("<input onClick=\"this.form.action='http://www.google.cn/custom';\" type='submit' class='btn' name='sa' value='Google搜索' id='sbb'></input> ");
document.write("<input onClick=\"this.form.action='"+weburl+"search.asp';\" type='Submit' class='btn' value='问答搜索'></input> ");
document.write("<input onClick=\"this.form.action='"+weburl+"ask.asp';\" type='Submit' class='btn' value='我要提问'></input> ");
document.write("<input type='hidden' name='Keyword' /><Input type='hidden' name='ModuleName' value='Article'><input type='hidden' name='client' value='pub-8006215866575392'></input><input type='hidden' name='forid' value='1'></input><input type='hidden' name='channel' value='6976134779'></input><input type='hidden' name='ie' value='GB2312'></input><input type='hidden' name='oe' value='GB2312'></input><input type='hidden' name='cof' value='GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1'></input><input type='hidden' name='hl' value='zh-CN'></input></td></tr></table></form>");
}
function AskTools(){
if(jie!=0 && jie!=4) return false;
var s="";
if(IsSender()){
s="<div id='AskTools' class='btnDIV'><span><a class='buttona' href='#' onClick=\"return openWindow('"+weburl+"modify.asp?act=bu&qid="+qid+"',500,250,'问题补充')\" title='可以对您的提问补充细节，以得到更准确的答案'><span>问题补充</span></a></span><span><a class='buttona' href='#' onClick=\"return openWindow('"+weburl+"modify.asp?act=tg&qid="+qid+"',400,160,'提高悬赏')\" title='提高悬赏分，以提高问题的关注度'><span>提高悬赏</span></a></span><span><a class='buttona' href='#' onClick=\"return openWindow('"+weburl+"modify.asp?act=wu&qid="+qid+"',440,140,'无满意答案')\" title='没有满意的回答，还可直接结束提问，关闭问题'><span>无满意答案</span></a></span>";
}
else if(CanShowReply()){
s="<div class='btnDIV'><a class='buttona' href='#ireply'><span>我来回答</span></a>"
}
document.write(s+"</div><div class='clear'></div>");
}
function AdminTools(cid){
try{
if(!cid)return;
if(IsLogined()==false)return;
if(!MasterC)return;
if(MasterC.indexOf(","+cid+",")>-1){
document.write("<div id='AdminTools' class='btnDIV'><a class='buttona' href='#' onClick=\"this.href='"+weburl+"answerit.asp?qid="+qid+"'\"><span>管理此问题</span></a></div>");
}
}catch(e){}
}
function CheckSenderTools(){
if(jie!=0 && jie!=4) return false;
var uid=getUserID();
if(IsSender()){
var AskTools=G("AskTools");
if(AskTools) AskTools.style.display="";
}
else if(CanShowReply()){
var IWillReply=G("IWillReply");
if(IWillReply) IWillReply.style.display="";
}
try{
if(!cid || uid==0 || !MasterC) return;
if(MasterC.indexOf(","+cid+",")>-1){
var AdminTools=G("AdminTools");
if(AdminTools) AdminTools.style.display="";
}
}catch(e){}
}
function DealTools(rid,ruid){
if( (jie==0 || jie==4) && getUserID()!=ruid && IsSender() ){
document.write("<span class='btnDIV'><a href='#' class='buttona' id='deal' onClick='return ClickDeal(this,"+qid+","+rid+")'><span>采纳</span></a></span>");
}
}
function AnswerTools(rid,ruid){
if ( jie==0 && IsReplyer(rid,ruid) ){
var s;
s="<div id='AnswerTools' class='btnDIV'>";
s=s+"<a class='buttona' href='#' onClick=\"return openWindow('"+weburl+"modify.asp?act=mr&qid="+qid+"&rid="+rid+"', '500', '300', '修改答复')\"><span>修改答复</span></a>&nbsp;";
s=s+"</div>";
document.write(s);
}
}
function CanShowReply(){
if(jie!=0 && jie!=4) return false;
var uid=getUserID();
if(WhoCanAnswer==2){
if(uid==0 || MasterC=="" || MasterC.indexOf(","+cid+",")==-1) return false;
}else if(WhoCanAnswer==1){
if(uid==0) return false;
}else if(WhoCanAnswer==0 && SenderCanReply==0 && uid==0){
var qqq=getCookie("oASK%5F0", "QQQ");
if(qqq && qqq.indexOf(","+qid+",")>-1) return false;
}
if(SenderCanReply==0 && IsSender()==true) return false;
if(ReplyOnce==1){
if(uid>0 && rus.indexOf(","+uid+",")>-1) return false;
if(uid==0 && rus.indexOf(",0,")>-1) try{
var rrr=getCookie("oASK%5F0", "RRR");
if(!rrr) return false;
var arr_r=rrr.split(",");
var id_r="";
while(id_r!=undefined){
id_r=arr_r.pop();
if( id_r && ridlist.indexOf(","+id_r+",")>-1 ){
return false;
}
}
}
catch(e){}
}
return true;
}
function ShowIReplyDiv(){
if(CanShowReply()){
show_hidden("ireply", 1);
}else{
show_hidden("ireply", 0);
}
}
function Ping(atype,rid){
if(EnableGuestPing==0 && getUserID()==0){
ShowLogin("登录后您才能做出评价!");
}else{
var s;
if(atype==1){s='做出好评';}else{s='做出坏评';}
openWindow(weburl+"modify.asp?act=pj&type="+atype+"&qid="+qid+"&rid="+rid, '400', '150', s);
}
}
function AddPinglun(divid,ping,isSender){
try{
if(ping){
var re=/\n/g;
ping.replace(re,"<br>");
if(isSender==1){
$("#pinglun").html("<hr size='1'>提问人的评论："+ping);
return;
}else{
top.location=weburl+'result.asp?act=pl&cid=' + cid + '&qid=' + qid;
}
}
if(!isSender){
var n=$("#"+divid).text().valueOf();
n++;
$("#"+divid).text(n.toString());
}
}catch(e){}
}
function Show_Nav(id,aCount,num){
for(var i=1;i<=aCount;i++){
if(num==i){
G("Nav_"+id+"_"+i).className="active";
G("NavContent_"+id+"_"+i).style.display="";
}else{
G("Nav_"+id+"_"+i).className="nav"+id+"_unsel";
G("NavContent_"+id+"_"+i).style.display="none";
}
}
}
function Show_Nav2(id,aCount,num){
for(var i=1;i<=aCount;i++){
if(num==i){
G("Nav_"+id+"_"+i).className="active";
G("NavContent_"+id+"_"+i).style.display="";
}else{
G("Nav_"+id+"_"+i).className="";
G("NavContent_"+id+"_"+i).style.display="none";
}
}
}
function cutText(jsonText) {
if (typeof(document.getElementsByTagName('body')[0].style.textOverflow)!='undefined' && typeof(window.opera)!='undefined') { return; }
var sName,iWidth;
for (sName in jsonText) {
if(!sName) return;
iWidth=jsonText[sName];
var elems=document.getElementsByName(sName);
for (var i=elems.length-1;i>=0;i--) {
if (elems[i].scrollWidth>iWidth) elems[i].innerHTML+="…"; else return;
while (elems[i].scrollWidth>iWidth) {
elems[i].innerHTML=elems[i].innerHTML.substr(0,elems[i].innerHTML.length-2)+"…";
if(elems[i].innerHTML=="…") return;
}
}
}
}
function cutText2(jsonText) {
var sName,iLen;
for (sName in jsonText) {
if(!sName) return;
iLen=jsonText[sName];
var elems=document.getElementsByName(sName);
for (var i=elems.length-1;i>=0;i--) {
if(elems[i].innerHTML.length<=iLen) return;
elems[i].innerHTML=elems[i].innerHTML.substr(0,iLen-3)+"…";
}
}
}
function cutWrap(linePath,childTarget){
var item;
var lineHeight=0;
var html="";
var valueBak=""
$(linePath).each(function(){
if($(this).attr("cut")=="line"){
item=$(this).children(childTarget);
if(item.length==1){
html=item.html();
item.html("…");
lineHeight=$(this).attr("scrollHeight");
item.html(html);
if (lineHeight && $(this).attr("scrollHeight")>lineHeight){
if(!item.attr("title")) item.attr("title",item.text());
html+="…";
while ($(this).attr("scrollHeight")>lineHeight) {
html=html.substr(0,html.length-2)+"…"
item.html(html);
if(!html || html=="…") break;
}
}
}
}
});
}
function cutByPx(linePath,childTarget,pxWidth){
var item;
var html;
$(linePath).each(function(){
if ($(this).attr("scrollWidth")>pxWidth){
item=$(this).children(childTarget);
if(item.length==1){
if(!item.attr("title")) item.attr("title",item.text());
html=item.html()+"…";
while ($(this).attr("scrollWidth")>pxWidth) {
item.html(html.substr(0,html.length-2)+"…");
if(!html || html=="…") break;
}
}
}
});
}
function cutByMaxPX(){
var html;
var maxPX;
$("*[maxPX]").each(function(){
html=$(this).html();
maxPX=$(this).attr("maxPX");
if ($(this).attr("scrollWidth") > maxPX) {
if(!$(this).attr("title")) $(this).attr("title",$(this).text());
html+="…";
while ($(this).attr("scrollWidth")>maxPX) {
html=html.substr(0,html.length-2)+"…"
$(this).html(html);
if(!html || html=="…") break;
}
}
});
}
function cutByMaxChar(){
var html;
var maxchar;
var iChars;
$("*[maxchar]").each(function(){
html=$(this).html();
maxchar=$(this).attr("maxchar");
if (html.length > maxchar/2) {
iChars=0;
for(var i=0;i < html.length;i++){
if(html.charCodeAt(i)>255) iChars+=2;else iChars++;
if(iChars>=maxchar){
$(this).html(html.substr(0,i+1)+"…");
break;
}
}
}
});
}
function WriteClouds(aDivID,aMinValue,aMaxValue,aCloudsStyle){
var MinFontSize=12;
var MaxFontSize=24;
var clrs=new Array('#00C0FF','#20C0FF','#60C0FF','#60C0C0', '#40A0FF','#60A0FF', '#40C0C0','#60FFA0','#60C0C0', '#A0C080', '#C0C040','#A0C000','#80A060','#80A040','#80A000', '#A0A080','#A0A060','#A0A060', '#A0A020','#808040 ','#808000','#608040', '#608000','#406060','#406040', '#406000','#204020','#204000', '#404080','#404060','#802000','#C00000 ','#FF40A0','#FF0000');
var iClrCount=clrs.length;
var CountRange=aMaxValue-aMinValue;
var FontSizeRange=MaxFontSize-MinFontSize;
var iFontSize,iClrIndex;
var iUseCount;
$("#"+aDivID+" > a").each(
function(i){
iUseCount=$(this).attr("rel").valueOf();
if(iUseCount<aMinValue) iUseCount=aMinValue;else if(iUseCount>aMaxValue) iUseCount=aMaxValue;
if(aCloudsStyle==1 || aCloudsStyle==3){
iFontSize=(iUseCount-aMinValue)*FontSizeRange/CountRange+MinFontSize;
$(this).css({fontSize:iFontSize+'px', height:(iFontSize+2)+'px', lineHeight:(iFontSize+2)+'px'});
}
if(aCloudsStyle==1 || aCloudsStyle==2){
var iClrIndex=(iUseCount-aMinValue)*(iClrCount-1)/CountRange;
iClrIndex=Math.round(iClrIndex,0);
if(iClrIndex<0) iClrIndex=0;else if(iClrIndex>=iClrCount) iClrIndex=iClrCount-1;
try{$(this).css({color:clrs[iClrIndex]});}catch(e){}
}
$(this).attr("title",iUseCount.toString());
}
);
}
function PrepareAntiSpam(frm,aType){
this.RemoveDebugInfo=function(aHtml){
var iPos=aHtml.indexOf("<div ");
if(iPos!=-1) aHtml=aHtml.substring(0,iPos);
return aHtml;
};
if(!aType)aType="";
if(!frm){alert("错误，未找到提交表单，请联系管理员！");return false;}
var UID=getUserID();
var html1=$.ajax({
type:"GET",
url:weburl+"js/ajaxServer.asp?lei=1&type=PRE&uid=" + UID,
async:false
}).responseText;
if(!html1) return;
var re=/[h-w]/g;
html1=RemoveDebugInfo(html1).replace(re,"");
var html2=$.ajax({
type:"POST",
url:weburl+"js/ajaxServer.asp?lei=1&type="+aType,
data:"inputsn="+html1+"&uid="+UID,
async:false
}).responseText;
$("#inputsn").remove();
html2="<input type='hidden' name='inputsn' id='inputsn' value='" +RemoveDebugInfo(html2)+ "'>";
$(frm).append(html2);
}
var CanDirectlySubmit=0;
var frmToBeSubmited=null;
var currentVCode="";
function NeedVCode(frm,aType){
var Obj_content,Obj_inputsn;
if(aType=="ask" || aType=="reply" || aType=="pl"){
Obj_content=$(frm.content || frm.co);
Obj_inputsn=$(frm.inputsn);
}else{
return false;
}
var s=Obj_content.val()+Obj_inputsn.val();
s=s.replace(/[\n\r]/g,"");
var NumArr=[0,0,0,0];
for(var i=0;i<s.length;i++){
var j=i%4;
NumArr[j]=(NumArr[j]+s.charCodeAt(i)) % 10;
}
currentVCode=NumArr.join("");
frmToBeSubmited=frm;
ShowVCode();
return true;
}
function VCodeOK(){
if(!frmToBeSubmited) return false;
var sCode=$("#confirm_vcode").val();
if(sCode && IsNumeric(sCode)){
$.dialog.hide(true);
$("#vcode").remove();
var sHtml="<input type='hidden' name='vcode' id='vcode' value='" + sCode + "'>";
$(frmToBeSubmited).append(sHtml);
$(frmToBeSubmited).submit();
}
}
function ShowVCode(){
var sHTML="<div onselectstart='return false;' style='margin:0px; border:none; padding:10px;'>";
sHTML+="<center>请输入验证码：<input type='text' size='5' maxlength='4' id='confirm_vcode' style='height:18px; line-height:18px;'> <span style='display:inline-block; width:35px; height:18px; line-height:18px; border:1px solid #cccccc; background-color:#eeeeee; font-weight:bold;'>" +currentVCode+ "</span><br><br><input type='button' value='确 定' onclick='VCodeOK();'>&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' value='取 消' onclick='$.dialog.hide();'></center>"
sHTML+="</div>";
dlg(sHTML,200,80,"系统提示");
$.dialog.setFocus("confirm_vcode");
$("#confirm_vcode").keydown(function(e){
if(e.keyCode==13){VCodeOK();}
});
}
function ShowQTopAd(jsUrl){
var html1=$.ajax({
type:"GET",
url:jsUrl,
async:false
}).responseText;
if(!html1) return;
$("#QTopAdPos").remove();
document.write(html1);
}
function StripHtml(html) {
html=html || "";
var scriptregex="<scr" + "ipt[^>.]*>[sS]*?</sc" + "ript>";
var scripts=new RegExp(scriptregex,"gim");
html=html.replace(scripts," ");
var styleregex="<style[^>.]*>[sS]*?</style>";
var styles=new RegExp(styleregex,"gim");
html=html.replace(styles," ");
var objRegExp=new RegExp("<(.| )+?>", "gim");
html=html.replace(objRegExp," ");
html=html.replace(/</,"&lt;");
html=html.replace(/>/,"&gt;");
objRegExp=null;
return trim(html);
}
function changeHDM(group,count,index){
for(var i=1;i<=count;i++){
try{
if(i==index){
G("hdm-btn-"+group+"-"+i).className="active hdm-sel";
G("hdm-"+group+"-"+i).style.display="";
}else{
G("hdm-btn-"+group+"-"+i).className="hdm-unsel";
G("hdm-"+group+"-"+i).style.display="none";
}
}catch(e){}
}
}
function changeHDM2(group,count,index){
for(var i=1;i<=count;i++){
try{
if(i==index){
G("hdm2-btn-"+group+"-"+i).className="active";
G("hdm2-"+group+"-"+i).style.display="";
}else{
G("hdm2-btn-"+group+"-"+i).className="";
G("hdm2-"+group+"-"+i).style.display="none";
}
}catch(e){}
}
}
var rollspeed=50;
function MarqueeV(ooRollV,ooRollV1,ooRollV2){
if(ooRollV2.offsetTop-ooRollV.scrollTop<=0) {
ooRollV.scrollTop-=ooRollV1.offsetHeight;
}else{
ooRollV.scrollTop++;
}
}
function StartRollV(divMain,div1,div2) {
var myInter;
var ooRollV=G(divMain);
var ooRollV1=G(div1);
var ooRollV2=G(div2);
if (ooRollV && ooRollV1 && ooRollV2) {
if (parseInt(ooRollV.style.height)>=ooRollV2.offsetTop) {
ooRollV.style.height=ooRollV2.offsetTop;
return;
}
ooRollV2.innerHTML=ooRollV1.innerHTML;
myInter=setInterval(function(){MarqueeV(ooRollV,ooRollV1,ooRollV2);},rollspeed);
ooRollV.onmouseover=function(){clearInterval(myInter)};
ooRollV.onmouseout=function(){myInter=setInterval(function(){MarqueeV(ooRollV,ooRollV1,ooRollV2);},rollspeed)};
}
}
function MarqueeH(ooRollH,ooRollH1,ooRollH2){
if(ooRollH2.offsetLeft-ooRollH.scrollLeft<=0) {
ooRollH.scrollLeft-=ooRollH1.offsetWidth;
}else{
ooRollH.scrollLeft++;
}
}
function StartRollH(divMain,div1,div2) {
var myInter;
var ooRollH=G(divMain);
var ooRollH1=G(div1);
var ooRollH2=G(div2);
if (ooRollH && ooRollH1 && ooRollH2) {
if (parseInt(ooRollH.style.width)>=ooRollH2.offsetLeft) {
oRollH.style.width=oRollH2.offsetLeft;
return;
}
ooRollH2.innerHTML=ooRollH1.innerHTML;
myInter=setInterval(function(){MarqueeH(ooRollH,ooRollH1,ooRollH2);},rollspeed);
ooRollH.onmouseover=function(){clearInterval(myInter)};
ooRollH.onmouseout=function(){myInter=setInterval(function(){MarqueeH(ooRollH,ooRollH1,ooRollH2);},rollspeed)};
}
}
function reloadRelatedQ(cid,keys,qid){
var js_q=$("#js_q[qCount]");
if(js_q.length<=0)return;
var lastDate=js_q.attr("lastDate");
if(lastDate && lastDate==new Date().getDate())return;
js_q.load(weburl+"js/RelatedQ.asp?lei="+js_q.attr("lei")+"&QCount="+js_q.attr("qCount")+"&qurl="+escape(document.location)+"&cid="+cid+"&keys="+escape(keys)+"&qid="+qid, function(){cutWrap("#js_q *[cut='line']", "*[cut]");});
}
function showLeftTime(jie,sendTime,overTime){
var s1=sendTime.replace(/-/g,"/");
var s2=overTime.replace(/-/g,"/");
var t1=new Date(s1);
var t2=new Date(s2);
var tnow=new Date();
if(jie!=0 || isNaN(t1) || isNaN(t2) || tnow>t2){
document.write("提问时间："+sendTime);
if(tnow>t2) document.write("(已过期)");
if(jie==4) document.write("&nbsp;<a href='" +weburl+ "help.asp#问题为何被关闭' target='_blank'>问题为何被关闭</a>");
}else{
var ns=(t2.getTime()-tnow.getTime())/(60000);
var d,h,n,s;
d=parseInt(ns/1440);
ns=ns-d*1440;
h=parseInt(ns/60);
ns=ns-h*60;
n=parseInt(ns);
if(d>0){
s=d+"天"+h+"小时";
}else if(h>0){
s=h+"小时"+n+"分钟";
}else{
s=n+"分钟";
}
document.write("离问题结束还有" + s);
}
}
function showStars(x){
if(!x) return;
try{if(!IsNumeric(x)) return;}catch(e){}
var html="<span>"
for(var i=1;i<=x;i++) html+="<img src='" +weburl+ "img/star.gif' width='16' height='16' border='0'>&nbsp;";
html+="</span>";
document.write(html);
}
function AddRandParam(aHref){
if(!aHref) return "";
if(aHref.indexOf('#')!=-1) return aHref;
var sRand=Math.random().toString();
if(aHref.indexOf('?')==-1)
aHref=aHref+"?rnd="+sRand;
else
aHref=aHref+"&rnd="+sRand;
return aHref;
}
(function($){$.fn.corner=function(o) {
var ie6=$.browser.msie &&/MSIE 6.0/.test(navigator.userAgent);
function sz(el,p){return parseInt($.css(el,p))||0;};
function hex2(s) {
var s=parseInt(s).toString(16);
return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
for (;node && node.nodeName.toLowerCase() !='html'; node = node.parentNode ) {
var v=$.css(node,'backgroundColor');
if ( v.indexOf('rgb') >= 0 ) {
if ($.browser.safari && v=='rgba(0, 0, 0, 0)')
continue;
var rgb=v.match(/\d+/g);
return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
}
if ( v && v !='transparent' )
return v;
}
return '#ffffff';
};
function getW(i) {
switch(fx) {
case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width))));
case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width))));
case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width))));
case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
case 'slide': return Math.round(width*(Math.atan2(i,width/i)));
case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1))));
case 'curl': return Math.round(width*(Math.atan(i)));
case 'tear': return Math.round(width*(Math.cos(i)));
case 'wicked': return Math.round(width*(Math.tan(i)));
case 'long': return Math.round(width*(Math.sqrt(i)));
case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
case 'dog': return (i&1) ? (i+1) : width;
case 'dog2': return (i&2) ? (i+1) : width;
case 'dog3': return (i&3) ? (i+1) : width;
case 'fray': return (i%2)*width;
case 'notch': return width;
case 'bevel': return i+1;
}
};
o=(o||"").toLowerCase();
var keep=/keep/.test(o);
var cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);
var sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);
var width=parseInt((o.match(/(\d+)px/)||[])[1]) || 10;
var re=/round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
var fx=((o.match(re)||['round'])[0]);
var edges={T:0,B:1};
var opts={
TL:/top|tl/.test(o),TR:/top|tr/.test(o),
BL:/bottom|bl/.test(o),BR:/bottom|br/.test(o)
};
if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
opts={TL:1,TR:1,BL:1,BR:1};
var strip=document.createElement('div');
strip.style.overflow='hidden';
strip.style.height='1px';
strip.style.backgroundColor=sc || 'transparent';
strip.style.borderStyle='solid';
return this.each(function(index){
var pad={
T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0,
B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0
};
if ($.browser.msie) this.style.zoom=1;//force 'hasLayout' in IE
if (!keep) this.style.border='none';
strip.style.borderColor=cc || gpc(this.parentNode);
var cssHeight=$.curCSS(this,'height');
for (var j in edges) {
var bot=edges[j];
if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
strip.style.borderStyle='none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
var d=document.createElement('div');
$(d).addClass('jquery-corner');
var ds=d.style;
bot ? this.appendChild(d) : this.insertBefore(d,this.firstChild);
if (bot && cssHeight !='auto') {
if ($.css(this,'position') == 'static')
this.style.position='relative';
ds.position='absolute';
ds.bottom=ds.left=ds.padding=ds.margin='0';
if ($.browser.msie)
ds.setExpression('width', 'this.parentNode.offsetWidth');
else
ds.width='100%';
}
else if (!bot && $.browser.msie) {
if ($.css(this,'position') == 'static')
this.style.position='relative';
ds.position='absolute';
ds.top=ds.left=ds.right=ds.padding=ds.margin='0';
var bw=0;
if (ie6 || !$.boxModel)
bw=sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
ie6 ? ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"') : ds.width = '100%';
}
else {
ds.margin=!bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :
(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';
}
for (var i=0;i < width;i++) {
var w=Math.max(0,getW(i));
var e=strip.cloneNode(false);
e.style.borderWidth='0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
bot ? d.appendChild(e) : d.insertBefore(e,d.firstChild);
}
}
}
});
};
$.fn.uncorner=function(o){return $('.jquery-corner', this).remove(); };
})(jQuery);
$.fn.equalizeCols=function() {
var max_height=0;
$(this).each(function() {
var self=$(this);
var height=self.height()-self.find(".auto_fill").height();
max_height=Math.max(height,max_height);
});
$(this).each(function() {
var self=$(this);
var height=self.height()-self.find(".auto_fill").height();
if ((max_height-height)>0)
self.append($("").height(max_height - height));
});
}
