document.domain		=	location.host.substr(location.host.indexOf(".")+1);

var colmgamePopupObject;
var thisUri				=	location.href.replace("http://"+ location.host,"").split("/");
var thisHost			=	location.host.split(".");
var thisDomain			=	thisHost[1];


function colmgameIlligalWordsCheck(str) {
	var strReplace		=	new RegExp(colmgameIlligalWords.replace(/[^a-z0-9\\\|]/gi,''),'gim');
	var strNew			=	str.replace(strReplace,function($0) { return $0.replace(/[a-z0-9]/gi,'*'); });
	
	if(str != strNew) alert('We have detected inappropriate word.');
	
	return strNew;
}

function colmgameLoginCheck(f,dest) {
	var returnUrl		=	encodeBase64(dest ? dest : top.location.href);
	var idReplace		=	f.userid.value.replace(/[^a-zA-Z0-9_\-]/gi,"");
	var idLength		=	f.userid.value.length;
	var pwReplace		=	f.pw.value.replace(/[^a-zA-Z0-9]/gi,"");
	var pwLength		=	f.pw.value.length;

	if(!f.userid.value.trim()) {
		error("Contraseña de 'ID'.");
		f.userid.focus();
		return false;
	}

	if(idLength < 4 || idLength > 12) {
		error("El nombre de Usuario debe estar dentro de 4-12 caracteres y debe contener únicamente letras y números.");
		f.userid.focus();
		return false;
	}
	/*
	if(f.userid.value != idReplace) {
		error("El nombre de Usuario debe estar dentro de 4-12 caracteres y debe contener únicamente letras y números.");
		f.userid.focus();
		return false;
	}
	*/

	if(!f.pw.value.trim()) {
		error("Contraseña de Clave.");
		f.pw.focus();
		return false;
	}

	if(pwLength < 4 || pwLength > 16) {
		error("Clave debe estar dentro de 4-16 caracteres y debe contener únicamente letras y números.");
		f.pw.focus();
		
		return false;
	}

	/*
	if(f.pw.value != pwReplace) {
		error("Clave debe estar dentro de 4-16 caracteres y debe contener únicamente letras y números.");
		f.pw.focus();
		return false;
	}
	*/	

	return true;
}
function error(msg,opt, url) {

	if(!msg) {
		msg	=	"Utilízalo después de iniciar sesión.";
	}

	if(opt) {
		return confirm(msg);
	} else {
		try {
			colmgameLayer(msg);
		} catch(ex) {
			alert(msg);
		}
	}
}

function colmgameLayer(msg,w,h,flag) {
	if(flag == 2) {
		var w			=	w ? parseInt(w+10) : 290;
		var h			=	h ? parseInt(h+38) : 380;
	} else {
		var w			=	290;
		var h			=	flag ? 380 : 200;
	}

	var position		=	colmgameLayerPosition(w,h);
	
	colmgameLayerShow();

	var html			=	'<iframe src="/common_lib/common_layer.php?msg='+ encodeURIComponent(msg) +'&flag='+ (flag ? flag : "") +'&w='+ w +'&h='+ h +'" width="'+ w +'" height="'+ h +'" scrolling="no" frameborder="0" allowtransparency="true"></iframe>';

	document.getElementById('divColmgameLayer').innerHTML	=	html;
}

/**
 * Show Iframe Layer Function
 * 
 * @param url Iframe URL
 * @param w Layer Width
 * @param h Layer Height
 * @return
 */
function colmgameIframeLayer(url, w, h) {
	// var w			=	w ? parseInt(w+10) : 500;
	// var h			=	h ? parseInt(h+38) : 500;
	var position	=	colmgameLayerPosition(w, h);
	
	colmgameLayerShow();

	var html		=	'<iframe src="'+ url +'" width="'+ w +'" height="'+ h +'" scrolling="auto" frameborder="0" color="#FFFFFF" allowtransparency="true"></iframe>';

	document.getElementById('divColmgameLayer').innerHTML	=	html;
}

