﻿
    // -----------------------------------------------------------
    // 使用方法
    // 1. 在 <body> 中增加如下属性 style="BEHAVIOR:url(#default#clientCaps)" id="oClientCaps"
    // 2. 在页面上增加下列 HTML 代码, 内容可以自己改
    //        <!--不支持 JavaScript 时候显示-->
    //        <noscript>
    //            <table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
    //                <tr>
    //                    <td>&nbsp;</td>
    //                </tr>
    //                <tr>
    //                    <td><table width="610" border="0" align="center" cellpadding="20" cellspacing="4" bgcolor="#cccccc">
    //                            <tr>
    //                                <td bgcolor="#ffffff"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="text-14-Georgia">
    //                                        <tr>
    //                                            <td width="70" valign="top"><img src="../images/login/err_icon.jpg.gif" width="60" height="74" alt="警告"></td>
    //                                            <td class="c-red">
    //                                                需要 JavaScript 支持！您正在使用的浏览器不支持 JavaScript 或者您已经禁用了 JavaScript。
    //                                                <br>
    //                                                <br>
    //                                                如果您的浏览器不支持 JavaScript，请立即升级到新的浏览器 Microsoft&copy; Internet Explorer 6。请在这里下载并安装 <a href=''>
    //                                                    <font color='#cc0000'>Internet Explorer 6.0</font></a>
    //                                                <br>
    //                                                <br>
    //                                                如果您已经禁用了 JavaScript, 可以通过下列方式重新启动它：
    //                                                <ol>
    //                                                    <li>
    //                                                    在“工具”菜单，点击“Internet 选项”
    //                                                    <li>
    //                                                    点击“安全”选项卡
    //                                                    <li>
    //                                                    点击“自定义级别”
    //                                                    <li>
    //                                                    滚动到“脚本”组， 在“活动脚本”下选择“启动”
    //                                                    <li>
    //                                                        点击“确定”两次</li>
    //                                                </ol>
    //                                            </td>
    //                                        </tr>
    //                                    </table>
    //                                </td>
    //                            </tr>
    //                        </table>
    //                    </td>
    //                </tr>
    //            </table>
    //        </noscript>
    //        <!--支持 JavaScript 时候显示-->
    //        <script>Detect();</script>
    // -----------------------------------------------------------

    // -----------------------------------------------------------
    // BrowserData() constructor
    // .userAgent: (string) the HTTP_USER_AGENT input string
    // .browser: (string) "MSIE", "Opera", "Nav", "Other"
    // .majorVer: (integer) major version
    // .minorVer: (string) minor (dot) version
    // .betaVer: (string) beta version
    // .platform: (string) operating system
    // .getsNavBar (boolean) whether browser gets the DHTML menus
    // .doesActiveX (boolean) whether browser does 32-bit ActiveX
    // -----------------------------------------------------------

    function BrowserData(sUA)
    {
	    this.userAgent = sUA.toString();
	    var rPattern = /(MSIE)\s(\d+)\.(\d+)((b|p)([^(s|;)]+))?;?(.*(98|95|NT|3.1|32|Mac|X11))?\s*([^\)]*)/;
	    if (this.userAgent.match(rPattern))
	    {
		    this.browser = "MSIE";
		    this.majorVer = parseInt(RegExp.$2) || 0;
		    this.minorVer = RegExp.$3.toString() || "0";
		    this.betaVer = RegExp.$6.toString() || "0";
		    this.platform = RegExp.$8 || "Other";
		    this.platVer = RegExp.$9 || "0";
	    }

	    else
	    {
		    this.browser = "Other";
	    }
	    this.getsNavBar = ("MSIE" == this.browser && 4 <= this.majorVer && "Mac" != this.platform && "X11" != this.platform);
	    this.doesActiveX = ("MSIE" == this.browser && 3 <= this.majorVer && ("95" == this.platform || "98" == this.platform || "NT" == this.platform));
	    this.fullVer = parseFloat( this.majorVer + "." + this.minorVer );
	    this.doesPersistence = ("MSIE" == this.browser && 5 <= this.majorVer && "Mac" != this.platform && "X11" != this.platform);
    }

    var oBD = new BrowserData(window.navigator.userAgent);

    // 判断是否支持 Cookie
    function IsCookieEnabled()
    {
	    return navigator.cookieEnabled;
    }

    // 判断浏览器是否是 IE6.0 及以上版本
    function IsIE6Enabled()
    {
	    return ("MSIE" == oBD.browser && oBD.majorVer >= 6);
    }

    // 判断是否允许弹出窗口
    function IsPopupDisabled()
    {
	    var e = false;
	    var pw1 = null;
	    var pw2 = null;
	    try
	    {
		    do
		    {
			    var d = new Date();
			    var wName = "ptest_" + d.getTime();
			    var testUrl = "";
			    pw1 = window.open(testUrl,wName,"width=0,height=0,left=5000,top=5000",true);
			    if (null == pw1 || true == pw1.closed)
			    {
				    e = true;
				    break;
			    }
			    pw2 = window.open(testUrl,wName,"width=0,height=0,left=5000,top=5000");
			    if (null == pw2 || true == pw2.closed)
			    {
				    e = true;
				    break;
			    }
			   try { pw1.close(); }catch(ex){}
			   try { pw2.close(); }catch(ex){}
			   pw1 = pw2 = null;
		    }
		    while(false);
	    }
	    catch(ex)
	    {
		    e = true;
	    }
	    if (null != pw1)
	    {
		    try { if (!pw1.closed) pw1.close(); } catch(ex){}
	    }
	    if (null != pw2)
	    {
		    try { if (!pw2.closed) pw2.close(); } catch(ex){}
	    }
	    return !e;
    }

    // 判断是否安装了 Flash 插件
    function IsFlash7Enabled()
    {
		try
		{
			for(i = 7; i < 10;i++)
			{
				var obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				
				if (obj != null)
				{
					return true;
				}
			}
		}
		catch(e)
		{
		}
		return false;
		
		// 以下代码在 Windows XP SP2 下失效
		// Microsoft 未曾就此方法可以检测指定的几个插件之外的插件作出承诺
        //try
        //{
        //  var sVersion = oClientCaps.getComponentVersion ("{D27CDB6E-AE6D-11cf-96B8-444553540000}","componentid");
		//	if(sVersion != null)
        //    {
        //        if(oClientCaps.compareVersions(sVersion, "7,0,0,0") != -1)
        //        {
        //            return true;
        //        }
        //    }
        //}
        //catch(e)
        //{
        //}
        //return false;
    }

    // 显示错误信息
    function BuildTable(content)
    {
	    document.write ("<table width='610' border='0' align='center' cellpadding='0' cellspacing='0'>")
	    document.write ("    <tr> ")
		document.write ("    <td>&nbsp;</td>")
		document.write ("    </tr>")
		document.write ("    <tr>")
		document.write ("    <td><table width='610' border='0' align='center' cellpadding='20' cellspacing='4' bgcolor='#CCCCCC'>")
		document.write ("	    <tr> ")
		document.write ("		    <td bgcolor='#FFFFFF'><table width='100%' border='0' cellpadding='0' cellspacing='0' class='text-14-Georgia'>")
		document.write ("		        <tr> ")
		document.write ("		        <td width='70' valign='top'><img src='../images/login/err_icon.jpg.gif' width='60' height='74'></td>")
		document.write ("		        <td class='c-red'><table width='100%' border='0' cellpadding='0' cellspacing='0' class='text-14-Georgia'>")
		document.write ("		            " + content)
		document.write ("		            <tr style='padding-top: 15pt'><td class='c-red' valign='top'></td><td class='c-red' valign='top'><strong><a target='_blank' href='../Help/Faq/LoginFaq.html'><font color='#cc0000'>为什么登录时候出现此警告信息？</font></a></strong></td></tr>")
        document.write ("                </table></td>")
		document.write ("		        </tr>")
		document.write ("		    </table></td>")
		document.write ("	    </tr>")
		document.write ("	    </table></td>")
		document.write ("    </tr>")
	    document.write (" </table>") 
    }        	
    
    // 检测几个必备的条件
    function Detect()
    {
    
        var message = '';

        if(!IsCookieEnabled())
        {
            message += "<tr><td class='c-red' valign='top'><p>·</p></td><td class='c-red' valign='top'><p>需要 Cookies 支持！您的 Web 浏览器选项当前已被设置为禁用 Cookies。若要正常使用本系统您必须启用 Cookies。详情请参阅 <a target='_blank' href='../Help/Default.html#Faq/LoginFaq.html'><font color='cc0000'>如何允许 Cookies？</font></a></p></td></tr>";
        }
      
        if(!IsIE6Enabled())
        {
            message += "<tr style='padding-top: 5pt'><td class='c-red' valign='top'><p>·</p></td><td class='c-red' valign='top'><p>需要 Internet Explorer 6.0 以上版本的浏览器，请下载并安装 <a href='../Setup/IE6.exe'><font color='cc0000'>Internet Explorer 6.0</font></a></p></td></tr>";
        }

        if(!IsPopupDisabled())
        {
            message += "<tr style='padding-top: 5pt'><td class='c-red' valign='top'><p>·</p></td><td class='c-red' valign='top'><p>检测到弹出窗口拦截程序，若要正常使用本系统需要关闭该拦截功能。详情请参阅 <a target='_blank' href='../Help/Default.html#Faq/LoginFaq.html'><font color='cc0000'>如何关闭常见的弹出窗口拦截功能？</font></a></p></td></tr>";
        }

        if(!IsFlash7Enabled())
        {
            message += "<tr style='padding-top: 5pt'><td class='c-red' valign='top'><p>·</p></td><td class='c-red' valign='top'><p>需要 Flash 7.0 插件，若要正常使用本系统请下载并安装 <a href='../Setup/Flash7AX.exe'><font color='cc0000'>Flash 7.0 插件</font></a></p></td></tr>";
        }

        if(message != '')
        {
			BuildTable(message);
        }
    }