// file: scroll.js
// version: 2.2
// author: KBE20090928



// --- object: scroll
TECHHOUSE.scroll = {};



// --- object: scroll.verticalarrows
TECHHOUSE.scroll.verticalarrows = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.parms = parms;

	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );
	this.upElem = document.getElementById( parms.buttona );
	this.downElem = document.getElementById( parms.buttonb );

	this.pause = ( parms.pause ) ? parseInt( parms.pause ) : 1;
	this.move = ( parms.move ) ? parseInt( parms.move ) : 3;
	this.arrowsdisable = ( parms.arrowsdisable ) ? parms.arrowsdisable.toLowerCase() : 'true';

	this.scroll = false;

	TECHHOUSE.disableSelection( { elementId: parms.buttona } )
	TECHHOUSE.disableSelection( { elementId: parms.buttonb } )

	// disable buttons if content is smaller than viewport
	if( ( this.cElem.offsetHeight < this.vElem.offsetHeight ) && ( this.arrowsdisable == 'true' ) ) {
		this.upElem.style.display = 'none';
		this.downElem.style.display = 'none';
		}

	var that = this;

	// method: up
	this.up = function() {
		that.scroll = true;
		var top = that.vElem.scrollTop;
		that.upElem.className = that.parms.buttona + '_click';
		var moveit = function() {
			if( that.scroll ) {
				if( top - that.move >= 0 ) {
					top -= that.move;
					that.vElem.scrollTop = top;
					if( that.bar ) { that.bar.refreshBox() }
					setTimeout( moveit, that.pause );
					}
				else {
					that.vElem.scrollTop = 0;
					}
				}
			that.refreshArrows();
			}
		setTimeout( moveit, that.pause );

		}

	// method: down
	this.down = function() {
		that.scroll = true;
		var top = that.vElem.scrollTop;
		that.downElem.className = that.parms.buttonb + '_click';
		var moveit = function() {
			if( that.scroll ) {
				if( ( parseInt( that.cElem.offsetHeight ) - top ) > parseInt( that.vElem.offsetHeight ) ) {
					top += that.move;
					that.vElem.scrollTop = top;
					if( that.bar ) { that.bar.refreshBox() }
					setTimeout( moveit, that.pause );
					}
				}
			that.refreshArrows();
			}
		setTimeout( moveit, that.pause );
		
		}

	// method: stop
	this.stop = function() {
		that.scroll = false;
		that.upElem.className = '';
		that.downElem.className = '';
		that.refreshArrows();
		}

	// method: refreshArrows
	this.refreshArrows = function() {

		// refresh up button
		if( that.upElem.className.indexOf( "_click" ) == -1 ) {
			if( that.vElem.scrollTop > 0 ) {
				that.upElem.className = that.parms.buttona;
				}
			else {
				that.upElem.className = that.parms.buttona + '_inactive';
				}
			}

		// refresh down button
		if( that.downElem.className.indexOf( "_click" ) == -1 ) {
			if( ( parseInt( that.cElem.offsetHeight ) - that.vElem.scrollTop ) > parseInt( that.vElem.offsetHeight ) ) {
				that.downElem.className = that.parms.buttonb;
				}
			else {
				that.downElem.className = that.parms.buttonb + '_inactive';
				}
			}

		}

	// attach events
	if( that.vElem && that.cElem ) {

		var upb = document.getElementById( parms.buttona );
		if( upb ) {

			if( parms.event.toLowerCase() == 'click' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					upb.attachEvent( 'onmousedown', this.up );
					upb.attachEvent( 'onmouseup', this.stop );
					upb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					upb.addEventListener( 'mousedown', this.up, false );
					upb.addEventListener( 'mouseup', this.stop, false );
					upb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			else if( parms.event.toLowerCase() == 'hover' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					upb.attachEvent( 'onmouseover', this.up );
					upb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					upb.addEventListener( 'mouseover', this.up, false );
					upb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			}

		var downb = document.getElementById( parms.buttonb );
		if( downb ) {

			if( parms.event.toLowerCase() == 'click' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					downb.attachEvent( 'onmousedown', this.down );
					downb.attachEvent( 'onmouseup', this.stop );
					downb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					downb.addEventListener( 'mousedown', this.down, false );
					downb.addEventListener( 'mouseup', this.stop, false );
					downb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			else if( parms.event.toLowerCase() == 'hover' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					downb.attachEvent( 'onmouseover', this.down );
					downb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					downb.addEventListener( 'mouseover', this.down, false );
					downb.addEventListener( 'mouseout', this.stop, false );
					}

				}
			
			}

		}

	}



// ----- object: scroll.horizontalarrows
TECHHOUSE.scroll.horizontalarrows = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.parms = parms;

	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );
	this.leftElem = document.getElementById( parms.buttona );
	this.rightElem = document.getElementById( parms.buttonb );

	this.pause = ( parms.pause ) ? parseInt( parms.pause ) : 1;
	this.move = ( parms.move ) ? parseInt( parms.move ) : 3;
	this.arrowsdisable = ( parms.arrowsdisable ) ? parms.arrowsdisable.toLowerCase() : 'true';
	
	this.scroll = false;

	TECHHOUSE.disableSelection( { elementId: parms.buttona } )
	TECHHOUSE.disableSelection( { elementId: parms.buttonb } )

	// disable buttons if content is smaller than viewport
	if( ( this.cElem.offsetWidth < this.vElem.offsetWidth ) && ( this.arrowsdisable == 'true' ) ) {
		this.leftElem.style.display = 'none';
		this.rightElem.style.display = 'none';
		}

	var that = this;

	// method: left
	this.left = function() {
		that.scroll = true;
		var left = that.vElem.scrollLeft;
		that.leftElem.className = that.parms.buttona + '_click';
		var moveit = function() {
			if( that.scroll ) {
				if( left - that.move >= 0 ) {
					left -= that.move;
					that.vElem.scrollLeft = left;
					if( that.bar ) { that.bar.refreshBox() }
					setTimeout( moveit, that.pause );
					}
				else {
					that.vElem.scrollLeft = 0;
					}
				}
			that.refreshArrows();
			}
		setTimeout( moveit, that.pause );
		
		}

	// method: right
	 this.right = function() {
		that.scroll = true;
		var left = that.vElem.scrollLeft;
		that.rightElem.className = that.parms.buttonb + '_click';
		var moveit = function() {
			if( that.scroll ) {
				if( ( parseInt( that.cElem.offsetWidth ) - left ) > parseInt( that.vElem.offsetWidth ) ) {
					left += that.move;
					that.vElem.scrollLeft = left;
					if( that.bar ) { that.bar.refreshBox() }
					setTimeout( moveit, that.pause );
					}
				}
			that.refreshArrows();
			}
		setTimeout( moveit, that.pause );
		
		}

	// method: stop
	this.stop = function() {
		that.scroll = false;
		that.leftElem.className = '';
		that.rightElem.className = '';
		that.refreshArrows();
		}

	// method: refreshArrows
	this.refreshArrows = function() {

		// refresh left button
		if( that.leftElem.className.indexOf( "_click" ) == -1 ) {
			if( that.vElem.scrollLeft > 0 ) {
				that.leftElem.className = that.parms.buttona;
				}
			else {
				that.leftElem.className = that.parms.buttona + '_inactive';
				}
			}

		// refresh right button
		if( that.rightElem.className.indexOf( "_click" ) == -1 ) {
			if( ( parseInt( that.cElem.offsetWidth ) - that.vElem.scrollLeft ) > parseInt( that.vElem.offsetWidth ) ) {
				that.rightElem.className = that.parms.buttonb;
				}
			else {
				that.rightElem.className = that.parms.buttonb + '_inactive';
				}
			}

		}

	// attach events
	if( that.vElem && that.cElem ) {

		var leftb = document.getElementById( parms.buttona );
		if( leftb ) {

			if( parms.event.toLowerCase() == 'click' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					leftb.attachEvent( 'onmousedown', this.left );
					leftb.attachEvent( 'onmouseup', this.stop );
					leftb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					leftb.addEventListener( 'mousedown', this.left, false );
					leftb.addEventListener( 'mouseup', this.stop, false );
					leftb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			else if( parms.event.toLowerCase() == 'hover' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					leftb.attachEvent( 'onmouseover', this.left );
					leftb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					leftb.addEventListener( 'mouseover', this.left, false );
					leftb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			}

		var rightb = document.getElementById( parms.buttonb );
		if( rightb ) {

			if( parms.event.toLowerCase() == 'click' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					rightb.attachEvent( 'onmousedown', this.right );
					rightb.attachEvent( 'onmouseup', this.stop );
					rightb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					rightb.addEventListener( 'mousedown', this.right, false );
					rightb.addEventListener( 'mouseup', this.stop, false );
					rightb.addEventListener( 'mouseout', this.stop, false );
					}

				}

			else if( parms.event.toLowerCase() == 'hover' ) {

				if( TECHHOUSE.browser.name == 'MSIE' ) {
					rightb.attachEvent( 'onmouseover', this.right );
					rightb.attachEvent( 'onmouseout', this.stop );
					}
				else {
					rightb.addEventListener( 'mouseover', this.right, false );
					rightb.addEventListener( 'mouseout', this.stop, false );
					}

				}		

			}

		}

	}



