 
// ajaxClass -- XMLHttp Object Pool and XMLHttp chunnel Pool
// == written by Apple <zysp322@gmail.com> ===
// == Copyright (C) 2006 Apple Blog - http://www.applelife.cn ==
 
var Request = new function(){

this.pool = new Array();

this.getXMLHttp = function (chunnel)
{
	
 if(chunnel != null)
 {
  for (var a = 0; a < this.pool.length; a++)
  {
   if(this.pool[a]["chunnel"] == chunnel)
   {
	if(this.pool[a]["obj"].readyState == 0 || this.pool[a]["obj"].readyState == 4)
    {
     return this.pool[a]["obj"];
    }
	else 
	{
      return "busy";
	}
   }
  }
  
  this.pool[this.pool.length] = new Array();
  this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
  this.pool[this.pool.length - 1]["chunnel"] = chunnel;
  return this.pool[this.pool.length - 1]["obj"];
 
 }
	
 for (var i = 0; i < this.pool.length; i++)
 {
  if (this.pool[i]["obj"].readyState == 0 || this.pool[i]["obj"].readyState == 4)
  {
   return this.pool[i]["obj"];
  }
 }
 
 this.pool[this.pool.length] = new Array();
 this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
 this.pool[this.pool.length - 1]["chunnel"] = "";
 return this.pool[this.pool.length - 1]["obj"];

}

this.createXMLHttp = function ()
{
 
 if(window.XMLHttpRequest)
 {
  var xmlObj = new XMLHttpRequest();
 } 
 else 
 {
  var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
  for(var n = 0; n < MSXML.length; n++)
  {
   try
   {
    var xmlObj = new ActiveXObject(MSXML[n]);        
    break;
   }
   catch(e)
   {
   }
  }
 } 
 
 return xmlObj;

}

this.reSend = function (url,data,callback,chunnel)
{
 var objXMLHttp = this.getXMLHttp(chunnel)
 
 if(typeof(objXMLHttp) != "object")
 {
   return ;
 }
 
 url += (url.indexOf("?") >= 0) ? "&nowtime=" + new Date().getTime() : "?nowtime=" + new Date().getTime();

 if(data == "")
 {
  objXMLHttp.open('GET' , url, true);
  objXMLHttp.send('');
 }
 else 
 { 
  objXMLHttp.open('POST' , url, true);
  objXMLHttp.setRequestHeader("Content-Length",data.length); 
  objXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  objXMLHttp.send(data);
 }
 
 if(typeof(callback) == "function" )
 {
  objXMLHttp.onreadystatechange = function ()
  {
   if (objXMLHttp.readyState == 4)
   {
    if(objXMLHttp.status == 200 || objXMLHttp.status == 304)
    {
     callback(objXMLHttp) 
    }
    else
    {
     alert("Error loading page\n"+ objXMLHttp.status +":"+ objXMLHttp.statusText);
    }
   }
  }
 }

}

}

var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

var base64DecodeChars = new Array(

　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

　　-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,

　　52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,

　　-1,　0,　1,　2,　3,  4,　5,　6,　7,　8,　9, 10, 11, 12, 13, 14,

　　15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,

　　-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,

　　41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);

function base64encode(str) {

　　var out, i, len;

　　var c1, c2, c3;

　　len = str.length;

　　i = 0;

　　out = "";

　　while(i < len) {

 c1 = str.charCodeAt(i++) & 0xff;

 if(i == len)

 {

　　 out += base64EncodeChars.charAt(c1 >> 2);

　　 out += base64EncodeChars.charAt((c1 & 0x3) << 4);

　　 out += "==";

　　 break;

 }

 c2 = str.charCodeAt(i++);

 if(i == len)

 {

　　 out += base64EncodeChars.charAt(c1 >> 2);

　　 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));

　　 out += base64EncodeChars.charAt((c2 & 0xF) << 2);

　　 out += "=";

　　 break;

 }

 c3 = str.charCodeAt(i++);

 out += base64EncodeChars.charAt(c1 >> 2);

 out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));

 out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));

 out += base64EncodeChars.charAt(c3 & 0x3F);

　　}

　　return out;

}

function base64decode(str) {

　　var c1, c2, c3, c4;

　　var i, len, out;

　　len = str.length;

　　i = 0;

　　out = "";

　　while(i < len) {

 /* c1 */

 do {

　　 c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];

 } while(i < len && c1 == -1);

 if(c1 == -1)

　　 break;

 /* c2 */

 do {

　　 c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];

 } while(i < len && c2 == -1);

 if(c2 == -1)

　　 break;

 out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));

 /* c3 */

 do {

　　 c3 = str.charCodeAt(i++) & 0xff;

　　 if(c3 == 61)

　return out;

　　 c3 = base64DecodeChars[c3];

 } while(i < len && c3 == -1);

 if(c3 == -1)

　　 break;

 out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));

 /* c4 */

 do {

　　 c4 = str.charCodeAt(i++) & 0xff;

　　 if(c4 == 61)

　return out;

　　 c4 = base64DecodeChars[c4];

 } while(i < len && c4 == -1);

 if(c4 == -1)

　　 break;

 out += String.fromCharCode(((c3 & 0x03) << 6) | c4);

　　}

　　return out;

}

