﻿//===============================以下webQQ操作代码=============================
var webQQURL = "http://webqq.ttf56.com";//webQQ的URL路径    需要修改的项
//var webQQURL = "http://webqq.nbttf.com";//webQQ的URL路径    需要修改的项
var domainName = "nbttf.com";//允许操作的公共域       需要修改的项
var contextPath = null;


//加载webQQ
function loadMsgAlert(userId, companyname, uname){
    //zcode="<div id='adleft' style='left:10px;position: absolute;z-index:1;top:100px;'><div style='width:110px;height:415px;background:#ccc;border:#999 solid 1px;'><iframe frameborder='0' height=300px' width='110px' scrolling='no' src='http://192.168.1.6:8086/Chat/MsgAlertServlet?myselfId="+userId+"'></iframe></div> <div align='right' style='background:#fff;font-size:0px;'> <!--<img src='../images/close.gif' title='关闭' onclick=adhide('adleft') style='cursor:pointer'>--> </div></div>";    
    //ycode="<div id='adright' style='right:10px;position: absolute;z-index:1;top:100px;display:none;'><div style='width:110px;height:300px;background:#ccc;border:#999 solid 1px;'>天天发及时通</div><div align='left' style='background:#fff;font-size:0px;'>　<!--<img src='../images/close.gif' title='关闭' onclick=adhide('adright') style='cursor:pointer'>--> </div></div>";
    //encodeURI
    if (domainName != null) {
        document.domain = domainName;
    }
    zcode = "<iframe id='adleft' style='right:10px;position: absolute;z-index:1;top:300px;' height='155px;' width='112px;'  frameborder='0' scrolling='no' src='" + webQQURL + "/MsgAlertServlet?uname=" + encodeURIComponent(uname) + "&myselfId=" + encodeURIComponent(userId) + "&companyname=" + encodeURIComponent(companyname) + "'></iframe>";
    ycode = "<div id='adright' style='right:10px;position: absolute;z-index:1;top:100px;display:none;'><div style='width:110px;height:300px;background:#ccc;border:#999 solid 1px;'>天天发及时通</div><div align='left' style='background:#fff;font-size:0px;'>　<!--<img src='../images/close.gif' title='关闭' onclick=adhide('adright') style='cursor:pointer'>--> </div></div>";
    document.write(zcode);
    document.write(ycode);
    screencl('adleft');
    screencl('adright');
    window.setInterval("heartBeat()", 1);
}

function perAlert(){
    alert("对不起，您不是物流用户不能在线报价！");
}

function setContextPath(path){
    contextPath = path;
}

function notOnLineAlert(){
    alert("对不起，对方不在线");
}


//判断是否遨游浏览器
function IsMaxthon(){
    try {
        window.external.max_invoke("GetHotKey");
        return true;
    } 
    catch (ex) {
        return false;
    }
}


//获取浏览器的类型
function getOs(){
    var OsObject = "";
    if (navigator.userAgent.indexOf("MSIE") > 0) {
        return "MSIE";
    }
    if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
        return "Firefox";
    }
    if (isSafari = navigator.userAgent.indexOf("Safari") > 0) {
        return "Safari";
    }
    if (isCamino = navigator.userAgent.indexOf("Camino") > 0) {
        return "Camino";
    }
    if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) {
        return "Gecko";
    }
}

//判断是不是允许的浏览器 
function isAllowBrowser(){
    var browser = getOs();
    
    if (browser == "MSIE" && !IsMaxthon()) {
        return true;
    }
    return false;
}

//打开对话窗口
function openChat(from, to, companyname, otherCompanyname, uname, otherUname, pkid, type, vip){

    if (!isAllowBrowser()) {
        alert("对不起，暂不支持您当前的浏览器。推荐您使用微软IE浏览器。");
        return;
    }
    
    if (from == null || from == "") {
        alert("对不起，您还没有登录，请您先登录。");
        var toPath = "/member/usr.do?zsj=login";
        if (contextPath != null && contextPath != "") {
            toPath = contextPath + toPath;
        }
        window.location = toPath;
        return;
    }
    
    if (from.toLowerCase() == to.toLowerCase()) {
        alert("对不起，您不能自己给自己进行通信!");
        return;
    }
    
    window.open(webQQURL + "/ChatServlet?from=" + from + "&to=" + to + "&companyname=" + encodeURI(companyname) + "&uname=" + encodeURI(uname) + "&otherUname=" + encodeURI(otherUname) + "&otherCompanyname=" + encodeURI(otherCompanyname) + "&pkid=" + pkid + "&type=" + type + "&vip=" + vip, "_blank", "scrollbars=no,status=no,width=705,height=475,left=500,top=150,location=no");
}


function isWuLiuUser(per){
    if (per == "1" || per == 1 || per == "") 
        return true;
    return false
}

var lastScrollY = 0;
function heartBeat(){
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop) 
        diffY = document.documentElement.scrollTop;
    else 
        if (document.body) 
            diffY = document.body.scrollTop
        else {/*Netscape stuff*/
        }
    
    percent = .1 * (diffY - lastScrollY);
    if (percent > 0) 
        percent = Math.ceil(percent);
    else 
        percent = Math.floor(percent);
    document.getElementById("adleft").style.top = parseInt(document.getElementById("adleft").style.top) + percent + "px";
    document.getElementById("adright").style.top = parseInt(document.getElementById("adright").style.top) + percent + "px";
    lastScrollY = lastScrollY + percent;
}

function adhide(names){
    document.getElementById(names).style.display = 'none';
}

function screencl(names){
    if (screen.width <= 800) {
        adhide(names);
    }
}
