
function $(s){return (document.getElementById)?document.getElementById(s):eval('document.all.'+s);}function SubO(o,f){var s='';f=(typeof(f)=='undefined')?false:true;for(v in o){if(f){s+=v+'\t';}else{s+=v+'\t\t'+o[v]+'\n';}}if(f){alert(s);}else{echo('<xmp style="background:#e8ecf6;border:1px solid grey;color:red;padding:5px;">'+s+'</xmp>');}}function isNumber(n){return (n!=null&&n.constructor==Number)?true:false;}function getCookie(cookieName){try{var cookieValue='';var posName=document.cookie.indexOf(escape(cookieName)+'=');if (posName==-1) return '';var posValue=posName+(escape(cookieName)+'=').length;var endPos=document.cookie.indexOf(';',posValue);return unescape(document.cookie.substring(posValue,(endPos==-1)?99999:endPos));}catch(e){}}function setCookie(nm,vu,tm){try{var expires=new Date();if(typeof(tm)=='undefined') tm=60*240;expires.setTime(expires.getTime()+tm*60000);document.cookie=escape(nm)+'='+escape(vu)+'; expires='+expires.toGMTString()+'; path=/; cookie domain=.gamech.com.cn;';}catch(e){}}var isIE=NavgT5('msie'),isMF=NavgT5('firefox'),isOP=NavgT5('opera'),isSF=NavgT5('safari');
function NavgT5(s){return window.navigator.userAgent.toLowerCase().indexOf(s)!=-1;}
function Right(s,len){s=s.substring(s.length-len);return s;}function getLevelByExp(exp){var tmp=',100,372,560,840,1242,1716,2360,3216,4200,5460,7050,8040,11040,13716,16680,20216,24402,28980,34320,40512,48614,58337,70004,84005,100806,120968,145161,174194,209033,250839,301007,361209,433450,520141,624169,749003,898803,1078564,1294277,1553132'.split(',');for(var i=1;i<tmp.length;i++){if(tmp[i]>exp) return i;}}function getPositionByLevel(n){var tmp=',平民,骑士见习,骑士,高阶骑士,骑士队长,骑士团长 ,皇冠骑士,男爵,子爵,伯爵,侯爵,公爵,国王,屠龙英雄'.split(',');n=ParseInt((n+2)/3);if(n<1 || n>tmp.length) n=1;return tmp[n];}function getPositionByExp(exp){return getPositionByLevel(getLevelByExp(exp));}function ParseInt(n){n=parseInt(n);return isNaN(n)?0:n;}function OptionNumric(min,max,value){var s='';if(typeof(value)=='undefined'){}else if(value=='mid'){value=min+ParseInt((max-min)/2);}for(var i=min;i<=max;i++){s+='<option value="'+i+'"> '+i+' </option>';}s=s.replace('value="'+value+'"','value="'+value+'" selected');return s;}
function eTop(e){n=e.offsetTop;while(e=e.offsetParent)n+=e.offsetTop;return n;}
function eLeft(e){n=e.offsetLeft;while(e=e.offsetParent)n+=e.offsetLeft;return n;}
function echo(s)
{
document.write(s);
}

function Import(path)
{
try
{
var rs=[['js','script','javascript','src'],['css','link','css','href','rel']][path.indexOf('.js')>0?0:1];
var o=document.createElement(rs[1]);o.setAttribute('type','text/'+rs[2]);o.setAttribute(rs[3],path);
if(typeof rs[4]!='undefined') o.setAttribute(rs[4],'stylesheet');
document.getElementsByTagName('head')[0].appendChild(o);
}
catch(e)
{
iDebug(e);
}
}
if(document.addEventListener)
{
document.addEventListener('DOMContentLoaded',_init_Pub,false);
}
else
{
setTimeout(_init_init,1000);
}

function _init_init()
{
if(document.readyState!='complete')
{
setTimeout(_init_init,1000);return;
}
else
{
_init_Pub();
}
}

function getHistory()
{
var s='';
try
{
s=parent.__frmLeft('History6').value;
if(s.length<10)
{
s=getCookie('History6');
}
}
catch(e)
{
}
return s;
}
function AdminsMenuInit(f)
{
if(f)
{
var o=document.createElement('div');
o.innerHTML='<div id="__div5Admins" style="z-index:1876;position:absolute;color:#999900;background:#fff;border:1px solid #cdcdcd;padding:3px;display:none;"><div id="__div9Admins"></div>+$(AdminsMenu).innerHTML+</div>';
document.body.appendChild(o);
document.oncontextmenu=function(e)
{var x;if(isMF){x=e.target;}else{e=window.event;x=e.srcElement;}if(x.tagName.toLowerCase()!='a'){return true;}var o=$('__div5Admins');o.style.display='block';o.style.top=e.clientY+'px';o.style.left=e.clientX+'px';$('__div9Admins').innerHTML=x.getAttribute('href')+'<br>'+x.innerHTML;return false;};
document.body.onclick=function()
{
$('__div5Admins').style.display='none';
};
}
else
{
document.oncontextmenu=null;
document.body.onclick=null;
}
}

