var ReplyOnce=0;
var SenderCanReply=1;
var OnlyZJCanReply=0;
var GuestShowPerson=1;
$(document).ready(function(){
inputfocus();
})
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;
}
}
}
return null;
}
var lastUID="ready";
function getUserID(){
if(lastUID=="ready") lastUID=getCookie("oASK", "UID");
return lastUID;
}
function IsLogined(){
if(getUserID()){return true;}else{return false;}
}
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="+escape(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=0&height=130&width=320";
if(js)surl=surl+"&js="+escape(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);}
}
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{
dialogBoxClose.click();
}catch(e){
try{
window.top.dialogBoxClose.click();
}catch(e){}
}
}
function openWindow2(_sUrl,_sWidth,_sHeight,_sTitle){
if(!getUserID()){
ShowLogin("登录后您才能执行此操作!");
}else{
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){
var u=weburl+"sms.asp?act=new";
if(to)u=u+"&touser="+to;
openWindow2(u,610,450,"站内短信");
}
function ShowPerson(id){
if(!GuestShowPerson&&!getUserID()){
ShowLogin("登录后您才能查看别人的资料!");
}else{
openScript(weburl+"showperson.asp?id="+id+"", 600, 400, "用户信息中心");
}
}
function ShowPerson2(name){
if(!name)return false;
if(!GuestShowPerson&&!getUserID()){
ShowLogin("登录后您才能查看别人的资料!");
}else{
openScript(weburl+"showperson.asp?name="+name+"", 600, 400, "用户信息中心");
}
}
function ShowIP(IP){
if(!getUserID()){
ShowLogin("登录后您才能查看别人的资料!");
}else{
openWindow(weburl+"ip.asp?ip="+IP, 400,200, "用户最后登陆的IP地址");
}
}
function ShowDealBtn(divid,replyerid){
var UID=getUserID();
if (jie==0&&UID==senderid && replyerid!=senderid) {
show_hidden(divid,1);
}else{
show_hidden(divid,0);
}
return;
}
function ClickDeal(obj,qid,rid){
if(!getUserID()){
ShowLogin("登录后您才能选择最佳答案!");
}else{
if(confirm('确实要把这个回复选择为最佳答案吗? ')){
location.href=weburl+"modify.asp?act=deal&qid="+qid+"&rid="+rid;
return true;
}else{return false;}
}
}
function ShowAnswerBtn(){
var UID=getUserID();
if (UID==senderid || jie==1) {
show_hidden("AnswerBtn",0);
}else{
show_hidden("AnswerBtn",1);
}
return;
}
function ShowModifyReBtn(divid,replyerid){
var UID=getUserID();
if (UID==replyerid && jie !=1) {
show_hidden(divid,1);
}else{
show_hidden(divid,0);
}
return;
}
function ShowLoginDiv(divid){
var UID=getUserID();
if (UID) {
show_hidden(divid,0);
}else{
show_hidden(divid,1);
}
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:"block"});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){
if(!getUserID()){
ShowLogin("请登录后再回答","top.document.hd.ok.click();");
return false;
}
if(!aform.co.value)
{alert("回答内容不能为空！"); return false; }
else if(aform.co.value.length>4000)
{alert("回答内容的长度不能超过4000字"); return false; }
else{
top.document.hd.ok.disabled=true;
show_hidden("da_loading", 1);
return true;
}
}
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 showit(id){$("#"+id).css({display:""});}
function hideit(id){$("#"+id).css({display:"none"});}
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
function hideifblank(id){var s=$("#"+id).text();if(!s || s.trim()=="")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("<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' \/>");
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='搜索答案'\/>");
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='我要提问'\/>");
if(searchword){
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='添加知识'\/>");
}
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(){
var s="<div id='AskTools'>";
var sReply="<a class='buttona' href='#ireply'>我来回答</a>";
var uid=getUserID();
if(uid==senderid){
s=s+"<a class='buttona' href='#' onClick=\"return openWindow2('"+weburl+"modify.asp?act=bu&qid="+qid+"',500,250,'问题补充')\" title='可以对您的提问补充细节，以得到更准确的答案'>问题补充</a>&nbsp;";
s=s+"<a class='buttona' href='#' onClick=\"return openWindow2('"+weburl+"modify.asp?act=tg&qid="+qid+"',500,180,'提高悬赏')\" title='提高悬赏分，以提高问题的关注度'>提高悬赏</a>&nbsp;";
s=s+"<a class='buttona' href='#' onClick=\"return openWindow2('"+weburl+"modify.asp?act=wu&qid="+qid+"',440,160,'无满意答案')\" title='没有满意的回答，还可直接结束提问，关闭问题'>无满意答案</a>";
}
if(!CanShowReply()) sReply="";
document.write(s+sReply+"</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'><a class='buttona' href='#' onClick=\"this.href='"+weburl+"answerit.asp?qid="+qid+"'\">管理此问题</a></div>");
}
}catch(e){}
}
function AnswerTools(rid,ruid){
if(getUserID()==ruid){
var s;
s="<div id='AnswerTools'>";
s=s+"<a class='buttona' href='#' onClick=\"return openWindow2('"+weburl+"modify.asp?act=mr&qid="+qid+"&rid="+rid+"', '500', '400', '修改答复')\">修改答复</a>&nbsp;";
s=s+"<a class='buttona' style='width:110px;' href='#' onClick=\"return openWindow2('"+weburl+"attach/up.asp?qid="+qid+"&rid="+rid+"','550','350','回答附件')\" title='上传附件文档、屏幕截图或演示动画，将会使您的解答更清晰易懂'>上传/更换附件</a>";
s=s+"</div>";
document.write(s);
}
}
function DealTools(rid,ruid){
var s;
if(getUserID()==senderid&&senderid!=ruid){
document.write("<a href='#' class='buttona' id='deal' onClick='return ClickDeal(this,"+qid+","+rid+")'>采纳</a>");
}
}
function CanShowReply(){
var uid=getUserID();
if( OnlyZJCanReply==1){
if(!uid || UserRights.indexOf(",5,")==-1) return false;
}
if(ReplyOnce==1 && uid && rus.indexOf(","+uid+",")>-1) return false;
if(SenderCanReply==0 && senderid==uid) return false;
if(jie==1) return false;
return true;
}
function ShowIReplyDiv(){
if(CanShowReply()){
show_hidden("ireply", 1);
}else{
show_hidden("ireply", 0);
}
}
function Ping(atype,rid){
if(!getUserID()){
ShowLogin("登录后您才能做出评价!");
}else{
var s;
if(atype==1){s='做出好评';}else{s='做出坏评';}
openWindow2(weburl+"modify.asp?act=pj&type="+atype+"&qid="+qid+"&rid="+rid, '400', '150', s);
}
}
function AddPinglun(divid,ping,isSender){
try{
if(ping){
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="nav"+id+"_sel";
G("NavContent_"+id+"_"+i).style.display="";
}else{
G("Nav_"+id+"_"+i).className="nav"+id+"_unsel";
G("NavContent_"+id+"_"+i).style.display="none";
}
}
}
function changeHDM(group,count,index){
for(var i=1;i<=count;i++){
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";
}
}
}
function changeHDM2(group,count,index){
for(var i=1;i<=count;i++){
if(i==index){
G("hdm2-btn-"+group+"-"+i).className="active";
G("hdm2-"+group+"-"+i).style.display="block";
}else{
G("hdm2-btn-"+group+"-"+i).className="";
G("hdm2-"+group+"-"+i).style.display="none";
}
}
}
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)};
}
}