<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title> </title>
    <style type="text/css">
    html, body {
	    height: 100%;
	    overflow: auto;
    }
    body {
	    padding: 0;
	    margin: 0;
    }
    #silverlightControlHost {
	    height: 100%;
	    text-align:center;
    }
    </style>
    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }

            var errMsg = "Unhandled error in silverlight application:" + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Type: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Row: " + args.lineNumber + "     \n";
                errMsg += "Location: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Row: " + args.lineNumber + "     \n";
                    errMsg += "Location: " + args.charPosition + "     \n";
                }
                errMsg += "Function name: " + args.methodName + "     \n";
            }

            alert(errMsg);
        }
    </script>
    <script language="javascript" type="text/javascript">
        var isLoginSystem = false;
        window.onbeforeunload = function (event) {
            if (isLoginSystem) {
                window.event.returnValue = "The message will lose if you leave the page!";
                //                var isIEc = getOs();
                //                if (isIEc == "MSIE") {
                //                    window.event.returnValue = "如果离开该页面,该页面的信息将会丢失.";
                //                } else if (isIEc == "Firefox") {
                //                    event.returnValue = "如果离开该页面,该页面的信息将会丢失.";
                //                }
                //                else if (isIEc == "Chrome") {
                //                    event.returnValue = "如果离开该页面,该页面的信息将会丢失.";
                //                }
            }
        }
        function SetLogin(isLogin) {
            isLoginSystem = isLogin;
        }
        //window.onunload = function () {
        //ExitAction();
        //}

        //设置应用程序名称
        function SetAppName(appName) {
            document.title = appName;
        }
        
        function getOs() {
            var OsObject = "";
            if (navigator.userAgent.indexOf("MSIE") > 0) {
                return "MSIE";
            }
            if (isFirefox == navigator.userAgent.indexOf("Firefox") > 0) {
                return "Firefox";
            }
            if (isSafari == navigator.userAgent.indexOf("Safari") > 0) {
                return "Safari";
            }
            if (isCamino == navigator.userAgent.indexOf("Camino") > 0) {
                return "Camino";
            }
            if (isMozilla == navigator.userAgent.indexOf("Gecko/") > 0) {
                return "Gecko";
            }
            if (isChrome == navigator.userAgent.indexOf("Chrome") > 0) {
                return "Chrome";
            }

        }

        function ExitAction(topoId) {

            var bigs = window.location.href;
            var name = ((bigs.split("//"))[1].split("/"))[0];
            url = "UnlockTopoGraphic.aspx?TopoId=" + topoId;
            var xmlhttp = CreateXMLHttpRequest();
            var parameter = "noparameter";

            //设置应用程序名称
            function SetAppName(appName) {
                document.title = appName;
            }

            ///....发送等

            var isIEc = getOs();
            if (isIEc == "MSIE") {
                xmlhttp.open("post", url, true);
                xmlhttp.setRequestHeader("content-length", parameter.length);
                xmlhttp.setRequestHeader("cache-control", "no-cache");
                xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                xmlhttp.onreadystatechange = function () { };
                xmlhttp.send(parameter);
            } else if (isIEc == "Firefox") {

                var ffurl = url + parameter;
                xmlhttp.open("post", ffurl, false);
                xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlhttp.onload = function () { };
                xmlhttp.send(null);
            }
        }

        // CreateXMLHttpRequest
        function CreateXMLHttpRequest() {
            // Initialize Mozilla XMLHttpRequest object
            var xmlHttp;
            if (window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
            }
            // Initialize for IE/Windows ActiveX version
            else if (window.ActiveXObject) {
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
                }
                catch (e) {
                    try {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (e) {
                        newsstring = "Sorry,your explore dose not support XMLHttpRequest object!";
                    }
                }
            }
            return xmlHttp;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" style="height:100%">
    <div id="silverlightControlHost">
        <object name="sl_control" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
          <param name="initParams" value="<%= String.Format("{0}={1},{2}={3}","UserHostAddress", Request.ServerVariables["REMOTE_ADDR"],"UserHostName", Request.UserHostName) %>" />
		  <param name="source" value="ClientBin/App.xap"/>
		  <param name="onError" value="onSilverlightError" />
		  <param name="background" value="white" />
		  <param name="minRuntimeVersion" value="4.0.50826.0" />
		  <param name="autoUpgrade" value="true" />
          <param name="EnableGPUAcceleration" value="true" />
		  <a href="Silverlight/Silverlight_4.0.exe" style="text-decoration:none" target="_blank">
 			  <img src="Silverlight/SL_Install.png" alt="Get Microsoft Silverlight" style="border-style:none"/>
		  </a>
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
    </form>
</body>
</html>