// --- object: scroll.verticalbar
TECHHOUSE.scroll.verticalbar = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.parms = parms;

	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );
	this.sElem = document.getElementById( parms.shaft );
	this.bElem = document.getElementById( parms.box );

	this.shaftdisable = ( parms.shaftdisable ) ? parms.shaftdisable.toLowerCase() : 'true';
	this.boxdisable = ( parms.boxdisable ) ? parms.boxdisable.toLowerCase() : 'hide';

	this.moveit = false; // only move bar+content if true
	this.mouseYonGrab = 0; // set to current mouse.y on grab

	this.jumpit = false;
	this.jumppause = ( parms.jumppause ) ? parseInt( parms.jumppause ) : 500;

	TECHHOUSE.disableSelection( { elementId: parms.shaft } )
	TECHHOUSE.disableSelection( { elementId: parms.box } )

	var that = this;

	/*
	RESIZE
	Y1 cHeight = height of content
	Y2 vHeight = height of viewport
	p = ( Y2 vHeight / Y1 cHeight ) * 100
	Y3 sHeight = height of shaft
	Y4 bHeight = ( Y3 sHeight / 100 ) * p
	REPOSITION
	Y5 vTop = viewport scrolltop
	p = ( Y5 vTop / Y1 cHeight ) * 100
	Y6 bTop = ( Y3 sHeight / 100 ) * p
	*/
	this.refreshBox = function() {

		var cHeight = that.cElem.offsetHeight;
		var vHeight = that.vElem.offsetHeight;

		if( cHeight > vHeight ) {

			// resize box
			var p = ( vHeight / cHeight ) * 100;
			var sHeight = that.sElem.offsetHeight;
			var bHeight = ( sHeight / 100 ) * p;
			that.bElem.style.height = bHeight + 'px';
			that.bElem.style.display = 'block';

			// reposition box
			var vTop = that.vElem.scrollTop;
			p = ( vTop / cHeight ) * 100;
			var bTop = ( sHeight / 100 ) * p;
			that.bElem.style.top = bTop + 'px';
			
			}

		else {

			// hide shaft or not
			if( that.shaftdisable == 'true' ) {
				that.sElem.style.display = 'none';
			}
			else {
				that.sElem.style.display = 'block';
				}

			// hide box or not
			if( that.boxdisable == 'full' ) {
				that.bElem.style.height = that.sElem.offsetHeight;
			}
			else {
				that.bElem.style.display = 'none';
				}

			}	

		}

	this.refreshBox();

	// method: grab
	this.grab = function() {
		that.bTopOnGrab = that.bElem.style.top;
		that.bTopOnGrab = ( that.bTopOnGrab ) ? parseInt( that.bTopOnGrab.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;
		that.mouseYonGrab = TECHHOUSE.mouse.y;
		that.moveit = true;
		that.bElem.className = that.parms.box + '_grabbed';
		}

	// method: release
	this.release = function() {
		that.moveit = false;
		that.jumpit = false;
		that.bElem.className = that.parms.box;
		}

	// method: move
	this.move = function() {
		if( that.moveit ) {

			var yMove = TECHHOUSE.mouse.y - that.mouseYonGrab;
			var bTop = that.bTopOnGrab + yMove;
			if( bTop < 0 ) { bTop = 0; }

			var bHeight = that.bElem.style.height;
			bHeight = ( bHeight ) ? parseInt( bHeight.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

			var sHeight = that.sElem.offsetHeight;

			var p = ( that.cElem.offsetHeight / that.sElem.offsetHeight );

			if( bTop + bHeight <= sHeight ) {
				that.bElem.style.top = bTop + 'px';
				that.vElem.scrollTop = ( bTop * p );
				}
			else {
				that.bElem.style.top = ( sHeight - bHeight ) + 'px';
				that.vElem.scrollTop = that.cElem.offsetHeight - that.vElem.offsetHeight;
				}

			if( that.arrows ) { that.arrows.refreshArrows(); }
			}

		}

	// method: jump
	this.jump = function() {

		that.jumpit = true;

		var jumpit = function() {
			if( that.jumpit ) {

				// move box up or down?
				var mY = TECHHOUSE.mouse.y;
				var sTop = TECHHOUSE.realPosition( { element: that.sElem } )[ 1 ];
				mY -= sTop;

				var bTop = that.bElem.style.top;
				bTop = ( bTop ) ? parseInt( bTop.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

				var bHeight = that.bElem.style.height;
				bHeight = ( bHeight ) ? parseInt( bHeight.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

				var bBottom = bTop + bHeight;

				if( mY < bTop ) {

					// move box up
					bTop -= bHeight;
					if( bTop < 0 )
						bTop = 0;
					that.bElem.style.top = bTop + 'px';

					}
				
				else if( mY > bBottom ) {

					// move box down				
					var sHeight = that.sElem.offsetHeight;
					bTop += bHeight;
					if( bTop > ( sHeight - bHeight ) )
						bTop = sHeight - bHeight;
					that.bElem.style.top = bTop + 'px';

					}				

				// move content
				var p = ( that.cElem.offsetHeight / that.sElem.offsetHeight );
				that.vElem.scrollTop = ( bTop * p );

				if( that.arrows ) { that.arrows.refreshArrows(); }

				setTimeout( jumpit, that.jumppause );
				}
			}

		jumpit();

		}

	// attach events
	if( that.vElem && that.cElem && that.sElem && that.bElem ) {

		if( TECHHOUSE.browser.name == 'MSIE' ) {
			this.bElem.attachEvent( 'onmousedown', this.grab );
			document.attachEvent( 'onmouseup', this.release );
			document.attachEvent( 'onmousemove', this.move );
			this.sElem.attachEvent( 'onmousedown', this.jump );
			}
		else {
			this.bElem.addEventListener( 'mousedown', this.grab, false );
			document.addEventListener( 'mouseup', this.release, false );
			document.addEventListener( 'mousemove', this.move, false );
			this.sElem.addEventListener( 'mousedown', this.jump, false );
			}

		}

	}



// --- object: scroll.horizontalbar
TECHHOUSE.scroll.horizontalbar = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.parms = parms;

	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );
	this.sElem = document.getElementById( parms.shaft );
	this.bElem = document.getElementById( parms.box );

	this.shaftdisable = ( parms.shaftdisable ) ? parms.shaftdisable.toLowerCase() : 'true';
	this.boxdisable = ( parms.boxdisable ) ? parms.boxdisable.toLowerCase() : 'hide';

	this.moveit = false; // only move bar+content if true
	this.mouseXonGrab = 0; // set to current mouse.x on grab

	this.jumpit = false;
	this.jumppause = ( parms.jumppause ) ? parseInt( parms.jumppause ) : 500;

	TECHHOUSE.disableSelection( { elementId: parms.shaft } )
	TECHHOUSE.disableSelection( { elementId: parms.box } )

	var that = this;

	/*
	RESIZE
	X1 cWidth = width of content
	X2 vWidth = width of viewport
	p = ( X2 vWidth / X1 cWidth ) * 100
	X3 sWidth = width of shaft
	X4 bWidth = ( X3 sWidth / 100 ) * p
	REPOSITION
	X5 vLeft = viewport scrollleft
	p = ( X5 vLeft / X1 cWidth ) * 100
	X6 bLeft = ( X3 sWidth / 100 ) * p
	*/
	this.refreshBox = function() {

		var cWidth = that.cElem.offsetWidth;
		var vWidth = that.vElem.offsetWidth;

		if( cWidth > vWidth ) {

			// resize box
			var p = ( vWidth / cWidth ) * 100;
			var sWidth = that.sElem.offsetWidth;
			var bWidth = ( sWidth / 100 ) * p;
			that.bElem.style.width = bWidth + 'px';
			that.bElem.style.display = 'block';

			// reposition box
			var vLeft = that.vElem.scrollLeft;
			p = ( vLeft / cWidth ) * 100;
			var bLeft = ( sWidth / 100 ) * p;
			that.bElem.style.left = bLeft + 'px';
			
			}

		else {

			// hide shaft or not
			if( that.shaftdisable == 'true' ) {
				that.sElem.style.display = 'none';
			}
			else {
				that.sElem.style.display = 'block';
				}

			// hide box or not
			if( that.boxdisable == 'full' ) {
				that.bElem.style.width = that.sElem.offsetWidth;
				}
			else {
				that.bElem.style.display = 'none';
				}
			
			}

		}

	this.refreshBox();

	// method: grab
	this.grab = function() {
		that.bLeftOnGrab = that.bElem.style.left;
		that.bLeftOnGrab = ( that.bLeftOnGrab ) ? parseInt( that.bLeftOnGrab.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;
		that.mouseXonGrab = TECHHOUSE.mouse.x;
		that.moveit = true;
		that.bElem.className = that.parms.box + '_grabbed';
		}

	// method: release
	this.release = function() {
		that.moveit = false;
		that.jumpit = false;
		that.bElem.className = that.parms.box;
		}

	// method: move
	this.move = function() {
		if( that.moveit ) {

			var xMove = TECHHOUSE.mouse.x - that.mouseXonGrab;
			var bLeft = that.bLeftOnGrab + xMove;
			if( bLeft < 0 ) { bLeft = 0; }

			var bWidth = that.bElem.style.width;
			bWidth = ( bWidth ) ? parseInt( bWidth.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

			var sWidth = that.sElem.offsetWidth;

			var p = ( that.cElem.offsetWidth / that.sElem.offsetWidth );

			if( bLeft + bWidth <= sWidth ) {
				that.bElem.style.left = bLeft + 'px';
				that.vElem.scrollLeft = bLeft * p;
				}
			else {
				that.bElem.style.left = ( sWidth - bWidth ) + 'px';
				that.vElem.scrollLeft = that.cElem.offsetWidth - that.vElem.offsetWidth;
				}

			if( that.arrows ) { that.arrows.refreshArrows(); }

			}

		}

	// method: jump
	this.jump = function() {

		that.jumpit = true;

		var jumpit = function() {
			if( that.jumpit ) {

				// move box left or right?
				var mX = TECHHOUSE.mouse.x;
				var sLeft = TECHHOUSE.realPosition( { element: that.sElem } )[ 0 ];
				mX -= sLeft;

				var bLeft = that.bElem.style.left;
				bLeft = ( bLeft ) ? parseInt( bLeft.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

				var bWidth = that.bElem.style.width;
				bWidth = ( bWidth ) ? parseInt( bWidth.replace( /[a-z]|[A-Z]/g, "" ) ) : 0;

				var bRight = bLeft + bWidth;

				if( mX < bLeft ) {

					// move box left
					bLeft -= bWidth;
					if( bLeft < 0 )
						bLeft = 0;
					that.bElem.style.left = bLeft + 'px';

					}
				
				else if( mX > bRight ) {

					// move box right
					var sWidth = that.sElem.offsetWidth;
					bLeft += bWidth;
					if( bLeft > ( sWidth - bWidth ) )
						bLeft = sWidth - bWidth;
					that.bElem.style.left = bLeft + 'px';

					}				

				// move content
				var p = ( that.cElem.offsetWidth / that.sElem.offsetWidth );
				that.vElem.scrollLeft = ( bLeft * p );

				if( that.arrows ) { that.arrows.refreshArrows(); }

				setTimeout( jumpit, that.jumppause );
				}
			}

		jumpit();

		}

	// attach events
	if( that.vElem && that.cElem && that.sElem && that.bElem ) {

		if( TECHHOUSE.browser.name == 'MSIE' ) {
			this.bElem.attachEvent( 'onmousedown', this.grab );
			document.attachEvent( 'onmouseup', this.release );
			document.attachEvent( 'onmousemove', this.move );
			this.sElem.attachEvent( 'onmousedown', this.jump );
			}
		else {
			this.bElem.addEventListener( 'mousedown', this.grab, false );
			document.addEventListener( 'mouseup', this.release, false );
			document.addEventListener( 'mousemove', this.move, false );
			this.sElem.addEventListener( 'mousedown', this.jump, false );
			}

		}

	}



// --- object: scroll.verticalwheel
TECHHOUSE.scroll.verticalwheel = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;
	
	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );

	this.speed = ( parms.speed ) ? parseInt( parms.speed ) : 20;

	var that = this;

	// method: action
	this.action = function( move ) {
		that.vTop = that.vElem.scrollTop;
		that.vTop -= move * that.speed;
		that.vElem.scrollTop = that.vTop;
		if( that.bar ) { that.bar.refreshBox(); }
		if( that.arrows ) { that.arrows.refreshArrows(); }
		}

	// register events
	if( this.vElem ) {
		this.mousewheel = new TECHHOUSE.mouseWheel( { element: parms.viewport } );
		this.mousewheel.action = this.action;
		}

	}



// --- object: scroll.horizontalwheel
TECHHOUSE.scroll.horizontalwheel = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;
	
	this.vElem = document.getElementById( parms.viewport );
	this.cElem = document.getElementById( parms.content );

	this.speed = ( parms.speed ) ? parseInt( parms.speed ) : 20;

	var that = this;

	// method: action
	this.action = function( move ) {
		that.vLeft = that.vElem.scrollLeft;
		that.vLeft -= move * that.speed;
		that.vElem.scrollLeft = that.vLeft;
		if( that.bar ) { that.bar.refreshBox(); }
		if( that.arrows ) { that.arrows.refreshArrows(); }
		}

	// register events
	if( this.vElem ) {
		this.mousewheel = new TECHHOUSE.mouseWheel( { element: parms.viewport } );
		this.mousewheel.action = this.action;
		}

	}



// --- object: scroll.verticaltab
TECHHOUSE.scroll.verticaltab = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.cElem = document.getElementById( parms.content );

	var that = this;

	this.tabEvents = function() {
		if( that.bar ) {
			TECHHOUSE.scroll.tabevents( that.cElem, that.bar, that.arrows );
			}
		else {
			setTimeout( that.tabEvents, 1000 );
			}
		}

	this.tabEvents();
	}



