﻿
var AjaxUrl = "ajax.aspx";

var UserId = 0;


/*
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}
*/

function getScrollTop() {
	if(window.pageYOffset)
		return window.pageYOffset;
	else if(document.documentElement&&document.documentElement.scrollTop)
		return bodyST=document.documentElement.scrollTop;
	else if(document.body)
		return bodyST=document.body.scrollTop;
}

function getScrollLeft() {
	if(window.pageXOffset)
		return window.pageXOffset;
	else if(document.documentElement&&document.documentElement.scrollLeft)
		return document.documentElement.scrollLeft;
	else if(document.body)
		return document.body.scrollLeft;
}

function getWinHeight() {
	if(window.innerHeight)
		return window.innerHeight;
	else if(document.documentElement&&document.documentElement.clientHeight)
		return document.documentElement.clientHeight; 
	else if(document.body)
		return document.body.clientHeight;
}

function getWinWidth() {
	if(window.innerWidth)
		return window.innerWidth;
	else if(document.documentElement&&document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	else if(document.body)
		return document.body.clientWidth;
}

function getPageHeight() {
	if (window.innerHeight && window.scrollMaxY)
		return window.innerHeight + window.scrollMaxY;
	else if (document.body.scrollHeight > document.body.offsetHeight)
		return document.body.scrollHeight;
	else
		return document.body.offsetHeight;
}

function setAbsCenter(objCenter) {
	objCenter.style.left = ((getWinWidth()/2)-(objCenter.offsetWidth/2)) + "px";
	objCenter.style.top = (getScrollTop() + (getWinHeight()/2)-(objCenter.offsetHeight/2)) + "px";
}

function getPosY(o, v) {
	if (!o || !o.style) return ;
	if (v) {
		o.style.top = parseInt(v) + "px";
	} else {
		return o.style.top;
	}
}

function getPosX(o, v) {
	if (!o || !o.style) return ;
	if (v) {
		o.style.left = parseInt(v) + "px";
	} else {
		return o.style.left;
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function atoi(s) {
	var r = parseInt(s);
	return isNaN(r) ? 0 : r;
}

function magicLocus(x1, x2) {
	x1 = atoi(x1);
	x2 = atoi(x2);
	if ((Math.abs(x1-x2))<2) {
		return x2;
	}else {
		return parseInt((x1+x2)/2);
	}
}

String.prototype.Trim = function() { 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

function isNotNull(s) {
	return ((s!=null)&&(s.Trim()!=""));
}

function HtmlEncode(str)
{
	if (str==null) {
		return "";
	}else {
		return str.replace(/&/g,"&amp;").replace(/\"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;");
	}
}

function HtmlDecode(str)
{
	if (str==null) {
		return "";
	}else {
		return str.replace(/&nbsp;/g," ").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&quot;/g,"\"").replace(/&amp;/g,"&");
	}
}

function getXByZoneId(zoneId) {
	if (zoneId%801==0) {
		return Math.floor((zoneId/801)-401);
	}else{
		return Math.floor((zoneId/801)-400);
	}
}

function getYByZoneId(zoneId) {
	if (zoneId%801==0) {
		return 400;
	}else{
		return Math.floor((zoneId%801)-401);
	}
}

function getXyByZoneId(zoneId) 
{
	return ("(" + getXByZoneId(zoneId) + "|" + getYByZoneId(zoneId) + ")");
}

function map50(zoneId,ally,people) {
	if ($("tb")) {
		if (zoneId>0) {
			$("tb").innerHTML = getMapDesc((getXByZoneId(zoneId)+25),(getYByZoneId(zoneId)+25),ally,people);
		}else{
			$("tb").innerHTML = getMapDesc();
		}
	}
}

function map5(zoneId,ally,people) {
	if ($("tb")) {
		if (zoneId>0) {
			//$("tb").innerHTML = getMapDesc((getXByZoneId(zoneId)+5),(getYByZoneId(zoneId)+5),ally,people);
			//坐标偏移在程序中完成，这边取消偏移
			$("tb").innerHTML = getMapDesc((getXByZoneId(zoneId)),(getYByZoneId(zoneId)),ally,people);
		}else{
			$("tb").innerHTML = getMapDesc();
		}
	}
}

function getTopEvent(title,date,type,point) {
	var retHtml = "";
	if (title) {
		retHtml += "<table class='f8 map_infobox_grey' cellspacing='1' cellpadding='2'>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c b' colspan='2' align='center'>" + title + "</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td width='45%' class='c s7'>时间:</td>\n";
		retHtml += "		<td class='c s7'>" + date + "</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c s7'>" + ((type==1)?"总米数":"抢得资源") + ":</td>\n";
		retHtml += "		<td class='c s7'>" + point + "</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "</table>\n";
	}else{
		retHtml += getMapDesc();
	}
	
	if ($("tb")) {
		$("tb").innerHTML = retHtml;
	}
	
}

function getMapDesc(xId,yId,ally,people) {
	var retHtml = "";
	if (xId!=null) {
		retHtml += "<table class='f8 map_infobox_grey' cellspacing='1' cellpadding='2'>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c b' colspan='2' align='center'>(" + xId + "|" + yId + ")</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td width='45%' class='c s7'>区域人口:</td>\n";
		retHtml += "		<td class='c s7'>" + people + "</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c s7'>最强联盟:</td>\n";
		retHtml += "		<td class='c s7'>" + ((ally)?ally:"-") + "</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "</table>\n";
	}else{
		retHtml += "<table class='f8 map_infobox_grey' cellspacing='1' cellpadding='2'>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c b' colspan='2' align='center'>详情:</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td width='45%' class='c s7'>区域人口:</td>\n";
		retHtml += "		<td class='c s7'>0</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "	<tr>\n";
		retHtml += "		<td class='c s7'>最强联盟:</td>\n";
		retHtml += "		<td class='c s7'>-</td>\n";
		retHtml += "	</tr>\n";
		retHtml += "</table>\n";
	}
	return retHtml;
}

function map1(typeId, xId, yId) {
	if (typeId==0) {
		map('','','','',xId,yId);
	}else{
		x_y(xId, yId);
		
		var retHtml = "";
		var tempHtml = "";
		switch (typeId) {
			case 1: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/4.gif\" />+50%";
				break;
			}
			case 2: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/1.gif\" />+50%";
				break;
			}
			case 3: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/3.gif\" />+50%";
				break;
			}
			case 4: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/2.gif\" />+50%";
				break;
			}
			case 5: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/2.gif\" />+25% <img src=\"" + ImgPath + "img/un/r/4.gif\" />+25%";
				break;
			}
			case 6: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/3.gif\" />+25% <img src=\"" + ImgPath + "img/un/r/4.gif\" />+25%";
				break;
			}
			case 7: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/1.gif\" />+25% <img src=\"" + ImgPath + "img/un/r/4.gif\" />+25%";
				break;
			}
			case 8: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/1.gif\" />+25%";
				break;
			}
			case 9: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/3.gif\" />+25%";
				break;
			}
			case 10: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/2.gif\" />+25%";
				break;
			}
			case 11: {
				tempHtml += "<img src=\"" + ImgPath + "img/un/r/4.gif\" />+25%";
				break;
			}
			case 22: {
				tempHtml += "1<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 1<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 1<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 15<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			case 23: {
				tempHtml += "3<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 3<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 3<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 9<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			case 24: {
				tempHtml += "5<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 3<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 4<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 6<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			case 28: {
				tempHtml += "4<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 4<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 4<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 6<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			case 29: {
				tempHtml += "3<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 4<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 5<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 6<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			case 30: {
				tempHtml += "4<img src=\"" + ImgPath + "img/un/r/1.gif\" /> 5<img src=\"" + ImgPath + "img/un/r/2.gif\" /> 3<img src=\"" + ImgPath + "img/un/r/3.gif\" /> 6<img src=\"" + ImgPath + "img/un/r/4.gif\" />";
				break;
			}
			default: {
				break;
			}
		}
		
		if (tempHtml) {
			retHtml += "					<TABLE class=\"f8 map_infobox_grey\" cellSpacing=\"1\" cellPadding=\"2\">\n";
			retHtml += "						<TBODY>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c b\" align=\"center\" colSpan=\"2\"></A><//A>详情:</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\" width=\"45%\">玩家:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\">居民:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\">联盟:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"\" align=\"center\" colspan=\"2\">" + tempHtml + "</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "						</TBODY>\n";
			retHtml += "					</TABLE>\n";
		} else {
			retHtml += "					<TABLE class=\"f8 map_infobox_grey\" cellSpacing=\"1\" cellPadding=\"2\">\n";
			retHtml += "						<TBODY>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c b\" align=\"center\" colSpan=\"2\"></A><//A>详情:</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\" width=\"45%\">玩家:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\">居民:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "							<TR>\n";
			retHtml += "								<TD class=\"c s7\">联盟:</TD>\n";
			retHtml += "								<TD class=\"c s7\">-</TD>\n";
			retHtml += "							</TR>\n";
			retHtml += "						</TBODY>\n";
			retHtml += "					</TABLE>\n";
		}
		
		if ($("tb")) {
			$("tb").innerHTML = retHtml;
		}
	}
}

