﻿//====================================================
//      Copyright 2010 版权所有
//      QQ：469992800
//      Tel：13553606735
//====================================================
var ShowDivObj; //记录当前显示的div
var imagepath = "";
var sw;
var sh;
var _sfun1;
var _sfun2;
function DragonDialog(path, w, h, sfun1, sfun2)
{
    if (w != null && h != null)
    {
        imagepath = path;
        sw = w;
        sh = h;
        _sfun1 = sfun1;
        _sfun2 = sfun2;
    }
    this.Init = function()
    {
        if (document.getElementById("DragonDialogDiv") == null)
        {
            var ddiv = document.createElement("div");
            ddiv.innerHTML = "<div style=\"position:absolute;z-index:600;display:none\" id=\"DragonDialogDiv\"><table cellspacing='0' cellpadding='3' id='DragonDialogDiv_tb1' style='border:solid 1px #959595;width:" + sw + "px;'><tr><td onmousedown='new DragonDialog().moveStart(event);' style='background-color:#0067AA;color:#ffffff;line-height:24px;'><div id='DragonDialogDiv_Title' style='float:left;text-indent:6px;'>系统消息</div><div style='float:right' id='DragonDialogDiv_CloseBtn'><a href='javascript:void(0);'><img style='margin-top:5px;margin-right:5px;' src='/Images/DragonDialog/tip_close.jpg' onclick='new DragonDialog().Close();' border='0' /></a></div></td></tr><tr><td style='border-bottom:solid 1px #cccccc;background-color:#ffffff;'><div id='DragonDialogContentDiv' style='width:100%;'></div></td></tr><tr><td id='DragonDialog_div_bottom' style='background-color:#f2f2f2;text-align:right;padding:3px 0px 3px 0px'><a href='javascript:void(0);'><img id='DragonDialogDiv_ok' src='/Images/DragonDialog/ok.jpg' border='0' /></a>&nbsp;<a href='javascript:void(0);'><img id='DragonDialogDiv_cancel' src='/Images/DragonDialog/cancel.jpg' border='0' /></a>&nbsp;</td></tr></table></div>";
            document.body.appendChild(ddiv);
        }
        document.getElementById("DragonDialogDiv_tb1").style.width = sw + "px";
        document.getElementById("DragonDialogDiv_tb1").style.height = sh + "px";
        var ok = document.getElementById("DragonDialogDiv_ok");
        var cancel = document.getElementById("DragonDialogDiv_cancel");
        ok.attachEvent('onclick', function() { eval(_sfun1) });
        cancel.attachEvent('onclick', function() { eval(_sfun2) });

        ok.style.display = "";
        cancel.style.display = "";
        ok.src = "/Images/DragonDialog/ok.jpg";
        cancel.src = "/Images/DragonDialog/cancel.jpg";
    }
     this.InitImage_tip = function()
    {
        if (document.getElementById("DragonDialogDiv")!= null){ 
        document.getElementById("DragonDialogDiv").parentNode.removeChild(document.getElementById("DragonDialogDiv"));}
        if (document.getElementById("DragonDialogDiv") == null)
        {
            var ddiv = document.createElement("div");/*border:solid 1px #959595;border-bottom:solid 1px #cccccc;*/
            ddiv.innerHTML = "<div style=\"position:absolute;z-index:600;background-color:#ffffff;display:none\" id=\"DragonDialogDiv\"><table cellspacing='0' cellpadding='0' id='DragonDialogDiv_tb1' style='width:" + sw + "px;'><tr><td onmousedown='new DragonDialog().moveStart(event);' style='height:10px;'> <div class='Prompt_head' id='Prompt_head'>           <div class='Prompt_left'>           </div>            <div class='Prompt_middle'>            </div>            <div class='Prompt_right' onclick='new DragonDialog().Close();'>            </div>        </div>      </td></tr><tr><td style='height:100%;'><div id='DragonDialogContentDiv' style='width:100%;'></div></td></tr></table></div>";
            document.body.appendChild(ddiv);//new DragonDialog().Close(); <div style='float:right' id='DragonDialogDiv_CloseBtn'><a href='javascript:void(0);'><img style='margin-top:5px;margin-right:5px;' src='/Images/DragonDialog/tip_close.jpg' onclick='new DragonDialog().Close();' border='0' /></a></div> 
            
        } 
        document.getElementById("DragonDialogDiv_tb1").style.width = sw + "px";
        document.getElementById("DragonDialogDiv_tb1").style.height = sh + "px";
    }
     this.InitImage_login = function()
    {
        if (document.getElementById("DragonDialogDiv")!= null){ 
        document.getElementById("DragonDialogDiv").parentNode.removeChild(document.getElementById("DragonDialogDiv"));}
        if (document.getElementById("DragonDialogDiv") == null)
        {
            var ddiv = document.createElement("div");
            ddiv.innerHTML = "<div style=\"position:absolute;z-index:600;background-color:#ffffff;display:none\" id=\"DragonDialogDiv\"><table cellspacing='0' cellpadding='0' id='DragonDialogDiv_tb1' style='width:" + sw + "px;'><tr><td onmousedown='new DragonDialog().moveStart(event);' style='height:10px;'> <div class='login_head' id='login_head'>           <div class='login_left'>           </div>            <div class='login_middle'>            </div>            <div class='login_right' onclick='new DragonDialog().Close();'>            </div>        </div>      </td></tr><tr><td style='background-color:#ffffff;height:100%;'><div id='DragonDialogContentDiv' style='width:100%;'></div></td></tr></table></div>";
            document.body.appendChild(ddiv);//new DragonDialog().Close();  <div class="login">
          /*  <div class="login_head">
                <div class="login_left">
                </div>
                <div class="login_middle">
                </div>
                <div class="login_right">
                </div>
            </div>*/
             
        } 
        document.getElementById("DragonDialogDiv_tb1").style.width = sw + "px";
        document.getElementById("DragonDialogDiv_tb1").style.height = sh + "px";
    }
    this.HiddenCloseBtn = function()
    {
        document.getElementById("DragonDialogDiv_CloseBtn").style.display = 'none';
    }
    this.HiddenBottomLine = function()
    {
        document.getElementById("DragonDialog_div_bottom").style.display = 'none';
    }
    this.ShowBasicDiv = function(objid, title)
    {  
        document.getElementById("DragonDialogDiv_Title").innerHTML = title;
        var div = document.getElementById("DragonDialogContentDiv");
        div.innerHTML = ""; 
        var obj = document.getElementById(objid);
        ShowDivObj = obj;
        obj.style.display = "";
        div.appendChild(obj);
        this.Show();
    }
    this.ShowDivImage_tip = function(objid)
    {
        this.Close();
        this.InitImage_tip();
        var div = document.getElementById("DragonDialogContentDiv");
        div.innerHTML = ""; 
        var obj = document.getElementById(objid);
        ShowDivObj = obj;
        obj.style.display = "";
        div.appendChild(obj);
        this.Show();
    }
    this.ShowDivImage_login = function(objid)
    {
        this.Close();
        this.InitImage_login();
        var div = document.getElementById("DragonDialogContentDiv");
        div.innerHTML = ""; 
        var obj = document.getElementById(objid);
        ShowDivObj = obj;
        obj.style.display = "";
        div.appendChild(obj);
        this.Show();
    }
    this.ShowDiv = function(objid, title)
    {
        this.Close();
        this.Init();
        this.ShowBasicDiv(objid, title);
    }
    this.ShowWizard = function(objid, title)
    {
        this.Close();
        this.Init();
        this.SetWizard();
        this.ShowBasicDiv(objid, title);
    }
    this.ShowFirstWizard = function(objid, title)
    {
        this.Close();
        this.Init();
        this.SetFirstWizard();
        this.ShowBasicDiv(objid, title);
    }
    this.ShowLastWizard = function(objid, title)
    {
        this.Close();
        this.Init();
        this.SetLastWizard();
        this.ShowBasicDiv(objid, title);
    }
    this.SetWizard = function()
    {
        var ok = document.getElementById("DragonDialogDiv_ok");
        var cancel = document.getElementById("DragonDialogDiv_cancel");
        ok.style.display = "";
        cancel.style.display = "";
        ok.src = "/Images/DragonDialog/btn_Back.jpg";
        cancel.src = "/Images/DragonDialog/btn_Next.jpg";
    }
    this.SetFirstWizard = function()
    {
        var ok = document.getElementById("DragonDialogDiv_ok");
        var cancel = document.getElementById("DragonDialogDiv_cancel");
        ok.style.display = "none";
        cancel.style.display = "";
        ok.src = "/Images/DragonDialog/btn_Back.jpg";
        cancel.src = "/Images/DragonDialog/btn_Next.jpg";
    }
    this.SetLastWizard = function()
    {
        var ok = document.getElementById("DragonDialogDiv_ok");
        var cancel = document.getElementById("DragonDialogDiv_cancel");
        ok.style.display = "none";
        cancel.style.display = "";
        ok.src = "/Images/DragonDialog/btn_Back.jpg";
        cancel.src = "/Images/DragonDialog/ok.gif";
    }
    this.Close = function()
    {
        try
        {
            var div = document.getElementById("DragonDialogDiv");
            //FadeOutObj(div);
            div.style.display = 'none';
            document.body.removeChild(document.getElementById("DragonBgDiv"));
            document.body.removeChild(document.getElementById("DragonBgObjDiv"));
          /*  document.body.removeChild(document.getElementById("login_head"));
            document.body.removeChild(document.getElementById("Prompt_head"));
              document.body.removeChild(document.getElementById("DragonDialogDiv"));*/
            if (ShowDivObj != null)
            {
                document.body.appendChild(ShowDivObj);
                ShowDivObj.style.display = "none";
            }
        } catch (e) { }
    }
    this.Alert = function(msg, objid)
    {
        var html = msg + "<br /><br /><input type='button' value='确　定' onclick=\"new DragonDialog().Focus('" + objid + "');\" class='btn' style='width:120px;' />";
        var div = document.getElementById("DragonDialogContentDiv");
        div.innerHTML = html;
        this.Show();

    }
    this.Focus = function(objid)
    {
        if (objid != "") { document.getElementById(objid).focus(); }
        this.Close();
    }
    this.Show = function()
    {
        var div = document.getElementById("DragonDialogDiv");
        var sClientWidth = parent ? parent.document.documentElement.clientWidth : document.documentElement.clientWidth;
        var sClientHeight = parent ? parent.document.documentElement.clientHeight : document.documentElement.clientHeight;
        var sScrollTop = parent ? parent.document.documentElement.scrollTop : document.documentElement.scrollTop;

        div.style.display = "";
        //FadeInObj(div);
        div.style.left = (document.documentElement.clientWidth / 2) - (div.offsetWidth / 2);
        var sTop = -40 + (sClientHeight / 2 + sScrollTop) - (div.offsetHeight / 2);
        div['style']['top'] = sTop > 0 ? sTop : (sClientHeight / 2 + sScrollTop) - (div.offsetHeight / 2);

        var bgdiv = document.createElement("div");
        bgdiv.id = "DragonBgDiv";
        bgdiv.style.width = div.clientWidth;
        bgdiv.style.height = div.clientHeight;
        bgdiv.style.position = "absolute";
        bgdiv.style.backgroundColor = "#BCBEC0";
        bgdiv.style.left = div.offsetLeft + 3;
        bgdiv.style.top = div.offsetTop + 3;
        bgdiv.style.zIndex = 550;
        document.body.appendChild(bgdiv);

        var bgObj = document.createElement("div");
        bgObj.setAttribute('id', 'DragonBgObjDiv');
        bgObj.style.position = "absolute";
        bgObj.style.top = "0";
        bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=100";
        bgObj.style.background = "url(" + imagepath + "/Images/DragonDialog/bg_page.jpg)";
        bgObj.style.opacity = "0.6";
        bgObj.style.left = "0";
        bgObj.style.width = document.body.offsetWidth + "px";
        bgObj.style.height = document.body.offsetHeight + "px";
        bgObj.style.zIndex = "500";
        document.body.appendChild(bgObj);

    }
    this.moveStart = function(event)
    {
        var oObj = document.getElementById("DragonDialogDiv");
        oObj.onmousemove = mousemove;
        oObj.onmouseup = mouseup;
        oObj.setCapture ? oObj.setCapture() : function() { };
        oEvent = window.event ? window.event : event;
        var dragData = { x: oEvent.clientX, y: oEvent.clientY };
        var backData = { x: parseInt(oObj.style.top), y: parseInt(oObj.style.left) };
        function mousemove()
        {
            var oEvent = window.event ? window.event : event;
            var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
            var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
            oObj.style.left = iLeft;
            oObj.style.top = iTop;
            dragData = { x: oEvent.clientX, y: oEvent.clientY };
            document.getElementById('DragonBgDiv').style.left = iLeft + 5;
            document.getElementById('DragonBgDiv').style.top = iTop + 5;
        }
        function mouseup()
        {
            var oEvent = window.event ? window.event : event;
            oObj.onmousemove = null;
            oObj.onmouseup = null;
            if (oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight)
            {
                oObj.style.left = backData.y;
                oObj.style.top = backData.x;
                document.getElementById('DragonBgDiv').style.left = backData.y + 5;
                document.getElementById('DragonBgDiv').style.top = backData.x + 5;
            }
            oObj.releaseCapture ? oObj.releaseCapture() : function() { };
        }
    }
}
var advid = "";
function ShowAdvDiv(objid, title)
{
    var div = document.getElementById(objid);
    var sClientWidth = parent ? parent.document.documentElement.clientWidth : document.documentElement.clientWidth;
    var sClientHeight = parent ? parent.document.documentElement.clientHeight : document.documentElement.clientHeight;
    var sScrollTop = parent ? parent.document.documentElement.scrollTop : document.documentElement.scrollTop;

    div.style.display = "";
    div.style.left = (document.documentElement.clientWidth / 2) - (div.offsetWidth / 2);
    var sTop = -40 + (sClientHeight / 2 + sScrollTop) - (div.offsetHeight / 2);
    div['style']['top'] = sTop > 0 ? sTop : (sClientHeight / 2 + sScrollTop) - (div.offsetHeight / 2);

    var bgdiv = document.createElement("div");
    bgdiv.id = "DragonBgDiv2";
    bgdiv.style.width = div.clientWidth;
    bgdiv.style.height = div.clientHeight;
    bgdiv.style.position = "absolute";
    bgdiv.style.backgroundColor = "#eeeeee";
    bgdiv.style.left = div.offsetLeft + 5;
    bgdiv.style.top = div.offsetTop + 5;
    bgdiv.style.zIndex = 550;
    document.body.appendChild(bgdiv);

    ShowBGDiv();

    advid = objid;
}
function CloseAdvDiv()
{
    var div = document.getElementById(advid);
    div.style.display = "none";
    CloseBGDiv();
    document.body.removeChild(document.getElementById("DragonBgDiv2"));
}
function ShowLoadingDiv(str)
{
    var loadingDiv = document.createElement("div");
    loadingDiv.setAttribute('id', 'loadingDiv');
    loadingDiv.style.backgroundColor = "#ffffff";
    loadingDiv.style.width = "160px";
    loadingDiv.style.height = "160px";
    loadingDiv.style.border = "solid 1px #CCCCCC";
    loadingDiv.style.zIndex = "550";
    loadingDiv.style.textAlign = "center";
    loadingDiv.innerHTML = "<br /><br /><br /><h5>" + str + "</h5><img src='/Images/Loading.gif' />";
    document.body.appendChild(loadingDiv);

    middleObj('loadingDiv');

    ShowBGDiv();
}
 
