﻿	var activeFloatingWindow = false;
	var activeFloatingWindowContent = false;
	var activeFloatingWindowMoveBar = false;

	var floatingWindowMoveCounter = -1;
	var initEventX = false;
	var initEventY = false;
	var window_posX = false;
	var window_posY = false;

	function initFloatingWindowMove(e)
	{
		if(document.all)e = event;	
		floatingWindowMoveCounter = 0;		
		activeFloatingWindow=this.parentNode;
		initEventX = e.clientX;
		initEventY = e.clientY;
		window_posX = activeFloatingWindow.style.left.replace('px','')/1;
		window_posY = activeFloatingWindow.style.top.replace('px','')/1;

		timerFloatingWindowMove();
		return false;
	}
	
	function timerFloatingWindowMove()
	{
		if(floatingWindowMoveCounter>=0 && floatingWindowMoveCounter<10){
			floatingWindowMoveCounter = floatingWindowMoveCounter + 1;
			setTimeout('timerFloatingWindowMove()',10);
		}		
	}
	function floatingWindowMove(e)
	{
		if(document.all)e = event;
		if(floatingWindowMoveCounter>=10){
			var leftPos = window_posX + e.clientX - initEventX;
			var topPos = window_posY + e.clientY - initEventY;
			if(topPos<0)topPos=0;
			if(leftPos<0)leftPos=0;
			activeFloatingWindow.style.left = leftPos + 'px';
			activeFloatingWindow.style.top = topPos + 'px';			
			return;
		}		
		
	}
	function floatingWindowStopMove(e)
	{
		floatingWindowMoveCounter = -1;	
		activeFloatingWindow = false;
	}
	function initFloatingWindowWithTabs(objid){
		var sx = document.body.scrollLeft;
		var sy = document.body.scrollTop;

		if(sx==0){
			sx = document.documentElement.scrollLeft;
		}
		if(sy==0) {
			sy = document.documentElement.scrollTop;
		}

		//获取屏幕宽度
		//var availWidth = parseInt(window.screen.availWidth);
		var availWidth = parseInt(document.body.clientWidth);
		//if(availWidth==0) {
		//	availWidth = parseInt(document.documentElement.clientWidth);
		//}
		var availHeight = parseInt(window.screen.availHeight);
		//浮动表格宽度
		var tblWidth = 600;
		if(typeof(catetblWidth)=="undefined" || catetblWidth=="" || catetblWidth==0){
			tblWidth = 600;
		} else {
			tblWidth = catetblWidth;
		}
        if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			//
		} else {
		    sy=0;
		}
		sy = sy + Math.round(availHeight/8);
		sx = Math.round((availWidth - tblWidth)/2);
		if(sx <= 10 ) { sx = 10; }
		
		var htmlDiv = '';
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		htmlDiv=htmlDiv+'<iframe id="dhtmlgoodies_floating_window_iframealpha"></iframe>';}
		htmlDiv=htmlDiv+'<div id="dhtmlgoodies_floating_window_alpha" ></div>';
		htmlDiv=htmlDiv+'<div class="dhtmlgoodies_floatingWindow" id="dhtmlgoodies_floating_window0" ';
		htmlDiv=htmlDiv+' style="visibility:hidden; width:'+tblWidth+'px; left:'+sx+'px; top:'+sy+'px;z-index:10001;">';
		htmlDiv=htmlDiv+'<div class="floatingWindow_moveBar" id="floatingWindow_moveBar" ><span></span></div>';
		htmlDiv=htmlDiv+'<div class="floatingWindow_topRow" ><div class="floatingWindowTab_active" id="floatingWindowTab0">';
		htmlDiv=htmlDiv+'<div id="floatingWindowTabTitle0"></div></div></div>';
		htmlDiv=htmlDiv+'<div class="fwContent" >';
		htmlDiv=htmlDiv+'<table border="0" id="TblParent" width="96%"></table>';
		htmlDiv=htmlDiv+'<hr size="1" />';
		htmlDiv=htmlDiv+'<table border="0" id="TblChild" width="96%"></table>';
		htmlDiv=htmlDiv+'<hr size="1" />';
		htmlDiv=htmlDiv+'<table border="0" id="tblSelected" width="96%"></table>';
		htmlDiv=htmlDiv+'<table border="0" id="Tblbutton" width="96%"></table>';
		htmlDiv=htmlDiv+'</div></div>';
		var fwdiv = document.getElementById(objid);
		fwdiv.innerHTML = htmlDiv;
		document.getElementById('floatingWindow_moveBar').onmousedown = initFloatingWindowMove;
		document.documentElement.onmousemove = floatingWindowMove;
		document.documentElement.onmouseup = floatingWindowStopMove;
		//document.getElementById('dhtmlgoodies_floating_window0').style.zIndex = 10001;
	}

