﻿// JScript 文件

//窗体变化处发
var MoveMaxHeight;
var MoveMaxWidth;
var pageWidth;//最大宽度
var pageHeight;//最大高度
var dE//浏览器
var dBy//页面
var dEClientWidth//浏览器宽度
var dEClientHeight//浏览器高度
var dByClientWidth//页面宽度
var dByClientHeight//页面高度
var Scrollleft;//浏览器滚动条左
var ScrollTop;//浏览器滚动条上
var cDivWidth="";//层宽
var cDivHeight="";//层高
var cDivID="";//(不是遮盖层)
var zDivID='';//(遮盖层)
//获取ID
function $(al)
{
	if(document.getElementById)
	{
	    return eval('document.getElementById("'+al+'")');		
	}
	else if(document.layers)
	{
	    return eval("document.layers['"+al+"']");		
	}
	else 
	{
    	return eval('document.all.'+al);
	}
}
function setcw(){
    dE=document.documentElement;//浏览器
    dBy=document.body;//页面
    dEClientWidth=dE.clientWidth;//浏览器宽度
    dEClientHeight=dE.clientHeight;//浏览器高度
    dByClientWidth=dBy.clientWidth;//页面宽度
    dByClientHeight=dBy.clientHeight;//页面高度
    Scrollleft=dE.scrollLeft;
    ScrollTop=dE.scrollTop;
}
function PositionIframe()
{
    setcw();
    sDocumentIframe();
    var div1=$(zDivID);
    div1.style.display="block";
    div1.style.height=pageHeight;
    div1.style.width=pageWidth;	
    $(cDivID).style.display="block"; 
	$(cDivID)['style']['position'] = "absolute";
	$(cDivID)['style']['left'] = (parseInt(dEClientWidth) / 2+parseInt(Scrollleft)) - parseInt(cDivWidth)/2;	
	$(cDivID)['style']['top'] = (parseInt(dEClientHeight) / 2 + parseInt(ScrollTop)) - parseInt(cDivHeight) / 2;
	$(cDivID).style.display="block"; 
	
}

window.onresize=function CollectionMsgSizeIframe()
{ 
    if(cDivID!=''){
        PositionIframe();	
    }
        if($('TreeOverlayBackgroundDiv')['style']['display']=="block")
    {
        var oTreeAlertMsg = $("TreeAlertMsgDiv");
		setcw();
        sDocumentIframe();
        $('TreeOverlayBackgroundDiv').style.height = pageHeight;
        iTree_Alert_MoveMaxHeight = pageHeight - parseInt(oTreeAlertMsg.offsetHeight);
        $('TreeOverlayBackgroundDiv').style.width = pageWidth;
        iTree_Alert_MoveMaxWidth = pageWidth - parseInt(oTreeAlertMsg.offsetWidth);
        TreeAlertMsgmiddle('TreeAlertMsgDiv');      
    }
}

//鼠标按住移动层

var excursionX = 0;
var excursionY = 0;
var popupDiv='';
function sDocumentIframe(){
   pageWidth=dByClientWidth>dEClientWidth?dByClientWidth: dEClientWidth;
   pageHeight=dByClientHeight>dEClientHeight?dByClientHeight: dEClientHeight;
}

function setValueIframe(){
    sDocumentIframe();
   popupDiv=$(cDivID);   
   MoveMaxHeight = pageHeight - parseInt(popupDiv.offsetHeight);
   MoveMaxWidth = pageWidth - parseInt(popupDiv.offsetWidth);  
}
/*MoveTreeAlertMsg*/
function IframeMsgmoveStart(event,divid)
{
    cDivID=divid;
    setcw();
    setValueIframe();    
    excursionX = event.clientX ;
    excursionY = event.clientY;   
    popupDiv.setCapture();
    popupDiv.onmousemove = IframeMsgmousemove;
    popupDiv.onmouseup = IframeMsgMouseup;
    
}

function IframeMsgmousemove()
{
    var tempmousex = event.clientX + Scrollleft;   
    var tempmousey = event.clientY + ScrollTop;
    popupDiv.style.top = parseInt(tempmousey) - excursionY;
    popupDiv.style.left = parseInt(tempmousex) - excursionX; 
}

/*MoveTreeAlertMsg*/
function IframeMsgMouseup()
{  
    var IframeMsgTop = parseInt(popupDiv.style.top);
    var IframeMsgLeft = parseInt(popupDiv.style.left);
    if(IframeMsgTop < 0)
    {
        popupDiv.style.top = 0;
    }
    else if(IframeMsgTop >MoveMaxHeight-2)
    {
       
        popupDiv.style.top = MoveMaxHeight-2;
    }
    
    if(IframeMsgLeft < 0 )
    {
        popupDiv.style.left = 0;
    }
    else if(IframeMsgLeft > MoveMaxWidth)
    {
        popupDiv.style.left = MoveMaxWidth;
    }
    
    popupDiv.releaseCapture();
    popupDiv.onmousemove = null;
    popupDiv.onmouseup = null;
}
//显示带iframe层
function showIframe(divID1,divID2,divWidth,divHeight){
    cDivID=divID2;//显示弹窗层
    zDivID=divID1;
    cDivWidth=divWidth;//层宽
    cDivHeight=divHeight;//层高
    PositionIframe(); //层定位  
}

//关闭带iframe层
function clossIframe1(divID1,divID2){
    cDivID="";
    zDivID="";
    $(divID1).style.display="none";
    $(divID2).style.display="none";
}

//关闭带iframe层
function clossIframe(divID1,divID2){
    cDivID="";
    zDivID="";
    $(divID1).style.display="none";
    $(divID2).style.display="none";
    getObject('ia').src="";
}