﻿
//右下脚弹出窗口开始
//希望获得网页可见区域的高度,可以采用 document.body.clientHeight ,这是在HTML 4.0 标准上使用的. 
//现在的XHTML1.0规范不再支持上面们的方法,而是采用 document.documentElement.clientHeight 实现! 

window.onload = getMsg; 
window.onresize = resizeDiv; 
window.onerror = function(){} 
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
//一下注释代码是判断浏览器类型的
//var documentBodyObj=document.documentElement;
//if(navigator.userAgent.indexOf("MSIE")>0) documentBodyObj=document.documentElement;//IE6.0-7 or marthon   
//if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)documentBodyObj=document.documentElement;//firefox   
//if(isopera=navigator.userAgent.indexOf("Opera")>0)documentBodyObj=document.documentElement;//opera   
//if(isSafari=navigator.userAgent.indexOf("Safari")>0)documentBodyObj=document.body;//google     
//if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 5;   
//if(isMozilla=navigator.userAgent.indexOf("Gecko")>0)return 6;  

function getMsg() 
{ 
  try 
  { 
   divTop = parseInt(document.getElementById("loft_win").style.top,10); 
   divLeft = parseInt(document.getElementById("loft_win").style.left,10); 
   divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10); 
   divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10); 
   docWidth = document.documentElement.clientWidth; 
   docHeight = document.documentElement.clientHeight; 
   if(isSafari=navigator.userAgent.indexOf("Safari")>0){
	   document.getElementById("loft_win").style.top = parseInt(document.body.scrollTop,10) + docHeight+10+'px';// divHeight 
	   document.getElementById("loft_win").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth+'px'; 
   }else{
	   document.getElementById("loft_win").style.top = parseInt(document.documentElement.scrollTop,10) + docHeight+10+'px';// divHeight 
	   document.getElementById("loft_win").style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth+'px'; 
   }
   document.getElementById("loft_win").style.visibility="visible"; 
   objTimer = window.setInterval("moveDiv()",10); 
  } 
  catch(e){} 
} 

//初始化位置 
function resizeDiv() 
{ 
  i+=1; 
  //if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句 
  try 
  { 
   divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10); 
   divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10); 
   docWidth = document.documentElement.clientWidth; 
   docHeight = document.documentElement.clientHeight ; 
   if(isSafari=navigator.userAgent.indexOf("Safari")>0){
	   document.getElementById("loft_win").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)-11+'px'; 
	   document.getElementById("loft_win").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)+'px'; 
   }else{
	   document.getElementById("loft_win").style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)-11+'px'; 
	   document.getElementById("loft_win").style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+'px'; 
   }

  } 
  catch(e){} 
} 

//最小化 
function minsizeDiv() 
{ 
  i+=1 
  //if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句 
  try 
  { 
   divHeight = parseInt(document.getElementById("loft_win_min").offsetHeight,10); 
   divWidth = parseInt(document.getElementById("loft_win_min").offsetWidth,10); 
   docWidth = document.documentElement.clientWidth; 
   docHeight = document.documentElement.clientHeight; 
   if(isSafari=navigator.userAgent.indexOf("Safari")>0){
	   document.getElementById("loft_win_min").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)+'px'; 
	   document.getElementById("loft_win_min").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)+'px'; 
   }else{
	   document.getElementById("loft_win_min").style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)+'px'; 
	   document.getElementById("loft_win_min").style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)+'px'; 
   }
  } 
  catch(e){} 
} 

//移动 
function moveDiv() 
{ 
try 
{ 
	var top1;
	if(isSafari=navigator.userAgent.indexOf("Safari")>0){
		top1=parseInt(document.body.scrollTop,10)
	}else{
		top1=parseInt(document.documentElement.scrollTop,10)
	}
	
  if(parseInt(document.getElementById("loft_win").style.top,10) <= (docHeight - divHeight + parseInt(top1,10))) 
  { 
   window.clearInterval(objTimer); 
   objTimer = window.setInterval("resizeDiv()",1); 
  } 
  divTop = parseInt(document.getElementById("loft_win").style.top,10); 
  document.getElementById("loft_win").style.top = divTop -1+'px'; 
} 
  catch(e){} 
} 

function minDiv() 
{ 
  closeDiv(); 
  document.getElementById('loft_win_min').style.visibility='visible'; 
  objTimer = window.setInterval("minsizeDiv()",1); 
} 

function maxDiv() 
{ 
  document.getElementById('loft_win_min').style.visibility='hidden'; 
  document.getElementById('loft_win').style.visibility='visible'; 
  objTimer = window.setInterval("resizeDiv()",1); 
  //resizeDiv() 
  getMsg(); 
} 

function closeDiv() 
{ 
  document.getElementById('loft_win').style.visibility='hidden'; 
  document.getElementById('loft_win_min').style.visibility='hidden'; 
  if(objTimer) window.clearInterval(objTimer); 
} 

