//examine the browser 检测浏览器的函数
var useragent = navigator.useragent.tolowercase();
var is_opera = (useragent.indexof('opera') != -1);
var is_saf = ((useragent.indexof('applewebkit') != -1) || (navigator.vendor == 'apple computer, inc.'));
var is_webtv = (useragent.indexof('webtv') != -1);
var is_ie = ((useragent.indexof('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (useragent.indexof('msie 4.') != -1));
var is_moz = ((navigator.product == 'gecko') && (!is_saf));
var is_kon = (useragent.indexof('konqueror') != -1);
var is_ns = ((useragent.indexof('compatible') == -1) && (useragent.indexof('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseint(navigator.appversion) == 4));
var is_mac = (useragent.indexof('mac') != -1);
//global registers
var currentblogid;
var currentstarid;
var currentcommentid;
var switchcomandmes;
var securitycodejs=null;
var onetimecounter=1;
//get absolute path, fix bug of ie when base path is set
var gotourl = location.href;
var absbaseurl;
var abspath;
var r_identifier=gotourl.lastindexof(/read.php/);
var r_identifier2=gotourl.lastindexof(/post/);
var r_identifier3=gotourl.lastindexof(/tag/);
if (r_identifier==-1) {
r_identifier=r_identifier2;
}
if (r_identifier==-1) {
r_identifier=r_identifier3;
}
if (r_identifier!=-1) {
absbaseurl = gotourl.substr(0, r_identifier)+/;
var simplegotourl=absbaseurl.replace(http://, '');
r_identifier2=simplegotourl.indexof(/);
abspath=simplegotourl.substr(r_identifier2+1);
} else {
absbaseurl='';
abspath=null;
}
//is ajax supported?
if ((is_ie & !is_ie4) || is_moz || is_saf || is_opera) var shutajax=0;
else var shutajax=1;
//for firefox, tell firefox not to display the content you input in last session
if (is_moz) {
var tmp_c=document.getelementbyid('v_content');
if (tmp_c) tmp_c.value='';
}
//show/hide a p
function showhidep(id){
try{
var panel=document.getelementbyid(id);
if(panel){
if(panel.style.display=='none'){
panel.style.display='block';
}else{
panel.style.display='none';
}
}
}catch(e){}
}
function addhtml (id, htmlcode, uniqueid) {
var panel=document.getelementbyid(id);
var hiddenpannel=document.getelementbyid(uniqueid);
if(panel){
hiddenpannel.value='';
hiddenpannel.value=panel.innerhtml;
panel.innerhtml=hiddenpannel.value+htmlcode;
hiddenpannel.value+=htmlcode;
}
}
function showadminreply (pid) {
switchcomandmes='reply';
var cleanid=pid.replace('com_', '');
var inputcontent=<form action='"+absbaseurl+"admin.php?go=reply_addadminreply_"+cleanid+"' method='post' id='formadminreply"+cleanid+"'>;
inputcontent+=jslang[0]+<br/><textarea cols='66' rows='3' name='adminreplycontent' id='adminreplycontent"+cleanid+"'></textarea><br/>;
inputcontent+=<input type='button' onclick=\"ajax_adminreply('"+cleanid+"'); return false;\" value='"+jslang[1]+"' class='button'/> <input type='reset' value='"+jslang[2]+"' class='button'/> <input type='button' value='"+jslang[3]+"' onclick=\"hideadminreply('"+pid+"');\" class='button'/></form>;
document.getelementbyid(pid).innerhtml=inputcontent;
document.getelementbyid(pid).style.display='block';
}
function showadminreplyformessage (pid) {
switchcomandmes='message';
var cleanid=pid.replace('com_', '');
var inputcontent=<form action='"+absbaseurl+"admin.php?go=message_addadminreply_"+cleanid+"' method='post' id='formadminreply"+cleanid+"'>;
inputcontent+=jslang[0]+<br/><textarea cols='66' rows='3' name='adminreplycontent' id='adminreplycontent"+cleanid+"'></textarea><br/>;
inputcontent+=<input type='button' onclick=\"ajax_adminreply('"+cleanid+"'); return false;\" value='"+jslang[1]+"' class='button'/> <input type='reset' value='"+jslang[2]+"' class='button'/> <input type='button' value='"+jslang[3]+"' onclick=\"hideadminreply('"+pid+"');\" class='button'/></form>;
document.getelementbyid(pid).innerhtml=inputcontent;
document.getelementbyid(pid).style.display='block';
}
function hideadminreply (pid) {
document.getelementbyid(pid).innerhtml='';
document.getelementbyid(pid).style.display='none';
}
function showdelblog(blogid) {
var urldel=absbaseurl+admin.php?go=entry_deleteblog_+blogid+'';
if(confirm(jslang[4])){
window.location=urldel;
}
else {
return;
}
}
function comfirmurl(urldel) {
if(confirm(jslang[5])){
window.location=absbaseurl+urldel;
}
else {
return;
}
}
function showdeladminreply(repid) {
var urldel=absbaseurl+admin.php?go=reply_deladminreply_+repid+'';
if(confirm(jslang[6])){
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdeladminreply', 'get', null);
}
}
else {
return;
}
}
function showdeladminreplyformessage(repid) {
var urldel=absbaseurl+admin.php?go=message_deladminreply_+repid+'';
if(confirm(jslang[7])){
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdeladminreply', 'get', null);
}
}
else {
return;
}
}
function showdelreply(repid, blogid) {
var urldel=absbaseurl+admin.php?go=reply_delreply_+repid+'-'+blogid;
if(confirm(jslang[8])){
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdelreply', 'get', null);
}
}
else {
return;
}
}
function showdelreplyformessage(repid) {
var urldel=absbaseurl+admin.php?go=message_delreply_+repid;
if(confirm(jslang[9])){
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdelreply', 'get', null);
}
}
else {
return;
}
}
function showblockreply(repid, blogid) {
var urldel=absbaseurl+admin.php?go=reply_block_+repid+'-'+blogid;
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdelreply', 'get', null);
}
}
function showblockmessage(repid) {
var urldel=absbaseurl+admin.php?go=message_block_+repid;
if (shutajax==1) window.location=urldel;
else {
urldel+=&ajax=on;
currentcommentid=repid;
makerequest(urldel, 'quickdelreply', 'get', null);
}
}
/* -- ajax related functions -- */
//starring
function dostar(blogid) {
if (shutajax==0) {
gourl=absbaseurl+admin.php?go=star&ajax=on&blogid=+blogid;
currentblogid=blogid;
currentstarid=starid+blogid;
makerequest(gourl, 'starblog', 'get', null);
} else {
gourl=absbaseurl+admin.php?go=star&ajax=off&blogid=+blogid;
window.location=gourl;
}
}
//comment and message
function ajax_submit (job) {
var stat_html = document.getelementbyid('stat_html').checked ? 1 : 0;
var stat_ubb = document.getelementbyid('stat_ubb').checked ? 1 : 0;
var stat_emot = document.getelementbyid('stat_emot').checked ? 1 : 0;
var stat_property = document.getelementbyid('stat_property').checked ? 1 : 0;
var v_replier = document.getelementbyid('v_replier').value+' ';
var v_repurl = document.getelementbyid('v_repurl').value;
var v_repemail = document.getelementbyid('v_repemail').value;
var v_content = document.getelementbyid('v_content').value+' ';
var v_password = document.getelementbyid('v_password').value;
var v_id = document.getelementbyid('v_id').value;
var v_reppsw = (document.getelementbyid('v_reppsw')) ? document.getelementbyid('v_reppsw').value : '';
var v_security_plus;
if (document.getelementbyid('v_security')) {
var v_security = document.getelementbyid('v_security').value;
if (v_security=='') {
alert(jslang[10]);
return false;
}
v_security_plus=&v_security=+v_security;
} else {
v_security_plus='';
}
if (v_replier=='' || v_content==''|| v_replier==' ' || v_content==' ' ) {
alert(jslang[11]);
return false;
}
document.getelementbyid('btnsubmit').value=jslang[12];
document.getelementbyid('btnsubmit').disabled='disabled';
if (shutajax==0) { //currently for ie, safari, mozilla and opera
v_replier = blogencode(v_replier);
v_repurl = blogencode(v_repurl);
v_repemail = blogencode(v_repemail);
v_content = blogencode(v_content);
v_password = blogencode(v_password);
v_id = blogencode(v_id);
v_reppsw = blogencode(v_reppsw);
var postdata = unuse=unuse&onetimecounter=+onetimecounter+&v_id=+v_id+&v_replier=+v_replier+&v_password=+v_password+&v_repurl=+v_repurl+&v_repemail=+v_repemail+&v_content=+v_content+&stat_html=+stat_html+&stat_ubb=+stat_ubb+&stat_emot=+stat_emot+&v_reppsw=+v_reppsw+&stat_property=+stat_property+v_security_plus;
var gourl=absbaseurl+visit.php?ajax=on&job=+job;
makerequest(gourl, 'quickreply', 'post', postdata);
} else {
document.getelementbyid('visitorinput').submit();
}
}
//ctrl+enter key submitting (textarea)
function ctrlenterkey (eventobject){
if(eventobject.ctrlkey && eventobject.keycode==13) {
document.getelementbyid(btnsubmit).click();
}
}
//admin reply
function ajax_adminreply (commentid) {
if (shutajax==0) {
var admid='adminreplycontent'+commentid;
var adminreplycontent = blogencode(document.getelementbyid(admid).value);
var postdata = unuse=unuse&adminreplycontent=+adminreplycontent;
var gourl=absbaseurl+admin.php?ajax=on&go=+switchcomandmes+_addadminreply_+commentid;
currentcommentid=commentid;
makerequest(gourl, 'quickadminreply', 'post', postdata);
} else {
var admid='formadminreply'+commentid;
document.getelementbyid(admid).submit();
}
}
function ajax_adminreply_edit (commentid, rptype) {
switchcomandmes=rptype;
ajax_adminreply(commentid);
}
function ajax_editcomment(repid, submitaction, onetimecounter) {
var admid='editcomcontent'+repid;
var v_content = blogencode(document.getelementbyid(admid).value);
var editjob=(submitaction=='reply') ? 'editreply' : 'editmessage';
var postdata = unuse=unuse&onetimecounter=+onetimecounter+&v_content=+v_content;
var gourl=absbaseurl+visit.php?ajax=on&go=+editjob+&repid=+repid;
currentcommentid=repid;
makerequest(gourl, 'quickeditcomment', 'post', postdata);
}
//encode string
function blogencode (str) {
str=encodeuricomponent(str);
if (is_moz) str=str.replace(/%0a/g, %0d%0a); //in ie, a new line is encoded as \r\n, while in mozilla it's \n
return str;
}
//avatar selection
function changeavatar (slname, area) {
var current=document.getelementbyid(slname);
var realvalue=current.options[current.selectedindex].value;
var areashow=document.getelementbyid(area);
if (areashow) {
if (realvalue!='' && realvalue!=null) {
areashow.innerhtml=<img src='images/avatars/"+realvalue+"' alt=''/>;
}
else {
areashow.innerhtml=jslang[13];
}
}
}
//insert emots
function insertemot (emotcode) {
var current=document.getelementbyid('v_content');
var emot=[emot]+emotcode+[/emot];
if (current) {
if (current.value!='' && current.value!=null) {
current.value+=emot;
}
else {
current.value=emot;
}
document.getelementbyid('v_content').focus();
}
}
// show/hide sidebar
function showhidesidebar(){
try{
var objsidebar=document.getelementbyid(sidebar);
var objcontent=document.getelementbyid(content);
if(objsidebar.classname!=sidebar-hide){
objsidebar.classname=sidebar-hide;
objsidebar.style.display=none;
objcontent.classname=content-wide;
setcookie('sidebaroff', 1,null, null, null, false);
}else{
objsidebar.classname=sidebar;
objsidebar.style.display=block;
objcontent.classname=content;
setcookie('sidebaroff', 0,null, null, null, false);
}
}catch(e){}
}
function loadsidebar(){
try{
var objsidebar=document.getelementbyid(sidebar);
var objcontent=document.getelementbyid(content);
var sidebaroff=getcookie ('sidebaroff');
if(sidebaroff==1){
objsidebar.classname=sidebar-hide;
objsidebar.style.display=none;
objcontent.classname=content-wide;
}else{
objsidebar.classname=sidebar;
objsidebar.style.display=block;
objcontent.classname=content;
}
}catch(e){}
}
//media link
function playmedia(strid,strtype,strurl,intwidth,intheight) {
var objp=document.getelementbyid(strid);
if (!objp) return false;
if (objp.style.display!='none') {
objp.innerhtml='';
objp.style.display='none';
} else {
objp.innerhtml=makemedia(strtype,strurl,intwidth,intheight,strid);
objp.style.display='block';
}
}
//media build
function makemedia (strtype,strurl,intwidth,intheight,strid) {
var strhtml;
switch(strtype) {
case 'wmp':
strhtml=<object width='"+intwidth+"' height='"+intheight+"' classid='clsid:6bf52a52-394a-11d3-b153-00c04f79faa6'><param name='url' value='"+strurl+"'/><embed width='"+intwidth+"' height='"+intheight+"' type='application/x-mplayer2' src='"+strurl+"'></embed></object>;
break;
case 'swf':
strhtml=<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='"+intwidth+"' height='"+intheight+"'><param name='movie' value='"+strurl+"'/><param name='quality' value='high' /><embed src='"+strurl+"' quality='high' type='application/x-shockwave-flash' width='"+intwidth+"' height='"+intheight+"'></embed></object>;
break;
case 'flv':
var fu = {movie:images/others/mediaplayer.swf,width:intwidth,height:+intheight,majorversion:8,build:0,bgcolor:#ffffff,allowfullscreen:true,flashvars:file=+strurl+&fullscreenpage=images/others/fullscreen.html&fsreturnpage=+location.href};ufo.create(fu, strid);
break;
case 'real':
strhtml=<object classid='clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa' width='"+intwidth+"' height='"+intheight+"'><param name='src' value='"+absbaseurl+"inc/realplay.php?link="+strurl+"' /><param name='controls' value='imagewindow' /><param name='console' value='clip1' /><param name='autostart' value='true' /><embed src='"+absbaseurl+"inc/realplay.php?link="+strurl+"' type='audio/x-pn-realaudio-plugin' autostart='true' console='clip1' controls='imagewindow' width='"+intwidth+"' height='"+intheight+"'></embed></object><br/><object classid='clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa' width='"+intwidth+"' height='44'><param name='src' value='"+absbaseurl+"inc/realplay.php?link="+strurl+"' /><param name='controls' value='controlpanel' /><param name='console' value='clip1' /><param name='autostart' value='true' /><embed src='"+absbaseurl+"inc/realplay.php?link="+strurl+"' type='audio/x-pn-realaudio-plugin' autostart='true' console='clip1' controls='controlpanel' width='"+intwidth+"' height='44'></embed></object>;
break;
}
return strhtml;
}
//font size control
function dozoom(size) {
document.getelementbyid('zoomtext').style.fontsize=size+'px';
}
//cookie
function setcookie(name,value,expiry,path,domain,secure) {
var namestring = name + = + value;
var expirystring = (expiry == null) ? : ;expires = + expiry.togmtstring();
var pathstring = (path == null) ? : ;path = + path;
var domainstring = (path == null) ? : ;domain = + domain;
var securestring = (secure) ?;secure :;
document.cookie = namestring + expirystring + pathstring + domainstring + securestring;
}
function getcookie (name) {
var cookiefound = false;
var start = 0;
var end = 0;
var cookiestring = document.cookie;
var i = 0;
while (i <= cookiestring.length) {
start = i ;
end = start + name.length;
if (cookiestring.substring(start, end) == name){
cookiefound = true;
break;
}
i++;
}
if (cookiefound){
start = end + 1;
end = cookiestring.indexof(";",start);
if (end < start) end = cookiestring.length;
return unescape(cookiestring.substring(start, end));
}
return "";
}
function deletecookie(name) {
var expires = new date();
expires.settime (expires.gettime() - 1);
setcookie( name , "delete cookie", expires,null,null,false);
}
function refreshsecuritycode(areaid, inputid) {
if (document.getelementbyid(areaid)) {
var rnds=math.random();
document.getelementbyid(areaid).innerhtml="<img src='inc/securitycode.php?rand="+rnds+"' alt=''/>;
}
if (document.getelementbyid(inputid)) document.getelementbyid(inputid).value='';
}
function ajax_login () {
if (shutajax==0) {
var username = blogencode(document.getelementbyid('username').value);
var password = blogencode(document.getelementbyid('password').value);
var tmpsavecookie;
for (var i=1; i<=5; i++) {
tmpsavecookie='savecookie'+i;
if (document.getelementbyid(tmpsavecookie).checked) {
var savecookie = blogencode(document.getelementbyid(tmpsavecookie).value);
break;
}
}
var postdata = "unuse=unuse&username="+username+"&password="+password+"&savecookie="+savecookie;
if (document.getelementbyid('securitycode')) postdata+="&securitycode="+blogencode(document.getelementbyid('securitycode').value);
var gourl=absbaseurl+"login.php?ajax=on&job=ajaxverify";
makerequest(gourl, 'quicklogin', 'post', postdata);
}
}
function quicklogout() {
setcookie ('userid','',null,null, null, false);
setcookie ('userpsw','',null,null, null, false);
}
function quickremember() {
var v_replier = blogencode(document.getelementbyid('v_replier').value);
var v_repurl = blogencode(document.getelementbyid('v_repurl').value);
var v_repemail = blogencode(document.getelementbyid('v_repemail').value);
var dateobjexp= new date();
dateobjexp.setseconds(3600*24*365);
if (document.getelementbyid('stat_rememberme').checked) {
setcookie ('rem_v_replier', v_replier, dateobjexp, null, null, false);
setcookie ('rem_v_repurl', v_repurl, dateobjexp, null, null, false);
setcookie ('rem_v_repemail', v_repemail, dateobjexp, null, null, false);
setcookie ('rem_v_rememberme', '1', dateobjexp, null, null, false);
} else {
setcookie ('rem_v_replier', '', dateobjexp, null, null, false);
setcookie ('rem_v_repurl', '', dateobjexp, null, null, false);
setcookie ('rem_v_repemail', '', dateobjexp, null, null, false);
setcookie ('rem_v_rememberme', '0', dateobjexp, null, null, false);
}
}
function decodetburl (str, ishidden, uniqueid) {
var resultstr='';
if (ishidden==1) { //hidden!
var randomnumber1=math.floor(math.random()*10+1);
var randomnumber2=math.floor(math.random()*10+1);
resultstr="<span id=\"showtbq"+uniqueid+"\">+jslang[66]+ <span id=\"qa"+uniqueid+"\">+randomnumber1+</span> <strong>+</strong> <span id=\"qb"+uniqueid+"\">+randomnumber2+</span> <strong>=</strong> <input type='text' id='ans"+uniqueid+"' maxlength='2' size='2'/> <input type='button' onclick='submithiddentbanswer(\""+uniqueid+"\");' value='"+jslang[1]+"'/><span id=\"answertb"+uniqueid+"\" style=\"display: none;\">+str+</span></span>;
}
else {
var codestr;
codestr=str.split('%');
var seed=codestr[0];
for (var i=1; i<codestr.length; i++) {
resultstr+=string.fromcharcode(codestr[i]-seed);
}
}
return resultstr;
}
function submithiddentbanswer(uniqueid) {
var randomnumber1=(document.getelementbyid("qa"+uniqueid)) ? parseint(document.getelementbyid("qa"+uniqueid).innerhtml) : 0;
var randomnumber2=(document.getelementbyid("qb"+uniqueid)) ? parseint(document.getelementbyid("qb"+uniqueid).innerhtml) : 0;
var anssubmited=(document.getelementbyid("ans"+uniqueid)) ? parseint(document.getelementbyid("ans"+uniqueid).value) : 0;
if (randomnumber1+randomnumber2!=anssubmited) alert (jslang[67]);
else {
var resultstr=(document.getelementbyid("answertb"+uniqueid)) ? document.getelementbyid("answertb"+uniqueid).innerhtml : null;
resultstr=decodetburl (resultstr, 0, 0);
if (document.getelementbyid("showtbq"+uniqueid)) document.getelementbyid("showtbq"+uniqueid).innerhtml=resultstr;
}
}
function getprotectedblog (blogid, way) {
var blogpsw=blogencode(document.getelementbyid('entrypsw'+blogid).value);
currentblogid=blogid;
var postdata = "unuse=unuse&job=getcontentonly&way="+way+"&blogid="+blogid+"&blogpsw="+blogpsw;
if (shutajax==0) {
var gourl=absbaseurl+"visit.php?ajax=on";
makerequest(gourl, 'quickgetprotectedblog', 'post', postdata);
}
}
function promptreppsw () {
var pswproperty=document.getelementbyid('stat_property');
if (!pswproperty) return;
else if (pswproperty.checked) {
var pswtxt=prompt(jslang[69],'');
if (pswtxt==null || pswtxt=='') {
pswproperty.checked='';
return;
} else {
if (pswtxt.length>12) {
alert(jslang[70]);
promptreppsw();
}
document.getelementbyid('v_reppsw').value=pswtxt;
}
} else {
document.getelementbyid('v_reppsw').value='';
}
}
function getprotectedreply (repid, way, onetimecounter) {
var reppsw=blogencode(document.getelementbyid('reppsw'+repid).value);
currentcommentid=repid;
var postdata = unuse=unuse&job=getreplyonly&way=+way+&reppsw=+reppsw+&repid=+currentcommentid+&onetimecounter+onetimecounter;
if (shutajax==0) {
var gourl=absbaseurl+visit.php?ajax=on;
makerequest(gourl, 'quickeditcomment', 'post', postdata);
}
}