// getElementById();
function $(element) {if (typeof element == "string") {element = document.getElementById(element);}return element;}
// 隐藏所有select
function hidehandle(){var els=document.getElementsByTagName("select");for(var i=0;i<els.length; i+=1){var objTemp = els[i];objTemp.style.display="none";}}
// 显示所有select
function showhandle(){var els=document.getElementsByTagName("select");for(var i=0;i<els.length; i+=1){var objTemp = els[i];objTemp.style.display="";}}
// 得到元素left值
function getLeft(el) {return !el ? 0 : (el.offsetLeft + getLeft(el.offsetParent));}   
// 得到元素top值
function getTop(el) {return !el ? 0 : (el.offsetTop + getTop(el.offsetParent));}
// 用,来分隔数字
function outputComma(number) {number = '' + number;if (number.length > 3){var mod = number.length%3;var output = (mod > 0 ? (number.substring(0,mod)) : '');for (i=0 ; i < Math.floor(number.length/3) ; i+=1) {if ((mod ==0) && (i ==0)){output+= number.substring(mod+3*i,mod+3*i+3);}else{output+= ',' + number.substring(mod+3*i,mod+3*i+3);}}return (output);}else{return number;}}
//单开页预览type 0:str;1:pic
function previewpage(str,type){var xx=window.open('', '预览', 'menubar=null,width=600,height=300,resizable=yes');if(type==1){str="<img src='"+str+"'/>";}xx.document.writeln(str);}
// 左上箭头提示
// example:<input type="text" id="ttttttt" onmouseover="left_up_tip(this,-100,30,'fsdfsdfsdfsdfds',200)" onmouseout="close_tip()"/>
function left_up_tip(tsrc,tleft,ttop,tstr,twidth){if($('the_up_tip')){}else{var eldiv = document.createElement("div");if (!twidth) {twidth = 320;}eldiv.id = "the_up_tip";eldiv.style.top = getTop(tsrc)+ttop+"px";eldiv.style.left = getLeft(tsrc)+tleft+"px";eldiv.style.width = twidth+"px";eldiv.style.position = "absolute";eldiv.style.zIndex = "65535";eldiv.style.marginLeft="200px";eldiv.style.fontSize="12px";eldiv.style.lineHeight="18px";tstr="<div style=\"width:"+twidth+"px; position: relative; top:1px;\"><img src=\"/gamers/style/images/tips/tip1.png\" style=\"display:block;\" /></div><div style=\"border:1px solid #999; background:#f7fae3; width:"+(twidth-10)+"px; font-size:12px; padding:8px;\">"+tstr+"</div>";eldiv.innerHTML=tstr;document.body.appendChild(eldiv);}}
// 左下箭头提示
// example:<input type="text" id="ttttttt" onmouseover="left_down_tip(this,-200,-58,'fsdfsdfsdfsdfds',200)" onmouseout="close_tip()"/>
function left_down_tip(tsrc,tleft,ttop,tstr,twidth){if($('the_up_tip')){}else{var eldiv = document.createElement("div");if (!twidth) {twidth = 320;}eldiv.id = "the_up_tip";eldiv.style.top = getTop(tsrc)+ttop+"px";eldiv.style.left = getLeft(tsrc)+tleft+"px";eldiv.style.width = twidth+"px";eldiv.style.position = "absolute";eldiv.style.zIndex = "65535";eldiv.style.marginLeft="200px";eldiv.style.fontSize="12px";eldiv.style.lineHeight="18px";tstr="<div style=\"border:1px solid #999; background:#f7fae3; width:"+(twidth-10)+"px; font-size:12px; padding:8px;\">"+tstr+"</div><div style=\"width:"+twidth+"px; position: relative; top:-1px\"><img src=\"/gamers/style/images/tips/tip2.png\" style=\"display:block;\" /></div>";eldiv.innerHTML=tstr;document.body.appendChild(eldiv);}}
// 关闭提示
function close_tip(){try{document.body.removeChild($('the_up_tip'));}catch(e){}}
// 得到cookie
function getCookie(str) {var strCookie = document.cookie;var arrCookie = strCookie.split("; ");var thevalue = "";for (var i = 0; i < arrCookie.length; i += 1) {var arr = arrCookie[i].split("=");if (str==arr[0]) {thevalue = arr[1];break;}}return thevalue;}
// 设置cookie
function setCookie(cookiename, cookievalue, cookieage) {if (!cookieage) {cookieage = 60 * 60 * 24 * 365;}var the_date = new Date("December 31, 9999");var expiresDate = the_date.toGMTString();var tempstr = cookiename + "=" + cookievalue + "; max-age=" + cookieage+";expires="+expiresDate;document.cookie = tempstr;}
// 默认红叉图
var default_rc_pic='';
//<body onload="handlepic('默认图地址')">
function handlepic(rc_pic){if(rc_pic!=null && rc_pic!=''){default_rc_pic=rc_pic;}try {var imgObjs=document.getElementsByTagName("img");for (var i = 0; imgObjs.length; i++) {var curObj = imgObjs[i];if (curObj.complete == false) {reloadPic(curObj);}}}catch (e) {}}
function reloadPic(imgObj) {imgObj.src = default_rc_pic;}
// 单开新页显示图片
function openPic() {window.open(this.src, "", "");}
//通用图片处理大小，按宽度等比例缩小,type：不写是按宽度，高度；1：宽度；2：高度
function pic_resizer(picname,picwidth,picheight,type){
	var pic_name=picname;
	var pic_width=picwidth;
	var pic_height=picheight;
	var vtype=null;
	if(type){
		vtype=type;
	}
	var elpics=null;
	if(pic_name){
		elpics=document.getElementsByName(pic_name);
	}else{
		elpics=document.getElementsByTagName("img");
	}
	for(var i=0;i<elpics.length;i++){
		elpics[i].onload=function (){
			if(vtype){
				if(vtype==1 && this.width>pic_width){
					this.height=this.height*pic_width/this.width;
					this.width=pic_width;
					this.style.cursor='pointer';
					this.onclick=openPic;
					this.style.display='block';
				}
				if(vtype==2 && this.height>pic_height){
					this.width=this.width*pic_height/this.height;
					this.height=pic_height;
					this.style.cursor='pointer';
					this.onclick=openPic;
					this.style.display='block';
				}
			}else{
				if(this.width>pic_width || this.height>pic_height){
					var rate1=this.width/pic_width;
					var rate2=this.height/pic_height;
					if(rate1>rate2){
						this.height=this.height*pic_width/this.width;
						this.width=pic_width;
						this.style.cursor='pointer';
						this.onclick=openPic;
						this.style.display='block';
					}else{
						this.width=this.width*pic_height/this.height;
						this.height=pic_height;
						this.style.cursor='pointer';
						this.onclick=openPic;
						this.style.display='block';
					}
				}
			}
		};
	}
}