function SubmitConfirm(memo) {
	if (confirm(memo)==true) {
		return true;
	} else {
		return false;
	}
}

var indexString = null;

function indexChange() {
	var ddObj1 = $("ddLeft");
	var ddObj2 = $("ddRight");
	if ((ddObj1)&&(ddObj2)) {
		indexString = "";
		for (var i=0; i<ddObj1.childNodes.length; i++) {
			if (i>0) {
				indexString += ";";
			}
			indexString += ddObj1.childNodes[i].id.replace("ap_","");
			indexString += ",";
			indexString += (ddObj1.childNodes[i].hasClassName("hide"))?"1":"0";
		}
		indexString += "|";
		for (var i=0; i<ddObj2.childNodes.length; i++) {
			if (i>0) {
				indexString += ";";
			}
			indexString += ddObj2.childNodes[i].id.replace("ap_","");
			indexString += ",";
			indexString += (ddObj2.childNodes[i].hasClassName("hide"))?"1":"0";
		}
		showDdTop("<span id=\"ddTop_AS_Info\"></span><input id=\"ddTop_AS_Submit\" type=\"image\" value=\"保存修改\" src=\"" + ImgPath + "img/cn/b/s1.gif\" onclick=\"indexUpdate();\" />");
		
	} else {
		indexString = null;
	}
}