function colmgameLayerPosition(w,h) {
	if(!document.getElementById('divColmgameLayer')) {
		var divNew;
		var divName	=	['divColmgameLayer','divColmgameLayerBg'];

		for(var i=0;i<divName.length;i++) {
			divNew		=	document.createElement('div');
		
			divNew.setAttribute('id',divName[i]);
			document.body.appendChild(divNew);
		}
	}
	
	var obj				=	document.getElementById('divColmgameLayer');
	var objBg			=	document.getElementById('divColmgameLayerBg');
	var xhtml			=	isXHTML();
	var cWidth			=	xhtml ? document.documentElement.clientWidth : document.body.clientWidth;
	var cHeight			=	xhtml ? document.documentElement.clientHeight : document.body.clientHeight;
	var sHeight			=	xhtml ? document.documentElement.scrollHeight : document.body.scrollHeight;
	var sScroll			=	xhtml ? document.documentElement.scrollTop : document.body.scrollTop;

	objBg.style.cssText	=	'margin:0;padding:0;position:absolute;top:0;left:0;width:100%;height:'+ ((cHeight > sHeight) ? cHeight : sHeight)+'px;z-index:1165;background:#000;filter:alpha(opacity=75);opacity:0.75;-moz-opacity:0.75;';
	obj.style.cssText		=	'margin:0;padding:0;position:absolute;z-index:6244;';
	obj.style.left		=	Math.ceil((cWidth-w)/2) +'px';
	obj.style.top		=	Math.ceil((cHeight-h)/2+sScroll) +'px';
}

function colmgameLayerShow() {
	try {
		var divName	=	['divColmgameLayer','divColmgameLayerBg'];
	} catch(ex) {
		error('maintenance not found');
		return;
	}
	
	var obj;
	
	for(var i=0;i<divName.length;i++) {
		obj		=	document.getElementById(divName[i]);

		obj.innerHTML		=	'';
		obj.style.display	=	(obj.style.display != 'block') ? 'block' : 'none';
	}
	
	if(isIE()) {
		if(!isIE7()) {
			var sel		=	document.getElementsByTagName('select');
	
			for(var j=0;j<sel.length;j++) {
				sel[j].style.visibility	=	(obj.style.display != 'block') ? 'visible' : 'hidden';
			}
		}
		
		var player	=	document.getElementsByTagName('object');
		
		for(var k=0;k<player.length;k++) {
			if(player[k].id == 'colmgamePlayer') {
				player[k].style.visibility	=	(obj.style.display != 'block') ? 'visible' : 'hidden';
			}
		}
	}
}

function colmgameUserCheck(opt) 
{
	if(!getCookie("MGUSA")) 
	{
		error("Utilízalo después de iniciar sesión.");
		return false;
	}

	return true;
}

function colmgameUserModify() {
	if(!colmgameUserCheck()) return;

	if(thisDomain == "gamengame") {
		top.location.href	=	"https://www.gamengame.com/gng/member/mypage_user.asp";
	} else {
		top.location.href	=	"http://www.colmgame.com/account/setting.php";
	}
}

function colmgameNcash() {
	if(!colmgameUserCheck()) return;

	top.location.href		=	"http://www.colmgame.com/account/ncash.php";
}

function colmgameUserNcash() {
	if(!colmgameUserCheck()) return;

	top.location.href		=	"http://www.colmgame.com/account/usage.php";
}

function colmgameUserManage() {
	if(!colmgameUserCheck()) return;

	top.location.href		=	"http://www.colmgame.com/account/profile.php";
}

function colmgameLogout() {
	if(thisDomain == "etc") {
		top.location.href	=	"/login/logout.php";
	} else {
		top.location.href	=	"http://www.mgame.com/login/logout.php?dest="+ thisGame();
	}
}

function colmgameIlligalWordsCheck(str) {
	var strReplace		=	new RegExp(colmgameIlligalWords.replace(/[^a-z0-9\\\|]/gi,''),'gim');
	var strNew			=	str.replace(strReplace,function($0) { return $0.replace(/[a-z0-9]/gi,'*'); });
	
	if(str != strNew) error('We have detected inappropriate word.');
	
	return strNew;
}

function colmgameFindId() {
	top.location.href	=	"http://www.colmgame.com/login/fid.php";
}

function colmgameFindPassword() {
	if(thisDomain == "gamengame") {
		top.location.href	=	"https://www.gamengame.com/gng/member/findpassword.asp";
	} else {
		top.location.href	=	"http://www.colmgame.com/login/fpasswd.php";
	}
}

