﻿
//克隆对象方式
var isdisplay;
function OpenDiv(o, divWight, divHegth) {
    if (isdisplay) return;
    var iw = divWight.indexOf('%');
    var ih = divHegth.indexOf('%');
    if (iw > 0) {
        divWight = (document.documentElement.clientWidth / 100 * parseInt(divWight)) - 5;
    }
    if (ih > 0) {
        divHegth = (document.documentElement.clientHeight / 100 * parseInt(divHegth)) - 5;
    }
    var fg = document.getElementById("divfg");
    if (fg == null || fg == undefined) {
        fg = GetDiv();
    }
    fg.style.display = "block";
    fg.style.height = document.documentElement.scrollHeight;
    var obj = o.cloneNode(true); //克隆一个对象
    obj.setAttribute("id", "cimg");
    var conentdiv = obj.document.getElementById(o.id + 'ContentDIV');
    conentdiv.style.height = (parseInt(divHegth) - 50) + "px";
    obj.style.position = "absolute";
    obj.style.background = "#FFFFFF";
    obj.style.display = "none";
    obj.style.top = "50%";
    obj.style.left = "50%";
    obj.style.width = divWight;
    obj.style.height = divHegth;
    var w = parseInt(divWight);
    obj.style.marginLeft = '-' + (w / 2) + "px";
    obj.style.marginTop = '-' + (parseInt(divHegth) / 2) + "px";
    obj.style.textAlign = "center";
    obj.style.zIndex = "1001";
    obj.title = "单击标题最小化窗体！";
    var titlieTable = obj.document.getElementById(o.id + 'tooltip');
    if (titlieTable != null && titlieTable != undefined) {
        titlieTable.style.display = 'none';
    }
    var TrContent = obj.document.getElementById(o.id + 'Content'); //将内容显示
    if (TrContent != null && TrContent != undefined) {
        TrContent.style.display = 'block';
    }
    obj.onmousemove = "return;";
    obj.onmousemout = "return;";
    var Contenttitle = obj.document.getElementById(o.id + 'title');
    Contenttitle.title = "单击此处最小化！";
    Contenttitle.style.cursor = "hand";
    isdisplay = true;
    Contenttitle.onclick = function() {
        isdisplay = false;
        $("#cimg").hide(1000);
        setTimeout(function() {
            document.body.removeChild(obj);
            fg.style.display = "none";
        }, 1000);
    }
    document.body.appendChild(obj);
    $("#cimg").show("slow");
}
//弹出tootip
var j;
var t;
function showTooltip(obj, tipID) {
    //    debugger;
    if (j != null && j != undefined) {
        if (j == obj) {
            return;
        }
    }
    if (t != "") {
        clearTimeout(t);
    }
    j = obj;
    tooltip = document.getElementById(tipID);
    oRect = obj.getBoundingClientRect();
    var objtop = oRect.top - 50;
    if (objtop <= 0) {
        objtop = 0;
    }
    tooltip.style.top = objtop
    tooltip.style.left = oRect.left + 10;
    t = setTimeout($("#" + tipID).show(2000), 3000);
    $("#" + tipID).hide(6000);
}

function colseTooltip(obj) {
    //    if (t != "") {
    //        clearTimeout(t);
    //    }
    //    obj.style.display = "none";
    //    if (j != null && j != undefined) {
    //        if (j != obj) {
    //            return;
    //        }
    //    } else {
    //        return;
    //    }
    //    document.getElementById(obj.id + "tooltip").style.display = "none";
    //    $("#" + obj.id + "tooltip").hide(1000);
}

function GetDiv() {
    var fg = document.createElement("div");
    fg.setAttribute("id", "divfg");
    fg.style.cssText = "filter: alpha(opacity=50);width: 100%;background-color: #8B8B8B;position: absolute;display: none;top: 0px;right: 0px;bottom: 0px;left: 0px;margin: 0px;height: 100%;z-index: 9;";
    fg.oncontextmenu = function() { return false; }
    var h1 = document.documentElement.scrollHeight;
    var h2 = document.documentElement.clientHeight;
    fg.style.height = h1 > h2 ? h1 : h2;
    document.body.appendChild(fg);
    return fg;
}