function utf16to8(str) {

　　var out, i, len, c;

　　out = "";

　　len = str.length;

　　for(i = 0; i < len; i++) {

 c = str.charCodeAt(i);

 if ((c >= 0x0001) && (c <= 0x007F)) {

　　 out += str.charAt(i);

 } else if (c > 0x07FF) {

　　 out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));

　　 out += String.fromCharCode(0x80 | ((c >>　6) & 0x3F));

　　 out += String.fromCharCode(0x80 | ((c >>　0) & 0x3F));

 } else {

　　 out += String.fromCharCode(0xC0 | ((c >>　6) & 0x1F));

　　 out += String.fromCharCode(0x80 | ((c >>　0) & 0x3F));

 }

　　}

　　return out;

}

function utf8to16(str) {

　　var out, i, len, c;

　　var char2, char3;

　　out = "";

　　len = str.length;

　　i = 0;

　　while(i < len) {

 c = str.charCodeAt(i++);

 switch(c >> 4)

 {

　 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:

　　 // 0xxxxxxx

　　 out += str.charAt(i-1);

　　 break;

　 case 12: case 13:

　　 // 110x xxxx　 10xx xxxx

　　 char2 = str.charCodeAt(i++);

　　 out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));

　　 break;

　 case 14:

　　 // 1110 xxxx　10xx xxxx　10xx xxxx

　　 char2 = str.charCodeAt(i++);

　　 char3 = str.charCodeAt(i++);

　　 out += String.fromCharCode(((c & 0x0F) << 12) |

　　　　((char2 & 0x3F) << 6) |

　　　　((char3 & 0x3F) << 0));

　　 break;

 }

　　}

