/// <reference path="jquery-1.4.1.min-vsdoc.js" />
//document.onload = function () {
//    $.post("Login.aspx", { "cmd": "LoginState" }, function (data) {
//        alert(data);
//        if (data == "0") {
//            document.location.href = "Login.aspx";
//        }
//    }, "text");
//}
function openDemoWindow6() {
    solution.popup.alert({ "title": "确认信息", "content": "已操作成功!" });
}
function popupAlert(content) {
    solution.popup.alert({ "title": "提示:", "content": content });
}
var html5test = {
    result: {},
    //开始检测
    loadCheck: function () {
        checkCanvas("imgCanvas");
        checkAudio("imgAudio");
        checkVideo("imgVideo");
        checkGeolocation("imgGeolocation");
        checkCrossDocument("imgCrossDocument");
        checkXMLHttpRequest2("imgXMLHttpRequest");
        checkWebSocket("imgWebSockets");
        checkWebWorker("imgWorkers");
        checkWebStorage("imgLocalStorage");
        checkApplicationCache("imgApplicationCache");
    },
    //canvas
    checkCanvas: function (idstr) {
        try {
            document.createElement("canvas").getContext("2d");
            return this.showResult(idstr, true);
        }
        catch (e) {
            return this.showResult(idstr, false);
        }
    },
    //音频
    checkAudio: function (idstr) {
        var hasAudio = !!document.createElement("audio").canPlayType;
        if (hasAudio == true) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //视频
    checkVideo: function (idstr) {
        var hasVideo = !!document.createElement("video").canPlayType;
        if (hasVideo == true) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //地理位置服务
    checkGeolocation: function (idstr) {
        if (navigator.geolocation) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //跨文档通信
    checkCrossDocument: function (idstr) {
        try {
            window.postMessage("", "http://192.168.0.1/");
            return this.showResult(idstr, true);
        } catch (e) {
            return this.showResult(idstr, false);
        }
    },
    //新版XMLHttpRequest
    checkXMLHttpRequest2: function (idstr) {
        try {
            var xhr = new XMLHttpRequest(); //IE6会出异常
        }
        catch (e) {
            return this.showResult(idstr, false);
        }

        if (xhr.withCredentials != undefined) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //检测WebSockets
    checkWebSocket: function (idstr) {
        if (window.WebSocket) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //检测WebWorkers
    checkWebWorker: function (idstr) {
        if (typeof (window.Worker) != "undefined") {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //离线存储(两种存储方式)
    checkWebStorage: function (idstr) {
        //if (window.sessionStorage) {
        //    showResult("imgSessionStorage", "y");
        //}
        //else {
        //    showResult("imgSessionStorage", "n");
        //}

        if (window.localStorage) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //离线Web应用
    checkApplicationCache: function (idstr) {
        if (window.applicationCache) {
            return this.showResult(idstr, true);
        }
        else {
            return this.showResult(idstr, false);
        }
    },
    //显示检测结果
    showResult: function (id, value) {
        //if (value) {
        //    document.getElementById(id).src = "/Images/basic/right1.png";
        //}
        //else {
        //    document.getElementById(id).src = "/Images/basic/error1.png";
        //}
        return value;
    }
};
var DropDownList = function (ddlid) {
    function id(idv) {
        return document.getElementById(idv);
    };
    var _ddlid = ddlid + "_dropdownlist", _spanid = ddlid + "_dropdownlistspan", _spanlistid = ddlid + "_dropdownlistspanlist";
    var uiobj = solution;
    var _liminwidth = "0px";
    this.initial = function (vallist, params) {
        params = params != null ? params : "";
        var obj = id(ddlid);
        var span = document.createElement("span");
        span.id = _spanid; span.className = "dropdownlist";
        var spanlist = document.createElement("span");
        spanlist.id = _spanlistid;
        span.appendChild(spanlist);
        if (typeof (obj) == "select") {
            span.appendChild(obj);
        }
        else {
            var selectobj = document.createElement("select");
            selectobj.id = _ddlid;
            selectobj.style.display = "none";
            var isselected = false;
            for (var key in vallist) {
                var option = document.createElement("option");
                option.innerHTML = key;
                option.value = vallist[key];
                if (params.value != null && params.value == option.value)//初始值
                {
                    id(ddlid).value = key;
                    option.selected = true;
                } else if (params.value == null && isselected == false) {
                    id(ddlid).value = key;
                    option.selected = isselected = true;
                }
                selectobj.appendChild(option);
            }
            span.appendChild(selectobj);
            //id(ddlid).value = selectobj.options[selectobj.selectedIndex].innerHTML;
        }
        if (params.extend != null && params.extend == true) {//默认不使用选项延伸
            _liminwidth = obj.style.width;
        }
        obj.parentNode.appendChild(span);
        obj.onclick = this.dropdownlisttextevent;
        var otersnode = obj.parentNode.getElementsByTagName("a");
        if (otersnode != null)//为其它需要触发的事件添加事件
        {
            for (var x = 0; x < otersnode.length; x++) {
                otersnode[x].onclick = this.dropdownlisttextevent;
            }
        }
        uiobj.utility.addEvent(document, "click", this.dropdownlisttextblur);
    };
    this.get = function () {
        return uiobj.dom.select.get(_ddlid);
    };
    this.dropdownlisttextevent = function (e) {
        var span = id(_spanlistid);
        var ul = document.createElement("ul");
        var options = id(_ddlid).options;
        for (var i = 0; i < options.length; i++) {
            var li = document.createElement("li");
            li.innerHTML = options[i].innerHTML;
            li.setAttribute("value", options[i].value);
            li.onclick = function () {
                id(ddlid).value = this.innerHTML;
                uiobj.dom.select.set(_ddlid, this.attributes["value"].value);
            };
            ul.appendChild(li);
        }
        if (_liminwidth != null && _liminwidth != "" && _liminwidth != "0px") {
            ul.style.minWidth = _liminwidth;
            ul.style.cssText = "position:absolute;";
        }
        span.innerHTML = "";
        span.appendChild(ul);
        if (e && e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            window.event.cancelBubble = true;
        }
    };
    this.dropdownlisttextblur = function () {
        id(_spanlistid).innerHTML = "";
    }
}
var DropDownList = function (ddlid) {
    function id(idv) {
        return document.getElementById(idv);
    };
    var _ddlid = ddlid + "_dropdownlist", _spanid = ddlid + "_dropdownlistspan", _spanlistid = ddlid + "_dropdownlistspanlist";
    var uiobj = bx;
    var _liminwidth = "0px";
    this.initial = function (vallist, params) {
        params = params != null ? params : "";
        var obj = id(ddlid);
        var span = document.createElement("span");
        span.id = _spanid; span.className = "dropdownlist";
        var spanlist = document.createElement("span");
        spanlist.id = _spanlistid;
        span.appendChild(spanlist);
        if (typeof (obj) == "select") {
            span.appendChild(obj);
        }
        else {
            var selectobj = document.createElement("select");
            selectobj.id = _ddlid;
            selectobj.style.display = "none";
            var isselected = false;
            for (var key in vallist) {
                var option = document.createElement("option");
                option.innerHTML = key;
                option.value = vallist[key];
                if (params.value != null && params.value == option.value)//初始值
                {
                    id(ddlid).value = key;
                    option.selected = true;
                } else if (params.value == null && isselected == false) {
                    id(ddlid).value = key;
                    option.selected = isselected = true;
                }
                selectobj.appendChild(option);
            }
            span.appendChild(selectobj);
            //id(ddlid).value = selectobj.options[selectobj.selectedIndex].innerHTML;
        }
        if (params.extend != null && params.extend == true) {//默认不使用选项延伸
            _liminwidth = obj.style.width;
        }
        obj.parentNode.appendChild(span);
        obj.onclick = this.dropdownlisttextevent;
        var otersnode = obj.parentNode.getElementsByTagName("a");
        if (otersnode != null)//为其它需要触发的事件添加事件
        {
            for (var x = 0; x < otersnode.length; x++) {
                otersnode[x].onclick = this.dropdownlisttextevent;
            }
        }
        uiobj.utility.addEvent(document, "click", this.dropdownlisttextblur);
    };
    this.get = function () {
        return uiobj.dom.select.get(_ddlid);
    };
    this.dropdownlisttextevent = function (e) {
        var span = id(_spanlistid);
        var ul = document.createElement("ul");
        var options = id(_ddlid).options;
        for (var i = 0; i < options.length; i++) {
            var li = document.createElement("li");
            li.innerHTML = options[i].innerHTML;
            li.setAttribute("value", options[i].value);
            li.onclick = function () {
                id(ddlid).value = this.innerHTML;
                uiobj.dom.select.set(_ddlid, this.attributes["value"].value);
            };
            ul.appendChild(li);
        }
        if (_liminwidth != null && _liminwidth != "" && _liminwidth != "0px") {
            ul.style.minWidth = _liminwidth;
            ul.style.cssText = "position:absolute;";
        }
        span.innerHTML = "";
        span.appendChild(ul);
        if (e && e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            window.event.cancelBubble = true;
        }
    };
    this.dropdownlisttextblur = function () {
        id(_spanlistid).innerHTML = "";
    }
}