﻿// JScript 文件

var move_obj_x0=0,move_obj_y0=0,move_obj_x1=0,move_obj_y1=0;//(x0,y0)为开始拖动时鼠标的位置(x1,y1)为开始拖动时对象的位置 
var obj_moveable=false; 

//开始拖动; 
function startDrag(obj,id) 
{ 
    if(event.button==1) 
    { 
        obj.setCapture(); 
        win=document.getElementById(id) 
        win.style.filter='alpha(opacity=70)';
        move_obj_x0 = event.clientX; 
        move_obj_y0 = event.clientY; 
        move_obj_x1 = parseInt(win.style.left); 
        move_obj_y1 = parseInt(win.style.top);
      
        obj_moveable = true; 
    } 
} 
//拖动; 
function drag(id) 
{ 
    if(obj_moveable) 
    { 
          
        win=document.getElementById(id) 
        win.style.filter='alpha(opacity=20)';
        win.style.left = (move_obj_x1 + event.clientX - move_obj_x0>0)?move_obj_x1 + event.clientX - move_obj_x0:0; 
        win.style.top = (move_obj_y1 + event.clientY - move_obj_y0>0)?move_obj_y1 + event.clientY - move_obj_y0:0; 
    } 
} 
//停止拖动; 
function stopDrag(obj,id) 
{ 
    if(obj_moveable) 
    { 
        document.getElementById("openpanel").style.filter='alpha(opacity=100)';
        obj.releaseCapture(); 
        obj_moveable = false; 
    } 
} 
//关闭窗口
function closePanel()
   {
   var obj=document.getElementById("showdiv");
       document.getElementById("openpanel").style.display='none';
      obj.style.display='none'; 
      
   }
   //弹出两个DIV
    function showbgPanel(title,url,width,height)
   {
	   //让弹出的DIV居中
	  var a = document.getElementById("openpanel");
      a.style.width=(width+8)+"px";
	  a.style.height=(height+40)+"px";
	  a.style.left=((document.body.clientWidth-width)/2)+"px";
      //a.style.top=((document.body.clientHeight-height-40)/2)+"px";
        var scrollPos; 
        if (typeof window.pageYOffset != 'undefined') { 
           scrollPos = window.pageYOffset; 
        } 
        else if (typeof document.compatMode != 'undefined' && 
             document.compatMode != 'BackCompat') { 
           scrollPos = document.documentElement.scrollTop; 
        } 
        else if (typeof document.body != 'undefined') { 
           scrollPos = document.body.scrollTop; 
        } 
        //alert(scrollPos);
		if(document.documentElement.clientHeight == 0)
		{
			bodyHeight = document.body.clientHeight
		}
		else
		{
			bodyHeight = document.documentElement.clientHeight;
		}
	    if(scrollPos>0)
	    {
		    a.style.top = scrollPos + ((bodyHeight-height-40)/2)+"px";
	    }
	    else
	    {
			a.style.top = ((bodyHeight-height-40)/2)+"px";
	    }

	   var obj=document.getElementById("showdiv");
       obj.style.display='';
       obj.style.width=document.body.scrollWidth+"px";
       obj.style.height=document.body.scrollHeight+"px";
       
        document.getElementById("openpanel").style.display='';
        document.getElementById("openurl").src=url;//浮动框调用的页
		document.getElementById("openurl").style.width=width+"px";//浮动框调用的页的宽
		document.getElementById("openurl").style.height=height+"px";//浮动框调用的页的高
        document.getElementById("_title").innerHTML="<span style='color:#ffffff;'>"+title+"</span>";
       return false;
   }