/*检查输入字符串是否为空*/
function isEmpty(inputString) {/*字符串长度为0，则字符串为空*/if ((inputString == null) || (inputString.length == 0)) {return true;}if(inputString=='<br/>'){return true;}/*字符串中有一个不是空格，则字符串不为空*/for (i = 0; i < inputString.length; i++) {if (inputString.charAt(i) != " ") {return false;}}/*字符串中全是空格，则字符串是空*/return true;}
/*检查是否为数字*/
function isDigit(obj){var patrn = /^[\d-]{1,50}$/;if (!patrn.exec(obj)) {return false;}return true;}
/*检验是不是日期*/
function isDate(str){var patrn = /\d{4}-{1}\d{1,2}-{1}\d{1,2}$/;if (!patrn.exec(str)) {return false;}return true;}

//底下为ajax调用
//var loader1=new net.ContentLoader(url,ajaxlogincallback,onerrors,"POST",strParams);
var net=new Object();net.READY_STATE_UNINITIALIZED=0;net.READY_STATE_LOADING=1;net.READY_STATE_LOADED=2;net.READY_STATE_INTERACTIVE=3;net.READY_STATE_COMPLETE=4;
//多浏览器适应
net.ContentLoader=function(url,onload,onerror,method,params,contentType){this.req=null;this.onload=onload;this.onerror=(onerror) ? onerror : this.defaultError;this.loadXMLDoc(url,method,params,contentType);}
net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){if (!method){method="GET";}if (!contentType && method=="POST"){contentType='application/x-www-form-urlencoded';}if (window.XMLHttpRequest){this.req=new XMLHttpRequest();}else if (window.ActiveXObject){this.req=new ActiveXObject("Microsoft.XMLHTTP");}if (this.req){try{var loader=this;this.req.onreadystatechange=function(){net.ContentLoader.onReadyState.call(loader);}
	this.req.open(method,url,true);if (contentType){this.req.setRequestHeader('Content-Type', contentType);}this.req.send(params);}catch (err){this.onerror.call(this);}}}
