<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%--<script src="<%=request.getContextPath()%>/js/main/jquery-latest.js" type="text/javascript" language="javascript"></script>--%>

<script type="text/javascript">
$(document).ready(function(){
//       alert($(window).outerHeight(true));
   var ajaxLoading = false;
    $("#waiting").css("display","none");

      $.ajax({
                url: "checkServerStatus.action",
                type:"post",
                cache:false,
                dataType:"json",
                success:function(data) {
                    if (data.resultServer == "1") {
                             $("#serverImage").find("img").attr("src","images/admin/server11.png");
                    } else {
                             $("#serverImage").find("img").attr("src","images/admin/server11stop.png");
                    }
                }
            });


//    var iii=1;
//    setInterval(function(){
//       if(iii%2==0){
//            $("#start").css("marginTop","62px");
//       }else{
//           $("#start").css("marginTop","64px");
//       }
//       iii++;
//    },1000);







      $("#start").click(function(){

          if(!ajaxLoading){
                     ajaxLoading=true;
                      $("#waiting").show();

                    $.ajax({
                            url: "startServer.action",
                            cache:false,
                            type:"post",
                            success:function(result) {
                                ajaxLoading = false;
                               if(result == "success"){
                                   alert("server started");
                                   $("#serverImage").find("img").attr("src","images/admin/server11.png");
                                   $("#server").find("div").css("backgroundImage", "url(images/server/server1.png)");
                               } else if(result == "error"){
                                   alert("error occurred");
                               } else if (result == "input"){
                                  alert("Server has been already started!");
                               }else if(result == "does_not_started"){
                                  alert("Server has not been started!");
                               }
                                $("#waiting").hide();
                            }
                     });
                }
          }) ;
      $("#stop").click(function(){

            if(!ajaxLoading){
                  ajaxLoading=true;
                 $("#waiting").show();
                 $.ajax({
                           url: "stopServer.action",
                           cache:false,
                           type:"post",
                           success:function(result) {
                              if(result == "success"){
                                   alert("server stopped");
                                     $("#serverImage").find("img").attr("src","images/admin/server11stop.png");
                                   $("#server").find("div").css("backgroundImage", "url(images/server/server2.png)");
                               }else  if(result == "error"){
                                   alert("error occurred");
                              }else  if(result == "input"){
                                   alert("Server has been already stopped!");
                              }else if(result == "does_not_stopped"){
                                  alert("Server has not been stopped!");
                               }
                                 $("#waiting").hide();
                            }
                 });
           ajaxLoading=false;
          }
      }) ;
})
</script>
<style type="text/css">

    #grayBox {
        z-index: 100;
    }

    #hello {
        float:left;
        width:980px;
        text-align:center;
        border:black solid 0px;
        margin-top:50px !important;
        /*margin-left: 390px;*/
        font-size:24px;
        /*font-family:cursive;*/
        font-style:italic;
        margin-bottom:30px;
    }

    #start,#stop {
        cursor: pointer;
    }
        /*#stop{*/
        /*float:right;*/
        /*width:50px;*/
    /*}*/
    /*#start{*/
        /*float:left;*/
        /*width:50px;*/
    /*}*/

    <%--version 2--%>
    /*#stop{*/
        /*float:right;*/
        /*width:45px;*/
        /*height:45px;*/
        /*background-image:url("images/server/Stop1.png");*/
    /*}*/

    /*#start{*/
        /*float:left;*/
        /*width:45px;*/
        /*height:45px;*/
        /*background-image:url("images/server/Go1.png");*/
    /*}*/
</style>
   <div id="grayBox"></div>
   <div id="waiting"></div>
<div id="hello">
    WELCOME    <span style="margin-left:10px;margin-right:10px;" ><s:property value="#session.user.username"/> </span> !!!
</div>
<div style="float: left;display: block;width:100px;margin-left: 156px;">
    <div  id="start" style="border:black solid 0px;width:74px;height:74px;float:left;margin-right:0px;margin-top:62px;margin-left:20px;">
        <img src="<%=request.getContextPath()%>/images/server/Go111.png" title="Click to START" width="74px" height="74px" alt="" />
    </div>
    <div style="border:black solid 0px;width:76px;height:38px;background-image:url('images/server/st111.png');float:left;margin-left:20px;"></div>
</div>

<div style="border:black solid 0px;width:141px; margin: 30px 160px 0;padding-top:0px;height:160px;float:left;" id="serverImage">
    <img src="<%=request.getContextPath()%>/images/admin/server11stop.png" alt="acs server"/>
    <%--<div style="width:110px; margin: 5px auto;padding-left: 10px;">--%>
         <%--<button id="start"></button>--%>
         <%--<button id="stop"></button>--%>
    <%--</div>--%>
</div>
<div style="float: left;display: block;width: 100px;">
    <div id="stop" style="border:black solid 0px;width:74px;height:74px;float:left;margin-top:62px;margin-left: 10px;">
        <img src="<%=request.getContextPath()%>/images/server/Stop111.png" title="Click to STOP" width="74px" height="74px" alt="" />
    </div>
    <div style="border:black solid 0px;width:76px;height:38px;background-image:url('images/server/stp111.png');float:left;margin-left: 15px;"></div>

</div>
<%--<div style="border:black solid 0px;width:76px;height:38px;background-image:url('images/server/st1.png');float:left;margin-left:250px;"></div>--%>


