/*		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'; }
	}
}



function getElementsByClass( theClass ) {
	var c,i,j;
	var els = new Array( );
	var es  = document.getElementsByTagName( '*' );

	//		getElement by class name
	for( i = 0,j = 0; i < es.length; i++ ) {
		c = ' ' +es[i].className +' ';
		if( c.indexOf( ' ' +theClass +' ' ) != -1 ) { els[j++] = es[i]; }
	}
	return els;
}


/*		TABS
----------------------------------------------------------------------	*/

var tflag = 0;

function doTab() {

	//	var ee  = this.parentNode;
	//	var len = ee.childNodes.length;
	var len = tflag;

	var num = this.id;
	num = num.substring( num.length -1 );
	var t = '';
	var p;

	//		hide
	for( var i = 0; i < len; i++ ) {
		t = 'pane' +( i +1 );
		p = document.getElementById( t );
		p.style.display = 'none';
		p.style.visibility = 'hidden';
		t = 'tab' +( i +1 );
		p = document.getElementById( t );
		p.className = 'tab';
		p.style.backgroundColor = '#ccc';
	}
	//	show
	t = 'pane' +num;
	p = document.getElementById( t );
	p.style.display    = 'block';
	p.style.visibility = 'visible';
	t = 'tab' +num;
	p = document.getElementById( t );
	p.className += ' selected';
	p.style.backgroundColor = '#fff';

	return false;
}

function tabMouseOver() {

	var num = this.id;
	var bg  = document.getElementById( num ).style.backgroundColor;

	if(( bg != 'rgb(255, 255, 255)' ) && ( bg != '#fff' ))  {
		document.getElementById( num ).style.backgroundColor = '#eee';
	}
}

function tabMouseOut() {
	var num = this.id;
	var bg  = document.getElementById( num ).style.backgroundColor;

	if(( bg != 'rgb(255, 255, 255)' ) && ( bg != '#fff' ))  {
		document.getElementById( num ).style.backgroundColor = '#ccc';
	}
}


function tabs_install() {

	var e = getElementsByClass( 'tab' );
	tflag = e.length;

	if( 0 == tflag ) { return; }
	for( var i = 0; i < tflag; i++ ) {
		e[i].onclick = doTab;
		e[i].onmouseover = tabMouseOver;
		e[i].onmouseout = tabMouseOut;
	}
	//		impose colors...
	e[0].style.backgroundColor = '#fff';
	e[1].style.backgroundColor = '#ccc';
}