/**
* <Input>
*/
var _init_Pub_flag=false;
function _init_Pub()
{
if(_init_Pub_flag) return;
try
{
winHeight=document.body.clientHeight;
winWidth=document.body.clientWidth;	
_init_Tips();
_init_Input();
_init_HiddenFrame();
_init_Pub_flag=true;
getCSS4U();
if(typeof(_init_self)=='function') _init_self();		
}
catch(e)
{
setTimeout(_init_Pub,1000);
}
}

function _init_Input()
{
var s,o=document.forms;	
for(var i=0;i<o.length;i++)
{
var oo=o[i];
for(var j=0;j<oo.length;j++)
{
InputOne(oo[j]);
}
}	
}
function InputOne(o)
{
try
{
s=o.getAttribute('type').toLowerCase();
if(s=='text' || s=='password' || s=='textarea')
{
o.onfocus=function(){InputFocus(this,1);};
o.onblur=function(){InputFocus(this,0);};
}
else if(s=='radio' || s=='checkbox')
{
o.setAttribute('hideFocus','true');
/**
* o.style.outlineWidth='0';
*/
}
}
catch(e)
{
}
}
function InputFocus(o,f)
{
if(o.tagName.toLowerCase()=='textarea')
{
o.style.backgroundColor=f?'#e9e9e9':'#fff';
}
else
{
o.style.backgroundColor=f?'#ae3':'#fff';
}
if(f)
{
o.select();
}
}

/**
* </Input>
*/

function _init_HiddenFrame()
{
var o=document.createElement('iframe');
o.setAttribute('id','_hidden');
o.setAttribute('name','_hidden');
o.setAttribute('src','images/_blank.gif');
o.style.cssText='width:0px;height:0px;display:none;';
document.body.appendChild(o);
}

/**
* <Tips>
*/

function _init_Tips()
{
var s,rs=document.getElementsByTagName('a');
for(var i=0;i<rs.length;i++)
{
s=rs[i].getAttribute('title');
if(s)
{
rs[i].onmouseover=function(e){TipShow(this,e);};
rs[i].onmouseout=function(){TipHidn();};
rs[i].setAttribute('tip',s);
rs[i].setAttribute('title','');
}
}
var o=document.createElement('div');
o.innerHTML='<div id="__divTips" style="z-index:876;position:absolute;color:#999900;background:#fff;border:1px solid #cdcdcd;padding:3px;display:none;"></div>';
document.body.appendChild(o);
}
function TipShow(oT,e)
{
var s=oT.getAttribute('tip');
var o=document.getElementById('__divTips');
o.innerHTML=s;
o.style.display='block';
var dW=o.offsetWidth;
var x=isMF?e.pageX:event.clientX;if(x>winWidth-dW) x-=dW;
var y=isMF?e.pageY:event.clientY;
var h=isMF?0:document.documentElement.scrollTop;
o.style.left=(20+x).toString()+'px';
o.style.top=(10+y+h).toString()+'px';
o.style.display='block';
}

function TipHidn()
{
var o=document.getElementById('__divTips');
o.style.display='none';
}

/**
* </Tips>
*/

function winSwitch(f)
{
parent.winHidden(f);
}
function PageJump(max,now,len,url)
{
var s='';
var begin=(now>len/2)?ParseInt(now-len/2):1;
var end=begin+len;if(end>max) end=max;
for(var i=begin;i<=end;i++)
{
s+='<a '+((i==now)?'class="no"':('href="'+url.replace('{p}',i)+'" onclick="parent.BoardLoad()"'))+'>第'+i+'页</a>';
}
return s;
}

/**
* <Login>
*/

function isLogin(s)
{
var f=(getUserRS()=='')?false:true;
if(!f&&s!='1')
{
(s.length>1)?alert(s):LoginExpired(1);
}
return f;
}

function LoginExpired(f)
{
if(f)
{
setCookie('ForumUserInfo','0',0);
window.open('/Beta1/html/top.htm','frmTop');
}
alert('对不起:您请求的服务仅限注册用户使用,可能您的登录已过期 \n\n\n\t   ↑您可以从本页顶部登录!\n\n');
}

function LoginChk()
{
var o=__frmTop('UserStats');if(o==null) return;if(o.innerHTML.indexOf('退出')>0) return true;
if(!getUserRS()) return false;
LoginStatus();
}

function ChangePic()
{
return;
__frmTop('tdRand').style.display='block';
__frmTop('tdRands').innerHTML='<img src="/pub/validity?'+Math.random().toString().substr(2)+'" class="vPic" onClick="this.src=this.src;">';
__frmTop('randPass').value='';
}

