﻿function Kitty() { };

////弹出层
Kitty.Alert = function(_Title, _Cont, _But, _Width) {
    if (_Title == null || _Title == "") { _Title = "温馨提醒"; }
    if (_Width == null || _Width == "") { _Width = 300; }
    if (_But == null || _But == "") {
        var Times = 3;
        var CloseWin = null;
        CloseWin = setInterval(function() { if (Times == 0) { $(".But1").click(); clearInterval(CloseWin); } else { Times = Times - 1; $(".But1").val('确定(' + Times + ')'); } }, 1000);
        _But = "<input  type=\"button\" value=\"确定(3)\" onclick=\"$('.BG,.tc_box').hide();\" class=\"but m_r10 But1\"/>";
    }
    $(".AlertDiv").remove();
    AlertObj = '<div class="tc_box AlertDiv display_none" style="display:; z-index:10000; width:' + _Width + 'px; margin-left:-' + _Width / 2 + 'px">';
    AlertObj += '<h1 class="tc_title"><span class="right"><a href="javascript:;" onclick="$(\'.BG,.tc_box\').hide();"><img src="/Content/images/close.jpg" /> </a></span>' + _Title + '</h1>';
    AlertObj += '<div class="tc_main">';
    AlertObj += '            	<div class="login_dl" onkeydown="if(event.keyCode==13){CheckLoginSubmit();}">';
    AlertObj += '                	<h1></h1>';
    AlertObj += '                     <div style="margin:20px 10px">';
    AlertObj += _Cont;
    AlertObj += '                        <div class="clear"></div>';
    AlertObj += '                    </div>';
    AlertObj += '                    <div style="margin-top:10px; text-align:center">';
    AlertObj += _But;
    AlertObj += '                        <div class="clear"></div>';
    AlertObj += '                    </div>';
    AlertObj += '                </div>       </div>    </div>'
    $("body").prepend(AlertObj);
    $(".BG").height(window.screen.height).show();
    $(".AlertDiv").animate({ opacity: 'toggle' }, 300);
}



////复制
Kitty.Copy = function copyToClipboard(txt) {
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
    } else if (navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
            return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
            return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
        alert("复制成功！")
    }
}