function colmgameNewAccount() {
	if(thisDomain == "gamengame") {
		top.location.href	=	"https://www.gamengame.com/gng/member/member_form.asp?gamename="+ thisGame() +"&ssoreturn="+ top.location.host;
	} else {
		top.location.href	=	"http://www.colmgame.com/login/create.php";
	}
}

function colmgameCoupon() {
	if(!colmgameUserCheck()) return;

	top.location.href	=	"http://www.colmgame.com/account/coupon.php";
}

function colmgameEmailGuide() {
	top.location.href	=	"http://www.colmgame.com/email/guide.php";
}

function colmgameStart(gameName) {
	if(!colmgameUserCheck()) return;

	try {
		game_run.location.href	=	"/launch/launch_cloudnine.php";
	} catch(e) {
		var obj		=	document.createElement("iframe");

		obj.setAttribute("id","game_run");
		obj.setAttribute("name","game_run");
		obj.setAttribute("width",0);
		obj.setAttribute("height",0);

		document.body.appendChild(obj);

		colmgameStart(gameName);
	}
}

function colmgameImageView(obj) {
	colmgamePopup("http://www.colmgame.com/lib/popup_image.php?imgUrl="+ obj);
}

function colmgamePopup(param,w,h) {
	var popupWidth	=	w ? w : 50;
	var popupHeight	=	h ? h : 50;

	colmgamePopupObject	=	window.open(param,"colmgamePopup","width="+ popupWidth +",height="+ popupHeight +",top=0,left=0");
}

function colmgameRollOver() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function colmgameFlash(flashUrl,flashWidth,flashHeight,flashDiv) {
	var flashPath,flashVars;
	var classId			=	"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	var codeBase		=	"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
	var pluginsPage	=	"application/x-shockwave-flash";
	var embedType	=	"application/x-shockwave-flash";
	var pluginsPage	=	"http://www.macromedia.com/go/getflashplayer";

	var flashHtml		=	"";

	flashHtml			+=	'<object id="colmgameFlashObj" classid="'+ classId +'" codebase="'+ codeBase +'" width="'+ flashWidth +'" height="'+ flashHeight +'">';
	flashHtml			+=	'	<param name="movie" value="' + flashUrl + '" />';
	flashHtml			+=	'	<param name="quality" value="high" />';
	flashHtml			+=	'	<param name="allowScriptAccess" value="always" />';
	flashHtml			+=	'	<param name="wmode" value="transparent" />';
	flashHtml			+=	'	<embed src="'+ flashUrl + '" allowScriptAccess="always" quality="high" wmode="transparent" width="'+ flashWidth +'" height="'+ flashHeight +'" type="' + embedType + '" pluginspage="' + pluginsPage + '" />';
	flashHtml			+=	'</object>';

	if(flashDiv) {
		document.getElementById(flashDiv).innerHTML	=	flashHtml;
	} else {
		document.write(flashHtml);
	}
}

function colmgameMovie(movieUrl,movieWidth,movieHeight,movieDiv,movieUI,moviePlay) {
	var classId			=	"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6";
	var playUI			=	movieUI ? "full" : "none";
	var playMode		=	moviePlay ? "false" : "true";
	var movieHtml		=	"";

	movieHtml			+=	'<object width="'+ movieWidth +'" height="'+ movieHeight +'" id="colmgamePlayer" classid="'+ classId +'">';
	movieHtml			+=	'	<param name="autostart" value="'+ playMode +'">';
	movieHtml			+=	'	<param name="url" value="'+ movieUrl +'">';
	movieHtml			+=	'	<param name="volume" value="70">';
	movieHtml			+=	'	<param name="showcontrols" value="true">';
	movieHtml			+=	'	<param name="defaultframe" value="content">';
	movieHtml			+=	'	<param name="uiMode" value="'+ playUI +'">';
	movieHtml			+=	'	<param name="enablecontextmenu" value="false">';
	movieHtml			+=	'	<param name="fullscreen" value="false">';
	movieHtml			+=	'	<param name="enabled" value="true">';
	movieHtml			+=	'	<param name="stretchtofit" value="true">';
	movieHtml			+=	'</object>';

	if(movieDiv) {
		document.getElementById(movieDiv).innerHTML	=	movieHtml;
	} else {
		document.write(movieHtml);
	}
}