function Login(n)
{
var s='';
switch(n)
{
case '1': s="对不起,您的用户名不在许可的范围内!";break;		
case '2': s="对不起,您的用户名与密码不匹配!";		break;
case '3': s="对不起,没有找到您的相关记录!";			break;
case '4': s="对不起,验证码丢失!";								break;
case '5': s="对不起,您的操作过于频繁,请几分钟后再试!";	break;
default:
setUserInfo();
alert('您好,欢迎登录GameCH网站!');
return LoginStatus();
}
alert(s);
ChangePic();
}
function getUserRS(){try{var nfo,uid,rs;uid=ParseInt(getCookie('ForumUserID'));nfo=getCookie('ForumUserInf0');if(!uid||nfo.length<10) return '';setCookie('ForumUserID',uid,60);rs=nfo.split('.,');return rs[1]==uid?rs:'';}catch(e){return '';}}
var logUserInfo='';setUserInfo();function setUserInfo()
{

try
{
var nfo,uid,rs,s='';
uid=getCookie('ForumUserID');
nfo=getCookie('ForumUserInf0');if(!uid||nfo.length<10) return;
setCookie('ForumUserID',uid,60);rs=nfo.split('.,');if(rs[1]!=uid) return;
node=['','ID','Name','Nick','Sex','Exp','Level','Pos','Money','Topics','Ico','Sign','Code'];	
for(i=1;i<node.length;i++)	{s+='"'+node[i]+'":rs['+i+'],'}
eval('logUserInfo={'+s+'Levelco:"'+(rs[6].length>1?'0':'00')+'"+rs[6]};');
}
catch(e)
{
return;
}
}
function LoginStatus()
{
try
{
if(!logUserInfo) return;
s=' &nbsp;'+logUserInfo.Nick+'&nbsp;<img src="http://bbs.gamech.com.cn/images/icon/image'+logUserInfo.Levelco+'.gif"> '+logUserInfo.Pos+'&nbsp;<img src="http://www.gamech.com.cn/pub/images/money.gif">&nbsp;'+logUserInfo.Money+' &nbsp; <span id="sms57" onclick="window.open(\'http://www.gamech.com.cn/?SMS/List.htm\')"><img src="http://www.gamech.com.cn/Beta3/images/pp/img_Wz.png" alt="" />&nbsp;0 条未读信息</span>&nbsp; <a href="http://www.gamech.com.cn/?Passport/My.htm" target="_blank">我的资料</a> &nbsp; <span class="a" onclick="Logout()">退出</span>';
parent.__frmTop('UserStats').innerHTML=s;
parent.frmMain.location.href=parent.frmMain.location.href;
Import('http://www.gamech.com.cn/upload/sms/'+Xcut(logUserInfo.ID)+'.js?'+Math.random().toString().substr(2));
}
catch(e)
{
}
}
function smsAlert(s)
{
n=ParseInt(s+'');
if(n>0)
{
parent.__frmTop('sms57').innerHTML='<img src="http://www.gamech.com.cn/Beta3/images/pp/news.gif" /><b>'+n+' 条未读信息</b>';
}
}

function avatarInit(uid,rs)
{
var i,s='',t='';if(typeof(rs)=='undefined') rs=getAvatarData();
if(typeof(avWidth)=='undefined') avWidth=140;
if(typeof(avHeight)=='undefined') avHeight=180;
for(i=0;i<rs.length;i++)
{
s+='<div id="av_layer_'+rs[i][1]+'" style="width:'+avWidth+'px; height:'+avHeight+'px; position:absolute; z-index:'+rs[i][1]+';"><img src="http://gh.gamech.com.cn/avatar/item/'+rs[i][0]+'.gif" width="'+avWidth+'px" height="'+avHeight+'px"></div>';
t+=rs[i][2]+' &nbsp; <br> &nbsp; ';
}
o=$('av_uid_'+uid);
if(o)
{
o.innerHTML='<div style="clear:both;"></div>'+s;
if(t.length>50&&typeof(TipShow)=='function')
{
o.onmouseover=function(e){TipShow(this,e);};
o.onmouseout=function(){TipHidn();};
o.setAttribute('tip',t);
o.setAttribute('title','');
}
}
o=$('tip_uid_'+uid);
if(o)
{
o.innerHTML=o.innerHTML.replace('{avatar}','<div style="clear:both;"></div>'+s);
o.innerHTML=o.innerHTML.replace('<!-- AVATAR -->','<div style="clear:both;"></div>'+s);
}
}
function Xcut(n)
{

var i,s='',t=n.toString();

for(i=0;i<t.length;i+=2)
{
s+=t.substr(i,2)+'/';
}
return s.substr(0,s.length-1);
}
function getLoginKuk()
{
return getUserRS();
}

function getNick()
{
return logUserInfo?logUserInfo.Nick:'';
}

function getUID()
{
return logUserInfo?ParseInt(logUserInfo.ID):0;
}

function Logout()
{
setCookie('GuildInfo2','',0);setCookie('ForumUserInfo','',0);setCookie('ForumUserInf0','',0);setCookie('ForumUserID','',0);
top.location.href='http://www.gamech.com.cn/?Passport/Logout.htm';
}

/**
* </Login>
*/

function go2(url,frm)
{
if(typeof(frm)=='undefined')
{
frm='frmData';
}
window.open(url,frm);
}
function getCSS4U()
{
Import(baseURL+'temps/s'+ParseInt(getCookie('uCSS'))+'/bbs.css');
}
var baseURL='http://bbs.gamech.com.cn/Beta1/';
var isTopFrame=(top.location==self.document.location)?true:false;
var winHeight,winWidth;
