/* -------------------------------------------------------------------------- *//**  *    @fileoverview *       Smooth Scroll w/auto setup * *    @version rev010.2005-07-31 *    @requires common.js *//* -------------------------------------------------------------------------- *//* -------------------- Default settings for BASmoothScroll -------------------- */var BASMOOTHSCROLL_AUTOSETUP_ENABLED      = true;var BASMOOTHSCROLL_DEFAULT_SCROLLUNIT     = 5;var BASMOOTHSCROLL_DEFAULT_SCROLLWAIT     = 55;var BASMOOTHSCROLL_DEFAULT_USEPOSTPROCESS = false;/* -------------------- Single Instance : BASmoothScroll -------------------- */function BASmoothScroll_() {	this.offsetX = 0;	this.offsetY = 0;	this.unit = BASMOOTHSCROLL_DEFAULT_SCROLLUNIT ||  5;	this.wait = BASMOOTHSCROLL_DEFAULT_SCROLLWAIT || 10;	this.usePostProcess = BASMOOTHSCROLL_DEFAULT_USEPOSTPROCESS;}BASmoothScroll_.prototype = {	setTargetNode : function(node) {		this.targetNode = node;		this.timer      = null;	},		setFromNode : function(node) {		this.fromNode = node;	},		startScroll : function() {		BAGetGeometry();		if (!this.timer) {			var maxX   = (BA.geom.pageW > BA.geom.windowW) ? BA.geom.pageW - BA.geom.windowW : 0;			var maxY   = (BA.geom.pageH > BA.geom.windowH) ? BA.geom.pageH - BA.geom.windowH : 0;			var posX   = this.targetNode.getAbsoluteOffsetBA().X + this.offsetX;			var posY   = this.targetNode.getAbsoluteOffsetBA().Y + this.offsetY;			this.cuX   = BA.geom.scrollX;			this.cuY   = BA.geom.scrollY;			this.toX   = (posX < 0) ? 0 : (posX > maxX) ? maxX : posX;			this.toY   = (posY < 0) ? 0 : (posY > maxY) ? maxY : posY;			this.timer = new BASetInterval(arguments.callee, this.wait, this);		}		this.cuX += (this.toX - BA.geom.scrollX) / this.unit; if (this.cuX < 0) this.cuX = 0;		this.cuY += (this.toY - BA.geom.scrollY) / this.unit; if (this.cuY < 0) this.cuY = 0;		var newX = Math.floor(this.cuX);		var newY = Math.floor(this.cuY);		window.scrollTo(newX, newY);		if (newX == this.toX && newY == this.toY) this.stopScroll();	},		stopScroll : function() {		if (this.timer) {			this.timer.clearTimer();			this.timer = null;			this.postProcess();		}	},		postProcess : function() {		if (this.usePostProcess && this.fromNode && (BA.ua.isGecko || BA.ua.isWinIE)) {			var href = this.fromNode.getAttributeBA('href');			if (href) location.href = href;		}	}}var BASmoothScroll = BASingleton(BASmoothScroll_);/* -------------------- Function : BASmoothScrollAutoSetup -------------------- */function BASmoothScrollAutoSetup() {	var oHTML = document.getElementsByTagNameBA('html')[0];	var oBODY = document.getElementsByTagNameBA('body')[0];	var cDIV  = document.createElementBA('div');	if (!document.getElementById('top'))    oHTML.setAttributeBA('id', 'top');	if (!document.getElementById('bottom')) cDIV.setAttributeBA('id', 'bottom');	cDIV.style.margin = cDIV.style.padding = 0;	cDIV.style.clear  = 'both';	oBODY.appendChildBA(cDIV);	var nodes = document.getElementsByTagNameBA('a');	for (var i = 0, n = nodes.length; i < n; i++) {		var ident = _getInternalLinkFragmentIdentifier(nodes[i]);		if (ident) {			var target = document.getElementById(ident) || document.getElementsByName(ident)[0];			if (target) {				nodes[i].__BASmoothScrollAutoSetup_targetNode__ = target;				nodes[i].addEventListenerBA('click', function(e) {					e.preventDefault();					e.stopPropagation();					BASmoothScroll.setTargetNode(e.currentTarget.__BASmoothScrollAutoSetup_targetNode__);					BASmoothScroll.setFromNode(e.currentTarget);					BASmoothScroll.startScroll();				});			}		}	}	function _getInternalLinkFragmentIdentifier(node) {		var ret      = '';		var linkHref = node.getAttributeBA('href');		if (linkHref && linkHref.match(/#/)) {			linkHref = linkHref.split('#');			if (!linkHref[0] || linkHref[0] == location.href.split('#')[0]) {				ret = linkHref[1];			}		}		return ret;	}}/* -------------------- Main : register start-up -------------------- */if (typeof BA == 'object' && BA.ua.DOMok && BASMOOTHSCROLL_AUTOSETUP_ENABLED) {	BAAddOnload(function() {		BASmoothScrollAutoSetup();		document.addEventListenerBA('click'     , function(e) { BASmoothScroll.stopScroll() });		document.addEventListenerBA('mousewheel', function(e) { BASmoothScroll.stopScroll() });	});}