function CloseLoadingDiv()
{
    document.body.removeChild(document.getElementById("loadingDiv"));
    CloseBGDiv();
}
function ShowOkTip(obj, title)
{
    obj.innerHTML = "<img width='16' height='16' src='/Images/DragonIcon/Icon_msg_ok.gif' /><span style=''>" + title + "</span>";
    obj.className = "icon_msg_ok";
}
function ShowLoadingTip(obj, title)
{
    obj.innerHTML = "<img width='16' height='16' src='/Images/DragonIcon/Loading.gif' /><span style=''>" + title + "</span>";
    obj.className = "icon_msg_ok";
}
//提示错误
function ShowErrorTip(obj, title)
{
    obj.innerHTML = "<img width='16' height='16' src='/Images/DragonIcon/Icon_msg_error.gif' /><span style=''>" + title + "</span>";
    obj.className = "icon_msg_error";
}
//提示警告
function ShowWarningTip(obj, title)
{
    obj.innerHTML = "<img width='16' height='16' src='/Images/DragonIcon/Icon_msg_Warning.gif' /><span style=''>" + title + "</span>";
    obj.className = "icon_msg_warning";
}
function ShowBGDiv()
{
    var bgObj = document.createElement("div");
    bgObj.setAttribute('id', 'DragonBgObjDiv2');
    bgObj.style.position = "absolute";
    bgObj.style.top = "0";
    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=100";
    bgObj.style.background = "url(/Images/DragonDialog/bg_page.jpg)";
    bgObj.style.opacity = "0.6";
    bgObj.style.left = "0";
    bgObj.style.width = document.body.offsetWidth + "px";
    bgObj.style.height = document.body.offsetHeight + "px";
    if (document.body.offsetHeight < window.screen.availHeight)
    {
        bgObj.style.height = window.screen.availHeight + "px";
    }
    bgObj.style.zIndex = "500";
    document.body.appendChild(bgObj);
}
function CloseBGDiv()
{
    document.body.removeChild(document.getElementById("DragonBgObjDiv2"));
}
function middleObj(_sId)
{
    var sClientWidth = document.documentElement.clientWidth;
    var sClientHeight = document.documentElement.clientHeight;
    var sScrollTop = document.documentElement.scrollTop;
    $(_sId)['style']['display'] = '';
    $(_sId)['style']['position'] = "absolute";
    $(_sId)['style']['left'] = (document.documentElement.clientWidth / 2) - ($(_sId).offsetWidth / 2);
    var sTop = -40 + (sClientHeight / 2 + sScrollTop) - ($(_sId).offsetHeight / 2);
    $(_sId)['style']['top'] = sTop > 0 ? sTop : (sClientHeight / 2 + sScrollTop) - ($(_sId).offsetHeight / 2);
}