function colmgameFooter(idx) {
	var filePath;

	switch(parseInt(idx)) {
		case 1 :
			filePath		=	"http://www.colmgame.com/footer/user_agreement.php";
			filePath		=	"http://www.colmgame.com/company/agreement.php";
			break;
		case 2 :
			filePath		=	"http://www.colmgame.com/footer/privacy_policy.php";
			filePath		=	"http://www.colmgame.com/company/policy.php";
			break;
		case 4 :
			filePath		=	"http://www.colmgame.com/footer/job.php";
			filePath		=	"http://www.colmgame.com/company/recruit.php";
			break;
		default :
			filePath		=	"http://www.colmgame.com/footer/rules.php";
			filePath		=	"http://www.colmgame.com/company/rules.php";
			break;
	}
	
	top.location.href	=	filePath;
}

function colmgamePolicy() {
	top.location.href	=	"";
}

function colmgameConduct() {
	top.location.href	=	"";
}

function iframeResize(ifrm) {
	if(ifrm) {
		ifrm.height	=	isXHTML(ifrm.contentWindow) ? ifrm.contentWindow.document.documentElement.scrollHeight : ifrm.contentWindow.document.body.scrollHeight;
	} else {
		var obj	=	parent.document.getElementsByTagName('iframe')[window.name];
		obj.style.height	=	isXHTML() ? document.documentElement.scrollHeight +'px' : document.body.scrollHeight;
	}
}

function if_Resize(td,iframe) {
	td			=	td ? td : 'resizeTd';
	iframe		=	iframe ? iframe : 'content';
	
	var obj		=	document.getElementById(td);
	var ifrm		=	obj.getElementsByTagName('iframe')[0].contentWindow;

	obj.style.height	=	Math.max(ifrm.document.documentElement.scrollHeight,ifrm.document.body.scrollHeight) +'px';
	document.body.scrollTop	=	0;
}

function ajaxCreate() {
	var xmlHttp;

	if(window.ActiveXObject) {
		xmlHttp	=	new ActiveXObject("Microsoft.XMLHTTP");
	} else if(window.XMLHttpRequest) {
		xmlHttp	=	new XMLHttpRequest();
	}

	return xmlHttp;
}

function ajaxRequest(div,actionfile,param,xml) {
	var ajax		=	ajaxCreate();

	ajax.open(param ? "POST" : "GET",actionfile,false);
	ajax.setRequestHeader("content-type","application/x-www-form-urlencoded");
	ajax.send(param ? param : null);

	if(ajax == null){
		alert("AJAX NOT SUPPORT.");
		history.back();
	}

	if(xml) {
		eval(div+"(ajax)");
	} else {
		if(div) {
			document.getElementById(div).innerHTML	=	ajax.responseText;
		} else {
			return ajax.responseText;
		}
	}
}

function isIE() {
	return (navigator.appName == "Microsoft Internet Explorer") ? true : false;
}

function isIE7() {
	var flag				=	false;
	var arrVerStr		=	window.navigator.appVersion.split("; ");

	if(arrVerStr.length >= 4) {
		var arrIEVer	=	arrVerStr[1].split(" ");
		
		if(arrIEVer[1] >= 7.0) {
			flag			=	true;
		}
	}

	return flag;
}

function windowVersion() {
	var osVerNum		=	5.1;
	var arrVerStr		=	window.navigator.appVersion.split('; ');
	
	if( arrVerStr.length >= 4 ) {
		var arrOsVer	=	arrVerStr[2].split(' ');

		if( arrOsVer.length >= 3) {
			var osVerNum	=	new Number(arrOsVer[2]);
		}
	}

	return osVerNum;
}

function winResize() {
	var Dwidth		=	parseInt(Math.max(document.body.scrollWidth,document.documentElement.scrollWidth));
	var Dheight	=	parseInt(Math.max(document.body.scrollHeight,document.documentElement.scrollHeight));
	var divEl		=	document.createElement("div");

	divEl.style.position	=	"absolute";
	divEl.style.left		=	"0px";
	divEl.style.top		=	"0px";
	divEl.style.width	=	"100%";
	divEl.style.height	=	"100%";

	document.body.appendChild(divEl);
	window.resizeBy(Dwidth-divEl.offsetWidth,Dheight-divEl.offsetHeight);
	document.body.removeChild(divEl);
}