function indexUpdate() {
	if (indexString) {
		$("ddTop_AS_Submit").disable = true;
		var option={
			parameters:"?action=chat&op=apsave&is=" + indexString + "&rd=" + Math.random(),
			method:"get",
			onSuccess:function(transport){
				AlertShow("保存成功。",500);
			},
			onFailure:function(transport){ }
		}
		var request=new Ajax.Request(AjaxUrl, option)
		hideDdTop();
		indexString = null;
	}
}

function showDdTop(s) {
	var obj = $("ddTop");
	if (obj) {
		obj.innerHTML = s;
		obj.style.display = "";
	}
}

function hideDdTop() {
	var obj = $("ddTop");
	if (obj) {
		obj.innerHTML = "";
		obj.style.display = "none";
	}
}

/*

var OpacityTimeout = null;

function hideDdTop() {
	changeOpacity("ddTop", 0, "hideDdTop");
}

function changeOpacity(objid, opacity, callback) {	var obj = $(objid);	clearTimeout(OpacityTimeout);	if (obj) {		var opacityNow = getOpacity(obj);		if (opacityNow==0) {			obj.style.display = "none";			setOpacity(obj, 100);		} else if (opacityNow>opacity) {			setOpacity(obj, Math.min((opacityNow+10),opacity));			OpacityTimeout = setTimeout(callback, 100);		} else if (opacityNow<opacity) {			setOpacity(obj, Math.min((opacityNow+10),opacity));			OpacityTimeout = setTimeout(callback, 100);		}	}}function getOpacity(obj) {	return (obj.style.opacity * 100);}
function setOpacity(obj, opacity) {	if (obj) {		obj.style.opacity = opacity / 100;		obj.style.filter = "Alpha(Opacity="+ opacity +")";	}}*/
function questionSend() {
	var Messenger = $("questionMsgInput").value;
	
	if (Messenger) {
		var option={
			parameters:"?action=hint&op=send&msg=" + encodeURIComponent(Messenger) + "&rd=" + Math.random(),
			method:"get",
			onSuccess:function(transport){
				$("questionMsgInput").value = "";
				$("questionMsgInput").focus();
			},
			onFailure:function(transport){ }
		}
		var request=new Ajax.Request(AjaxUrl, option)
	}else{
		$("questionMsgInput").focus();
	}
}