net.ContentLoader.onReadyState=function(){var req=this.req;var ready=req.readyState;if (ready==net.READY_STATE_COMPLETE){var httpStatus=req.status;if (httpStatus==200 || httpStatus==0){this.onload.call(this);}else{this.onerror.call(this);}}}
net.ContentLoader.prototype.defaultError=function(){alert("error fetching data!"+"\n\nreadyState:"+this.req.readyState+"\nstatus: "+this.req.status+"\nheaders: "+this.req.getAllResponseHeaders());}
function onerrors(){}
// 跳转页面
function goto_page(str,value){window.location=str+value;}
var theshowerrormsgopacity = 0;	// 透明度
// 使用方法：确定按钮问文字，内容，type,回调函数（如果没有的话传null）
//type  1:出错信息 2:普通信息
// exp1:msgwindow.showmsg('确定','我艹',1,null);
// exp2:msgwindow.showmsg('确定','我艹',1,,tf);
// exp3:$debug('test');
var msgwindow=function(){
	this.theshowerrormsgopacity=0;
	this.callback=null;
};
// 创建显示div
msgwindow.showmsg=function(title, content, type, callback) {
	if($('theshowerrormsg')){
	}else{
	hidehandle();
	var eldiv = document.createElement("div");
	eldiv.id = "theshowerrormsg";
	eldiv.style.backgroundColor = "#3c628f";
	eldiv.style.top = 0;
	eldiv.style.left = 0;
	var wwidth=document.documentElement.scrollWidth;
	var hheight=document.documentElement.scrollHeight;
	try{
		if(document.documentElement.clientWidth>=wwidth){
			wwidth=document.documentElement.clientWidth;
		}
		if(document.documentElement.clientHeight>=hheight){
			hheight=document.documentElement.clientHeight;
		}
	}catch(e){};
	eldiv.style.width = wwidth+"px";
	eldiv.style.height = hheight+"px";
	eldiv.style.position = "absolute";
	eldiv.style.display = "";
	eldiv.style.zIndex = "65534";
	var str = "";
	if (callback) {
		str = "<button onclick=\"msgwindow.removeerrormsg(true)\">确定</button>";
		msgwindow.callback=callback;
	}
	var errorstr = "";
	switch(type){
	case 1:errorstr = "		<div class='ti' style=\"top:" + (210+document.documentElement.scrollTop) + "px;left:" + ((document.documentElement.scrollWidth - 307) / 2) + "px;z-index:65535;position:absolute\" onmouseup='upDrag()' class='dragAble' onmousedown='initDrag(event)'><div class='ti1'><img src='/_style/images/t3_03.gif' /></div><div class='ti2'>提示<br />" + content + "	<br /><a href='javascript:void(0);' onclick=\"msgwindow.removeerrormsg(false)\"><img src='/_style/images/c3.gif' /></a>				</div>		</div>";break;
	case 2:errorstr = "		<div class='ti' style=\"top:" + (210+document.documentElement.scrollTop) + "px;left:" + ((document.documentElement.scrollWidth - 307) / 2) + "px;z-index:65535;position:absolute\" onmouseup='upDrag()' class='dragAble' onmousedown='initDrag(event)'><div class='ti1'><img src='/_style/images/t_06.gif' /></div><div class='ti2'>提示<br />" + content + "<br /><a href='javascript:void(0);' onclick=\"msgwindow.removeerrormsg(false)\"><img src='/_style/images/c3.gif' /></a>				</div>		</div>";break;
	default:errorstr = "		<div class='ti' style=\"top:" + (210+document.documentElement.scrollTop) + "px;left:" + ((document.documentElement.scrollWidth - 307) / 2) + "px;z-index:65535;position:absolute\" onmouseup='upDrag()' class='dragAble' onmousedown='initDrag(event)'><div class='ti1'><img src='/_style/images/t_09.gif' /></div><div class='ti2'>提示<br />" + content + "<br /><a href='javascript:void(0);' onclick=\"msgwindow.removeerrormsg(false)\"><img src='/_style/images/c3.gif' /></a>				</div>		</div>";break;
	}
	eldiv.innerHTML = errorstr;
	eldiv.style.filter = "alpha(Opacity=0)";
	eldiv.style.opacity = "0";
	document.body.appendChild(eldiv);
	eldiv.timer = window.setInterval(this.displaytheshowerrormsg, 150);
	}
}
// 移除
msgwindow.removeerrormsg=function(temp) {
	var el = $("theshowerrormsg");
	if (temp) {
		this.callback.call();
	}
	el.timer = window.setInterval(this.disappeartheshowerrormsg, 150);
}
// 渐显
msgwindow.displaytheshowerrormsg=function() {
	var eldiv = $("theshowerrormsg");
	this.theshowerrormsgopacity += 26;
	if (this.theshowerrormsgopacity >= 98) {
		window.clearInterval(eldiv.timer);
	} else {
		eldiv.style.opacity = "0." + this.theshowerrormsgopacity;
		eldiv.style.filter = "alpha(Opacity=" + this.theshowerrormsgopacity + ")";
	}
}
// 渐隐
msgwindow.disappeartheshowerrormsg=function() {
	var eldiv = $("theshowerrormsg");
	this.theshowerrormsgopacity -= 45;
	if (this.theshowerrormsgopacity <= 0) {
		window.clearInterval(eldiv.timer);
		document.body.removeChild(eldiv);
		showhandle();
	} else {
		eldiv.style.opacity = "0." + this.theshowerrormsgopacity;
		eldiv.style.filter = "alpha(Opacity=" + this.theshowerrormsgopacity + ")";
	}
}
function get_game_type_(str){var temp="";for(var i=0;i<str.length;i++){temp+=str.substring(i,i+1)+"<br/>";}document.writeln(temp);}
function fav_my_game(gameid){window.location= '/game/game.gx?id='+gameid;}
function checkclick(msg){if(confirm(msg)){try{event.returnValue=true;}catch(e){return true;}}else{try{event.returnValue=false;}catch(e){return false;}}}
function addBookmark(title,url) {if (window.sidebar) {window.sidebar.addPanel(title, url,"");} else if( document.all ) {window.external.AddFavorite( url, title);} else if( window.opera && window.print ) {return true;}}
function emptyfunc(){}
function changeValidCode(){
	elemt=$("validImg");
	var timenow = new Date().getTime();
	elemt.src="/change/getValidCode.gx?&state="+timenow;
}	