/* -------------------------------------------------------------------------- *//**  *    @fileoverview *       Common Script Libraries. * *    @version rev010.2005-08-10 *//* -------------------------------------------------------------------------- *//* --------------- Constructor : BAEnvironment --------------- */function BAEnvironment() {	var d  = document;	var di = d.implementation;	var de = d.documentElement;	var ua = navigator.userAgent;	var lp = location.protocol;	var lh = location.hostname;	this.url = {}; this.ns = {}; this.prefix = {}; this.ua = {}; this.env = {}; this.css = {}; this.geom = {};	this.url.commonDir   = BAGetCommonDir('common');	this.url.cssDir      = this.url.commonDir + 'style/';	this.url.scriptDir   = this.url.commonDir + 'js/';	this.ns.defaultNS    = (de && de.namespaceURI) ? de.namespaceURI : (de && de.tagUrn) ? de.tagUrn : null;	this.ns.xhtml1       = 'http://www.w3.org/1999/xhtml';	this.ns.xhtml2       = 'http://www.w3.org/2002/06/xhtml2';	this.ns.bAattrs      = 'urn:bA.attrs';	this.prefix.bAattrs  = 'bAattrs:';	this.ua.isGecko      = ua.match(/Gecko\//);	this.ua.isSafari     = ua.match(/AppleWebKit/);	this.ua.isOpera      = window.opera;	this.ua.isOpera6     = (this.ua.isOpera && ua.match(/Opera.6/));    // Opera 6.x	this.ua.isIE         = (d.all && !this.ua.isGecko && !this.ua.isSafari && !this.ua.isOpera);	this.ua.isIE40       = (this.ua.isIE && ua.match(/MSIE 4\.0/));     // IE 4.0x	this.ua.isIE45       = (this.ua.isIE && ua.match(/MSIE 4\.5/));     // IE 4.5x	this.ua.isIE50       = (this.ua.isIE && ua.match(/MSIE 5\.0/));     // IE 5.0x	this.ua.isIE55       = (this.ua.isIE && ua.match(/MSIE 5\.5/));     // IE 5.5x	this.ua.isNN4        = d.layers;                                    // NN 4.x	this.ua.isMac        = ua.match(/Mac/);	this.ua.isWin        = ua.match(/Win/);	this.ua.isWinIE      = this.ua.isWin && this.ua.isIE;	this.ua.isMacIE      = this.ua.isMac && this.ua.isIE;	this.ua.productSub   = navigator.productSub;	this.ua.revision     = (this.ua.isGecko)  ? ua.match(/; rv:([\d\.]+)/)[1] :	                       (this.ua.isSafari) ? ua.match(/AppleWebKit\/([\d\.]+)/)[1] :	                                            0;	this.ua.DOMok        = (di) ? di.hasFeature('HTML','1.0') : (this.ua.isIE && de);	this.env.online      = (lp == 'http:' && !lh.match(/.local\.?$/));	this.env.referer     = (typeof document.referrer == 'string') ? document.referrer : '';	this.css.revise      = {//		'Safari'   : 'revise_safari.css',//		'IE50.Win' : 'revise_winie50.css'	};	this.css.reviseTitle = '';	this.debugMode       = false;}/* --------------- EventHandler : BAErrorHandler --------------- */window.onerror = function() {	if (BA.debugMode) {		var msg = 'Error: ' + arguments[0] + '\n' +		          'File: '  + arguments[1] + '\n' + 		          'Line: '  + arguments[2];		alert(msg);	}	return true;}/* ---------- Custom methods for built-in objects ---------- *//* ----- Array.pop() ----- */if (!Array.prototype.pop) {	Array.prototype.pop = function() {		if (!this.length) {			return null;		} else {			var last = this[this.length - 1];			--this.length;			return last;		}	}}/* ----- Array.push() ----- */if (!Array.prototype.push) {	Array.prototype.push = function() {		for (var i = 0, n = arguments.length; i < n; i++) {			this[this.length] = arguments[i];		}		return this.length;	}}/* ----- Array.shift() ----- */if (!Array.prototype.shift) {	Array.prototype.shift = function() {		if (!this.length) {			return null;		} else {			this.reverse();			var ret = this.pop();			this.reverse();			return ret;		}	}}/* ----- Array.unshift() ----- */if (!Array.prototype.unshift) {	Array.prototype.unshift = function() {		this.reverse();		for (var i = arguments.length - 1; i >= 0; i--) {			this.push(arguments[i]);		}		this.reverse();		return this.length;	}}/* ----- Array.indexOf() ----- */if (!Array.prototype.indexOf) {	Array.prototype.indexOf = function(aSearchElement, aFromIndex) {		if (typeof aFromIndex != 'number') {			aFromIndex = 0;		} else if (aFromIndex < 0) {			aFromIndex = this.length + aFromIndex;		}		for (var i = aFromIndex, n = this.length; i < n; i++) {			if (this[i] === aSearchElement) {				return i;			}		}		return -1;	}}/* ----- Array.lastIndexOf() ----- */if (!Array.prototype.lastIndexOf) {	Array.prototype.lastIndexOf = function(aSearchElement, aFromIndex) {		if (typeof aFromIndex != 'number') {			aFromIndex = this.length - 1;		} else if (aFromIndex < 0) {			aFromIndex = this.length + aFromIndex;		}		for (var i = aFromIndex; i >= 0; i--) {			if (this[i] === aSearchElement) {				return i;			}		}		return -1;	}}/* ----- Array.filter() ----- */if (!Array.prototype.filter) {	Array.prototype.filter = function(aCallback, aThisObject) {		var ret = [];		if (!aThisObject) aThisObject = {};		aThisObject.__ARRAY_FILTER_TEMPFUNC__ = aCallback;		for (var i = 0, n = this.length; i < n; i++) {			if (aThisObject.__ARRAY_FILTER_TEMPFUNC__(this[i], i, this)) {				ret.push(this[i]);			}		}		delete aThisObject.__ARRAY_FILTER_TEMPFUNC__;		return ret;	}}/* ----- String.BAGetAfter() ----- */String.prototype.BAGetAfter = function(word) {	var offset = this.indexOf(word);	return (offset == -1) ? '' : this.substring(offset + word.length, this.length);}/* ---------- Constructor : BAElement ---------- */function BAElement() { }BAElement.prototype = {	/* ----- Node.addEventListenerBA() ----- */	addEventListenerBA : function(type, listener, useCapture) {		function _Event_IE(_node) {			var e  = window.event;			var de = document.documentElement;			var db = document.body;			this.currentTarget   = _node;			if (!e) return;			this.type            = e.type;			this.target          = e.srcElement;			this.relatedTarget   = (e.srcElement == e.toElement) ? e.fromElement : e.toElement;			this.clientX         = e.clientX;			this.clientY         = e.clientY;			this.pageX           = (de.scrollLeft ? de.scrollLeft : (db ? db.scrollLeft : 0)) + e.clientX;			this.pageY           = (de.scrollTop  ? de.scrollTop  : (db ? db.scrollTop  : 0)) + e.clientY;			this.charCode        = /* (this.type == 'keypress') ? */ e.keyCode /* : 0 */;			this.keyCode         = /* (this.type != 'keypress') ? */ e.keyCode /* : 0 */;			this.ctrlKey         = e.ctrlKey;			this.shiftKey        = e.shiftKey;			this.altKey          = e.altKey;			this.metaKey         = e.metaKey;			this.stopPropagation = function() { e.cancelBubble = true  };			this.preventDefault  = function() { e.returnValue  = false };		}		function _Event_Safari(_e) {			for (var i in _e) this[i] = _e[i];			try {this.target = (_e.target.nodeType == 3) ? _e.target.parentNode : _e.target } catch (err) { }			this.preventDefault  = function() { _e.currentTarget['on' + type] = function() { return false } };			this.stopPropagation = function() { window.event_safari_cancelBubble[_e.type] = true };		}		if (this.addEventListener) {			if (BA.ua.isGecko && type == 'mousewheel') {				type = 'DOMMouseScroll';			}			if (!BA.ua.isSafari) {				this.addEventListener(type, listener, useCapture);			} else {				this.addEventListener(type, function(e) {					if (typeof window.event_safari_cancelBubble != 'object') {						window.event_safari_cancelBubble = {};					} else if (typeof window.event_safari_cancelBubble[e.type] != 'boolean') {						document.addEventListener(e.type, function(_e) {							window.event_safari_cancelBubble[_e.type] = false;						}, false);					}					if (!window.event_safari_cancelBubble[e.type]) {						listener(new _Event_Safari(e));					}				}, useCapture);			}//		} else if (this.attachEvent) {//			var _this = this;//			this.attachEvent('on' + type, function() { listener(new _Event_IE(_this)) });		} else {			var _this  = (this.window) ? this.window : this; // measure for WinIE			var exists = _this['on' + type];			_this['on' + type] = (exists) ?				function() { exists(); listener(new _Event_IE(_this)) } :				function() {           listener(new _Event_IE(_this)) } ;		}	},	/* ----- Node.dispatchEventBA() ----- */	dispatchEventBA : function(e) {		if (this.dispatchEvent) {			this.dispatchEvent(e);		} else if (this.fireEvent) {			this.fireEvent('on' + e.type);		} else if (this['on' + e.type]) {			this['on' + e.type]();		}	},	/* ----- Node.createElementBA() ----- */	createElementBA : function(tagName) {		var node = (BA.ns.defaultNS && document.createElementNS && tagName.match(/:/)) ?		           	document.createElementNS(BA.ns[tagName.split(':')[0]], tagName.split(':')[1]) :		           	(BA.ns.defaultNS && document.createElementNS) ?		           		document.createElementNS(BA.ns.defaultNS, tagName) : 		           		document.createElement(tagName) ;		return BARegisterDOMMethodsTo(node);	},	/* ----- Node.getElementsByTagNameBA() ----- */	getElementsByTagNameBA : function(tagName) {		if (tagName == '*') {			var nodes = this.getElementsByTagName(tagName);			if (nodes.length > 0) {				return nodes;			} else {				var ret   = [];				var nodes = (document.all && this.nodeType != 1) ?					document.all :					(function (_node) {						var _nodes = _node.childNodes;						var _ret   = [];						for (var i = 0, n = _nodes.length; i < n; i++) {							_ret.push(_nodes[i]);							_ret = _ret.concat(arguments.callee(_nodes[i]));						}						return _ret;					})(this);				for (var i = 0, n = nodes.length; i < n; i++) {					if (nodes[i].nodeType == 1 && !nodes[i].nodeName.match(/^[!\?]/)) {						ret.push(nodes[i]);					}				}				return ret;			}		} else if (tagName.match(/:/)) {			var prfx  = tagName.split(':')[0];			var name  = tagName.split(':')[1];			var nodes = (BA.ns.defaultNS && this.getElementsByTagNameNS) ?			            	this.getElementsByTagNameNS(BA.ns[prfx], name) :			            	this.getElementsByTagName(tagName) ;			if (nodes.length == 0) {				var nodes = (name == '*') ? this.getElementsByTagNameBA(name) : this.getElementsByTagName(name);				for (var nodes_ = [], i = 0, n = nodes.length; i < n; i++){					if (BA.ns.defaultNS && nodes[i].namespaceURI == BA.ns[prfx] || nodes[i].tagUrn == BA.ns[prfx]) {						nodes_.push(nodes[i]);					}				}				if (nodes_.length == 0) {					var nodes = (name == '*') ? nodes : this.getElementsByTagNameBA('*');					for (var nodes_ = [], i = 0, n = nodes.length; i < n; i++) {						var prfx_ = nodes[i].nodeName.split(':')[0];						var name_ = nodes[i].nodeName.split(':')[1];						if (name_ && prfx_ == prfx && (name == '*' || name_.toLowerCase() == name.toLowerCase())) {							nodes_.push(nodes[i]);						}					}				}				nodes = nodes_;			}			return nodes;		} else {			var nodes = (BA.ns.defaultNS && this.getElementsByTagNameNS) ?			            	this.getElementsByTagNameNS(BA.ns.defaultNS, tagName) :			            	(tagName.match(/^body$/i) && document.body) ?			            		/* measure for Netscape7.1 */ [document.body] :			            		this.getElementsByTagName(tagName) ;			if (typeof document.documentElement.tagUrn == 'string') {				for (var nodes_ = [], i = 0, n = nodes.length; i < n; i++){					if (!nodes[i].tagUrn || nodes[i].tagUrn == BA.ns.defaultNS) {						nodes_.push(nodes[i]);					}				}				nodes = nodes_;			}			return nodes;		}	},	/* ----- Node.getElementsByClassNameBA() ----- */	getElementsByClassNameBA : function(className, tagName) {		if (!className) return undefined;		if (!tagName)   tagName = '*';		var nodes = this.getElementsByTagNameBA(tagName);		var ret   = [];		for (var i = 0, n = nodes.length; i < n; i++) {			if (nodes[i].hasClassNameBA && nodes[i].hasClassNameBA(className)) {				ret.push(nodes[i]);			}		}		return ret;	},	/* ----- Node.appendChildBA() ----- */	appendChildBA : function(content) {		if (content.nodeType == 1 || content.nodeType == 3) {			return this.appendChild(content);//		} else if (content instanceof BATag) { // 'instanceof' operator always causes error in MacIE.		} else if (content.instanceOf && content.instanceOf == BATag) {			this.innerHTML += content.toString();			var nodes = BAConcatNodeList(this.lastChild, this.lastChild.getElementsByTagName('*'));			for (var i = 0, n = nodes.length; i < n; i++) {				BARegisterDOMMethodsTo(nodes[i]);			}			return this.lastChild;//		} else if (typeof content == 'string') {		} else if (content.toString) {			    content = content.toString();			var node    = document.createTextNode(content);			if (BA.ua.isMac && BA.ua.isIE50) {				this.innerHTML += content;				return node;			} else {				return this.appendChild(node);			}		}	},	/* ----- Node.getInnerTextBA() ----- */	getInnerTextBA : function() {		var nodes = this.childNodes;		var ret   = [];		for (var i = 0, n = nodes.length; i < n; i++) {			if (nodes[i].hasChildNodes()) {				ret.push(nodes[i].getInnerTextBA());			} else if (nodes[i].nodeType == 3) {				ret.push(nodes[i].nodeValue);			} else if (nodes[i].alt) {				ret.push(nodes[i].alt);			}		}		return ret.join('').replace(/\s+/g, ' ');	},	/* ----- Node.getAttributeBA() ----- */	getAttributeBA : function(attr) {		if (BA.ua.isIE && attr == 'class') {			attr += 'Name';		}		var ret = this.getAttribute(attr);		if (!ret && this.getAttributeNS && attr.match(/:/)) {			var prfx = attr.split(':')[0];			var attr = attr.split(':')[1];			return this.getAttributeNS(BA.ns[prfx], attr)		}		return ret;	},	/* ----- Node.setAttributeBA() ----- */	setAttributeBA : function(attr, value) {		if (attr.match(/:/)) {			var prfx = attr.split(':')[0];			var attr = attr.split(':')[1];			if (this.setAttributeNS && this.namespaceURI || BA.ua.isSafari) {				this.setAttributeNS(BA.ns[prfx], attr, value);			} else {				this.setAttribute('xmlns:' + prfx, BA.ns[prfx]);				this.setAttribute(prfx + ':' + attr, value);			}		} else {			if (BA.ua.isIE && attr == 'class') attr += 'Name';			this.setAttribute(attr, value);		}	},	/* ----- Node.hasClassNameBA() ----- */	hasClassNameBA : function(className) {		if (this.nodeType != 1) return false;		var flag  = false;		var cname = this.getAttributeBA('class');		if (cname) {			cname = cname.split(' ');			for (var i = 0; i < cname.length && !flag; i++) {				flag = (cname[i] == className);			}		}		return flag;	},	/* ----- Node.appendClassNameBA() ----- */	appendClassNameBA : function(className) {		if (className && !this.hasClassNameBA(className)) {			var cnames = this.getAttributeBA('class');			this.setAttributeBA('class', ((cnames) ? cnames + ' ' + className : className));		}	},	/* ----- Node.removeClassNameBA() ----- */	removeClassNameBA : function(className) {		if (className && this.hasClassNameBA(className)) {			var cname = this.getAttributeBA('class');			var cntmp = [];			if (cname) {				cname = cname.split(' ');				for (var i = 0; i < cname.length; i++) if (cname[i] != className) cntmp.push(cname[i]);			}			this.setAttributeBA('class', cntmp.join(' '));		}	},	/* ----- Node.normalizeTextNodeBA() ----- */	normalizeTextNodeBA : function (deep) {		(function (curNode) {			for (var i = 0; i < curNode.childNodes.length; i++) {				var node = curNode.childNodes[i];				if (node.nodeType == 3) {					node.nodeValue = node.nodeValue.replace(/^\s+/, '');					node.nodeValue = node.nodeValue.replace(/\s+$/, '');					if (node.nodeValue.match(/^\s*$/))  {						node.parentNode.removeChild(node);						i--;					}				} else if (deep && node.nodeType == 1 && node.hasChildNodes()) {					arguments.callee(node);				}			}		})(this);	},	/* ----- Node.getAbsoluteOffsetBA() ----- */	getAbsoluteOffsetBA : function() {		var offset = { X : this.offsetLeft, Y : this.offsetTop };		if (this.offsetParent) {			offset.X += this.offsetParent.getAbsoluteOffsetBA().X;			offset.Y += this.offsetParent.getAbsoluteOffsetBA().Y;		}		return offset;	},	/* ----- Node.getCurrentStyleBA() ----- */	getCurrentStyleBA : function(property, pseudo) {		return (window.getComputedStyle) ?			window.getComputedStyle(this, pseudo)[property] : (this.currentStyle) ?				this.currentStyle[property] : 0;	},	/* ----- Node.setPositionFixedBA() ----- */	setPositionFixedBA : function(autoHide) {		if (this.__setPositionFixedBAisApplied__) return;		this.__setPositionFixedBAisApplied__ = true;		var reviseLeft = 0;		var reviseTop  = 0;		if (BA.ua.isMacIE) {			this.style.position = 'fixed';			var paddingLeft = this.getCurrentStyleBA('paddingLeft') || '0';			var paddingTop  = this.getCurrentStyleBA('paddingTop' ) || '0';			var reviseLeft  = (paddingLeft.match(/px$/)) ? -1 * parseFloat(paddingLeft) : 0;			var reviseTop   = (paddingTop.match(/px$/) ) ? -1 * parseFloat(paddingTop)  : 0;		} else if (BA.ua.isWinIE) {			var origDisplay = this.getCurrentStyleBA('display') || 'block';			this.style.display = 'block';		}		this.style.left     = (this.getAbsoluteOffsetBA().X + reviseLeft) + 'px';		this.style.top      = (this.getAbsoluteOffsetBA().Y + reviseTop ) + 'px';		this.style.right    = 'auto';		this.style.bottom   = 'auto';		this.style.margin   = '0';		this.style.position = 'absolute';		if (BA.ua.isWinIE) {			this.style.display = origDisplay;		}		var node  = this;		var timer;		window.addEventListenerBA('scroll', function() {			if (timer) timer.clearTimer();			BAGetGeometry();			node.style.marginLeft = BA.geom.scrollX + 'px';			node.style.marginTop  = BA.geom.scrollY + 'px';			if (autoHide) {				node.style.visibility = 'hidden'				timer = new BASetTimeout(function() { node.style.visibility = 'visible' }, 100);			}		});	}}/* --------------- Add custom DOM methods ------------------ */function BARegisterDOMMethods() {	window.addEventListenerBA = BAElement.prototype.addEventListenerBA;	if (typeof Node == 'object' && Node.prototype) {		for (var i in BAElement.prototype) {			Node.prototype[i] = BAElement.prototype[i];		}	}	BARegisterDOMMethodsTo(document);}function BARegisterDOMMethodsTo(node) {	if (node && (node === document || node.nodeType == 1)) {		for (var i in BAElement.prototype) {			if (!node[i]) {				node[i] = BAElement.prototype[i];			}		}	}	return node;}/* --------------- define onload func register --------------- */function BAAddOnload(func) {	if (BA.ua.isGecko) {		document.addEventListenerBA('DOMContentLoaded', func);	} else if (BA.ua.isMacIE) {		window.addEventListenerBA('load', func);	} else {		var oFunc  = arguments.callee;		var exists = oFunc.__store__;		oFunc.__store__ = (exists) ?			function() { exists(); func() } :			function() {           func() } ;		if (!oFunc.__timer__) {			BARegisterDOMMethodsTo(document);			oFunc.__timer__ = new BASetInterval(function() {				if (document.getElementsByTagNameBA('body')[0]) {					if (!oFunc.__skipped__) {						oFunc.__skipped__ = true;					} else {						oFunc.__store__();						oFunc.__timer__.clearTimer();					}				}			}, 500);		}	}}function BAAddDuringLoad(func, wait) {	if (!wait) wait = 500;	var oFunc = arguments.callee;	    oFunc.__store__ = [];	    oFunc.__store__.push(new BASetInterval(func, wait));	BAAddOnload(function() {		for (var i = 0, n = oFunc.__store__.length; i < n; i++) {			oFunc.__store__[i].clearTimer();		}	});}/* --------------- Function : BAGetCommonDir --------------- */function BAGetCommonDir(dirName) {	var sheets = document.styleSheets;	var ptn    = new RegExp('(.*\\/?' + dirName + '\\/).+$');	return (sheets && sheets.length && sheets[0].href && sheets[0].href.match(ptn)) ? RegExp.$1 : '';}/* --------------- Function : BASingleton --------------- */function BASingleton(_constructor) {	return _constructor.__BASingleInstance__ || (_constructor.__BASingleInstance__ = new _constructor());}/* --------------- Function : BAAlreadyApplied --------------- */function BAAlreadyApplied(func) {	if (!BA.ua.DOMok || func.__BAAlreadyApplied__) return true;	func.__BAAlreadyApplied__ = true;	return false;}/* --------------- Function : BAConcatNodeList --------------- */function BAConcatNodeList() {	var nodes = [];	(function(list) {		for (var i = 0, n = list.length; i < n; i++) {			if (list[i].nodeType == 1) {				nodes.push(list[i]);			} else if (list[i].length > 0) {				arguments.callee(list[i]);			}		}	})(arguments);	return nodes;}/* --------------- Function : BAPreloadImage --------------- */function BAPreloadImage(src) {	var img = new Image();	img.src = src;	return img;}/* --------------- Function : BAOpenWindow --------------- */function BAOpenWindow(url, target, width, height, options, moveFlag) {	if (!target)                target = '_blank';	if (target == 'addresbook') target = 'addressbook';	var optVariations = {		'example1' : 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes',		'example2' : 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'	}	options = options || optVariations[target] || '';	width  += (options.match('scrollbars=yes')) ? 16 : 0;	if (width && height) options = 'width=' + width + ',height=' + height + ((options) ? ',' + options : '');	var newWin = window.open(url, target, options);	newWin.focus();	if (moveFlag) newWin.moveTo(0, 0);	if (window.event) window.event.returnValue = false;	return newWin;}/* --------------- Function : BAOpenFullscreenWindow --------------- */function BAOpenFullscreenWindow(url, target, options) {	options = options || 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no';	return BAOpenWindow(url, target, screen.availWidth, screen.availHeight, options, true);}/* --------------- Function : BAAppendJS --------------- */function BAAppendJS(src) {	var E = new BATag('script');	E.setAttributeBA('type', 'text/javascript');	E.setAttributeBA('src' , src.replace(/~/g, '%7E'));	E.appendChildBA('');	document.write(E.toString());}/* --------------- Function : BAAppendCSS --------------- */function BAAppendCSS(href, title) {	var act = BAGetActiveCSSTitle();	var E   = new BATag('link');	E.setAttributeBA('rel', ((!title || !act || title == act) ? 'stylesheet' : 'alternate stylesheet'));	E.setAttributeBA('type', 'text/css');	E.setAttributeBA('media', (!BA.ua.isNN4 ? 'screen, tv' : 'screen'));	E.setAttributeBA('href', href.replace(/~/g, '%7E'));	if (title) E.setAttributeBA('title', title);	document.write(E.toString());}/* --------------- Function : BAGetActiveCSSTitle --------------- */function BAGetActiveCSSTitle() {	var sheets = document.styleSheets;	if (sheets) {		for (var i = 0, n = sheets.length; i < n; i++) {			if (!sheets[i].disabled && sheets[i].title) {				return sheets[i].title;			}		}	}	if (BA.ua.DOMok) {		// measure for Safari's lack of implement of document.styleSheets!		var nodes = document.getElementsByTagNameBA('link');		for (var i = 0, n = nodes.length; i < n; i++) {			if (nodes[i].rel.match(/^stylesheet$/i)) {				return nodes[i].title			}		}	}	return null;}/* --------------- Function : BAGetGeometry --------------- */function BAGetGeometry(e) {	if (!document.getElementsByTagNameBA) BARegisterDOMMethodsTo(document); // measure for safari	var w = window;	var d = document.documentElement;	var b = document.getElementsByTagNameBA('body')[0];	var isWinIEqm = BA.ua.isWinIE && (!document.compatMode || document.compatMode == 'BackCompat');	var isMacIE   = BA.ua.isMacIE;	var isSafari  = BA.ua.isSafari;	BA.geom.scrollX  = w.scrollX     || d.scrollLeft || b.scrollLeft || 0;	BA.geom.scrollY  = w.scrollY     || d.scrollTop  || b.scrollTop  || 0;	BA.geom.windowW  = w.innerWidth  || (isMacIE ? b.scrollWidth  : d.offsetWidth );	BA.geom.windowH  = w.innerHeight || (isMacIE ? b.scrollHeight : d.offsetHeight);	BA.geom.pageW    = (isMacIE) ? d.offsetWidth  : (isWinIEqm) ? b.scrollWidth  : d.scrollWidth ;	BA.geom.pageH    = (isMacIE) ? d.offsetHeight : (isWinIEqm) ? b.scrollHeight : d.scrollHeight;	BA.geom.windowX  = (!e) ? (BA.geom.windowX  ||  0) : e.clientX - ( isSafari ? BA.geom.scrollX : 0);	BA.geom.windowY  = (!e) ? (BA.geom.windowY  ||  0) : e.clientY - ( isSafari ? BA.geom.scrollY : 0);	BA.geom.mouseX   = (!e) ? (BA.geom.mouseX   ||  0) : e.clientX + (!isSafari ? BA.geom.scrollX : 0);	BA.geom.mouseY   = (!e) ? (BA.geom.mouseY   ||  0) : e.clientY + (!isSafari ? BA.geom.scrollY : 0);	BA.geom.nodeName = (!e) ? (BA.geom.nodeName || '') : e.target.nodeName;	if (BA.debugMode) {		BAStatusMsg.set(   'pageW: '   + BA.geom.pageW   + ' | pageH: '   + BA.geom.pageH   +		                ' | windowX: ' + BA.geom.windowX + ' | windowY: ' + BA.geom.windowY +		                ' | scrollX: ' + BA.geom.scrollX + ' | scrollY: ' + BA.geom.scrollY +		                ' | left: '    + BA.geom.mouseX  + ' | top: '     + BA.geom.mouseY  +		                ' | node: '    + BA.geom.nodeName);	}}/* --------------- Constructor : BASetTimeout --------------- */function BASetTimeout(func, ms, aThisObject) {	this.storePointName   = 'BASetTimeoutStore';	this.storeFuncPrefix  = 'BATimeoutFunc';	this.storeFuncNumSeed = 'BASetTimeoutStoreNum';	if (arguments.length > 0) {		this.storeFunc(func, ms, aThisObject);	}}BASetTimeout.prototype = {	storeFunc : function(func, ms, aThisObject) {		if (typeof ms != 'number' || ms < 0) ms = 0;		if (typeof aThisObject != 'object' ) aThisObject = window;		if (typeof window[this.storePointName]   != 'object') window[this.storePointName]   = [];		if (typeof window[this.storeFuncNumSeed] != 'number') window[this.storeFuncNumSeed] = 0;		for (var i = 0, n = window[this.storePointName].length; i < n; i++) {			if (window[this.storePointName][i] == aThisObject) {				break;			}		}		if (i == n) {			window[this.storePointName][i] = aThisObject;		}		window[this.storePointName][i]['__' + this.storeFuncPrefix + window[this.storeFuncNumSeed] + '__'] = func;		this.storeName = this.storePointName + '[' + i + '].__' + this.storeFuncPrefix + window[this.storeFuncNumSeed] + '__';		this.setTimer(ms);		window[this.storeFuncNumSeed]++;	},	setTimer : function(ms) {		this.timer = setTimeout(this.storeName + '()', ms);	},		clearTimer : function() {		clearTimeout(this.timer);	}}/* --------------- Constructor : BASetInterval inherits BASetTimeout --------------- */function BASetInterval(func, ms, aThisObject) {	this.storePointName   = 'BASetTimeoutStore';	this.storeFuncPrefix  = 'BAIntervalFunc';	this.storeFuncNumSeed = 'BASetIntervalStoreNum';	if (arguments.length > 0) {		this.storeFunc(func, ms, aThisObject);	}}BASetInterval.prototype = new BASetTimeout;BASetInterval.prototype.setTimer = function(ms) {	this.timer = setInterval(this.storeName + '()'  , ms);}BASetInterval.prototype.clearTimer = function() {	clearInterval(this.timer);}/* --------------- Instance : BAStatusMsg --------------- */function BAStatusMsg_() {	this.defaultStatus = window.defaultStatus || '';}BAStatusMsg_.prototype = {	set : function(msg, delay, sustain) {		this.msg     = (typeof msg     != 'undefined' && msg        ) ? msg     : '';		this.delay   = (typeof delay   == 'number'    && delay   > 0) ? delay   :  0;		this.sustain = (typeof sustain == 'number'    && sustain > 0) ? sustain :  0;		if (this.delay > 0) {			this.delayTimer = new BASetTimeout(this.setMsg, this.delay, this);		} else {			this.setMsg();		}	},	unset : function() {		this.clearTimer();		window.status = this.defaultStatus;	},	setMsg : function() {		this.clearTimer();		if (this.msg) {			window.status = this.msg;			if (this.sustain > 0) {				this.sustainTimer = new BASetTimeout(this.unset, this.sustain, this);			}		} else {			this.unset();		}	},		clearTimer : function() {		if (this.delayTimer  ) this.delayTimer.clearTimer();		if (this.sustainTimer) this.sustainTimer.clearTimer();	}}var BAStatusMsg = BASingleton(BAStatusMsg_);/* --------------- Constructor : BATimer --------------- */function BATimer() { 	this.reset();}BATimer.prototype = {	reset : function() {		this.startTime = (new Date()).getTime();	},		getTime : function() {		return (new Date()).getTime() - this.startTime;	},		getSecond : function() {		return this.getTime() / 1000;	}}/* --------------- Constructor : BATag --------------- */function BATag(tagName, attrs) {	this.tagName    = tagName;	this.attributes = attrs || {};	this.childNodes = [];	this.instanceOf = BATag;}BATag.prototype = {	setAttributeBA : function(attrName, value) {		this.attributes[attrName] = value;	},	appendChildBA : function(arg) {		this.childNodes.push(arg);	},	toString : function(debug) {		var tagOpen    = (debug) ? '&lt;' : '<';		var tagClose   = (debug) ? '&gt;' : '>';		var tag        = tagOpen + this.tagName;		var content    = (this.childNodes.length) ? '' : null;		for (var i = 0, n = this.childNodes.length; i < n; i++) {			content += this.childNodes[i].toString(debug);		}		for (var attr in this.attributes) {			tag += ' ' + attr + '="' + this.attributes[attr] + '"';		}		tag += (content != null) ?		       	tagClose + content + tagOpen + '/' + this.tagName + tagClose :		       	' /' + tagClose;		return tag;	}}/* --------------- Constructor : BAKeyEquivalents --------------- */function BAKeyEquivalents() {	this.keyAlias = {		'$' : { aliasName : 'Shift'       , keyCode : 16, DOMName : 'shiftKey' },		'^' : { aliasName : 'Ctrl'        , keyCode : 17, DOMName : 'ctrlKey'  },		'~' : { aliasName : 'Alt/Option'  , keyCode : 18, DOMName : 'altKey'   },		'@' : { aliasName : 'Meta/Command', keyCode : 91, DOMName : 'metaKey'  },		'<' : { aliasName : '\u2190'      , keyCode : 37, DOMName : null       },  /* left  */		'{' : { aliasName : '\u2191'      , keyCode : 38, DOMName : null       },  /* up    */		'>' : { aliasName : '\u2192'      , keyCode : 39, DOMName : null       },  /* right */		'}' : { aliasName : '\u2193'      , keyCode : 40, DOMName : null       }   /* down  */	}	this.equivalents = {};	this.numOfEquivs = 0;}BAKeyEquivalents.prototype = {	addKeyEquivalent : function(key, name, func, aThisObject) {		this.numOfEquivs++;		if (!name) name = 'BAKeyEquivalents' + this.numOfEquivs;		this.equivalents[name] = { key : key, func : func, aThisObject : aThisObject || window };		return name;	},		getKeybind : function(name) {		var equiv = this.equivalents[name];		var keys  = equiv.key.split('');		var ret   = [];		for (var i = 0, n = keys.length; i < n; i++) {			ret.push(this.keyAlias[keys[i]] ? this.keyAlias[keys[i]].aliasName : keys[i].toUpperCase());		}		return ret;	},		execFunc : function(name) {		if (name && this.equivalents[name]) {			var equiv = this.equivalents[name];			equiv.aThisObject.__BAKeyEquivalents__ = equiv.func;			equiv.aThisObject.__BAKeyEquivalents__();			delete equiv.aThisObject.__BAKeyEquivalents__;		}	},		dispatchEvent : function(e) {		for (var name in this.equivalents) {			var equiv = this.equivalents[name];			var keys  = equiv.key.split('');			var flag  = true;			for (var i = 0, n = keys.length; (i < n && flag); i++) {				var key      = keys[i].toLowerCase();				var keyAlias = this.keyAlias[key];				if (keyAlias && keyAlias.DOMName) {					flag = (flag && e[keyAlias.DOMName]);				} else if (keyAlias && keyAlias.keyCode) {					flag = (flag && (e.keyCode == keyAlias.keyCode));				} else {					var chr = String.fromCharCode(e.charCode ? e.charCode : e.keyCode).toLowerCase();					flag = (flag && (key == chr));				}			}			if (flag) {				this.execFunc(name);			}		}	}}/* --------------- Startup Functions (non-DOM / pre onload) --------------- *//* ----- BAAppendReviseCSS ----- */function BAAppendReviseCSS() {	for (var i in BA.css.revise) {		var ua = i.split('.')[0];		var os = i.split('.')[1];		if (os && BA.ua['is' + os] && BA.ua['is' + ua] || !os && BA.ua['is' + ua]) {			BAAppendCSS(BA.url.cssDir + BA.css.revise[i], BA.css.reviseTitle);			break;		}	}}/* --------------- Startup Functions (DOM / post onload) --------------- *//* ----- BARegisterDOMMethodsToEveryNode ----- */function BARegisterDOMMethodsToEveryNode() {	if (typeof Node == 'object' && Node.prototype) return;	if (BAAlreadyApplied(arguments.callee))        return;	var nodes = document.getElementsByTagNameBA('*');	for (var i = 0, n = nodes.length; i < n; i++) {		BARegisterDOMMethodsTo(nodes[i]);	}}/* ----- BAStartGeometryMeasure ----- */function BAStartGeometryMeasure() {	if (BAAlreadyApplied(arguments.callee)) return;	document.addEventListenerBA('mousemove' , BAGetGeometry);	document.addEventListenerBA('mousewheel', BAGetGeometry);}/* ----- BAScrollToFragmentIDTarget ----- */function BAScrollToFragmentIDTarget() {	if (BAAlreadyApplied(arguments.callee)) return;	if (!BA.ua.isSafari || !BA.css.revise.Safari) return;	var target = location.hash                   || '';	    target = target.split('#')[1]            || '';	    target = document.getElementById(target) || null;	if (target) {		window.scrollTo(0, target.getAbsoluteOffsetBA().Y);	}}/* --------------- Main --------------- */var BA = BASingleton(BAEnvironment);BARegisterDOMMethods();BAAppendReviseCSS();BAAddOnload(function() {	BARegisterDOMMethodsToEveryNode();	BAStartGeometryMeasure();	BAScrollToFragmentIDTarget();	BAStatusMsg.unset();});