﻿document.oncontextmenu=function(){return false;};
document.ondragstart=function(){return false;};
document.onselectstart=function(){return false;};
document.onbeforecopy=function(){return false;};
document.onselect=function(){document.selection.empty();};
document.oncopy=function(){document.selection.empty();};

/*
* 功能:弹出一个窗口
* 
**/
function OpenWin(url, title, width, height) {
    _title = title || 'OTI Win';
    _url = url || 'http://www.opentide.com.cn';
    _width = width || 640;
    _height = height || 320;

    art.dialog({ 'title': _title, 'iframe': _url, 'width': _width, 'height': _height }); //url参数其实就是iframe
    return false;
}

/*
* 功能:锁定窗口
**/
function LockWin(msg, callbackFuc) {
    art.dialog({ content: msg, style: 'alert noClose', lock: true }, function() { }); //lock参数就是锁屏，它会中断用户操作，用于显示非常重要的消息。慎用
    return false;
}

function ShowErrorInfo() {
    var err = "";
    $("div.validation-summary-errors > ul > li").each(function(i, o) {
        err = err + $(o).text() + "<br/>";
    });

    if (err != null && err != "") {
        $("div.validation-summary-errors").hide();
        //LockWin(err);
        ShowModal(err);
    }
}

function ShowModal(msg, callbackFuc) {
    //    art.dialog({ content: msg, style: 'succeed', width: '14em', lock: true }, function() {
    //        callbackFuc();
    //    }, function() { });

    $(function() {
        if (msg != null && msg != '') {
            $('div.bp_top > p.text:first').html(msg);
        }
        if (callbackFuc != null) {
            $('#imgConfirm').click(callbackFuc);
        }
        else {
            $('#imgConfirm').click(function() { closelay(1) });
        }
        openlay(1);
        scall();
    });

    return false;
}

function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)';
        obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PRivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 [signed.applets.codebase_principal_support]设置为'true'");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        }
    }
}
/*
* 注册后跳转到邮箱登陆地址
**/
function GetMailLoginUrl() {
    //1.
    var mail2web = {
        'gmail.com': 'https://mail.google.com/',
        'live.com': 'http://mail.live.com/',
        'live.cn': 'http://mail.live.com/',
        '126.com': 'http://www.126.com/',
        '163.com': 'http://mail.163.com/',
        '163.net': 'http://mail.163.net/',
        '188.com': 'http://mail.188.com/',
        'sina.com': 'http://mail.sina.com.cn/',
        'hotmail.com': 'http://www.hotmail.com',
        'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
        'yahoo.cn': 'http://mail.cn.yahoo.com/',
        'sohu.com': 'http://login.mail.sohu.com/',
        '21cn.com': 'http://mail.21cn.com/',
        'eyou.com': 'http://www.eyou.com/',
        'sina.com.cn': 'http://mail.sina.com.cn/',
        'qq.com': 'http://mail.qq.com/',
        'tom.com': 'http://mail.tom.com/',
        'sogou.com': 'http://mail.sogou.com/',
        'aol.com': 'http://mail.aol.com/'
    };

    // 为减少雅虎邮箱的特别处理对代码维护带来的困难
    // 宁可多引入重复，以隔离复杂性，减少对清晰性的破坏
    // added by qingming.wang@alibaba-inc.com on 2008.04.06
    var mail2href = {
        'gmail.com': 'https://mail.google.com/',
        'live.com': 'http://mail.live.com/',
        'live.cn': 'http://mail.live.com/',
        '126.com': 'http://www.126.com/',
        '163.com': 'http://mail.163.com/',
        '163.net': 'http://mail.163.net/',
        '188.com': 'http://mail.188.com/',
        'sina.com': 'http://mail.sina.com.cn/',
        'hotmail.com': 'http://www.hotmail.com/',
        'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
        'yahoo.cn': 'http://mail.cn.yahoo.com/',
        'sohu.com': 'http://login.mail.sohu.com/',
        '21cn.com': 'http://mail.21cn.com/',
        'eyou.com': 'http://www.eyou.com/',
        'sina.com.cn': 'http://mail.sina.com.cn/',
        'qq.com': 'http://mail.qq.com/',
        'tom.com': 'http://mail.tom.com/',
        'sogou.com': 'http://mail.sogou.com/',
        'aol.com': 'http://mail.aol.com/'
    };

    //2.当用户离开该页面时提示

    //3.

    //得到email
    var webMail = $('.suc_tit > span > a');
    var email = $('.suc_tit > span > a').html();  
    var host = email.substring(email.indexOf("@") + 1);
    if (mail2web[host]) {
        webMail.attr('href', mail2href[host]);
        webMail.html(email);
    } else {
        webMail.attr('href', '');
    }
}