function ChatSend() {
	var ToUserId = $("ChatSelectUser").value;
	var Color = $("ChatColor").value;
	var ChatType = ($("ChatType").value=="公") ? 0 : 1;
	var Messenger = $("ChatMsgInput").value;
	
	if (Messenger) {
		var option={
			parameters:"?action=chat&op=send&ct=" + ChatType + "&cl=" + Color + "&ti=" + ToUserId + "&msg=" + encodeURIComponent(Messenger) + "&rd=" + Math.random(),
			method:"get",
			onSuccess:function(transport){
				$("ChatMsgInput").value = "";
				$("ChatMsgInput").focus();
			},
			onFailure:function(transport){ }
		}
		var request=new Ajax.Request(AjaxUrl, option)
	}else{
		$("ChatMsgInput").focus();
	}
}

var ChatJson = [
	{ "ty":9, "fi":"0", "fn":"系统", "ti":"0", "tn":"所有人", "cl":"0", "msg":"欢迎来到WEBATTLE联盟聊天室。","st":(new Date()) }
]

var hintJson = [
	{ "ty":9, "fi":"0", "fn":"系统", "ti":"0", "tn":"所有人", "cl":"0", "msg":"欢迎进入百晓生点评天下。","st":(new Date()) }
]

var ChatTimeout = null;
var hintTimeout = null;

function getChatJson() {
	var prm = "";
	if (ChatTimeout==null) {
		prm = "?action=chat&op=get&ga=1&rd=" + Math.random();
	} else {
		prm = "?action=chat&op=get&rd=" + Math.random();
	}
	var option={
		parameters:prm,
		method:"get",
		onSuccess:function(json){
			ChatTimeout = setTimeout(getChatJson,1000);
			if (ChatJson.length>0) {
				ChatView();
			}
			ChatJson = eval("(" + json.responseText + ")");
			ChatView();
		},
		onFailure:function(json){
			ChatTimeout = setTimeout(getChatJson,1000);
		}
	}
	var request=new Ajax.Request(AjaxUrl, option)
}

function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
				var _result = document.cookie.substring(c_start,c_end);
				return decodeURIComponent(_result);
			} 
	}
	return null
}

function setCookie(c_name,value,expiredays){
	value = encodeURIComponent(value);
	var exdate=new Date();
	exdate.setTime(exdate.getTime()+(expiredays*24*3600*1000))
	document.cookie=c_name+ "=" +value+";path=/"+((expiredays==null)?"":";expires="+exdate.toGMTString());
}

var AlertTimeout = null;
var AlertOpacity = 100;

function AlertShow(s,t) {
	clearTimeout(AlertTimeout);
	var obj = $("alert");
	if (obj) {
		AlertOpacity = 100;
		setOpacity(obj, AlertOpacity);
		$("alertcontent").innerHTML = s;
		obj.style.display = "";
		setAbsCenter(obj);
		AlertTimeout = setTimeout("AlertHide()",t);
	}
}

function AlertHide() {
	var obj = $("alert");
	if (obj) {
		AlertOpacity = AlertOpacity - 5;
		if (AlertOpacity > 4) {
			setOpacity(obj,AlertOpacity);
			AlertTimeout = setTimeout("AlertHide()",30);
		} else {
			AlertOpacity = 0;
			obj.style.display = "none";
		}
	}
}

function setOpacity(obj, opacity) {
	if (obj) {
		obj.style.opacity = opacity / 100;
		obj.style.filter = "Alpha(Opacity="+ opacity +")";
	}
}

function AvatarSelect(id) {
	var obj = document.getElementById("avatardemo");
	if (obj) {
		obj.src = "images/avatar/avatar_u" + id + ".gif"
	}
}

