﻿// JavaScript Document
window.returnValue = false;
//-------------------------------
function $id(n){ return document.getElementById(n); }
function $name(n){ return document.getElementsByName(n); }
function $tag(n){ return document.getElementsByTagName(n); }
function $chkid(n){ if(document.getElementById(n)){ return true; }else{ return false; } }
function $chkmoney(v) {return (/^[0-9\,]{0,8}[\.]{0,1}[0-9]{0,3}$/).test(v);}
function $getmoney(v,n){if($chkmoney(v)){return ('0'+v.replace(/,/g,''))*n;}else{return 0;}}
var site_css_obj = $id('conn1_css_default');
function connGetValue(n){
    try{
        return site_css_obj.attributes[n].nodeValue;
    }catch(e){
        return eval('site_css_obj.'+n);
    }
}
function getNodeValue(o,n){
    try{
        return o.attributes[n].nodeValue;
    }catch(e){
        return eval('o.'+n);
    }
}
//-------------------------------
var site_ver = connGetValue('site_ver');
var cookies = new CookieClass();
var Brower = {
    // 判断是否为IE浏览器
    isIE: function () { return (navigator.userAgent.search('MSIE') > 0); },
    isSafe: function () {
        switch (hrefarray[2].split(':')[0]) { 
            case 'www.51mmk.com': { return (cookies.GetCookie('isSafe') == 'true'); break; }
            case 'csz.51mmk.com': { return (cookies.GetCookie('isSafe') == 'true' || cookies.GetCookie('isSafe') == ''); break; }
            case 'localhost': { return (cookies.GetCookie('isSafe') == 'true'); break; }
            default: { return (cookies.GetCookie('isSafe') == 'true'); break; }
        }
        return false;
    },
    // 判断是否为Opera浏览器
    isOpera: function () { return (navigator.userAgent.indexOf('Opera') > -1); },
    // 判断是否为FireFox浏览器
    isMoz: function () { return (navigator.userAgent.indexOf('Mozilla/5.') > -1); },
    isChrome: function () { return (navigator.userAgent.indexOf('Chrome') > -1); }
}
var self_location_href = self.location.href.toLowerCase();
var hrefarray = (self_location_href).split('/');
var hrefroot = hrefarray[0]+'/'+hrefarray[1]+'/'+hrefarray[2];
if(top.location==self.location){
if((hrefarray[0]!='https:')&&(hrefarray[2]=='www.51mmk.com'||hrefarray[2]=='ts.lyb.zy')){
    if(hrefarray.length>3){
        switch(hrefarray[3].toLowerCase()){
            case 'system':
            case 'admin':
            case 'esales':
            case 'vip':{
                self.location.href = self_location_href.replace('http://','https://');
                break;
            }
        }
    }
}}
function setBrowerHomePage(o) {
    if (Brower.isIE()) {
        try {
            if(parent){
                o.setHomePage(parent.location.href);
            }else{
                o.setHomePage(self.location.href);
            }            
        } catch (e) {
            alert("此操作被浏览器拒绝！请更改浏览器的安全设置。");
        }
    } else {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
        catch (e) {
            window.open("javascript:document.write('此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为 true。');");
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        if(parent){
            prefs.setCharPref('browser.startup.homepage', parent.location.href);
        }else{
            prefs.setCharPref('browser.startup.homepage', self.location.href);
        }
    }
}
function saveHref(sURL, sTitle) {
    if (Brower.isIE()) {
        try{window.external.AddFavorite(sURL, sTitle);}catch(e){window.external.addToFavoritesBar(sURL, sTitle);}
    } else {
        window.sidebar.addPanel(sTitle, sURL, '');
    }
}
function gotoUrl(url)
{
    self.location.assign(url);
    if($chkid('showbody')){
        $id('showbody').style.display = 'none';
    }document.title = '请稍候。。。';
}
function openUrl(url) {
    var randtime = new Date();
    if(url.indexOf('?')<0)
        url += '?';
    else
        url += '&';
    window.open(url+randtime);
}
function adialog(url) {
    var randtime = new Date();
    if(url.indexOf('?')<0)
        url += '?';
    else
        url += '&';
    if(url.substr(0,4)!='http'){
        var a = self.location.href.split('?')[0].split('/');
        a[a.length-1] = url; url = a.join('/');
    }
    var n = writewindiv(url);
    return false;
    var s = 'dialogWidth:800px;dialogHeight:600px;scroll:no;menubar:0;status:0;';
    var result=false;try{result=window.external.show_dialog(url+randtime,800,600);}catch(e){}
    if(!result){return window.showModalDialog(url+randtime, '', s);}
    return result;
}
function alerttxt(n){
    return adialog('../Server/download.aspx?type=sql&dir=txt.log&name='+n+'.txt');
}
window_print = function() {
    var result=false;try{result=window.external.print_button();}catch(e){}
    //if(!result){try{result=true;$id('DLPrinter').PrintDirect();}catch(e){}}
    if(!result){window.print();}
}
window.close = (function(window_close) {
    return function(){
        try{if(window.name=='win_frame'){parent.document.getElementById('win_close').click();}}catch(e){}
        window_close();
    }
})(window.close)
var page_atime, page_etime;
function setTimer(n) {
    page_atime = new Date();
}
setTimer(Math.random());
function chkTimer() {
    page_etime = new Date();
    var n = page_etime - page_atime;
    if (n < 3000) {
        alert("请您稍后提交信息!");
        return false;
    }
    return true;
}