var maxHeightValue = 0;
var minHeightValue = 0;
var evalCode = "";
var alphaValue = 30;
var _checkAlphaObj = null;
function FadeInObj(obj, eCode)
{
    evalCode = eCode;
    _checkAlphaObj = obj;
    AlphaObj();
}
function AlphaObj()
{
    alphaValue += 20;
    _checkAlphaObj.style.filter = "alpha(opacity=" + alphaValue.toString() + ")";
    if (alphaValue < 100)
    {
        window.setTimeout("AlphaObj();", 100);
    }
    else
    {
        eval(evalCode);
    }
}
function FadeOutObj(obj,eCode)
{
    evalCode = eCode;
    alphaValue = 100;
    obj.style.filter = "alpha(opacity=100)";
    _checkAlphaObj = obj;
    CheckAlphaObj();
}
function CheckAlphaObj()
{
    alphaValue -= 20;
    _checkAlphaObj.style.filter = "alpha(opacity=" + alphaValue.toString() + ")";
    if (alphaValue <= 0)
    {
        _checkAlphaObj.style.display = 'none';
        eval(evalCode);
    }
    else
    {
        window.setTimeout("CheckAlphaObj();", 100);
    }
}
function FadeOutHeightObj(obj, eCode)
{
    _checkAlphaObj = obj;
    evalCode = eCode;
    maxHeightValue = obj.offsetHeight;
    minHeightValue = 0;
    checkOutHeight();
}
function checkOutHeight()
{
    maxHeightValue -= 4;
    if (maxHeightValue <= minHeightValue)
    {
        _checkAlphaObj.style.display = 'none';
        eval(evalCode);
    }
    else
    {
        _checkAlphaObj.style.height = maxHeightValue;
        window.setTimeout("checkOutHeight();", 2);
    }

}
function FadeInHeightObj(obj, h, eCode)
{
    _checkAlphaObj = obj;
    _checkAlphaObj.style.height = 0;
    _checkAlphaObj.style.display = '';
    evalCode = eCode;
    maxHeightValue = h;
    minHeightValue = 0;
    checkInHeight();
}
function checkInHeight()
{
    minHeightValue += 4;
    if (minHeightValue >= maxHeightValue)
    {
        eval(evalCode);
    }
    else
    {
        _checkAlphaObj.style.height = minHeightValue;
        window.setTimeout("checkInHeight();", 2);
    }

}