function ClipShow(objid,nw,nh)
{
	var showObj = $(objid);
	if (nw==null) {
		nw = 0;
		nh = 0;
	}
	var sw = Math.min( (showObj.offsetWidth) , (nw+15) );
	var sh = Math.min( (showObj.offsetHeight) , (nh+15) );
	showObj.style.clip = "rect(0px " + sw + "px " + sh + "px 0px)";
	if (showObj.style.display=="none") {
		showObj.style.display = "";
	}
	if ((sw!=(showObj.offsetWidth))||(sh!=(showObj.offsetHeight))) {
		setTimeout("clipShow(\"" + objid + "\"," + sw + "," + sh + ")",20);		
	}
}

function ClipHide(objid,nw) {
	var showObj = $(objid);
	if (nw==null) {
		nw = 0;
	}
	var sw = Math.min( (showObj.offsetWidth) , (nw+15) );
	showObj.style.clip = "rect(0px " + showObj.offsetWidth + "px " + showObj.offsetHeight + "px " + sw + "px)";
	if (sw!=showObj.offsetWidth) {
		setTimeout("clipHide(\"" + objid + "\"," + sw + ")",20);		
	} else {
		showObj.style.display = "none";
	}
}

function OpacityShow(objid, op) {
	var obj = $(objid);
	if (obj) {
		if (op==null) {
			op = 0;
		}
		op += 20;
		if (op > 100) {
			setOpacity(obj, 100);
			obj.style.display = "";
		}else{
			setOpacity(obj, op);
			obj.style.display = "";
			setTimeout("OpacityShow('" + objid + "'," + op + ")",10);
		}
	}
}

function OpacityHide(objid, op) {
	var obj = $(objid);
	if (obj) {
		if (op==null) {
			op = 100;
		}
		op -= 20;
		if (op > 0) {
			setOpacity(obj, op);
			setTimeout("OpacityHide('" + objid + "'," + op + ")",10);
		}else{
			obj.style.display = "none";
			setOpacity(obj, 100);
		}		
	}
}

function LightBoxOpen(html) {
	var objOverlay = $("LB_Overlay");
	var objLightbox = $("LB_Content");
	if ((!objOverlay)||(!objLightbox)) {
		LightBoxInit();
		objOverlay = $("LB_Overlay");
		objLightbox = $("LB_Content");
	}
	objOverlay.style.width = getWinWidth() + "px";
	objOverlay.style.height = Math.max(getWinHeight(),getPageHeight()) + "px";
	objOverlay.style.display = "";
	objLightbox.innerHTML = html;
	OpacityShow("LB_Content");
	setAbsCenter(objLightbox);
}

function LightBoxClose() {
	OpacityHide("LB_Content");
	$("LB_Content").innerHTML = "";
	$("LB_Overlay").style.display = "none";
}

function LightBoxInit() {
	var bodyobj = document.getElementsByTagName("BODY").item(0);
	if (bodyobj) {
		var c = document.createElement("DIV");
		c.id = "LB_Content";
		var o = document.createElement("DIV");
		o.id = "LB_Overlay";
		bodyobj.appendChild(o);
		bodyobj.appendChild(c);
	}
}

function CopyToClipBoard() {
    var clipBoardContent='';
    try{
		if (arguments[0]){
			clipBoardContent = arguments[0];
		}
		window.clipboardData.setData("Text",clipBoardContent);
		AlertShow("已经拷贝到剪贴板.",1000);
	}catch(error){
		alert(error,"系统错误");
	}
}

function imgResize(_obj) {
	var _width = 100;
	var _height = 100;
	if (arguments[1]){
		if (typeof(arguments[1])=="number"){
			_width = arguments[1];
			if (arguments[2]){
				if (typeof(arguments[2])=="number"){
					_height = arguments[2];
				} else {
					_height = arguments[1];
				}
			} else {
				_height = arguments[1];
			}
		}
	}
	if ( _obj.width > _width || _obj.height > _height ){
		var scale = _obj.width / _obj.height ;
		var _scale = _width / _height;
		if ( scale >= _scale ){
			_obj.width = _width ;
			_obj.height = _obj.width / scale ;
		} else {
			_obj.height = _height ;
			_obj.width = _obj.height * scale ;
		}
	}
}

