
  function fenster (url,xs,ys) {
	var win,hoch,breit,x,y;
	hoch=(screen.height-xs)/2;
	breit=(screen.width-ys)/2;
	self.focus();
	win=window.open(url,'fenster','scrollbars=no,resizable=no,height='+xs+',width='+ys+',screenX='+breit+',screenY='+hoch);
	win.moveTo(breit,hoch);
  }

  function choosePage( page ) { 
	var url = page+'.php';
	fenster(url,350,500);
  }

  function showInfoframe()
  {
	document.getElementById('infolayer').style.display = "block";
  }
  function hideInfoframe() {
	document.getElementById('infolayer').style.display = "none";
  }

	function showForgottenPW() {
	document.getElementById('div_register').style.display = "none";
	document.getElementById('div_sendpw').style.display = "block";
	document.getElementById('registerlayer').style.display = "block";
	hideInfoframe();
  }
  function showRegisterform() {
	document.getElementById('div_sendpw').style.display = "none";
	document.getElementById('div_register').style.display = "block";
	document.getElementById('registerlayer').style.display = "block";
	hideInfoframe();
  }

  function hideRegisterLayer() {
	document.getElementById('registerlayer').style.display = "none";
	document.getElementById('div_register').style.display = "none";
	document.getElementById('div_sendpw').style.display = "none";
  }
  
  function showLogoutLayer()
  {
	document.getElementById('logoutlayer').style.display = "block";
	document.getElementById('logoutimp').style.display = "block";
	document.getElementById('loginlayer').style.display = "none";
	hideRegisterLayer();
	hideInfoframe();
  }
  function showLoginLayer()
  {
	document.getElementById('logoutlayer').style.display = "none";
	document.getElementById('logoutimp').style.display = "none";
	document.getElementById('loginlayer').style.display = "block";
  }

	function displayBrowserUpdateInformation(whichOne) {
		document.getElementById('uptoolbar').style.top = "50px";
		var bui = document.getElementById('bui');
		var blogo = document.getElementById('browserlogo');
		var blink = document.getElementById('browserlink');
		//bui.innerHTML = "blabla";
		if (whichOne == 'firefox'){
			blogo.src  = 'pics/ff3_logo_f.png';
			blink.href = 'http://www.mozilla.com/en-US/';
		}
		if (whichOne == 'ie'){
			blogo.src  = 'pics/ie8_logo_f.png';
			blink.href = 'http://www.microsoft.com/windows/internet-explorer/worldwide-sites.aspx';
		}

		bui.style.display = "block";

	}



var Base64 = {

	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}
}

/* define some globals... */
HASCLICKED = false;
microCache = null;

/* reset locking of one of the form items is changed */
function resetClick() {
	HASCLICKED = false;
	return true;
}

function trim( str)
{
	var s = str;
	// make sure the string is not empty
	if(s.length > 0 && s.search(/\S+/) == -1) return '';
	
	var s2 = s.replace(/^\s*([\S\s|\s]*)\b\s*$/,'$1');
	return s2;
}
/* submit the form */
function submitLogin() {	
	document.getElementById('b64_pass').value = Base64.encode( document.getElementById('login_pass').value );
	return true;
}
/* logout page uses different ids*/
function submitLoginLogout() {
	document.getElementById('b64_pass_logout').value = Base64.encode( document.getElementById('login_pass_logout').value );
	return true;
}


function showcb(id) 
{
	for(var i = 1 ; i <= 7 ; i++)
	{
		if(document.getElementById('contentbox' + i) && i != id) document.getElementById('contentbox' + i).style.display="none";
	}
	document.getElementById('contentbox' + id).style.display="block";
}

function closecb () 
{
	for(var i = 1 ; i <= 7 ; i++)
	{
		if(document.getElementById('contentbox' + i)) document.getElementById('contentbox' + i).style.display="none";
	}
}

function chkGamesload(init)
{
	var GL = window.myGLTicket.ticket;
	var tickinfo = GL.tickinfo;
	var hashinfo = GL.hashinfo;
	var status = GL.status;
	
	if(status == 'OK') location.href="gl_login.php?tickinfo=" + tickinfo + "&hashinfo=" + hashinfo;
	else
	{
		if(init == 1) return false;
		else ;	
	}
}