// --- object: scroll.horizontaltab
TECHHOUSE.scroll.horizontaltab = function( parms ) {

	this.name = parms.name;
	window[ parms.name ] = this;

	this.cElem = document.getElementById( parms.content );

	var that = this;

	this.tabEvents = function() {
		if( that.bar ) {
			TECHHOUSE.scroll.tabevents( that.cElem, that.bar, that.arrows );
			}
		else {
			setTimeout( that.tabEvents, 1000 );
			}
		}

	this.tabEvents();
	}



// ----- function: TECHHOUSE.scroll.tabevents
TECHHOUSE.scroll.tabevents = function( node, bar, arrows ) {

	var validNames = new Array( 'A', 'IFRAME', 'IMAGE', 'INPUT', 'TEXTAREA' );

	var child = node.firstChild;

	var refresh = function() {
		bar.refreshBox();
		arrows.refreshArrows();
		}

	while( child ) {

		if( child.nodeType == 1 )
			if( validNames.inArray( child.nodeName ) )
				if( TECHHOUSE.browser.name == 'MSIE' )
					child.attachEvent( 'onfocus', refresh );
				else
					child.addEventListener( 'focus',
						function() { setTimeout( refresh, 100 ) },
						false );

		TECHHOUSE.scroll.tabevents( child, bar, arrows );

		child = child.nextSibling;

		}

	}