var WbGameServer = {
    id: null,
    severs: {
        '1': 'http://s1.webattle.cn/dologingame.aspx?',
        '2': 'http://s2.webattle.cn/dologingame.aspx?',
        '3': 'http://t1.webattle.cn/dologingame.aspx?',
        '4': 'http://s3.webattle.cn/dologingame.aspx?',
        '5': 'http://s1.mayawar.com/dologingame.aspx?',
        '6': 'http://webattle.13gm.com/dologingame.aspx?',
        '7': 'http://s1.176616.com/dologingame.aspx?',
        '8': 'http://s5.webattle.cn/dologingame.aspx?'
    },
    WbLoginGame: function (id) {
        WbGameServer.id = id;
        var params = "oper=wblogingame&par=" + id;
        new Ajax.Request("member/control.aspx",
        {
            method: 'get', 
            parameters: params,
            evalJSON : true,
            onSuccess: WbGameServer.DoWbLoginGame.bind(this)
        });
    },
    DoWbLoginGame: function (response) {
        var ret = response.responseJSON;
        if (ret.state != 0) {
            alert("请先登入");
        } else
        {
            document.location.href = WbGameServer.severs[WbGameServer.id] + ret.par;
        }
    }
};

function SelectServer() {
	var retHtml = "";
	retHtml += "<div class=\"loginbox\">";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(1);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s1);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(2);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s2);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(3);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=t1);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(4);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s3);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(5);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=maya);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(6);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=gm13);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(7);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=qm);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(8);return false;\"><img src=\"images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s5);\" alt=\"\" /></a>";
	retHtml += "	<img src=\"images/spacer.gif\" onclick=\"LightBoxClose();\" style=\"width:13px; height:13px; cursor:pointer; background: #9A0000 url(images/sclose.gif) no-repeat 0 0;\" />";
	retHtml += "</div>";
	LightBoxOpen(retHtml);
}var WbGameServer = {
    id: null,
    severs: {
        '1': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '2': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '3': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '4': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '5': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '6': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '7': 'http://test.webattle.cn:8000/dologingame.aspx?',
        '8': 'http://test.webattle.cn:8000/dologingame.aspx?'
    },
    WbLoginGame: function (id) {
        WbGameServer.id = id;
        var params = "oper=wblogingame&par=" + id;
        new Ajax.Request("control.aspx",
        {
            method: 'get', 
            parameters: params,
            evalJSON : true,
            onSuccess: WbGameServer.DoWbLoginGame.bind(this)
        });
    },
    DoWbLoginGame: function (response) {
        var ret = response.responseJSON;
        if (ret.state != 0) {
            alert("请先登入");
        } else
        {
            document.location.href = WbGameServer.severs[WbGameServer.id] + ret.par;
        }
    }
};

function SelectServer() {
	var retHtml = "";
	retHtml += "<div class=\"loginbox\">";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(1);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s1);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(2);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s2);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(3);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=t1);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(4);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s3);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(5);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=maya);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(6);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=gm13);\" alt=\"\" /></a>";
	retHtml += "	<br />";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(7);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=qm);\" alt=\"\" /></a>";
	retHtml += "	<a href=\"#\" onclick=\"javascript:WbGameServer.WbLoginGame(8);return false;\"><img src=\"wb/images/spacer.gif\" class=\"llpic\" style=\"background-image:url(server.aspx?s=s5);\" alt=\"\" /></a>";
	retHtml += "	<img src=\"wb/images/spacer.gif\" onclick=\"LightBoxClose();\" style=\"width:13px; height:13px; cursor:pointer; background: #9A0000 url(wb/images/sclose.gif) no-repeat 0 0;\" />";
	retHtml += "</div>";
	LightBoxOpen(retHtml);
}

function onScroll() {
	var floatAd_l = $("floatAd_l");
	var floatAd_r = $("floatAd_r");
	if ((floatAd_l)&&(floatAd_r)) {
		floatAd_l.style.top = (getScrollTop() + 38) + "px";
		floatAd_r.style.top = (getScrollTop() + 38) + "px";
	}
}

function onLoad() {
	window.onscroll = onScroll;
}

onLoad();


