﻿// 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='';//(遮盖层)
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.width=pageWidth+"px";	
    div1.style.height=pageHeight+"px";
    $(cDivID).style.display="block"; 
	$(cDivID)['style']['position'] = "absolute";
	$(cDivID)['style']['left'] = (parseInt(dEClientWidth) / 2+parseInt(Scrollleft)) - parseInt(cDivWidth)/2+"px";	
	$(cDivID)['style']['top'] = (parseInt(dEClientHeight) / 2 + parseInt(ScrollTop)) - parseInt(cDivHeight) / 2+"px";
	$(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;
    
    var yScroll;  
    if (window.innerHeight && window.scrollMaxY) {  
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        yScroll = document.body.offsetHeight;
    }

    var windowHeight;
    if (self.innerHeight) {  // all except Explorer
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
    }
    pageHeight=(yScroll < windowHeight)?windowHeight:yScroll;
}

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+ Scrollleft-parseInt(popupDiv.style.left);
    excursionY = event.clientY+ ScrollTop-parseInt(popupDiv.style.top);
    popupDiv.setCapture();
    popupDiv.onmousemove = IframeMsgmousemove;
    popupDiv.onmouseup = IframeMsgMouseup;
}

function IframeMsgmousemove(){
    var tempmousex = event.clientX + Scrollleft-excursionX;   
    var tempmousey = event.clientY + ScrollTop-excursionY;
    popupDiv.style.top = parseInt(tempmousey);
    popupDiv.style.left = parseInt(tempmousex);
}

/*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="";
}

//上传图片
function updatepic(picid,divID1,divID2,divWidth,divHeight,iframe,hid){
    getObject(divID2).style.height="355px";
    getObject(divID2).style.width="544px";
    getObject(iframe).src='/Control/ImgUpload.aspx?pictrueID='+picid+'&picWidth='+divWidth+'&picHeigth='+divHeight+'&hid='+hid;
    showIframe(divID1,divID2,'544px','355px');
}
//使图片大小自动适应
function pimsize(imgname,widths,heights){
    var imgid=document.getElementById(imgname)
    if(imgid.width>widths)
        imgid.width=widths;
    if(imgid.height>heights)
        imgid.height=heights; 
}
//插入图片
function getimage(picid,width,height,picurl){
  document.getElementById(picid).innerHTML="<img id=picid onload=pimsize('picid',"+width+","+height+") src="+picurl+">";
}
function getlogo(picid,width,height,picurl){
  document.getElementById(picid).innerHTML="<img id=picid onload=pimsize('picid',"+width+","+height+") src="+picurl+" style='padding:2px 0 0 2px;' border=0 width=100 height=100>";
}

function getresume(picid,width,height,picurl){
  document.getElementById(picid).innerHTML="<img id=picid onload=pimsize('picid',"+width+","+height+") src="+picurl+" style='padding:2px 2px 2px 2px;border:solid 1px #bcbbbb' width=123 height=138>";
}

//使图片大小自动适应
function picsize(imgname,width,height){
    var w;
    var h;
    var imgid=document.getElementById(imgname);
    w=imgid.width;
    h=imgid.height;
    if(w>width){
        imgid.width=width;
    }
    if(h>height){
        imgid.height=height;
    }
    imgid.style.marginTop=(height-imgid.height)/2+"px";
}
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);
    }
}

//显示带iframe层
function showIframeByRList(divID1,divID2,divWidth,divHeight,top, left){
    cDivID=divID2;//显示弹窗层
    zDivID=divID1;
    cDivWidth=divWidth;//层宽
    cDivHeight=divHeight;//层高
    PositionIframeRL(top,left); //层定位  
}

function PositionIframeRL(top, left){
    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'] = left+'px';	
	$(cDivID)['style']['top'] = top+'px';
	$(cDivID).style.display="block"; 
}