<%@ include file="validate.jsp" %>
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
<%@ page import="cn.sendsms.jdsmsserver.web.Charge"%>
<%@ page import="cn.sendsms.jdsmsserver.*"%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/util.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_gateway_service")%></title>
<link rel="stylesheet" type="text/css" href="css.css">
<style type="text/css">
a:link {
	color: #FFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFF;
}
a:hover {
	text-decoration: underline;
	color: #FFF;
}
a:active {
	text-decoration: none;
	color: #FFF;
}

</style>
<!-- <link href="css2.css" type="text/css" rel="stylesheet"/> -->
<%
Charge charge=(Charge)request.getAttribute("charge");
%>
<script type="text/javascript">
function getExplorerVersions(){
	var userAgent = navigator.userAgent,   
	rMsie = /(msie\s|trident.*rv:)([\w.]+)/,   
	rFirefox = /(firefox)\/([\w.]+)/,   
	rOpera = /(opera).+version\/([\w.]+)/,   
	rChrome = /(chrome)\/([\w.]+)/,   
	rSafari = /version\/([\w.]+).*(safari)/;  
	var browser;  
	var version;  
	var ua = userAgent.toLowerCase();  
function uaMatch(ua){  
	var match = rMsie.exec(ua);  
	if(match != null){  
		return { browser : "IE", version : match[2] || "0" };  
	}  
	var match = rFirefox.exec(ua);  
	if (match != null) {  
		return { browser : match[1] || "", version : match[2] || "0" };  
	}  
	var match = rOpera.exec(ua);  
	if (match != null) {  
		return { browser : match[1] || "", version : match[2] || "0" };  
	}  
	var match = rChrome.exec(ua);  
	if (match != null) {  
		return { browser : match[1] || "", version : match[2] || "0" };  
	}  
	var match = rSafari.exec(ua);  
	if (match != null) {  
		return { browser : match[2] || "", version : match[1] || "0" };  
	}  
	if (match != null) {  
		return { browser : "", version : "0" };  
	}  
}  
	var browserMatch = uaMatch(userAgent.toLowerCase());  
	if (browserMatch.browser){  
		browser = browserMatch.browser;  
		version = browserMatch.version;  
	}  
	var re = browser+version;
	return re;
}  

	function check(){
		var serialnum = $('#serialnum').text();
		if(trim(serialnum)==''){
			alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_please_enter_the_user_name")%>');
			document.getElementById('serialnum').focus();
			return false;
		}
		var pwd = $('#pwd').val();
		if(trim(pwd)==''){
			alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_please_enter_the_password")%>');
			document.getElementById('pwd').focus();
			return false;
		}
		return true;
	}
	function balance(serialnumval,pwdval){
	   //if(check()){
            $.get("gateway",{action : "balance",
					                    serialnum : serialnumval,
					                    pwd : pwdval,
				                        time      : new Date().getTime()
				 },function(data,textStatus){
				 	
					 var result=$(data).find("error").text();
					 var errorDesc=$(data).find("errorDesc").text();
					 var surplusNumber=$(data).find("surplusNumber").text();

					 if(result=="-1"){
						  alert(errorDesc);
						  return;
					 }
					 if(result=="0"){
						  document.getElementById('surplusNumber').innerText=surplusNumber;
						  
						  return;
					 }
				 });
	   //}
	}
	function register(){
		   var iWidth=450; //窗口宽度
           var iHeight=350;//窗口高度
           var iTop=(window.screen.height-iHeight)/2;
           var iLeft=(window.screen.width-iWidth)/2;
           var register_result;
		   var eee = getExplorerVersions();
		   if(eee == 'IE8.0'){
           register_result=window.showModalDialog("gatewayregister.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           }
		   else{
		   register_result = window.open("gatewayregister.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
		   }
           //var register_result=window.showModalDialog("gatewayregister.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           //var register_result = window.open("gatewayregister.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
           window.onfocus=function (){register_result.focus();}
           window.onclick=function (){register_result.focus();}
           /* if(register_result=='true'){
			   if(window.confirm("激活成功,是否现在充值?")){
				   renew();
			   }
		   } */
	}
	function gatewayServiceApplay(){
           var iWidth=450; //窗口宽度
           var iHeight=350;//窗口高度
           var iTop=(window.screen.height-iHeight)/2;
           var iLeft=(window.screen.width-iWidth)/2;
           
           var apply_result;
		   var eee = getExplorerVersions();
		   if(eee == 'IE8.0'){
			   apply_result=window.showModalDialog("gatewayaply.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           }
		   else{
			   apply_result = window.open("gatewayaply.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
		   }
           //var apply_result=window.showModalDialog("gatewayaply.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           //var apply_result = window.open("gatewayaply.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
           window.onfocus=function (){apply_result.focus();}
           window.onclick=function (){apply_result.focus();}
           /* if(apply_result=='true'){
			   if(window.confirm("申请成功,是否现在激活?")){
                  register();
			   }
		   } */
	}
	function chargefee(){
		   var iWidth=450; //窗口宽度
           var iHeight=350;//窗口高度
           var iTop=(window.screen.height-iHeight)/2;
           var iLeft=(window.screen.width-iWidth)/2;
           
           var charge_result;
		   var eee = getExplorerVersions();
		   if(eee == 'IE8.0'){
			   charge_result=window.showModalDialog("gatewaycharge.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           }
		   else{
			   charge_result = window.open("gatewaycharge.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
		   }
           
           //window.showModalDialog("gatewaycharge.jsp",window,"dialogHeight: "+iHeight+"px; dialogWidth: "+iWidth+"px; dialogTop:"+iTop+" ; dialogLeft: "+iLeft+"; resizable: no;status: no;scroll:no;location:no");
           //var charge_result = window.open("gatewaycharge.jsp",window,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+", resizable=no,status=no,scroll=no,location=no");
           window.onfocus=function (){charge_result.focus();}
           window.onclick=function (){charge_result.focus();}
	}
	function renew(){
		  // 2023.07.14 119.90.56.86 -> gateway.sendsms.cn
		  var url="http://gateway.sendsms.cn:8050/alipay?action=Init&serialnum="+$("#serialnum").text();
		  window.open(url);
		 //window.open('http://www.baidu.com');
         // window.top.location.href="http://127.0.0.1:8050/alipay?action=Init&serialnum="+$("#serialnum").val();
	  // }
	}

	// 点击刷新
	function refresh(obj){
		var serialnum = $("#serialnum").html();
		var pwd = $('#pwd').val();
		$(obj).css({'transform':'rotate(0deg)'});
		$(obj).css({'transform':'rotate(180deg)'});
		setTimeout(function(){
			$(obj).css({'transform':'rotate(0deg)'});
		},1000);

		if(serialnum != "" && pwd != ""){
			balance(serialnum,pwd);
		}else{
			return false;
		}
	}
</script>
<script type="text/javascript">
function check(){
		var serialnum = $('#serialnum').val();
		if(trim(serialnum)==''){
			alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_please_enter_the_user_name")%>');
			document.getElementById('serialnum').focus();
			return false;
		}
		var pwd = $('#pwd').val();
		if(trim(pwd)==''){
			alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_please_enter_the_password")%>');
			document.getElementById('pwd').focus();
			return false;
		}
		return true;
	}
function apliay(){
	//window.returnValue='false';
    if(check()){
		   $.get("gateway",{action : "apply",
					                    serialnum : $("#serialnum").val(),
					                    pwd : $("#pwd").val(),
			                       telephone: $("#telephone").val(),
			                     companyname: $("#companyname").val(),
			                     userDesc   : $("#userDesc").val(),
				                        time      : new Date().getTime()
				 },function(data,textStatus){
					 var result=$(data).find("error").text();
					 var errorDesc=$(data).find("errorDesc").text();
					 var surplusNumber=$(data).find("surplusNumber").text();
					 if(result=="-1"){
						  alert(errorDesc);
						  return;
					 }
					 if(result=="0"){
						  if(trim(document.getElementById('serialnum').innerText)==''){
						  document.getElementById('serialnum').innerText=$("#serialnum").val();
						  document.getElementById('pwd').value=$("#pwd").val();
						  }
						  //window.returnValue='true';
						  alert('<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_apply_successfully_please_ctivate")%>');
					 }
				 });
	}
}
</script>
<style type="text/css">
	.action{
		background: #fff !important;
		box-shadow: 0 0 4px 2px #40D1D3 !important;
		border-radius: 5px !important;
		behavior:url(css/PIE.htc);
	}
	.clear{
		clear:both;
	}
	.getway_header{
		background: #f3f3f3;
		border-radius: 5px;
		padding:15px 30px 20px 30px;
		min-width: 1000px;
	}
	.getway_one{
		width:45%;
		margin:0 auto;
		margin-bottom:20px;
	}
	.getway_one_left{
		display: inline-block;
		float:left;
	}
	.getway_one_left i,.getway_one_right i{
		display: inline-block;
		width:60px;
		height:60px;
		float:left;
		background: url(w_img/getway_account.png) 100%;
	}
	.getway_one_right i{
		background: url(w_img/getway_total.png) 100%;
	}
	.getway_one_left span,.getway_one_right span{
		line-height: 60px;
	}
	.getway_one_right{
		display: inline-block;
		float:right;
	}

	.getway_two{
		width:90%;
		margin:0 auto;
	}
	.getway_two_item{
		display: inline-block;
		float:left;
		margin:0 auto;
		background: #e9e9e9;
		border-radius: 5px;
		box-shadow: 0px 1px 3px 0px #e9e9e9;
		padding:20px 10%;
		line-height: 36px;
		/*margin-left:30px;*/
		font-size:16px;
		color:#000;
		z-index: 99;
		zoon:1;
	}
	.getway_two_item a{
		color:#1b1b1b;
		text-decoration: none;
	}
	.getway_two_item:first-child{
		margin-left:0px;
	}
	.getway_two_item_ico1{
		display: inline-block;
		width:36px;
		height:36px;
		float:left;
		margin-right:10px;
		background: url(w_img/getway_sq.png);
		font-family: MicrosoftYaHei;
		font-size: 16px;
		color: #1B1B1B;
	}
	.getway_two_item_ico2{
		display: inline-block;
		width:36px;
		height:36px;
		float:left;
		margin-right:10px;
		background: url(w_img/getway_jh.png);
		font-family: MicrosoftYaHei;
		font-size: 16px;
		color: #1B1B1B;
	}
	.getway_two_item_ico3{
		display: inline-block;
		width:36px;
		height:36px;
		float:left;
		margin-right:10px;
		background: url(w_img/getway_cz.png);
		font-family: MicrosoftYaHei;
		font-size: 16px;
		color: #1B1B1B;
	}

	/*  */
	.getway_container{
		background: #fff;
		margin-top:20px;
		padding:30px 0px;
	}
	.getway_container_content{
		margin:0 auto;
		width:300px;
		margin-top:30px;
	}

	.getway_content_item{
		padding:5px;
		margin-bottom:10px;
	}
	.getway_item_left{
		display: inline-block;
		float:left;
		width:100px;
		margin-right:10px;
		text-align: right;
		line-height: 28px;
		font-size: 14px;
	}
	.getway_input{
		height:20px;
		outline: none;
		border:1px solid #dbdada;
		border-radius: 3px;
		padding:3px 0px 3px 5px;
	}
	.getway_btn{
		width:130px;
		height:28px;
		border:1px solid #fff;
		background: #5dbcb6;
		color:#fff;
		border-radius: 5px;
		cursor: pointer;
	}
	.refresh{
		display: inline-block;
		overflow: hidden;
		position: relative;
		top:10px;
		left:5px;
		transition: all 1s;
        transform: rotate(0deg);
        outline: none;
	}
	.refresh img{
		width:36px;
		outline: none;
	}

</style>
</head>
<body style="overflow-y:hidden;">
<div id="top"><span><img src="img/tu1.jpg"></span><%
		out.println(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.menu_gateway"));
	%></div>
<div id="center" style="padding:15px 33px 0px 33px;background: #fcfcfc;min-height: 0px;">
&nbsp;
	<div class="getway_header">
		<div class="getway_one">
			<div class="getway_one_left">
				<i></i>
				<span><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_user_name1")%></span>
				<h2 id="serialnum" style="display: inline-block;font-weight: normal;font-size:30px;line-height: 5px;"><%=charge.getSn()%></h2>
			</div>
			<input type="hidden" name="p" id="pwd" value="<%=charge.getPwd()%>">
			<div class="getway_one_right" >
				<i></i>
				<span><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_the_currently_available_number1")%></span>
				<h2 style="display: inline-block;font-weight: normal;font-size:30px;line-height: 5px;" id="surplusNumber"><%=request.getAttribute("surplusNumber")%></h2> 
				<a href="javascript:;" class="refresh" onclick="refresh(this)">
					<img src="w_img/refresh.png">
				</a>
				
			</div>
			<div class="clear"></div>
		</div>
		<div class="getway_two">
			<a href="gatewayaply.jsp" target="gatewaybottom">
			<div class="action getway_two_item">
					<i class="getway_two_item_ico1"></i>
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_apply_for_using_SMS_platform1")%>
			</div>
			</a>

			<a href="gatewayregister.jsp" target="gatewaybottom">
			<div class="getway_two_item">
					<i class="getway_two_item_ico2"></i>
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_activate")%>
			</div>
			</a>
			
			<a href="javascript:;" onclick="renew()">
			<div class="getway_two_item">
					<i class="getway_two_item_ico3"></i>
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_pay_online_via_alipay1")%>
			</div>
			</a>
			<div class="clear"></div>
		</div>
	</div>

<!-- 	<div class="getway_container">
		<center style="font-size:18px;font-weight: bold;"><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_apply_for_using_SMS_platform1")%></center>
		<div class="getway_container_content">
			<div class="getway_content_item">
				<div class="getway_item_left">
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_user_name")%>
				</div>
				<input type="text" class="getway_input" name="serialnum" id="serialnum"  value="">
			</div>
			<div class="getway_content_item">
				<div class="getway_item_left">
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_password")%>
				</div>
				<input type="password" class="getway_input" name="pwd" id="pwd" value="">
			</div>
			<div class="getway_content_item">
				<div class="getway_item_left">
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_customer_name")%>
				</div>
				<input type="text" class="getway_input" name="userDesc" id="userDesc" value="">
			</div>
			<div class="getway_content_item">
				<div class="getway_item_left">
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_phone_number")%>
				</div>
				<input type="text" class="getway_input" name="telephone" id="telephone" value="">
			</div>
			<div class="getway_content_item">
				<div class="getway_item_left">
					<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_company_name")%>
				</div>
				<input type="text" class="getway_input" name="companyname" id="companyname" value="">
			</div>
			<div class="getway_content_item">
				<input type="button" class="getway_btn" value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_sure")%>" onclick="apliay()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<input style="border:1px solid #9cc0c1;background: #fff;color:#5db3b6;" type="button" class="getway_btn" value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.gateway_cancel")%>">
			</div>
		</div>
	</div> -->
</div>

</body>
<script type="text/javascript">
	$('.getway_two_item').eq(2).css({'float':'right'});
	var gateway_width = $('.getway_two').width();
	var gateway_item_width = $('.getway_two_item').innerWidth();
	var gateway_item_offset = ((gateway_width-gateway_item_width*2.1)-gateway_item_width)/2;
	$('.getway_two_item').eq(1).css({"margin-left":gateway_item_offset+"px"});

	$('.getway_two_item').click(function(){
		$('.getway_two_item').removeClass("action");
		$(this).addClass("action");
	})
</script>
</html>