
VeryCD=window.VeryCD||{}
VeryCD.namespace=function(a){if(!a||!a.length){return null}
var b=a.split(".")
var c=VeryCD
for(var i=(b[0]=="VeryCD")?1:0;i<b.length;i++){c[b[i]]=c[b[i]]||{}
c=c[b[i]]}
return c}
VeryCD.namespace("config")
VeryCD.namespace("events")
VeryCD.namespace("client")
VeryCD.namespace("cookie")
VeryCD.namespace("layout")
VeryCD.namespace("member")
VeryCD.namespace("Members")
VeryCD.namespace("util")
VeryCD.config.root={statics:"https:"==document.location.protocol?"https://ssl-statics.verycd.com":"http://statics.verycd.com",img:"http://img.verycd.com",doc:"http://doc.verycd.com",dynamic:"http://www.verycd.com",secure:"http://secure.verycd.com",yui:"http://cn.yui.yahooapis.com/2.5.2/build"}
$=YAHOO.util.Dom.get
getElementsByClassName=YAHOO.util.Dom.getElementsByClassName
VeryCD.cookie={get:function(name){var arg=name+"="
var alen=arg.length
var clen=document.cookie.length
var i=0
while(i<clen){var j=i+alen
if(document.cookie.substring(i,j)==arg){var endstr=document.cookie.indexOf(";",j)
if(endstr==-1){endstr=document.cookie.length}
return decodeURIComponent(document.cookie.substring(j,endstr))}
i=document.cookie.indexOf(" ",i)+1
if(i==0){break}}
return null},set:function(name,value){var argv=arguments
var argc=arguments.length
var expr=(argc>2)?argv[2]:null
var path=(argc>3)?argv[3]:null
var domain=(argc>4)?argv[4]:null
var secure=(argc>5)?argv[5]:false
document.cookie=name+"="+encodeURIComponent(value)+
((expr==null)?"":("; expires="+expr.toGMTString()))+
((path==null)?"":("; path="+path))+
((domain==null)?"":("; domain="+domain))+
((secure==true)?"; secure":"")}}
var getCookie=VeryCD.cookie.get;var setCookie=VeryCD.cookie.set;var readCookie=VeryCD.cookie.get;if(1!=getCookie('is_root')){window.onerror=function(){return false;}}
VeryCD.client.agent={ie:false,ie5:false,ie6:false,ie7:false,opera:!!window.opera,webkit:navigator.userAgent.indexOf('AppleWebKit/')>-1,gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1}
document.write('<!--[if IE]>  <scr'+'ipt type="text/javascript">VeryCD.client.agent.ie  = true;</scr'+'ipt><![endif]-->')
document.write('<!--[if IE 5]><scr'+'ipt type="text/javascript">VeryCD.client.agent.ie5 = true;</scr'+'ipt><![endif]-->')
document.write('<!--[if IE 6]><scr'+'ipt type="text/javascript">VeryCD.client.agent.ie6 = true;</scr'+'ipt><![endif]-->')
document.write('<!--[if IE 7]><scr'+'ipt type="text/javascript">VeryCD.client.agent.ie7 = true;</scr'+'ipt><![endif]-->')
VeryCD.member.id=parseInt(VeryCD.cookie.get("member_id"))
if(!VeryCD.member.id){VeryCD.member.id=0}
VeryCD.member.mgroupId=parseInt(VeryCD.cookie.get("mgroupId"))
if(!VeryCD.member.mgroupId){VeryCD.member.mgroupId=0}
VeryCD.member.username=VeryCD.member.id==0?'':VeryCD.cookie.get("member_name")
var locHostName="";if(VeryCD.member.id){if(location.hostname=='game.verycd.com'){var locHostName="http:\/\/www.verycd.com";}
var msgRef=document.createElement('script')
msgRef.setAttribute("type","text/javascript")
msgRef.setAttribute("src",'http://www.verycd.com/api/member?m=messages&format=js')
document.getElementsByTagName("head")[0].appendChild(msgRef)}
VeryCD.member.showUnreadMessage="<a href=\""+locHostName+"\/messages\/\"><img alt=\"\" src=\""+VeryCD.config.root.statics+"\/images\/message\/nomessage.gif\" style=\"margin-bottom:0px;#margin-bottom:-4px\" title=\"你有0条新消息\"/><\/a>"
setTimeout(function(){if(VeryCD.Members.Messages){VeryCD.member.unreadMessage=parseInt(VeryCD.Members.Messages.unRead);if(!VeryCD.member.unreadMessage){VeryCD.member.unreadMessage=0}
if(VeryCD.member.unreadMessage!=0){VeryCD.member.showUnreadMessage="<a href=\""+locHostName+"\/messages\/\"><img alt=\"\" src=\""+VeryCD.config.root.statics+"\/images\/message\/newmessage.gif\" style=\"margin-bottom:0px;#margin-bottom:-4px\" title=\"你有"+VeryCD.member.unreadMessage+"条新消息\" align=\"absmiddle\"\/>("+VeryCD.member.unreadMessage+")<\/a>"}else{VeryCD.member.showUnreadMessage="<a href=\""+locHostName+"\/messages\/\"><img alt=\"\" src=\""+VeryCD.config.root.statics+"\/images\/message\/nomessage.gif\" style=\"margin-bottom:0px;#margin-bottom:-4px\" title=\"你有0条新消息\"/><\/a>"}}
if($('user-loginfo'))VeryCD.member.showUserName()},1000);VeryCD.member.showUserName=function(){if(VeryCD.member.username!=''){$('user-loginfo').innerHTML="<a href=\""+locHostName+"\/members\/\@u"+VeryCD.member.id+"\/\" style=\"font-weight: bold;\">"+VeryCD.member.username+"</a> "+VeryCD.member.showUnreadMessage+" &bull; <a href=\""+locHostName+"\/members\/\@u"+VeryCD.member.id+"\/favorites\/\" onclick=\"pageTracker._trackPageview(\'\/stat\/toplinkFav\/\')\">收藏<\/a>"+" &bull; <a href=\""+VeryCD.config.root.secure+"\/signout\/*\/"+location.href+"\">退出<\/a> | "}else{$('user-loginfo').innerHTML="<a href=\""+VeryCD.config.root.secure+"\/signin\/*\/"+location.href+"\">登录</a> &bull; <a href=\""+VeryCD.config.root.secure+"\/signup\/*\/"+location.href+"\">注册<\/a> | "}}
VeryCD.member.showUserFace=function(){if(VeryCD.member.id!=0){var current_time=(new Date()).getTime();$('userFace').innerHTML="<img alt=\"\" src=\""+VeryCD.config.root.img+"/vcgroup/face/48-48/"+VeryCD.member.id+".jpg?"+current_time+"\" class=\"faceLeft loginUser\" />"}else{$('userFace').innerHTML="<img alt=\"\" src=\""+VeryCD.config.root.img+"/vcgroup/face/48-48/0.jpg\" class=\"faceLeft loginUser\" />"}}
VeryCD.member.showOrzUrl=function(){if(VeryCD.member.id!=0){$('orz-link').innerHTML=" | <a href='/orz/'>候选区</a>"}else{$('orz-link').innerHTML=""}}
VeryCD.layout.searchToggler={modules:{folders:"资源"},currentModule:"folders",displayingMenu:false,autoCompletor:function(){},_inited:false,_linkElement:null,_imageElement:null,_optionsElement:null,_init:function(){if(!this._inited){this._imageElement=$("current-search-module-img")
this._linkElement=$("search-module-toggle-link")
this._optionsElement=$("search-module-options")
this._inited=true}},_generateList:function(mod){var html=""
for(var i in this.modules){if(i=="extend"){continue}
n=this.modules[i]
html+='<li><a href="#" onmousedown="return VeryCD.layout.searchToggler.selectModule(\''+i+'\');"><img alt="" src="'+VeryCD.config.root.statics+'\/images\/layout\/search-modules\/'+i+'.png" style="width: 18px; height: 18px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+VeryCD.config.root.statics+'\/images\/layout\/search-modules\/'+i+'.png\', sizingMethod=\'crop\');" onload="this.onload=\'\'; if(this.style.filter) { this.src=\''+VeryCD.config.root.statics+'\/images\/0.gif\'; this.width=18; this.height=18; }" />'+n+'<\/a><\/li>'}
return html},init:function(mod){this.currentModule=mod
var html=""
html+='<div id="search-module-options" style="z-index:100;display: none;" onmouseover="return VeryCD.layout.searchToggler.selectModule();" onmouseout="VeryCD.layout.searchToggler.hideOptions();">'
html+='<ul id="search-module-options-list">'
html+=this._generateList(mod)
html+='<\/ul>'
html+='<\/div>'
html+='<span id="search-module-toggle" onmouseover="return VeryCD.layout.searchToggler.selectModule();" onmouseout="VeryCD.layout.searchToggler.hideOptions();">'
html+='<img id="current-search-module-img" alt="" src="'+VeryCD.config.root.statics+'\/images\/layout\/search-modules\/'+mod+'-selected.png" style="width: 21px; height: 18px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+VeryCD.config.root.statics+'\/images\/layout\/search-modules\/'+mod+'-selected.png\', sizingMethod=\'crop\');" onload="this.onload=\'\'; if(this.style.filter) { this.src=\''+VeryCD.config.root.statics+'\/images\/0.gif\'; this.width=21; this.height=18; }" \/><\/span>'
document.write(html)},generate:function(){var txt=""
var mod=arguments[0]||this.currentModule
var ckm=VeryCD.cookie.get("lsm")
if(ckm!=null){for(var i in this.modules){if(i==ckm){mod=ckm}}}
if(arguments.length==2){txt=arguments[1]}
var html=""
if(VeryCD.client.agent.opera){html+='\n<style type="text/css">#top-search-input, #current-search-module-img { margin-top: 8px; } .top-search-button { padding-top: 10px; }</style>'}else if(VeryCD.client.agent.webkit){html+='\n<style type="text/css">#top-search-input { margin-top: 9px; } #current-search-module-img { margin-top: 10px; } .top-search-button { padding-top: 10px; }</style>'}
html+='<br style="padding: 0px; margin: 0px; line-height: 30px;" class="package" \/><br />'
html+='<form method="get" onsubmit="return VeryCD.events.topSearchBar.findIt(this.kw.value);">\n'
html+='<div id="top-search" class="auto-complete">\n'
html+='<script type="text\/javascript">VeryCD.layout.searchToggler.init("'+mod+'");<\/scr'+'ipt>\n'
html+='<input type="text"  id="top-search-input" name="kw" value="'+txt+'" class="yui-ac-input" \/>'
html+='<button type="submit" id="top-search-button"  class="top-search-button">搜索<\/button>'
html+='<button type="button" id="top-search-advance" class="top-search-button" onclick="return VeryCD.events.topSearchBar.goAdvance();">高级搜索<\/button>'
html+='<button type="button" id="top-search-publish" class="top-search-button" onclick="return VeryCD.events.topSearchBar.goPublish();">发布资源<\/button>'
html+='<div id="top-search-ac-container"><\/div>'
html+='<\/div><!-- End #top-search -->\n'
html+='</form>'
document.write(html)
this.autoCompletor=new function(){this.formatter=function(resultItem,query){var key=resultItem[0]
var quantity=resultItem[1]
var keyQuery=key.substr(0,query.length)
var keyRemainder=key.substr(query.length)
var markup=["<div class='result-result'><div class='result-quantity'>",quantity," 结果</div><span class='result-query'>",key,"</span>","</div>"]
return(markup.join(""))}
this.ds=new YAHOO.widget.DS_XHR("/suggest",["\n","\t"])
this.ds.scriptQueryParam="q"
this.ds.scriptQueryAppend="m="+VeryCD.layout.searchToggler.currentModule+"&format=xhr"
this.ds.responseType=YAHOO.widget.DS_XHR.TYPE_FLAT
this.ds.maxCacheEntries=0
this.ds.queryMatchSubset=true
this.ds.connTimeout=5000
this.ac=new YAHOO.widget.AutoComplete('top-search-input','top-search-ac-container',this.ds)
this.ac.delimChar=""
this.ac.formatResult=this.formatter
this.ac.queryMatchCase=false
this.ac.queryMatchContains=false
this.ac.typeAhead=false
this.ac.useIFrame=true
this.ac.useShadow=false
this.ac.queryDelay=0
this.ac.minQueryLength=1
this.ac.maxResultsDisplayed=10
this.ac.autoHighlight=false}},selectModule:function(){this._init()
if(arguments.length==0){if(this.displayingMenu){this.hideOptions()}else{this.showOptions()}}else{var m=arguments[0]
this.currentModule=m
this.hideOptions()
this._imageElement.src=VeryCD.config.root.statics+"/images/layout/search-modules/"+m+"-selected.gif"
$("search-module-options-list").innerHTML=this._generateList(m)
VeryCD.cookie.set("lsm",m)}
return false},hideOptions:function(){this._optionsElement.style.display="none"
this.displayingMenu=false},showOptions:function(){this._optionsElement.style.display=""
this.displayingMenu=true}}
VeryCD.events.resizeWindow=function(){var w=document.documentElement?document.documentElement.clientWidth:document.body.clientWidth
switch(VeryCD.layout.pageWidth){case"full":if(!VeryCD.client.agent.webkit){$('page-wrapper').style.width="94%"}
break
case"broad":$('page-wrapper').style.width="990px"
break
default:}}
window.onload=VeryCD.events.resizeWindow
window.onresize=VeryCD.events.resizeWindow
VeryCD.events.topSearchBar={findIt:function(kw){if(kw.indexOf("+")==-1&&kw.indexOf("#")==-1){location.href="http://www.verycd.com/search/"+VeryCD.layout.searchToggler.currentModule+"/"+this.formatKeywords(kw)}else{location.href="http://www.verycd.com/search/"+VeryCD.layout.searchToggler.currentModule+"?kw="+this.formatKeywords(kw)}
return false},searchSite:function(kw){location.href="http://search.verycd.com/site/"+encodeURIComponent(kw).replace(/\+/g,"%2B").replace(/(%20)+/,"+")+"/"
return false},goAdvance:function(){location.href="http://www.verycd.com/search#advanced"
return false},goPublish:function(){location.href="http://"+location.hostname+"/topics/post"
return false},formatKeywords:function(s){return encodeURIComponent(s).replace(/\+/g,"%2B").replace(/(%20)+/g,"+")}}
VeryCD.events.copy=function(text2copy){if(window.clipboardData){window.clipboardData.setData("Text",text2copy)
return}
var flash_el=null
if(arguments.length==2){if(typeof $(arguments[1])=="object"){flash_el=$(arguments[1])}}
if(!flash_el){var div_holder=document.createElement('div')
div_holder.id="flash-copier"
document.body.appendChild(div_holder)
flash_el=$("flash-copier")}
flash_el.innerHTML='<embed src="'
+VeryCD.config.root.statics
+'\/images\/clipboard.swf" FlashVars="clipboard='
+encodeURIComponent(text2copy).replace(/\+/g,"%2B")
+'" width="0" height="0" type="application\/x-shockwave-flash"><\/embed>'}
var displayBroadPage=VeryCD.client.broadScreen
var currentUserId=VeryCD.member.id
function searchFolders(o){VeryCD.layout.searchToggler.currentModule="folders"
if(typeof o.q.value=="string"){return VeryCD.events.topSearchBar.findIt(o.q.value)}else if(typeof o.kw.value=="string"){return VeryCD.events.topSearchBar.findIt(o.kw.value)}else{return false}}
function searchSite(s){return VeryCD.events.topSearchBar.searchSite(s)}
function searchTopics(s){VeryCD.layout.searchToggler.currentModule="topics"
return VeryCD.events.topSearchBar.findIt(o.q.value)}
function postAct(action,url){if(!url){url='./'}
var f=document.createElement('form')
f.setAttribute('method','POST')
f.setAttribute('action',url)
var m=document.createElement('input')
m.setAttribute('type','hidden')
m.setAttribute('name','method')
m.setAttribute('value',action)
f.appendChild(m)
document.body.appendChild(f)
f.submit()
return false}
function getWindowLength(type,debug){type=(typeof type=='undefined')?'error':type
type=type.toLowerCase()
var w='width'
var h='height'
if(w.indexOf(type)===0){type='Width'}else if(h.indexOf(type)===0){type='Height'}else{alert('wrong parameter'+type)}
var attrs=['offset'+type,'scroll'+type,'client'+type,'inner'+type]
var db=document.body
var de=document.documentElement
var r=0
var tmp_r=0
var a=''
for(var i=0;i<attrs.length;i++){a=attrs[i]
tmp_r=db[a]>de[a]?db[a]:de[a]
if(debug){alert(a+':'+tmp_r)}
if(typeof tmp_r=='undefined'||tmp_r<r){continue}
c_attr=a
r=tmp_r}
if(debug){alert(c_attr+':'+r)}
return r}
if(!VeryCD.client.agent.ie){document.write('<style type="text\/css" media="all">\n')
document.write('body, input, textarea, select, button, td { font-family: "Lucida Grande", Tahoma, Arial, sans-serif; }')
document.write('<\/style>\n')}
function IsInstallSupMiniQQ(QQVersion){if(VeryCD.client.agent.ie){try{var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck")
var n=xmlhttp.GetVersion()
if(n<QQVersion){location.href='http://is.qq.com/up_alarm.shtml'
return false}
return true}catch(e){location.href='http://is.qq.com/up_alarm.shtml'
return false}
return false}else{alert('抱歉，由于腾讯比较傻，这个功能只能在IE下使用:(')}}
function RealAddPortal(FpanelID,QQVersion){var boolFals=IsInstallSupMiniQQ(QQVersion)
if(boolFals==true){if(FpanelID==17002){var exe="Tencent://AddPortal/?Menu=Yes&Exe=QQ&PanelID="+FpanelID}else{var exe="Tencent://AddPortal/?Menu=Yes&PanelID="+FpanelID}
location.href=exe}}
VeryCD.events.fixPostImagesWidth=function(){var imageName="post_img"
var blockArea="resoucePostData"
var srcWidth=0
var srcHeight=0
var changed=0
var timer
var width=592
var setWidth=600
var setHeight=2000
var postImages=document.getElementsByName(imageName)
try{for(i=0;i<postImages.length;i++){var e=postImages[i]
srcWidth=e.width
srcHeight=e.height
changed=0
if(e.width>setWidth){n=e.width/setWidth
e.width=setWidth
changed=1}
if(e.height>setHeight){n=e.height/setHeight
e.width=e.width/n
e.height=setHeight
changed=1}
if(changed==1){}}
timer=window.setTimeout("VeryCD.events.fixPostImagesWidth()",1000)}catch(e){timer=window.setTimeout("VeryCD.events.fixPostImagesWidth()",1000)}}
VeryCD.events.fixPostImagesWidth()
var JSTarget={init:function(att,val){if(document.getElementById&&document.createElement&&document.appendChild){var strAtt=((typeof att=='undefined')||(att==null))?'class':att
var strVal=((typeof val=='undefined')||(val==null))?'non-html':val
var arrLinks=document.getElementsByTagName('a')
var oLink
var oRegExp=new RegExp("(^|\\s)"+strVal+"(\\s|$)")
for(var i=0;i<arrLinks.length;i++){oLink=arrLinks[i]
if((strAtt=='class')&&(oRegExp.test(oLink.className))||(oRegExp.test(oLink.getAttribute(strAtt)))){oLink.onclick=JSTarget.openWin}}
oWarning=null}},openWin:function(e){var event=(!e)?window.event:e
if(event.shiftKey||event.altKey||event.ctrlKey||event.metaKey){return true}else{var oWin=window.open(this.getAttribute('href'),'_blank')
if(oWin){if(oWin.focus)oWin.focus()
return false}
oWin=null
return true}},addEvent:function(obj,type,fn){if(obj.addEventListener)
obj.addEventListener(type,fn,false)
else if(obj.attachEvent){obj["e"+type+fn]=fn
obj[type+fn]=function(){obj["e"+type+fn](window.event);}
obj.attachEvent("on"+type,obj[type+fn])}}}
JSTarget.addEvent(window,'load',function(){JSTarget.init("rel","external");})
function iserror(id,msg){var inputid=$(id)
if(!inputid){return false;}
inputid.style.borderColor="#FF4500"
inputid.style.borderStyle="solid"
inputid.style.borderWidth="2px"}
TxtRsz={formEl:null,adEv:function(t,ev,fn){if(typeof document.addEventListener!='undefined'){t.addEventListener(ev,fn,false)}else{t.attachEvent('on'+ev,fn)}},rmEv:function(t,ev,fn){if(typeof document.removeEventListener!='undefined'){t.removeEventListener(ev,fn,false)}else{t.detachEvent('on'+ev,fn)}},init:function(){var inputs=document.getElementsByTagName('input')
var handler=document.getElementById("handle")
handler.style.cursor='s-resize'
TxtRsz.adEv(document,'mousedown',TxtRsz.initResize)},initResize:function(event){var textid=document.getElementById('contents')
if(typeof event=='undefined'){event=window.event}
var target=event.target||event.srcElement;if(target.id=="handle"){TxtRsz.formEl=textid
TxtRsz.formEl.startWidth=TxtRsz.formEl.clientWidth
TxtRsz.formEl.startHeight=TxtRsz.formEl.clientHeight
TxtRsz.formEl.startX=event.clientX
TxtRsz.formEl.startY=event.clientY
TxtRsz.adEv(document,'mousemove',TxtRsz.resize)
TxtRsz.adEv(document,'mouseup',TxtRsz.stopResize)}},resize:function(event){if(typeof event=='undefined'){event=window.event}
if(TxtRsz.formEl.type.toLowerCase()=='textarea'){TxtRsz.formEl.style.height=TxtRsz.formEl.startHeight+(event.clientY-TxtRsz.formEl.startY)+'px'
return false}},stopResize:function(event){TxtRsz.rmEv(document,'mousedown',TxtRsz.initResize)
TxtRsz.rmEv(document,'mousemove',TxtRsz.resize)
var textareas=document.getElementsByTagName('textarea')
for(var i=0;i<textareas.length;i++){textareas[i].style.cursor='text'}
var inputs=document.getElementsByTagName('input')
for(var i=0;i<inputs.length;i++){if(inputs[i].type=='text'){inputs[i].style.cursor='text'}}}}
VeryCD.util.text={getChars:function(str){var i=0
var c=0.0
var unicode=0
var len=0
if(str==null||str==""){return 0}
len=str.length
for(i=0;i<len;i++){unicode=str.charCodeAt(i)
if(unicode<127){c+=1}else{c+=2}}
return c},getLength:function(str){return this.getChars(str)},subString:function(str,startp,endp){var i=0;c=0;unicode=0;rstr=''
var len=str.length
var sblen=this.getLength(str)
if(startp<0){startp=sblen+startp}
if(endp<1){endp=sblen+endp}
for(i=0;i<len;i++){if(c>=startp){break}
var unicode=str.charCodeAt(i)
if(unicode<127){c+=1}else{c+=2}}
for(i=i;i<len;i++){var unicode=str.charCodeAt(i)
if(unicode<127){c+=1}else{c+=2}
rstr+=str.charAt(i)
if(c>=endp){break}}
return rstr},briefTitle:function(){var txt="";var len=61;var brk="..."
switch(arguments.length){case 3:brk=arguments[2]
case 2:len=arguments[1]
case 1:txt=arguments[0]
break;case 0:return}
var ret=txt
if(this.getLength(txt)>len){var half=Math.floor(len/2)
ret=this.subString(txt,0,half)
+brk
+this.subString(txt,0-(half-this.getLength(brk)))}
return ret}}
function js_vc_imgurl_format(imgUrl,size,type,imgName){var regExp=/(\d+)\/([0-9a-z]{32}\d+)/i;var re='';var url='';if(re=imgUrl.match(regExp)){url='http:\/\/image-'+re[1]+'.verycd.com';if(typeof(type)!='undefined'&&type!=''){url+='\/'+type;}
url+='\/'+re[2];if(typeof(size)!='undefined'&&size!=''){url+='('+size+')';}
if(typeof(imgName)!='undefined'&&imgName!=''){url+='\/'+imgName;}else{if(typeof(size)!='undefined'&&size!=''){url+='\/thumb.jpg';}else{url+='\/origin.jpg';}}
return url;}else{return imgUrl;}}
function js_vc_truncate(string,length,middle,etc){if(sb_strlen(string)<=length){return string;}else{var s='';if(middle=='true'){s=sb_substr(string,0,length/2);if(typeof(etc)!='undefined'&&etc!=''){s+=etc;}
s+=sb_substr(string,-length/2);}else{sb_substr(string,0,length);if(typeof(etc)!='undefined'&&etc!=''){s+=etc;}}
return s;}}
function getChars(str){var i=0;var c=0.0;var unicode=0;var len=0;if(str==null||str==""){return 0;}
len=str.length;for(i=0;i<len;i++){unicode=str.charCodeAt(i);if(unicode<127){c+=1;}else{c+=2;}}
return c;}
function sb_strlen(str){return getChars(str);}
function sb_substr(str,startp,endp){var i=0;c=0;unicode=0;rstr='';var len=str.length;var sblen=sb_strlen(str);if(startp<0){startp=sblen+startp;}
if(endp<1){endp=sblen+endp;}
for(i=0;i<len;i++){if(c>=startp){break;}
var unicode=str.charCodeAt(i);if(unicode<127){c+=1;}else{c+=2;}}
for(i=i;i<len;i++){var unicode=str.charCodeAt(i);if(unicode<127){c+=1;}else{c+=2;}
rstr+=str.charAt(i);if(c>=endp){break;}}
return rstr;}