var numDiv_num = -1;
var numDiv_event = "";
function ShowNumDiv(str,num,event)
{
    numDiv_num = num;
    numDiv_event = event;
    var loadingDiv = document.createElement("div");
    loadingDiv.setAttribute('id', 'numDiv');
    loadingDiv.style.backgroundColor = "#ffffff";
    loadingDiv.style.width = "160px";
    loadingDiv.style.height = "160px";
    loadingDiv.style.border = "solid 1px #CCCCCC";
    loadingDiv.style.zIndex = "550";
    loadingDiv.style.textAlign = "center";
    loadingDiv.innerHTML = "<br /><br /><br /><div id='numDiv_num' style='font-weight:bold;font-size:36pt;'></div><div>"+str+"</div>";
    document.body.appendChild(loadingDiv);

    middleObj('numDiv');

    ShowBGDiv();
    ShowNumDiv_SetNum();;
}
function CloseNumDiv()
{
    document.body.removeChild(document.getElementById("numDiv"));
    CloseBGDiv();
}
function ShowNumDiv_SetNum()
{
    if (numDiv_num > -1)
    {
        var numStr = numDiv_num;
        if (numDiv_num < 10)
            numStr = "0" + numStr;
        document.getElementById("numDiv_num").innerHTML = numStr;
        numDiv_num--;
        window.setTimeout("ShowNumDiv_SetNum();", 1000);
    }
    else
    {
        CloseNumDiv();
        eval(numDiv_event);
    }
}
