/*
Copyright by Audi 2006
http://audi.tw
http://www.carousel.com.tw
歡迎應用於無償用途散播，並請勿移除本版權宣告

*/

var currentX = currentY = 0; 
var whichIt = null;
var lastScrollX = 0; lastScrollY = 0;
var isNS = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >=5)) ? 1 : 0;
var isIE = (document.all) ? 1: 0;
var layerWidth,layerHeight;
var bWidth,bHeight;

var scrollSpeed=30		//捲動速度

function init(){
	if (isIE){ // mean ie4,ie5,ie5.5 or above
		layerHeight=document.getElementById('floater').clientHeight;
		layerWidth=document.getElementById('floater').clientWidth;
	}

	if (isNS){
		layerHeight=document.getElementById('floater').offsetHeight;
		layerWidth=document.getElementById('floater').offsetWidth;
	}
	
	if (typeof window.innerWidth != 'undefined') 
{ 
      bWidth = window.innerWidth, 
      bHeight = window.innerHeight 
} 

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) 

else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) 
{ 
       bWidth = document.documentElement.clientWidth, 
       bHeight = document.documentElement.clientHeight 
} 

// older versions of IE 

else 
{ 
       bWidth = document.getElementsByTagName('body')[0].clientWidth, 
       bHeight = document.getElementsByTagName('body')[0].clientHeight 
} 

	//bHeight=(isNS)?window.innerHeight:document.body.clientHeight;
	//bWidth=(isNS)?window.innerWidth:document.body.clientWidth;

	newY=bHeight-layerHeight;
	//newX=bWidth-layerWidth-32; //靠右
	newX = 0; //靠左
	
	document.getElementById('floater').style.top=newY+'px';
	document.getElementById('floater').style.left=newX+'px';
	//alert(layerHeight +" "+bHeight+" "+newY);
	window.setInterval('heartBeat()',1);
}

function heartBeat() {
	if(isIE){
		diffY = document.documentElement.scrollTop + document.body.scrollTop;
		diffX = 0;
	}
	
	if(isNS){ 
		diffY = self.pageYOffset;
		diffX = 0; 
	}
	newY = bHeight-layerHeight + diffY;
	if (document.getElementById('floater').style.visibility!='hidden'){		
		document.getElementById('floater').style.top = newY+'px';
	}
}