	function onclick_page(style , gameId , kindId , currentPage){
		if(style == 'page_up_gray'){
			return;
		}
		if(style == 'next_page_gray'){
			return;
		}
		$('#gameId').val(gameId);
		$('#currentPage').val(currentPage);
		$('#kindId').val(kindId);
		if(gameId == 0){
			document.getElementById('lobbyDataForm').action = 'gotoWebLobby.do';
		}else{
			document.getElementById('lobbyDataForm').action = 'gotoGameRoom.do';
		}
		document.getElementById('lobbyDataForm').submit();
	}
	function over_page(obj){
		var style = obj.className;
		obj.className = style + "_over";
	}
	function out_page(obj){
		var style = obj.className;
		obj.className = style.substring(0 , style.length-5);
	}
	function getIndex(obj){
		var cn = obj.className;
		return cn.substring(cn.length - 1);
	}
	function onclick_kind(obj){
		var index = getIndex(obj);
		if(index == 0){
			$('#kindId').val(-1);
		}else{
			$('#kindId').val(index);
		}
		document.getElementById('lobbyDataForm').action = "gotoWebLobby.do";
		document.getElementById('lobbyDataForm').submit();
	}
	function over_kind(obj){
		var index = getIndex(obj);
		obj.className="lobby_btnshow_" + index;
	}
	function out_kind(obj){
		var index = getIndex(obj);
		obj.className="lobby_btn_" + index;
	}
	
	function gotoGame(gameId , kindId){
		if(gameId != 21){
			alert("这个游戏将在稍后推出，您可以选择下载客户端玩这个游戏，谢谢您的关注");
			if(confirm("您是否下载客户端")){
				window.open("http://dlx.gc73.com/pokercity-st1.0.0.27.exe");
			}
			return;
		}
		$('#gameId').val(gameId);
		$('#kindId').val(kindId);
		document.getElementById('lobbyDataForm').action = "gotoGameRoom.do";
		document.getElementById('lobbyDataForm').submit();
	}

	function goFlashRoom(roId , leftSpace, money, level , roomLv){
		if(roomLv == 4){
			if(level >= 5){
				alert("对不起，您的等级已经达到五级不能进入新手房");
				return;
			}
		}else if(roomLv == 5){
			if(level < 5 && money < 12000){
				alert("对不起，您的星币数没有12000不能进入初级房");
				return;
			}
		}
		$.ajax({url:'ajaxGetFreshToken.do',type:'post',dataType:'json',
			success:function(data){
				$('#roId').val(roId);
				$('#freshToken').val(data.freshToken);
				document.getElementById('lobbyDataForm').action = "gotoFlashRoom.do";
				document.getElementById('lobbyDataForm').submit();
			}
		});

	}

	function gotoBack(kindId){
		$('#kindId').val(kindId);
		$('#currentPage').val(1);
		document.getElementById('lobbyDataForm').action = "gotoWebLobby.do";
		document.getElementById('lobbyDataForm').submit();
	}
	
	function loginLobby(){
		var username = $('#username').val();
		var password = $('#password').val();
		if(username == ''){
			alert('请输入用户名');
			return false;
		}
		if(password == ''){
			alert('请输入密码');
			return false;
		}
		document.getElementById('webLobbyLoginForm').action="loginWebLobby.do";
		document.getElementById('webLobbyLoginForm').submit();
	}

	function enterLoginLobby(event){
		if(event.keyCode == 13){
			var username = $('#username').val();
			var password = $('#password').val();
			if(username != "" && password != ""){
 				login_lobby_gray();
			}
		}
	}
	
	function login_lobby_gray(){
		var _this = document.getElementById('loginButton');
		var className = _this.className;
		if(className.indexOf('gray_') == -1){
			_this.className = "gray_"+className.substring(className.indexOf('_') + 1);
			if(!loginLobby()){
				setTimeout(function(){
					back_state_skip(_this);
				} , 5000);
			}else{
				setTimeout(function(){
					back_state_skip(_this);
				} , 20000);
			}
		}else{
			return;
		}
		
	}
	
	function onkey_over(obj){
		var className = obj.className;
		if(className.indexOf('_init') == -1){
			return;
		}
		obj.className = className.substring(0 , className.length - 5) + "_over";
	}
	
	function onkey_down(obj){
		var className = obj.className;
		if(className.indexOf('_over') == -1){
			return;
		}
		obj.className = className.substring(0 , className.length - 5);
	}
	
	function onkey_up(obj){
		var className = obj.className;
		if(className.substring(className.length - 5) == "_over"){
			return;
		}
		obj.className = className + "_over";
		var keys = className.split('_');
		if(keys[2] == 'cap'){
			setCaps();
		}
		if(focusId == undefined){
			return;
		}
		var input = document.getElementById(focusId);
		var text = input.value;
		if(focusId == 'username'){
			if(text.length >= 14){
				if(keys[2] == 'back'){
					text = text.substring(0 , 13);
					document.getElementById(focusId).value = text;
				}
				return ;
			}
		}else if(focusId == 'password'){
			if(text.length >= 16){
				if(keys[2] == 'back'){
					text = text.substring(0 , 15);
					document.getElementById(focusId).value = text;
				}
				return ;
			}
		}
		
		if(keys[2] == 'back'){
			if(text != ""){
				text = text.substring(0 , text.length -1);
				document.getElementById(focusId).value = text;
			}
		}else if(keys[2] == 'cap'){
			return;
		}else{
			document.getElementById(focusId).value = text + keys[2];
		}
		
	}
	
	function onkey_out(obj){
		var className = obj.className;
		if(className.split('_').length == 3){
			obj.className = obj.className + "_init";
		}else{
			obj.className = className.substring(0 , className.length - 5) + "_init";
		}		
	}

	var focusId;
	var cursorPosition;
	
	function setRange(id){
		
		focusId = id;
	}
	
	function setCursorPosition(id,pos){ 
	    var textbox = document.getElementById(id);
	    var r = textbox.createTextRange();
	    r.collapse(true); 
	    r.moveStart('character',pos);
	    r.select();
	} 
	
	function getCursorPosition(id){
		var textbox = document.getElementById(id); 
	 	var rng = textbox.createTextRange();
	    rng.moveToPoint(event.x,event.y); 
	    rng.moveStart("character",-textbox.value.length);
	    return rng.text.length; 
	}
	
	function remeberAccount(){
		var checkImg = document.getElementById('checkImg');
		if(checkImg.src.indexOf('account_check.png') != -1){
			checkImg.src = "http://png.gc73.com.cn/web_lobbyimg/account.png";
			$('#ifRemember').val(0);
		}else{
			checkImg.src = "http://png.gc73.com.cn/web_lobbyimg/account_check.png";
			$('#ifRemember').val(1);
		}
	}
	var words = new Array('A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y' ,'Z');
	function setCaps(){
		for(var i = 0 ; i < 26; i++){
			var wordKeys = document.getElementById('wordKey'+i);
			var className = wordKeys.className;
			if(className.split('_')[2] == words[i]){
				wordKeys.className='lobby_key_'+words[i].toLowerCase()+'_init';
			}else{
				wordKeys.className='lobby_key_'+words[i].toUpperCase()+'_init';
			}
		}
	}
	
	var intervalId;
	
	function displayRank(id){
		if(id == 'contain_moneyRank'){
			document.getElementById('contain_integralRank').style.display = "none";
			document.getElementById('contain_expTimeRank').style.display = "none";
			if(document.getElementById(id).firstChild.id != 'first_money'){
				changeRank(document.getElementById(id));
			}
			$('#rank_title').html('星币');
			document.getElementById(id).style.display = "block";
			document.getElementById("contain_moneyRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_07.png";
			document.getElementById("contain_integralRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_05.png";
			document.getElementById("contain_expTimeRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_12.png";
		}else if(id == 'contain_integralRank'){
			document.getElementById('contain_moneyRank').style.display = "none";
			document.getElementById('contain_expTimeRank').style.display = "none";
			if(document.getElementById(id).firstChild.id != 'first_integral'){
				changeRank(document.getElementById(id));
			}
			$('#rank_title').html('元宝');
			document.getElementById(id).style.display = "block";
			document.getElementById("contain_moneyRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_02.png";
			document.getElementById("contain_integralRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_08.png";
			document.getElementById("contain_expTimeRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_12.png";
		}else if(id == 'contain_expTimeRank'){
			document.getElementById('contain_moneyRank').style.display = "none";
			document.getElementById('contain_integralRank').style.display = "none";
			if(document.getElementById(id).firstChild.id != 'first_expTime'){
				changeRank(document.getElementById(id));
			}
			$('#rank_title').html('等级');
			document.getElementById(id).style.display = "block";
			document.getElementById("contain_moneyRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_02.png";
			document.getElementById("contain_integralRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_05.png";
			document.getElementById("contain_expTimeRank_img").src="http://png.gc73.com.cn/lobbyimg/ph_06.png";
		}
		if(intervalId != undefined){
			window.clearInterval(intervalId);
		}
		intervalId = setInterval('changeRank(' +id+ ')' , 4000);
	}
	
	function changeRank(_this){
		_this.appendChild(_this.firstChild);
	}
	
	function openUrl(url , target , _this){
		if(_this != undefined){
			if(_this.className.indexOf("gray_") != -1){
				return;
			}
		}
		if(target == undefined){
			window.location.href=url;
		}else if(target == '_blank'){
			window.open(url);
		}else if(target == '_self'){
			window.location.href=url;
		}else{
			window.location.href=url;
		}
	}
	
	function lobby_over(_this){
		var className = _this.className;
		if(className.indexOf('out_') != -1){
			_this.className = "over_" + className.substring(4);
		}
	}
	
	function lobby_down(_this){
		var className = _this.className;
		if(className.indexOf('over_') != -1){
			_this.className = "click_"+className.substring(5);
		}
	}
	
	function lobby_up(_this){
		var className = _this.className;
		if(className.indexOf('click_') != -1){
			_this.className = "over_" + className.substring(6);
		}
	}
	
	function lobby_out(_this){
		var className = _this.className;
		if(className.indexOf('gray_') != -1){
			return;
		}
		var pos = className.indexOf('_');
		_this.className = "out_" + className.substring(pos + 1);
	}
	
	function lobby_gray_skip(_this , url){
		var className = _this.className;
		if(className.indexOf('over_') != -1){
			_this.className = "gray_"+className.substring(5);
			if(url != undefined){
				openUrl(url);
			}
		}
		setTimeout(function(){
			back_state_skip(_this);
		} , 20000);
	}
	
	function back_state_skip(_this){
		var className = _this.className;
		var pos = className.indexOf('_');
		_this.className = "out_" + className.substring(pos + 1);
	}
	
	function lobby_gray(_this){
		var className = _this.className;
		if(className.indexOf('over_') != -1){
			_this.className = "gray_"+className.substring(5);
		}
		setTimeout(function(){
			back_state(_this);
		} , 20000);
	}
	
	function back_state(_this){
		var className = _this.className;
		var pos = className.indexOf('_');
		_this.className = "out_" + className.substring(pos + 1);
		_this.onclick=function(){updateUserInfo(this);};
	}
	
	function updateUserInfo(_this){
		_this.onclick = function(){void(0);};
		$.ajax({
			url:'updateUserInfo.do',
			type:'post',
			dataType:'json',
			success:function(data){
				if(data.code == 'S'){
					$('#updateMoney').html(data.money);
					$('#updateIntegral').html(data.integral);
				}else if (data.code == 'G'){
					alert(data.message);
					window.location.href='login.do';
				}else if (data.message != undefined && data.message != ''){
					alert(data.message);
				}
			},
			error:function(data){
				alert("网络异常，请稍后重试");
			}
		})
	}

	function noFunction(){
		alert("此功能将在稍后推出");
	}
	