<%@ page language="java" import="java.util.*,com.letousky.lottery.util.InsiderCenterFormat,com.letousky.lottery.action.LoginAction,com.anylotto.client.MD5Util,com.letousky.lottery.delegate.WinsFlat" pageEncoding="UTF-8"%>
<%

//********************************************************测试外来用户的cookie***************************//
String ssid=request.getParameter("sid");
String euid=request.getParameter("euid");
String mid=request.getParameter("mid");
if("duomai".equals(ssid)){
	  Cookie sidCookies = new Cookie("sid", ssid);
	  sidCookies.setMaxAge(3600*24*30);//30天的保存周期
	  sidCookies.setPath("/");
	  
	  Cookie euidCookies = new Cookie("euid", euid);
	  euidCookies.setMaxAge(3600*24*30);//30天的保存周期
	  euidCookies.setPath("/");
	  
	  Cookie midCookies = new Cookie("mid", mid);
	  midCookies.setMaxAge(3600*24*30);//30天的保存周期
	  midCookies.setPath("/");
	  response.addCookie(sidCookies);
	  response.addCookie(euidCookies);
	  response.addCookie(midCookies);
}
//********************************************************测试外来用户的cookie***************************//

	InsiderCenterFormat ide = new InsiderCenterFormat();
	String lotteryName = ide.getLotteryTypeName(request.getParameter("gameid"),request.getParameter("type"));
	String[] userAry=(String[])session.getAttribute("userAry");
	//**************************************************获取cookies********************************************************//
	String userId="";
	String passWord="";
	if(userAry==null){
		WinsFlat winsFlat=new WinsFlat();
		
		Cookie Cookies[]=request.getCookies();
		if(Cookies==null)
		{
			
		}
		else
		{
		for(int i=0;i < Cookies.length;i++)
		  {
			if("userId".equals(Cookies[i].getName())){
				userId=Cookies[i].getValue();
		     System.out.println("============Cookies============"+Cookies[i].getName()+"="+userId+"============Cookies============");
			}
			if("password".equals(Cookies[i].getName())){
				passWord=Cookies[i].getValue();
			     System.out.println("============Cookies============"+Cookies[i].getName()+"="+Cookies[i].getValue()+"============Cookies===============");
				}
		  }
		if(null!=userId && !"".equals(userId) && null!=passWord && !"".equals(passWord)){
			String loginName=winsFlat.findLoginNameByUserId(request,response,userId);	
			winsFlat.newLogin(request,response,new String[]{loginName,passWord,"",""});
		userAry = (String[]) session.getAttribute("userAry");
		}
	  }
	}
		//********************************************************获取cookies**************************************************//
	String uc_user = (String)session.getAttribute("uc_user");
	String uc_userout = (String)session.getAttribute("uc_userout");
	String password = "--" , key = "--" , un = "--" , keyout = "--";
	if(userAry!=null){
		new LoginAction().upLogin(request,response);
		userAry=(String[])session.getAttribute("userAry");
		if(uc_user!=null && !"".equals(uc_user)){
				out.print(uc_user);
		}
	}else{
		if(uc_userout!=null && !"".equals(uc_userout)){
			out.print(uc_userout);
			session.setAttribute("uc_userout",null);
		}
	}
	//String rootUrl=request.getContextPath();
	
	//============================================测试cookies======================================================//		
	Cookie Cookies[]=request.getCookies();
	if(Cookies==null)
	//out.print("还没有cookie值");
	;
	else
	{
	for(int i=0;i < Cookies.length;i++)
	  {
		if("userId".equals(Cookies[i].getName())){
	     System.out.println("============Cookies============"+Cookies[i].getName()+"="+Cookies[i].getValue()+"============Cookies============");
		}
		if("password".equals(Cookies[i].getName())){
		     System.out.println("============Cookies============"+Cookies[i].getName()+"="+Cookies[i].getValue()+"============Cookies===============");
			}
	  }
  }
//============================================测试cookies======================================================//
%>
	<link href="<%=request.getContextPath()%>/css/css.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/letoula/css/top.css" rel="stylesheet" type="text/css" />
	<!-- SCRIPT type=text/javascript src="<%=request.getContextPath()%>/js/jquery.min.js"></SCRIPT -->
    <SCRIPT type=text/javascript src="<%=request.getContextPath()%>/js/menu-js.js"></SCRIPT>
	<script type='text/javascript' src='<%=request.getContextPath()%>/letoula/js/plugin/library.js'></script>
	<script type='text/javascript'>
		var url = '<%=request.getContextPath()%>';
		var rootUrl = url;
	</script>

 <div class="topLine">
<div class="row">
<div class="fleft">您好，欢迎来到贝壳彩！</div>           
                    <span class='userMsg' id='userMsg'>
	      			<%if(userAry!=null){%>
	      			
	      			<a style="padding-right:10px; color:#fff" href="<%=request.getContextPath()%>/member/index.jsp"><%=userAry[2]%></a><a style="color:#fff" href="javascript:void(0)"   id='showm' onclick='document.getElementById("money").style.display="inline-block";document.getElementById("hidem").style.display="inline-block";this.style.display="none"'>显示余额</a>
	      			<div id='money' style='display:none; color:#fff'>账户余额：<b style="padding-left: 10px; color:#fff">￥<%=userAry[8]%></b> 活动奖金：<b style="padding-left: 10px;color:#fff">￥<%=userAry[13]%> </b>
	      			<a style="padding-left:10px; color:#fff" href="javascript:void(0)"  id='hidem' onclick='document.getElementById("money").style.display="none";document.getElementById("showm").style.display="inline-block";this.style.display="none"'>隐藏余额</a>
	      			</div>
	      			<a style="padding-left:10px; color:#fff" href="<%=request.getContextPath()%>/member/prepayIntro.jsp">充值</a>
	      			<a style="padding:0 10px; color:#fff" href="<%=request.getContextPath()%>/member/tzjl.jsp">我的投注</a>
	      			
	      			<a style="padding-left:10px; color:#fff" href="javascript:setting.unLogin()">退出</a>
	      			<%}else{%>
	      		    <a style="color:#fff" href="javascript:setting.login()">登录</a>&nbsp;&nbsp;
	      			<a style="color:#fff" href="<%=request.getContextPath()%>/member/reg.jsp" target="_blank" class='white'>免费注册</a>
	      			<%}%>
	      		</span>
                
</div></div>
  <div class="tips_m" id='loginEntrance' style="width:500px;height:192px; " id="blk1">
    <div class="tips_b">
         <div class="tips_box">
              <div class="tips_title">
                    <h2>用户登录</h2>
                    <span class="closes"><a class='close' onclick="setting.loginClose()">关闭</a></span>
               </div>
               <div class="tips_text">
             		<iframe id='entrance' width="440" height="150" frameborder="0" scrolling="no" src="<%=request.getContextPath()%>/letoula/loginDiv.jsp"></iframe>
              </div>
         </div>
    </div>
</div> 
<div id='bd'>aa</div>
<script type='text/javascript' src='<%=request.getContextPath()%>/letoula/js/public.js'></script>