function imageResize(obj,size) {
	if(!size) {
		obj.width		=	"100%";
	} else {
		if(w=eval(obj.width) > size) obj.width = size;
	}
}

function addEvent(ev,fnc,obj) {
	obj		=	obj ? obj : window;

	if(isIE()) {
		obj.attachEvent(ev,fnc);
	} else {
		obj.addEventListener(ev.replace("on",""),fnc,false);
	}
}

function thisGame() {
	var gameName;
	var thisUri			=	top.location.host.split(".");

	if(thisUri[0].substr(0,2) == "mg") {
		gameName		=	thisUri[0].substr(2);
	} else if(thisUri[0].substr(thisUri[0].length-4) == "test") {
		gameName		=	thisUri[0].substr(0,thisUri[0].length-4);
	} else {
		gameName		=	thisUri[0];
	}

	return gameName;
}

function thisName() {
	var thisHref			=	location.href.split("/");
	var thisReFile		=	thisHref[thisHref.length-1].replace(/(\?(.)*)/gi,"");
	var thisLocate		=	thisReFile.split(".");

	return thisLocate[0].replace(/(_(.)*)/gi,"");
}

function thisFile(a) {
	var thisHref			=	location.href.split("/");
	var thisReFile		=	thisHref[thisHref.length-1].replace(/(\?(.)*)/gi,"");
	var thisLocate		=	thisReFile.split(".");
	var thisName		=	thisLocate[0].replace(/(_(.)*)/gi,"");

	return a ? thisName + "_" + a +"."+thisLocate[1] : thisName + "."+thisLocate[1];
}

function sortLink(v) {
	var f	=	document.procForm;
	
	f.sort.value	=	v;
	f.submit();
}

function copyLink(v) {
	try {
		var copyPath	=	copyUrl;
	} catch(e) {
		var copyPath	=	location.href +"?idx="+ v;
	}

	clipboardData.setData("Text",copyPath);
	error("It is successfully saved.");
}

function writeLink() {
	if(!colmgameUserCheck()) return;

	var p	=	document.procForm;

	p.action			=	thisFile("write");
	p.submit();
}

function recomLink() {
	if(!colmgameUserCheck()) return;

	var p	=	document.procForm;

	p.mode.value		=	"recom";
	p.action			=	thisFile("proc");
	p.submit();
}

function viewLink(idx,a) {
	var p	=	document.procForm;

	p.idx.value			=	idx;

	if(a) {
		p.action		=	a;
	} else {
		try {
			p.action	=	procAction;
		} catch(e) {
			p.action	=	thisFile("view");
		}
	}

	p.submit();
}

function pageLink(page) {
	var p	=	document.procForm;

	p.page.value		=	page;
	p.submit();
}

function listLink() {
	var p	=	document.procForm;

	p.action			=	thisFile();
	p.submit();
}

function modeLink(m) {
	if(!colmgameUserCheck()) return;

	var p	=	document.procForm;

	p.mode.value		=	m;
	p.action			=	thisFile("proc");
	p.submit();
}

function deleteLink() {
	if(!colmgameUserCheck()) return;

	if(!error("Do you want to delete?",true)) {
		return;
	}

	var p	=	document.procForm;

	p.mode.value		=	"delete";
	p.action			=	thisFile("proc");
	p.method			=	'post';
	p.submit();
}

function editLink() {
	if(!colmgameUserCheck()) return;

	var p	=	document.procForm;

	p.mode.value		=	"edit";
	p.action			=	thisFile("write");
	p.submit();
}

function ajaxProc() {
	try {
		var cAction		=	ajaxAction;
	} catch(e) {
		var cAction		=	thisFile("comment");
	}

	return cAction;
}

function ajaxResize() {
	try {
		parent.if_Resize2();
	} catch(e) {

	}
}

function ajaxId() {
	try {
		var div			=	ajaxDiv;
	} catch(e) {
		var div			=	"divAjax";
	}

	return div;
}

function ajaxVariable() {
	try {
		var query		=	ajaxQuery;
	} catch(e) {
		var query		=	"";
	}

	return query;
}

