<%@ page import="cn.sendsms.jdsmsserver.web.User"%>
<%@ page import="cn.sendsms.jdsmsserver.JDSMSServer"%>
<%@ page import="cn.sendsms.jdsmsserver.*"%>
<%@ page import="cn.sendsms.Library"%>
<%@ page language="java" contentType="text/html; charset=GBK"  pageEncoding="GBK"%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
String userID;
try{
    User user1=(User)session.getAttribute("user");
    userID=user1.getUserId();
}catch(Exception e){
    userID="Unkown";
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<noscript>
<meta http-equiv="refresh" content="2;url=/system?action=callRestart">
</noscript>
<title>Restart</title>
<link href="css.css" type="text/css" rel="stylesheet">
<link href="css/w_css.css" type="text/css" rel="stylesheet">
<style>
a{color:darkcyan;}
a:hover{text-decoration:underline;}
</style>
<script type="text/javascript" src="./js/wjs.js"></script>
<script type="text/javascript">
var i = 0;
var cycleTimer;
var ajaxTimer;
window.onBeforeUnload=clear;
function cycler(){
	if(i == 11)
		i = 0;
	i++;
	
	for(var j =1;j<=11;j++){
		var obj =document.getElementById('wait'+j);
		if(i == j){
			obj.style.display='block';
		}else
			obj.style.display='none';
	}	
	cycleTimer=setTimeout(cycler,60);
}
function clear(){
	clearTimeout(cycleTimer);
}
function restart(){
	var xmlhttp1;
    var xmlhttp2;
    if (window.XMLHttpRequest)
    {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp1=new XMLHttpRequest();
        xmlhttp2=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp1.open("GET","/system?action=callRestart&rand="+Math.round(Math.random()*700 + 800),true);
    xmlhttp1.send();/*发送指令重启 */
    wait();/*转圈圈~ */
    xmlhttp1.onreadystatechange=function()
    {
        if (xmlhttp1.readyState==4)
        {
            ajaxTimer=setInterval(function(){
                xmlhttp2.open("GET","/logon.jsp",true);
                xmlhttp2.send();
                xmlhttp2.onreadystatechange=function()
                {
                    if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
                    {
                        clearInterval(ajaxTimer);
                        document.getElementById('waitText').innerHTML="<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.restart_done")%>";
                        window.top.location.href="/logon.jsp";
                    }
                }
            },1000);            
        }
    }	
}
function wait(){
	ld.style.display="block";
	waitdiv.style.display="block";
	cycler();    
}
</script>
</head>
<body onload="restart()">
<div id="top"><span><img src="img/tu1.jpg"></span><%
    out.println(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.restart_midware"));
    JDSMSServer.getInstance().getService().getLogger().logInfo(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.restart_request"),null,null);
%></div>
<div id="news"></div>
<div id="ld" style="position:absolute; display:none; left:-1px; top:1px; width:100%; height:100%; background-color:#FFFFFF; 
	filter:alpha(opacity=50);-moz-opacity:0.5; -khtml-opacity: 0.5;opacity: 0.5; z-index:1000;">
</div>
<div id="waitdiv" style="position:absolute;display:none;left:50%;top:40%;width:100px;height:100px;background-color:#FFFFFF; z-index:1001;" >
<img alt="" id="wait1" src="img_new/cycle1.jpg" style="display:none">
<img alt="" id="wait2" src="img_new/cycle2.jpg" style="display:none">
<img alt="" id="wait3" src="img_new/cycle3.jpg" style="display:none">
<img alt="" id="wait4" src="img_new/cycle4.jpg" style="display:none">
<img alt="" id="wait5" src="img_new/cycle5.jpg" style="display:none">
<img alt="" id="wait6" src="img_new/cycle6.jpg" style="display:none">
<img alt="" id="wait7" src="img_new/cycle7.jpg" style="display:none">
<img alt="" id="wait8" src="img_new/cycle8.jpg" style="display:none">
<img alt="" id="wait9" src="img_new/cycle9.jpg" style="display:none">
<img alt="" id="wait10" src="img_new/cycle10.jpg" style="display:none">
<img alt="" id="wait11" src="img_new/cycle11.jpg" style="display:none">
<p id="waitText" ><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.restart_initiating")%></p>
<p id="waitAnchor"><a href="/logon.jsp" ><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.restart_manual_jump")%></a></p>
</div>

</body>
</html>