/*		function backToTop()
			http://web-graphics.com/mtarchive/001659.php
			The cool BackToTop Javascript for smooth scrolling back
			to the top of a page was written by David Lindquist.
--------------------------------------------------------------------- */
function btt_install( ) {
	if( !document.getElementsByTagName ) { return; }
	var a, i = 0;
	while(( a = document.getElementsByTagName( 'a' )[i++] )) {
		if( '#top' == a.getAttribute( 'href' )) {
			a.onclick = function() { backToTop(); return false; }
		}
	}
}

function backToTop() {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;

	if( document.documentElement ) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}

	if( document.body ) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}

	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;

	var x = Math.max( x1,Math.max( x2,x3 ));
	var y = Math.max( y1,Math.max( y2,y3 ));

	window.scrollTo(Math.floor( x/2 ), Math.floor( y/2 ));

	if( x > 0 || y > 0 ) {
		window.setTimeout( 'backToTop()',25 );
	}
	return false;
}


/*		function extTarget( )
			JM & AP
			r5 - 2007/11/10

			changes target on external links
			so that they open in a new window
			now takes into account presence of subdomains
--------------------------------------------------- */
function extTarget() {

	var n = '';
	//		get window information
	var w = window.location.hostname;
	var t = w.split( '.' );		
	//		do we have a subdomain
	if(( 'com' == t[t.length -1] ) && ( t.length >= 3 )) { t[0] = ''; }
	w = t.join( '.' );

	var a = document.links;
	for( var i = 0; i < a.length; i++ ) {
		n = a[i].hostname;
		t = n.split( '.' );
		if(( 'com' == t[t.length -1] ) && ( t.length >= 3 )) { t[0] = ''; }
		n = t.join( '.' );
		if(( '' != n ) && ( n != w )) { a[i].target = '_blank'; }
	}
}