function ajaxPage(page) {
	ajaxRequest(ajaxId(),ajaxProc(),ajaxVariable() +"&page="+ ((typeof page == 'undefined') ? 1 : page));
	ajaxResize();

	try {
		document.commentForm.comment.focus();
		document.commentForm.comment.blur();
	} catch(ex) {
	}
}

 
function commentWrite() {
	if(!colmgameUserCheck()) return;

	var f	=	document.commentForm;
	
	f.comment.value	=	colmgameIlligalWordsCheck(f.comment.value);

	if(!f.comment.value.trim()) {
		error("Please type the comment.");
		f.comment.focus();
		return;
	}

	if(document.getElementsByName('emoticon')){
		var obj		=	document.getElementsByName('emoticon');
		for(var i=0;i<obj.length;i++){

			if(obj[i].checked	==	true){
				var emoticon	=	obj[i].value;
				break;
			}
		}
	}

	ajaxRequest(ajaxId(),ajaxProc(),ajaxVariable() +"&mode=write&comment="+ encodeURIComponent(f.comment.value)+"&emoticon="+emoticon);
	f.reset();
	ajaxResize();
}

function commentDelete(idx) {
	if(!colmgameUserCheck()) return;
	if(!error("Do you want to delete?",1)) return;

	ajaxRequest(ajaxId(),ajaxProc(),ajaxVariable() +"&mode=delete&idx="+ idx);
	ajaxResize();
}

String.prototype.trim = function() {
    return this.replace(/(^[ \f\n\r\t]*)|([ \f\n\r\t]*$)/g, "");
}

String.prototype.numberFormat	=	function() {
    return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
}

String.prototype.cut = function(len) {
	var str	=	this;
	var l	=	0;

	for(var i=0;i<str.length;i++) {
		l += (str.charCodeAt(i) > 128) ? 2 : 1;

		if(l > len) return str.substring(0,i) + "..";
	}

	return str;
}



function setCookie(name, value, expiredays)	{
	var expire_date = new Date();
	expire_date.setDate(expire_date.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; expires=" + expire_date.toGMTString() + "; path=/; domain="+ document.domain;
}

function getCookie(name) {
	var nameOfCookie = name + "=";
	var x = 0;

	while(x <= document.cookie.length) {
		var y	=	(x+nameOfCookie.length);
		if(document.cookie.substring(x,y) == nameOfCookie) {
			if((endOfCookie = document.cookie.indexOf(";",y)) == -1) {
				endOfCookie	=	document.cookie.length;
			}

			return unescape( document.cookie.substring(y,endOfCookie));
		}

		x	=	document.cookie.indexOf(" ",x) + 1;
		if(x == 0)
		break;
	}

	return "";
}

function encodeBase64(what) {
      var encodeTable	=	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
      var result			=	"";
      var len				=	what.length;
      var x,y;
      var ptr				=	0;

      while(len-- > 0) {
            x				=	what.charCodeAt(ptr++);
            result			+=	encodeTable.charAt((x >> 2) & 63);

            if(len-- <= 0) {
                  result		+=	encodeTable.charAt((x << 4) & 63);
                  result		+=	"==";
                  break;
            }

            y				=	what.charCodeAt(ptr++);
            result			+=	encodeTable.charAt(((x << 4) | ((y >> 4) & 15)) & 63);

            if(len-- <= 0) {
                  result		+=	encodeTable.charAt((y << 2) & 63);
                  result		+=	"=";
                  break;
            }

            x				=	what.charCodeAt(ptr++);
            result			+=	encodeTable.charAt( ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63 );
            result			+=	encodeTable.charAt( x & 63 );

      }

      return result;
}



function isXHTML(obj) {
	var xhtml;

	if(isIE()) {
		xhtml		=	(obj ? obj.document.documentElement.clientHeight : document.documentElement.clientHeight) ? 1 : 0;
	} else {
		try {
			xhtml	=	((obj ? obj.document.doctype.publicId.indexOf('XHTML') : document.doctype.publicId.indexOf('XHTML')) == -1) ? 0 : 1;
		} catch(ex) {
			xhtml	=	0;
		}
	}

	return xhtml;
}

function colmgameInit() {
	try {
		document.loginForm.userid.focus();
	} catch(ex) {
	}
}

//addEvent('onload',colmgameInit);
