// JavaScript Document
/*
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 intv;
var scrollSpeed=30		//捲動速度

var stopa = true;
function init(){

	layerHeight = $("#floater").height();
	layerWidth = $("#floater").width();
	
	bHeight = $(window).height();
	bWidth = $(window).width();
	

	newY=370;
	
	
	var p = $('#container').position();
	newX= p.left +$('#container').width()+ 22;

	
	$("#floater").fadeIn();

	$('#floater').css("top",newY);
	$('#floater').css("left",newX);
	
	intv = window.setInterval('heartBeat()',10);

}

function heartBeat() {

	diffY = $(document).scrollTop()

	if (document.getElementById('floater').style.visibility!='hidden'){
		if(diffY != lastScrollY){
			percent = 1 * (diffY - lastScrollY) / scrollSpeed;
			if(percent > 0) percent = Math.ceil(percent);
			else percent = Math.floor(percent);
			var pos = $('#floater').position();
			newY=parseInt(pos.top);
			newY+=percent;
			
			$('#floater').css("top",newY);

			lastScrollY += percent;
			window.status='Y:'+ lastScrollY;
		}
	}
	
} 

$(function(){
	window.setTimeout('init()','1500');
//$(window).resize(init);
})
