﻿function history()
{
opost('user_action','ac=history');
}

function static(url)
{
if (window.innerWidth){var theWidth = window.innerWidth;}else{var theWidth = document.documentElement.clientWidth;}
if (theWidth<846) {GE("info").style.width="185px";GE("thumbs").style.width="80px";}
else if (theWidth<872) {GE("info").style.width="195px";GE("thumbs").style.width="120px";}
else if (theWidth<977) {GE("info").style.width=(theWidth*0.75*0.94-419)+"px";}
GE('review_info').innerHTML='请确认您发表的言论遵守国家法律法规，并符合图书的主题。<br />用户讨论仅代表作者观点，与 YoYoTo 立场无关。<br />游客发表评论不需要填写密码。<br />仅支持纯文本，字数限制1600字符以内。<input value="查看当前字数" onclick="viewstrlen();" type="button" /> <span id="viewstr"></span>';
opost('pro_action','url='+escape(url)+'&ref='+escape(document.referrer));
}
function viewstrlen()
{
GE('viewstr').innerHTML="共输入了"+StrL(document.usereview.content.value)+" 个字符";
}

function user_review(id)
{
  if (document.usereview.content.value.indexOf('发票')!=-1 || 
document.usereview.content.value.indexOf('exvv')!=-1){GE("wait").innerHTML="发表成功";return false;}
  if (!document.usereview.anonymity.checked){
  if(document.usereview.username.value=="") {GE("wait").innerHTML="请输入你的用户名";return false;}
  if(c2c(document.usereview.username.value)){GE("wait").innerHTML='用户名不要包含\\/:;*?"<>|()%^等半角字符';return false;}}  
  if(document.usereview.content.value=="") {GE("wait").innerHTML="请输入正文";return false;}
  if(StrL(document.usereview.content.value)>1600) {GE("wait").innerHTML="正文字数限制在1600字符以内，一个汉字为两个字符";return false;}
  var ano="0";
  if (document.usereview.anonymity.checked){ano="1";}
  document.usereview.submit.disabled=true;
  GE("wait").innerHTML="正在提交，请稍侯……";
  oget('user_action','ac=user_review'+'&id='+id+'&username='+document.usereview.username.value+'&content='+escape(document.usereview.content.value)+'&password='+document.usereview.password.value+'&ano='+ano);
}
function subook(url,bookname)
{
url.href='/reader?q='+encodeURIComponent(bookname);
}

function key_review(event)
{
	if(event.keyCode!=13) document.usereview.submit.disabled=false;
}

function StrL(sString)
{
var sStr,iCount,i,strTemp ; 

iCount = 0 ;
sStr = sString.split("");
for (i = 0 ; i < sStr.length ; i ++)
{
strTemp = escape(sStr[i]); 
if (strTemp.indexOf("%u",0) == -1)
{ 
iCount = iCount + 1 ;
} 
else 
{
iCount = iCount + 2 ;
}
}
return iCount ;
}

function c2c(strTmp){
if(strTmp.indexOf('\\', 0)!=-1 || 
strTmp.indexOf('/', 0)!=-1 ||
strTmp.indexOf(':', 0)!=-1 ||
strTmp.indexOf('*', 0)!=-1 ||
strTmp.indexOf('"', 0)!=-1 ||
strTmp.indexOf("'", 0)!=-1 ||
strTmp.indexOf('?', 0)!=-1 ||
strTmp.indexOf('<', 0)!=-1 ||
strTmp.indexOf('>', 0)!=-1 ||
strTmp.indexOf('&', 0)!=-1 ||
strTmp.indexOf('(', 0)!=-1 ||
strTmp.indexOf(')', 0)!=-1 ||
strTmp.indexOf('%', 0)!=-1 ||
strTmp.indexOf(';', 0)!=-1 ||
strTmp.indexOf(',', 0)!=-1 ||
strTmp.indexOf('=', 0)!=-1 ||
strTmp.indexOf('|', 0)!=-1){return true;}}

function blogclick(url,title,id)
{
opost('user_action','ac=blogclick&title='+escape(title)+'&url='+escape(url)+'&id='+id);
}