﻿//-----------------------关闭方法-----------------------------------

//关闭
function DivClose() {
    var eViocePlayer=document.getElementById("eViocePlayer");
    if (eViocePlayer != null) {
        eViocePlayer.parentNode.removeChild(eViocePlayer);
    }        
        
    var bDiv = window.parent.document.getElementById("backDiv");
    if (bDiv != null) {
        bDiv.parentNode.removeChild(bDiv);
    }

    var fDiv = window.parent.document.getElementById("floatDiv");   
    fDiv.parentNode.removeChild(fDiv);
    
}
//当被嵌在IFRAME中时关闭
function IFrameDivClose() {
    var bDiv = window.document.getElementById("backDiv");
    if (bDiv != null) {
        bDiv.parentNode.removeChild(bDiv);
    }

    var fDiv = window.document.getElementById("floatDiv");
    fDiv.parentNode.removeChild(fDiv);
    
}
function DivTransOk() {
    window.parent.setValue($$("txtSelectID").value, $$("txtSelectName").value);    
    var bDiv = window.parent.document.getElementById("backDiv");
    if (bDiv != null) {
        bDiv.parentNode.removeChild(bDiv);
    }

    var fDiv = window.parent.document.getElementById("floatDiv");
    fDiv.parentNode.removeChild(fDiv);
    
}
//-----------------------关闭方法-----------------------------------

//-------------------------------------------------------------
//$$方法
function $$(elem) {
    return document.getElementById (elem );
}
//--------------------------------------------------------------

//---------------------login方法--------------------------------
//Login方法
//<isbackDiv>是否存在Div层      如:True/False
//<IframeWidth>新打开窗口宽度   如:"300"
//<IframeHeight>新打开窗口高度  如:"300"
//<PageName>网而地址            如:"FriendShuXing.aspx"
function DivTip(isbackDiv, IframeWidth, IframeHeight, PageName) {
    if (window.ActiveXObject) {
      //  alert ("IE");
    } else {
//      var intHeight=parseInt(IframeHeight);
//      IframeHeight=(intHeight +16).toString();
   
    }
    if ($$('floatDiv') == null) {
      
        var floatDiv = document.createElement('div');
        floatDiv.id = "floatDiv";
        floatDiv.style.position = "absolute";
        floatDiv.style.width = IframeWidth + "px";
        floatDiv.style.height = IframeHeight + "px";
        floatDiv.style.left = (document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft - IframeWidth / 2) + "px";
        floatDiv.style.top = (document.documentElement.clientHeight / 2 + document.documentElement.scrollTop - IframeHeight / 2) + "px";
        floatDiv.style.zIndex = 1001;
        var loginText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"" + PageName + "\" width=\"100%\" height=\"" + IframeHeight + "\"></iframe>";
        floatDiv.innerHTML = loginText;
        setTimeout(function() { document.body.appendChild(floatDiv); }, 1);
    }
    else {
         
        $$('floatDiv').style.display = "block";
    }
    if ($$('backDiv') == null && isbackDiv == true) {
       
        var backDiv = document.createElement('div');
        backDiv.id = "backDiv";
        backDiv.style.backgroundColor = "Black";
        backDiv.style.filter = "alpha(opacity=70)";
        backDiv.style.MozOpacity = "0.70";
        backDiv.style.position = "absolute";
        backDiv.style.left = "0px";
        backDiv.style.top = "0px";
        backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) + "px";
        backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight) + "px";
        document.body.appendChild(backDiv);
        $$('backDiv').style.zIndex = 1000;
    }
    else if (isbackDiv == true) {
        $$('backDiv').style.display = "block";
    }
}
//---------------------login方法--------------------------------
//Login方法
//<isbackDiv>是否存在Div层      如:True/False
//<IframeWidth>新打开窗口宽度   如:"300"
//<IframeHeight>新打开窗口高度  如:"300"
//<IframeHeight>新打开窗口高度  如:"20"
//<PageName>网而地址            如:"FriendShuXing.aspx"
function Login2(isbackDiv, IframeWidth, IframeHeight,IframeTop, PageName) {
    if (window.ActiveXObject) {
      //  alert ("IE");
    } else {
//      var intHeight=parseInt(IframeHeight);
//      IframeHeight=(intHeight +16).toString();
   
    }
    if ($$('floatDiv') == null) {
      
        var floatDiv = document.createElement('div');
        floatDiv.id = "floatDiv";
        floatDiv.style.position = "absolute";
        floatDiv.style.width = IframeWidth + "px";
        floatDiv.style.height = IframeHeight + "px";
        floatDiv.style.left = (document.documentElement.clientWidth / 2 + document.documentElement.scrollLeft - IframeWidth / 2) + "px";
        floatDiv.style.top = IframeTop + "px";
        floatDiv.style.zIndex = 1001;
        var loginText = "<iframe id=\"iframe1\" frameborder=\"0\" scrolling=\"no\" src=\"" + PageName + "\" width=\"100%\" height=\"" + IframeHeight + "\"></iframe>";
        floatDiv.innerHTML = loginText;
        setTimeout(function() { document.body.appendChild(floatDiv); }, 1);
    }
    else {
         
        $$('floatDiv').style.display = "block";
    }
    if ($$('backDiv') == null && isbackDiv == true) {
       
        var backDiv = document.createElement('div');
        backDiv.id = "backDiv";
        backDiv.style.backgroundColor = "Black";
        backDiv.style.filter = "alpha(opacity=70)";
        backDiv.style.MozOpacity = "0.70";
        backDiv.style.position = "absolute";
        backDiv.style.left = "0px";
        backDiv.style.top = "0px";
        backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) + "px";
        backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight) + "px";
        document.body.appendChild(backDiv);
        $$('backDiv').style.zIndex = 1000;
    }
    else if (isbackDiv == true) {
        $$('backDiv').style.display = "block";
    }
}
//拖动Div
function moveDiv(event, elem) {
    $$('floatDiv').style.filter = "alpha(opacity=50)";
    var oObj = $$(elem);
    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
        };
    }
    function mouseup() {
        var oEvent = window.event ? window.event: event;
        oObj.onmousemove = null;
        oObj.onmouseup = null;
        $$('floatDiv').style.filter = "";
        if (oEvent.clientX < 1 || oEvent.clientY < 1) {
            oObj.style.left = backData.y;
            oObj.style.top = backData.x;
        }
        oObj.releaseCapture ? oObj.releaseCapture() : function() {};
    }
}
function CloseFloatDiv() {
    $$('floatDiv').style.display = "none";
    if ($$('backDiv')) {
        $$('backDiv').style.display = "none";
    }
}
//-----弹出对话框
function ShowDailog(PageHref,Title,Heights,Widths)
{
	//--------------left位置
	var dleft =(screen.availHeight-Heights)/2
	//--------------top位置
	var dtop  =(screen.availWidth-Widths)/2
	//---------------
	var sRet = window.showModalDialog(PageHref,Title,'scrollbars=yes;resizable=no;help=no;status=no;center=yes;dialogTop=25;dialogLeft='+ dleft +';dialogTop='+ dtop +';dialogHeight='+Heights+';dialogWidth='+Widths);
	//--------return
	if (sRet =="refresh")
	{
		window.location.reload();
	}
}