　　return out;

}
 function GetCookie(Name)
{
	var search = Name + "="
	if(document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if(offset != -1) 
		{
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if(end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		 }
	else return ""
	  }
}
  var uname=GetCookie("MyName");

function f_frameStyleResize(targObj){
 var targWin = targObj.parent.document.all[targObj.name];
 if(targWin != null) {
  var HeightValue = targObj.document.body.scrollHeight
  if(HeightValue < 600){HeightValue = 600} 
  targWin.style.pixelHeight = HeightValue;
 }
}
function f_iframeResize(){
 bLoadComplete = true; f_frameStyleResize(self);
}
var bLoadComplete = false;
window.onload = f_iframeResize;




String.prototype.trim   =   function()   {   
      return   this.replace(/(^\s*)|(\s*$)/g,   "");   
}
if(typeof(Array.prototype.push) == "undefined") {
	Array.prototype.push = function() {
		var i;
		for (i = 0; i < arguments.length; i++) {
			this[this.length] = arguments[i];
		}
		return this.length;
	}
}

Array.prototype.remove = function(o) {
	var i = 0;
	var found = false;
	while (i < this.length) {
		if (this[i] == o) {
			found = true;
			break;
		}
		i++;
	}
	if (found) {
		while (i < (this.length - 1)) {
			this[i] = this[i + 1];
			i++;
		}
		this.length -= 1;
	}
	return this.length;
}

Array.prototype.addAll = function(arr) {
	for (var i = 0; i < arr.length; i++) {
		this[this.length] = arr[i];
	}
	return this.length;
}

function format(number, precision) {
	if (precision == null) {
		precision = 2;
	}
	var factor = Math.pow(10, precision);
	var ret = Math.round(number * factor) / factor;
	var tmp = "" + ret;
	if (precision > 0) {
		var p = tmp.lastIndexOf(".");
		if (p == -1) {
			ret += ".0";
			p = 1;
		} else {
			p = tmp.length - p - 1;
		}
		while (p < precision) {
			ret += "0";
			p++;
		}
	}
	return ret;
}

function handleError(err, url, line) {
	if (err.indexOf('focus') != -1) {
		return true;
	}
	return false; // let the browser handle the error
}

var REGION = parseInt(readCookie("Region"));
var SITES = ["", ""];
var OS = [0, 1];

function setRegion(n) {
	if (!isNaN(REGION)) {
		MM_findObj("reg" + REGION).disabled = false;
	}
	saveCookie("Region", n);
	REGION = n;
	dlgBox.style.visibility = "hidden";
}

function showFlash(u, width, height, bgcolor, ps, rate, u2) {
	if (typeof(bgcolor) == "undefined") {
		bgcolor = '';
	}
	if (typeof(rate) == "undefined") {
		rate = 0;
	}
	if (typeof(u2) == "undefined") {
		u2 = '';
	}
	new Game('', '', 0, width, height, bgcolor, u, rate, u2, ps).show();
}

function Game(gname, glabel, pre, width, height, bgcolor, u, rate, u2, ps) {
	this.gname = gname;
	this.glabel = glabel;
	this.pre = pre;
	this.width = width;
	this.height = height;
	this.bgcolor = bgcolor;
	this.u = u;
	this.rate = rate;
	this.ps = addVars(ps, "width=" + width + "&height=" + height );
	if (typeof(u2) == "undefined") {
		this.base = "";
		this.u2 = "";
		//this.ps = addVars(this.ps, "logo=logo.swf&cfg=/do/cfg&game=" + gname);
	} else {
		this.base = "";
		if (u2.length > 0) {
			this.u2 = u2;
		}
	}
}

function addVars(vars, v) {
	if (v && v.length > 0) {
		if (vars && vars.length > 0) {
			vars += "&" + v;
		} else {
			vars = v;
		}
	}
	return vars;
}

var _plug_id = 0, _bgcolor = 'FFFFFF';

function getFlash(movie, width, height, bgcolor, vars, id, opaque) {
	var obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="' + id + _plug_id + '" align="middle">\
		<param name="movie" value="' + movie + '" />\
		<param name="allowScriptAccess" value="always" />\
		<param name="quality" value="high" />';
	var emb = '<embed src="' + movie + '" quality="high" width="' + width + '" height="' + height + '" name="' + id + _plug_id + '" swLiveConnect=true align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"';
	if (!opaque) {
		obj += '<param name="wmode" value="opaque" />';
		emb += ' wmode="opaque"';
	}
	if (typeof(bgcolor) != "undefined" && bgcolor.length > 0) {
		obj += '<param name="bgcolor" value="' + bgcolor + '" />';
		emb += ' bgcolor="' + bgcolor + '"';
		_bgcolor = bgcolor.substr(1);
	}
	if (typeof(vars) != "undefined" && vars.length > 0) {
		obj += '<param name="FlashVars" value="' + vars + '" />';
		emb += ' FlashVars="' + vars + '"';
	}
	return obj + emb + '/></object>';
}

function showSChat(vars) {
	var movie = "/mu/schat.swf";
	document.writeln(getFlash(movie, 200, 480, "#EEEEEE", addVars(vars, "port=2006&cfg=/mu/chat.cfg"), "", true));
}

function showCtrl(bgcolor, vars) {
	var movie = "http://swf.4299.com/showCtrl.swf";
	if (!isNaN(REGION)) {
		movie = SITES[REGION] + movie;
	}
	document.writeln(getFlash(movie, 60, 25, bgcolor, addVars(vars, "plug_id=" + _plug_id + "&b=" + _bgcolor)));
	//document.writeln('<a href="/help" target="_blank"><img src="/game_logo/birdflight.gif" width="28" height="28" border="0" alt="使用帮助" align="absmiddle"></a>');
}
function showGameScore(bgcolor, vars) {
	var movie = "game/showGameScore.swf";
	if (!isNaN(REGION)) {
		movie = SITES[REGION] + movie;
	}
	document.writeln(getFlash(movie, 200, 180, bgcolor, addVars(vars, "plug_id=" + _plug_id + "&b=" + _bgcolor)));
	//document.writeln('<a href="/help" target="_blank"><img src="/game_logo/birdflight.gif" width="28" height="28" border="0" alt="使用帮助" align="absmiddle"></a>');
}

Game.prototype.show = function(ps) {
	var movie = this.base;
	var enc = false;
	if (!isNaN(REGION)) {
		movie = SITES[REGION] + movie;
		if (OS[REGION]) {
			enc = true;
		}
	}
	var vars = this.ps;
	if (this.u2) {
		movie += this.u2;
		if (enc) {
			vars = addVars(vars, "base=" + escape(encodeURI(this.base)) + "&url=" + escape(encodeURI(this.u)));
		} else {
			vars = addVars(vars, "base=" + this.base + "&url=" + this.u);
		}
	} else {
		movie += this.u;
	}
	vars = addVars(vars, ps);
	_plug_id = new Date().getTime();
	vars = addVars(vars, "plug_id=" + _plug_id);
	if (enc) {
		movie = encodeURI(movie);
	}
	document.writeln('<div style="OVERFLOW-Y: auto; OVERFLOW-X: auto; width: ' + this.width + 'px; height: ' + this.height + 'px">');
	document.writeln(getFlash(movie, this.width, this.height, this.bgcolor, vars, "cm_"));
	document.writeln('</div>');
}

Game.prototype.format = function(score) {
	if (isNaN(score)) {
		score = 0;
	}
	return format(score, this.pre);
}

Game.prototype.getLabel = function() {
	return this.glabel;
}

var GAME_LIST = new Array();

function addGame() {
	var obj = new Game();
	Game.apply(obj, arguments);
	GAME_LIST.push(obj);
}

var isInGame = false;

function showSwf(game, ps) {
	var g = getGame(game);
	if (g) {
		g.show(ps);
		isInGame = true;
	}
}
function getGame(gname) {
	for (var i = 0; i < GAME_LIST.length; i++) {
		if (GAME_LIST[i].gname == gname) {
			return GAME_LIST[i];
		}
	}
	return null;
}

String.prototype.len = function() {
	var arr = this.match(/[^\x00-\xff]/ig);
	return this.length + (arr == null ? 0 : arr.length);
}

String.prototype.left = function(num, mode) {
	if(!/\d+/.test(num))
		return (this);
	var str = this.substr(0, num);
	if(!mode)
		return str;
	var ret = "", l = 0, i = 0;
	while (i < str.length) {
		if (str.charCodeAt(i) > 0xff) {
			l += 2;
		} else {
			l++;
		}
		if (l > num) {
			break;
		}
		ret += str.charAt(i);
		i++;
	}
	return ret;
}

function getDate(ymd) {
	var dt = ymd.split(" ");
	var dd = dt[0].split("-");
	var year = parseInt(dd[0], 10);
	var month = parseInt(dd[1], 10) - 1;
	var day = parseInt(dd[2], 10);
	var hour = null, minute = null, second = null;
	if(dt.length > 1) {
		var tt = dt[1].split(":");
		hour = parseInt(tt[0], 10);
		minute = parseInt(tt[1], 10);
		second = parseInt(tt[2], 10);
	}
	return new Date(year, month, day, hour, minute, second);
}

//popup a window
function populateData(formName, values) {
	var thisForm = document.forms(formName);
	var theForm = opener.document.forms(thisForm.elements("BAYSOFT_FORM_NAME").value);
	var fields = thisForm.elements("BAYSOFT_FORM_FIELDS").value;
	fields = fields.split(",");
	for(i=0;i< fields.length;i++) {
		theForm.elements(fields[i]).value = values[i];
	}
	return false;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function saveCookie(name,value,mins) {
	if (!mins) {
		mins = 365 * 24 * 60;
	}
	var date = new Date();
	date.setTime(date.getTime() + (mins * 60 * 1000));
	var expires = "; expires=" + date.toGMTString();
	document.cookie = name + "=" + value + expires + "; path=/"
}

function deleteCookie(name) {
	saveCookie(name,"",-1)
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}

var qs = unescape(location.search.substring(1));
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) {
	eq = nv[i].indexOf('=');
	url[nv[i].substring(0,eq)] = unescape(nv[i].substring(eq + 1));
}

function switchCells(currentitem, itemtext, totalitems) {
	for (var i = 1; i<= Number(totalitems); i++) {
		var item = String(itemtext) + String(i);
		var it = MM_findObj(item);
		var ita = MM_findObj(item + String("a"));
		if (i != Number(currentitem)) {
			it.style.display = "none";
			if (ita != null) {
				ita.className = "";
			}
		} else {
			it.style.display = "block";
			if (ita != null) {
				ita.className = "active";
			}
		}
	}
}

function focusTo(fld) {
	var field = MM_findObj(fld);
	if (field != null) {
		field.focus();
		return true;
	}
	return false;
}

function newStandardWin(url) {		
	return openWin222(url, 640, 480, 1);
}

function openWin222() {
	var url = "about:blank";
	var width = 640;
	var height = 480;
	var resize = "yes";
	var name = "NewWindow";
	var args = arguments;
	switch (args.length) {
		case 5:
			resize = args[4];
		case 4:
			name = args[3];
		case 3:
			height = args[2];
		case 2:
			width = args[1];
		case 1:
			url = args[0];
		default:
			break;
	}
	var parameters = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable="
		+ resize + ",copyhistory=no,width=" + width + ",height=" + height;
	return window.open(url, name, parameters);
}

function newWin(url, width, height, resizable, newWinName) {
	if (resizable == 0) {
		parameter = "no";
	} else {
		parameter = "yes";
	}
	return openWin222(url, width, height, newWinName, parameter);
}

var validChars = "\\s\\(\\)<>@,;:\\\\\\\"\\[\\]";
var emailPattern = new RegExp("^[^" + validChars + "]+@([^" + validChars + "\\.]+\\.)+[^" + validChars + "\\.]+$");
function isEmail(value) {
	return emailPattern.test(value);
}

function checkString(s, badChars) {
	var i;
	var found = -1;
	for (i = 0; i < badChars.length; i++) {
		found = s.indexOf(badChars.charAt(i));
		if (found > -1) {
			break;
		}
	}
	return found;
}

function convertToHtml(str) {
	if (str && str.length > 0) {
		str = str.replace(/&nbsp;/gi, " ");
		str = str.replace(/<br>/gi, "\n\r");
		str = str.replace(/&lt;/gi, "<");
		str = str.replace(/&gt;/gi, ">");
		str = str.replace(/&amp;/gi, "&");
		str = str.replace(/&quot;/gi, "\"");
		str = str.replace(/%22/gi, "\"");
	} else {
		str = "";
	}
	return str;
}

function convertToText(str) {
	if (str && str.length > 0) {
		str = str.replace(/&/gi, "&amp;");
		str = str.replace(/</gi, "&lt;");
		str = str.replace(/>/gi, "&gt;");
	} else {
		str = "";
	}
	return str;
}

function showThumbnail(name, href) {
	var os;
	if (name != "/images/user/0.jpg")	{
		var pos = name.lastIndexOf(".");
		if (pos == -1) {
			return;
		}
		var tname = name.substring(0, pos) + "t.jpg";
		os = "<a href=\"";
		if (href) {
			os += href + "\">";
		} else {
			os += name + "\" target=\"_blank\">";
		}
		os += "<img src=\"" + tname + "\" border=\"0\" align=\"absmiddle\"></a>";
	} else {
		os = "<img src='/images/1px.gif' width='20' height='1'>";
	}
	document.write(os);
}

function fillStr() {
	var args = fillStr.arguments;
	var str = args[0];
	if(args.length < 2) {
		return str;
	}
	var rep = str;
	for(var i = 1; i < args.length; i++) {
		if(!args[i]) {
			continue;
		}
		var regex = eval("/\\{" + i + "\\}/g");
		rep = rep.replace(regex, args[i]);
	}
	return rep;
}

var lastimg = null;

function selectCal(scrname,inputname,start, max, min) {
  var v = (MM_findObj(inputname)).value;
  if(v) {
	  start = getDate(v);
  }
  showCalendar(scrname,max,min,inputname,start);
}

function showCalendar(scrname,maxdate,mindate,inputname,startdate) {
  var doccalendar = document.all.calendar;
  var walendar = window.frames.calendar;
  var scrobj = document.all(scrname);
  var calendarloaded = walendar.calendarloaded;

  if (calendarloaded==null || !calendarloaded) {
    alert('对不起，网页有部分功能未能下传完毕，请重新访问本页。');
    return;
  }

  if ('block'==doccalendar.style.display && scrobj==lastimg) {
    doccalendar.style.display = 'none';
  } else {
    walendar.reset(maxdate,mindate,inputname,startdate);
    walendar.reLoad();

    var scrtop    = 0;
    var scrleft   = 0;
    var scrheight = scrobj.height;
    var tmp       = scrobj;
    while (tmp && tmp.tagName!="body") {
      scrtop  += tmp.offsetTop;
      scrleft += tmp.offsetLeft;
      tmp      = tmp.offsetParent;
    }

    doccalendar.style.top = scrtop + scrheight;
    doccalendar.style.left = scrleft;
    doccalendar.style.display = 'block';
    lastimg = scrobj;
  }

}


function showMM(value, credit) {
	var n = "1";
	if (value <= 10) n = "0";
	if (value > 10 && value < 50) n = "1";
	if (value >= 50 && value < 250) n = "2";
	if (value >= 250 && value <= 1000) n = "3";
	if (value > 1000) n = "4";
	
	document.write("<a href='ChargeIPay'><img src='/images/tab/mm" + n + ".gif' alt='" + value + "mm' border=0></a>");

}

function showLastVisit(y,M,d,h,m,s) {
	var now = new Date();
	var last = new Date();
	last.setYear(y);
	last.setMonth(M - 1);
	last.setDate(d);
	last.setHours(h);
	last.setMinutes(m);
	last.setSeconds(s);
	var n = (now - last)/1000/60;
	var os = "";
	if (n < 3) {
		os = "3分钟以内";
	} else if (n < 5) {
		os = "5分钟以内";
	} else if (n < 10) {
		os = "10分钟以内";
	} else if (n < 15) {
		os = "15分钟以内";
	} else if (n < 30) {
		os = "30分钟以内";
	} else if (n < 60) {
		os = "1小时以内";
	} else if ( n < 180) {
		os = "2小时以内";
	} else if ( n < 240) {
		os = "3小时以内";
	} else if ( n < 360) {
		os = "6小时以内";
	} else if ( n < 480) {
		os = "8小时以内";
	} else if ( n < 720) {
		os = "12小时以内";
	} else if (n < 2880) {
		os = "24小时以内";
	} else if ( n < 4320) {
		os = "1天以前";
	} else if ( n < 5760) {
		os = "2天以前";
	} else if ( n < 7200) {
		os = "3天以前";
	} else if ( n < 8640) {
		os = "4天以前";
	} else if ( n < 10080) {
		os = "5天以前";
	} else if ( n < 11520) {
		os = "6天以前";
	} else if ( n < 21600) {
		os = "一星期以前";
	} else if ( n < 43200) {
		os = "两星期以前";
	} else if ( n < 129600) {
		os = "一个月以前";
	} else {
		os = "三个月以前";
	} 

	document.write(os);
}

function showMenu(sid) {
	var os = "";
	if (typeof(sid) != "undefined") {
		os = '<a href="javascript:openHost(\'' + sid + '\');"><font color="#ff0000">开启聊天简约版</font></a><sup>Cool!</sup>';
	} else {
		os = "";
	}
	MM_findObj("tip").innerHTML = "&nbsp;&nbsp;" + os;
}

function showVisited(txt, type) {
	var os = "";
	for (var i = txt.length; i < 6; i++) {
		os += "<img src='/images/countdown/" + type + "/0.gif'>";
	}
	for (var i = 0; i < txt.length; i++) {
		os += "<img src='/images/countdown/" + type + "/"  + txt.charAt(i) + ".gif'>";
	}
	document.write(os);
}

function showTimeElapsed(s, e) {
	var start = new Date(s);
	var end = new Date(e);
	var os = "";
	
	if ( end < start) {
		os = " ";
	} else {
		var elapsed = (end - start) / 1000;
		var h = parseInt(elapsed / 3600);
		var m = parseInt((elapsed - h * 3600) / 60);
		var s = (elapsed - h * 3600 - m * 60);
		
		if (h > 0) os += h + "<font color=green>:</font>";
		if (m > 0) os += m + "<font color=green>'</font>";
		os += s + "<font color=green>''</font>";
	}

	document.write(os);
}

function date2star(month, date) {

	var value ="";

	if (month == 1 && date >=20 || month == 2 && date <=18) {value = "水瓶座";}
	if (month == 2 && date >=19 || month == 3 && date <=20) {value = "双鱼座";}
	if (month == 3 && date >=21 || month == 4 && date <=19) {value = "白羊座";}
	if (month == 4 && date >=20 || month == 5 && date <=20) {value = "金牛座";}
	if (month == 5 && date >=21 || month == 6 && date <=21) {value = "双子座";}
	if (month == 6 && date >=22 || month == 7 && date <=22) {value = "巨蟹座";}
	if (month == 7 && date >=23 || month == 8 && date <=22) {value = "狮子座";}
	if (month == 8 && date >=23 || month == 9 && date <=22) {value = "处女座";}
	if (month == 9 && date >=23 || month == 10 && date <=22) {value = "天秤座";}
	if (month == 10 && date >=23 || month == 11 && date <=21) {value = "天蝎座";}
	if (month == 11 && date >=22 || month == 12 && date <=21) {value = "射手座";}
	if (month == 12 && date >=22 || month == 1 && date <=19) {value = "摩羯座";}

	document.write(value);
}

function checkBirthday(m,d) {
	var os = "";
	var D = new Date();
	var mm=D.getMonth()+1;
	var dd=D.getDate();

	if (mm == m && dd == d){
		os = "<img src='/images/misc/baloon.gif' width=16 height=15>";
	}
	document.write(os);
}
function showWeapon(sweeper, bomb, robot) {
	var os = "";
	for (var i = 0; i < sweeper; i++) {
		os += "<a href='TeamTools'><img src='/images/tool/minesweepersm.gif' height='21' width='18' align='absmiddle' alt='工兵' border='0'></a>&nbsp;";
		if (i % 10 == 9) {
		os += "<br>";
		}
	}
	for (var j = 0; j < bomb; j++) {
		os += "<a href='TeamTools'><img src='/images/tool/bombsm.gif' height='22' width='21' align='absmiddle' alt='地雷' border='0'></a>&nbsp;";
		if (j % 10 == 9) {
		os += "<br>";
		}
	}
	for (var j = 0; j < robot; j++) {
		os += "<a href='TeamTools'><img src='/images/tool/robotsm.gif' height='16' width='14' align='absmiddle' alt='机器人' border='0'></a>&nbsp;";
		if (j % 10 == 9) {
		os += "<br>";
		}
	}
	document.write(os);
}

function showPeople() {
	var rnd = parseInt(Math.random() * 4);
	os = "<img src='/images/people" + rnd + ".jpg' border='0'>";
	document.write(os);
}


function daynight(h) {
	var os = "<img src='/images/misc/";
	if (h > 18 || h < 5){
		os += "moon.gif"
	} else {
		os += "sun.gif"
	}
	os +=  "' width='9' height='9' align='absmiddle'> "
	document.write(os);
}

function hello(name, r) {
	var h = new Date().getHours();
	var os = name;
	if (h <= 4 || h > 23) {
		os += "深夜了注意休息";
	} else if (h <= 10) {
		os += "早上好";
	} else if (h <= 14) {
		os += "中午好";
	} else if (h <= 18) {
		os += "下午好";
	} else if (h <= 23) {
		os += "晚上好";
	}
	if (r) return os;
	document.write(os);
}

function hi() {
	var h = new Date().getHours();
	var os = "";
	if (h <= 4 || h > 23) {
		os += "别太晚了";
	} else if (h <= 10) {
		os += "早";
	} else if (h <= 12) {
		os += "hello";
	} else if (h <= 14) {
		os += "你好";
	} else if (h <= 17) {
		os += "下午好";
	} else if (h <= 18) {
		os += "hi";
	} else if (h < 23) {
		os += "晚上好";
	} else if (h == 23) {
		os += "晚安";
	}
	document.write(os);
}

function showMsn() {
	var args = showMsn.arguments;
	var cl = "";
	var e = "info";
	var s = "";
	var txt = "";
	if (args.length > 2) {
		s = "?subject=" + args[2];
	}
	if (args.length > 1) {
		e = args[1];
	}
	if (args.length > 0) {
		cl = args[0];
	}
	if (args.length > 3) {
		txt = args[3];
	} else {
		txt = e + "&#64;&#49;&#99;m.&#99;om.&#99;n";
	}
	document.write('<a class="' + cl + '" href="#" onClick="navigate(\'&#109;ailto&#58;' + e + '&#\' + (65 - 1) + \';1&#99;m.&#99;om.&#99;n' + s + '\');return false;">' + txt + '</a>');
}

function b4retr(form) {
	var src = document.forms["TopLogin"];
	if (typeof(src) == "undefined") {
		src = document.forms["Logme"];
	}
	var fld = src["User.login"];
	if (fld.value && isEmail(fld.value)) {
		form["User.email"].value = fld.value;
		newWin("about:blank", 500, 320, 1, "Retrieve");
		return true;
	}
	alert("请正确输入您的Email帐号。");
	fld.focus();
	return false;
}

function showBonus(seats, fee, mode) {
	var ret = "持续增加中";
	if (seats > 0) {
		if (fee > 0)
		{
			ret = (seats * fee * 0.9) + ("&cent;m");
		}else{
			ret = "5&cent;m";
		}
	}
	document.write(ret);
}

function showUnit(mode) {
	var ret = "&cent;m";
	if (mode == 2) {
		ret = "mm";
	}
	document.write(ret);
}

function appendUnit(b, m) {
	if (b.length > 0) {
		document.write(b + (m == 2? "mm" : "&cent;m"));
	}
}

function setRndShout() {
	var msg = MM_findObj("ShoutMsg.message");
	if (msg) {
		msg.value = "";
	}
}

function setGame(game) {
	if (game == "") {
		return;
	}
	window.location = game;
}

var BONUS_PERCENTS = new Array();
BONUS_PERCENTS.push(0.75);
BONUS_PERCENTS.push(0.1);
BONUS_PERCENTS.push(0.075);
BONUS_PERCENTS.push(0.05);
BONUS_PERCENTS.push(0.025);

function showPoint(seats, fee, fund, mode, pos, seated) {
	var t = 0;
	if (mode == 0) {
		if (pos == 0)
		{
			t = seats * fee * 2/ 100;
		}else{
			t = seats * fee / 100;
		}
	} else if (((mode == 1) || (mode ==3)) && pos < 5)
	{
		t = (seated * fee + fund)*BONUS_PERCENTS[pos] / 20;
	}
	if (t != 0)
	{
		document.write("+" + parseInt(t));
	}
}

function diff(score, standard) {
	var t = 0;
	if (parseInt(score) != parseInt(standard))
	{
		if (score > standard)
		{
			t = score - (standard + 1);
		}else{
			t = score - standard;
		}
		
	}
	var st = t.toString();
	var index = st.indexOf(".");
	if (index != -1 && st.length>(index+3))
	{
		st = st.substring(0,index+3);
	}
	if (t >= 0)
	{
		document.write("+" + st);
	} else {
		document.write(st);
	}
}



function showGroups(size, group, yn, wn) {
	var out = "";
	for (var i = 0; i < size; i++) {
		var gname = String.fromCharCode(65 + i);
		out += " ";
		if (group == gname) {
			out += gname;
		} else {
			out += '<a href="?group=' + gname + '&year=' + yn + '&week=' + wn + '" class="nav2">' + gname + '</a>';
		}
		out += " |";
	}
	document.write(out);
}

var voteTeams = new Array();
var totalBallot = 0;

function TeamVote(tid, ballot) {
	this.tid = tid;
	this.ballot = ballot;
}

function addTeamVote(tid, ballot) {
	voteTeams.push(new TeamVote(tid, ballot));
	totalBallot += ballot;
}

function getVote(tid) {
	for (var i = 0; i < voteTeams.length; i++) {
		if (voteTeams[i].tid == tid) {
			return voteTeams[i];
		}
	}
	return null;
	return parseInt(r / totalBallot * 100);
}

function showGraph(tid) {
	var vote = getVote(tid);
	document.writeln('<img src="/images/misc/vt.gif" height="5" width="' + (parseInt(vote.ballot / totalBallot * 100)) + '" alt="支持人数: ' + vote.ballot + '">')
}

function showBar(width, max) {
	document.writeln('<img src="/images/misc/vt.gif" height="5" width="' + (parseInt(width / max * 100)) + '">')
}

Date.prototype.show = function() {
	var year = this.getYear() % 100;
	if (year < 10) {
		year = "0" + year;
	}
	var month = this.getMonth() + 1;
	if (month < 10) {
		month = "0" + month;
	}
	var date = this.getDate();
	if (date < 10) {
		date = "0" + date;
	}
	return year + "." + month + "." + date;
}

var ONE_DAY = 24 * 60 * 60 * 1000;
var DAYS = new Array(6, 3, 0, 1);
function showSeason(diff, index) {
	var d = new Date();
	var i = diff - d.getDay();
	d.setTime(d.getTime() + i * ONE_DAY);
	document.write("[" + d.show());
	diff = DAYS[index];
	if (diff > 0) {
		d.setTime(d.getTime() + diff * ONE_DAY);
		document.write(" - " + d.show());
	}
	document.writeln("]");
}

function addPortal() {
	try {
		var xmlhttp = new ActiveXObject("TimwpDll.TimwpCheck");
		if (xmlhttp.GetVersion() < 2.1) {
			alert("请升级您的QQ软件以便使用该功能。");
		} else {
			navigate("Tencent://AddPortal/?Menu=Yes&PanelID=20193");
		}
	} catch(e) {
		window.status = "请安装QQ后再使用本功能";
	}
	return false;
}
function JM_cc(ob,t){
	var obj = MM_findObj(ob);
	if (ob) {
		obj.select();
		window.clipboardData.setData("text",t);
		alert("复制成功啦！您可以通过QQ等发送给您的好友，一起来分享快乐。");
	}
	return false;
}

function JM_cc1(ob){
	var obj = MM_findObj(ob);
	if (obj) {
		obj.select();
		js = obj.createTextRange();
		js.execCommand("Copy");
		alert("复制成功啦！您可以复制到博客的编辑器中，让您的好友也分享到您的快乐。");
	}
	return false;
}

function copyImg(ob) {
	var obj = MM_findObj(ob);
	if (obj) {
		var ctrl = document.body.createControlRange();
		ctrl.add(obj);
		ctrl.execCommand("Copy");
		alert("复制成功！可以立刻粘贴到msn/QQ/email/blog。");
	}
}

function mail(subject, content, receiver) {
	var tmp = "";
	if (arguments.length > 2) {
		tmp = arguments[2];
	}
	navigate('mailto:' + tmp + '?subject=' + subject + "&body=" + content);
	return false;
}

function AlertCharge(href,args){
	var ret = window.showModalDialog(href,args,"dialogWidth:15em; dialogHeight:10em; status:0; help:0");
}

function AlertHelp(href,args){
	var ret = window.showModalDialog(href,args,"dialogWidth:18em; dialogHeight:15em; status:0; help:0");
}

function playRobotMatch(game, robotLevel) {
	var form = document.forms["PlayRobotMatch"];
	form["RobotMatch.game.name"].value = game;
	if (robotLevel != -1)
		form["RobotMatch.robotLevel"].value = robotLevel;
	form.submit();
}

function ReturnCredit(){
	var ret = window.showModalDialog('ConfirmReturnCredit',window,"dialogWidth:15em; dialogHeight:12em; status:0; help:0");
}

function getVcExpense(formName){
	var vcexpense = 1;
	if (formName == "UpdateTeam")
	{
		vcexpense = 20;
	}else if (formName == "CreateTeam")
	{
		vcexpense = 100 ;
	}else if (formName == "InviteFriendMatch")
	{
		vcexpense = 5;
	}else if (formName == "VoteChampion")
	{
		vcexpense = 2;
	}else if (formName == "TeamTrainMatch")
	{
		vcexpense = 0; // free for team training
	}else if (formName == "InviteTopTenMatch")
	{
		vcexpense = 10;
	}else if (formName == "SendJoinInvite")
	{
		vcexpense = 100;
	}else if (formName == "SentJoinApply")
	{
		vcexpense = 100;
	}else if (formName == "PlayAgain")
	{
		vcexpense = 0 ;
	}
	return vcexpense;
}

function showGameListSelect(){
	var output = '<select class="font-txt2" onChange="setGame(this.value)">';
	output += '<option class="font-txt2" value="">&nbsp;游戏快捷通道&nbsp;</option>';
	for (var i = 0; i < GAME_LIST.length; i++) {
		output += '<option class="font-txt2" value="gameopen?game=' + GAME_LIST[i].gname + '"';
		if (url["game"] == GAME_LIST[i].gname) {
			output += ' selected';
		}
		output += '>' + GAME_LIST[i].glabel + '</option>';
	}
	output += '</select>';
	document.writeln(output);
}
function showGameList(){
	var output = '<select class="font-txt2" name="favorite">';
	output += '<option class="font-txt2" value="">-请选择-</option>';
	for (var i = 0; i < GAME_LIST.length; i++) {
		output += '<option class="font-txt2" value="' + GAME_LIST[i].gname + '"';
		if(arguments.length>0){
			if (arguments[0] == GAME_LIST[i].gname) {
				output += ' selected';
			}
		}
		output += '>' + GAME_LIST[i].glabel + '</option>';
	}
	output += '</select>';
	document.writeln(output);
}

function abbr(str, size, r) {
	str = str.replace(/&quot;/gi, "\"");
	var tmp = str.left(size, 1);
	if (tmp.length < str.length) {
		str = str.replace(/\"/gi, "&quot;");
		tmp = "<font title=\"" + str + "\">" + tmp + "...</font>";
	}
	if (r) {
		return tmp;
	}
	document.writeln(tmp);
}

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
	if ((obj=MM_findObj(args[i]))!=null) {
		v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; 
	}
}

function openHost(sid) {
	var w = openWin222("/do/ChatHost?sid="+sid, 216, 480, "chathost" + sid, "no");
	if (w == null) {
		MM_findObj("tip").innerHTML = '&nbsp;&nbsp;<a href="javascript:openHost(\'' + sid + '\');"><font color="#ff0000">窗口被拦截，再试一次……</font></a>';
	} else {
		showMenu();
	}
}

var agePattern = new RegExp("\\d+岁*");

function b4finduser(form) {
	form["query"].value="";
	form["age"].value="";
	form["sex"].value="";
	var val=form["condition"].value;
	if (!val) {
		return false;
	}
	var vs=val.split(" ");
	var m=vs.length;
	var query="";
	for (var i=0; i<m; i++) {
		var v = vs[i];
		if (v=="男") {
			form["sex"].value=1;
		} else if (v=="女") {
			form["sex"].value=2;
		} else if (agePattern.test(v) && parseInt(v) > 0 && parseInt(v) < 100) {
			form["age"].value=parseInt(v);
		} else if (v=="在线" || v=="在线玩家" || v=="online") {
			form["online"].value=1;
		} else {
			if( v.trim()=="")continue;
			query+=v;
			query+=" ";
		}
	}
	form["query"].value=query.substr(0, query.length-1);
	return true;
}

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 ga() {
	if(typeof(_uacct) != "undefined") {
		_uacct = "UA-548038-1";
		urchinTracker();
	}
}

function elapse(ms1, ms2) {
	document.title += " - " + ms1 + ":" + ms2;
}

deleteCookie("autologin");
deleteCookie("User.login");
deleteCookie("User.password");
deleteCookie("alwaysoff");

function limit(form){
	var areas = form.getElementsByTagName("textarea");
	for(var i=0;i<areas.length;i++){
		var len=areas[i].len;
		if(parseInt(areas[i].value.length)>parseInt(len)){
			alert("\""+areas[i].sign+"\"，不能超过"+len+"字！");
			areas[i].focus();
			areas[i].select();
			return false ;
		}
		if(areas[i].required=="true"){
			if(areas[i].value==""||areas.value.length==0){
				alert("\""+areas[i].sign+"\"，不能为空");
				areas[i].focus();
				return false ;
			}
		}
	}
	return true ;
}

function nextGame(game){
	var i = 0 ;
	for( i ; i< GAME_LIST.length ; i ++ ) {
		if( game == GAME_LIST[i].gname ) {
			break ;
		}
	}
	if( i >= GAME_LIST.length -1 ) {
		i = 0 ;
	} else {
		i = i + 1 ;
	}
	location.href="/gameopen?game="+GAME_LIST[i].gname;
}
function nextGame1(game){
	var i = 0 ;
	for( i ; i< GAME_LIST.length ; i ++ ) {
		if( game == GAME_LIST[i].gname ) {
			break  ;
		}
	}	
	if( i >= GAME_LIST.length -1 ) {
		i = 0 ;
	} else {
		i = i + 1 ;
	}
	document.write( GAME_LIST[i].glabel ) ;
}
function previosGame(game){
	var i = 0 ;
	for( i ; i< GAME_LIST.length ; i ++ ) {
		if( game == GAME_LIST[i].gname ) {
			break ;
		}
	}
	if( i <= 0 ) {
		i = GAME_LIST.length - 1 ;
	} else {
		i = i - 1 ;
	}
	location.href="/gameopen?game="+GAME_LIST[i].gname;
}
function previosGame1(game){
	var i = 0 ;
	for( i ; i< GAME_LIST.length ; i ++ ) {
		if( game == GAME_LIST[i].gname ) {
			break ;
		}
	}
	if( i <= 0 ) {
		i = GAME_LIST.length - 1 ;
	} else {
		i = i - 1 ;
	}
	document.write( GAME_LIST[i].glabel ) ;
}


