// file: techhouse.js
// version: 2.9
// author: KBE20090928


/*

*** RECOMMENDATIONS FOR "GOOD PRACTICES" ***

#1: Put EVERYTHING in the TECHHOUSE object
to keep the javascript namespace clean.

#2: Make objects unless you're writing a
support function.

#3: System objects and functions goes in here.
Other objects goes into separate files in this directory.

#4: Check all new and altered functions in all browsers
(MSIE, Firefox, Safari, Chrome and Opera)

#5: Always pass parameters to functions/objects in a hash.
 -The order of the parameters becomes irrelevant
 -It's easy to extend the function to react to new parameters
 -A hash of parameters can be built prior to calling the function

*/



// ----- custom prototypes

// Returns true if the value is found in the array.
Array.prototype.inArray = function( value ) {
	var i;
	for( i = 0; i < this.length; i++ )
		if( this[ i ] === value )
			return true;
	return false;
	};



// ----- object: TECHHOUSE
var TECHHOUSE = {};



// ----- object: browserDetect
TECHHOUSE.browserDetect = function() {

	var tmp1, tmp2, tmp3;

	// get platform from navigator.userAgent
	if( navigator.userAgent.indexOf( 'Win' ) != -1 ) {
		this.platform = 'WINDOWS';
		}

	else if( navigator.userAgent.indexOf( 'Mac' ) != -1 ) {
		this.platform = 'MAC';
		}

	else if( navigator.userAgent.indexOf( 'Linux' ) != -1 ) {
		this.platform = 'LINUX';
		}

	else {

		// on fail, get platform from navigator.platform
		if( navigator.platform.indexOf( 'Win' ) != -1 ) {
			this.platform = 'WINDOWS';
			}

		else if( navigator.userAgent.indexOf( 'Mac' ) != -1 ) {
			this.platform = 'MAC';
			}

		else if( navigator.userAgent.indexOf( 'Linux' ) != -1 ) {
			this.platform = 'LINUX';
			}

		else {	
			this.platform = 'UNKNOWN';
			}

		}

	// get browser name from navigator.userAgent
	if( navigator.userAgent.indexOf( 'Firefox' ) != -1 ) {
		this.name = 'FIREFOX';
		}

	else if( navigator.userAgent.indexOf( 'Chrome' ) != -1 ) {
		this.name = 'CHROME';
		}

	else if( navigator.userAgent.indexOf( 'Safari' ) != -1 ) {
		this.name = 'SAFARI';
		}

	else if( navigator.userAgent.indexOf( 'Opera' ) != -1 ) {
		this.name = 'OPERA';
		}

	else if( navigator.userAgent.indexOf( 'MSIE' ) != -1 ) {
		this.name = 'MSIE';
		}

	else {

		// on fail, get name from navigator.appName
		switch( navigator.appName ) {

			case 'Microsoft Internet Explorer':
				this.name = 'MSIE';
				break;

			case 'Opera':
				this.name = 'OPERA';
				break;

			case 'Netscape':

				if( navigator.appVersion.indexOf( 'Chrome' ) != -1 ) {
					this.name = 'CHROME';
					}

				else if( navigator.appVersion.indexOf( 'Safari' ) != -1 ) {
					this.name = 'SAFARI';
					}

				else {
					this.name = 'FIREFOX';
					}

				break;

			default:
				this.name = 'UNKNOWN';
		
			}
		
		}

	// get major and minor
	if( this.name == 'FIREFOX' ) {
		tmp1 = navigator.userAgent.split( ' ' );
		if( this.platform == 'LINUX' ) {
			tmp2 = tmp1[ 10 ].split( '/' );
			}
		else if( this.platform == 'MAC' ) {
			tmp2 = tmp1[ 11 ].split( '/' );
			}
		else{
			tmp2 = tmp1[ 9 ].split( '/' );
		}
		tmp3 = tmp2[ 1 ].split( '.' );
		this.major = tmp3[ 0 ];
		this.minor = tmp3[ 1 ];
		}

	else if( this.name == 'CHROME' ) {
		tmp1 = navigator.userAgent.split( ' ' );
		if( this.platform == 'WINDOWS' ) {
			tmp2 = tmp1[ 11 ].split( '/' );
			}
		else if( this.platform == 'MAC' ) {
			tmp2 = tmp1[ 10 ].split( '/' );
			}
		else if( this.platform == 'LINUX' ) {
			tmp2 = tmp1[ 10 ].split( '/' );
			}
		tmp3 = tmp2[ 1 ].split( '.' );
		this.major = tmp3[ 0 ];
		this.minor = tmp3[ 1 ];
		}

	else if( this.name == 'SAFARI' ) {
		tmp1 = navigator.userAgent.split( ' ' );
		if( this.platform == 'MAC' ) {
			tmp2 = tmp1[ 13 ].split( '/' );
			}
		else {
			tmp2 = tmp1[ 11 ].split( '/' );
			}
		tmp3 = tmp2[ 1 ].split( '.' );
		this.major = tmp3[ 0 ];
		this.minor = tmp3[ 1 ];
		}

	else if( this.name == 'OPERA' ) {
		tmp1 = navigator.userAgent.split( ' ' );
		tmp2 = tmp1[ 7 ].split( '/' );
		tmp3 = tmp2[ 1 ].split( '.' );
		this.major = tmp3[ 0 ];
		this.minor = tmp3[ 1 ];
		}

	else if( this.name == 'MSIE' ) {
		tmp1 = navigator.appVersion.split( ';' );
		tmp2 = tmp1[ 1 ].split( ' ' );
		tmp3 = tmp2[ 2 ].split( '.' );
		this.major = tmp3[ 0 ];
		this.minor = tmp3[ 1 ];

		//IE8 compability mode
		if( document.documentMode ) {
			if( document.documentMode == 7 ) {
				this.major = 8;
				this.minor = 0;
				}
			}
		}

	this.longName = {
		FIREFOX: 'Mozilla Firefox',
		CHROME: 'Google Chrome',
		SAFARI: 'Apple Safari',
		OPERA: 'Opera',
		MSIE: 'Microsoft Internet Explorer'
		};

	/*
		IMPORTANT
		Update these values manually
		as browser vendors releases
		new major versions of their software.
	*/
	this.latestMajor = {
		FIREFOX: 3,
		CHROME: 6,
		SAFARI: 5,
		OPERA: 10,
		MSIE: 8
		};

	// method: upgradeAlert
	this.upgradeAlert = function( lang ) {
		var elem;
		if( this.name != 'UNKNOWN' ) {
			if( this.major < this.latestMajor[ this.name ] ) {
				elem = document.createElement( 'div' );
				if( elem ) {
					elem.style.position = 'fixed';
					elem.style.top = '0';
					elem.style.left = '0';
					elem.style.width = '100%';
					elem.style.zIndex = '999';
					elem.style.backgroundColor = '#E00000';
					elem.style.color = '#FFFFFF';
					elem.style.fontFamily = 'Verdana, DejaVu Sans, sans-serif';
					elem.style.fontSize = '10px';
					elem.style.fontWeight = 'bold';
					elem.style.textAlign = 'center';
					elem.style.paddingTop = '3px';
					elem.style.paddingBottom = '3px';

					switch( lang ) {

						case 'DK':
							elem.innerHTML = 'ADVARSEL: Din webbrowser (' + this.longName[ this.name ] + ' ' + this.major + ') er forældet og dermed en sikkerhedsrisiko. Websiden vises muligvis også forkert. Du bør opgradere til nyeste version. Det er gratis. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">KLIK HER</a>';
							break;

						case 'SE':
							elem.innerHTML = 'VARNING: Din webbläsare (' + this.longName[ this.name ] + ' ' + this.major + ') är föråldrad och därmed en säkerhetsrisk. Webbplatsen kan också visas felaktigt. Du bör uppgradera till den senaste versionen. Det är gratis. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">KLICKA HÄR</a>';
							break;

						case 'NO':
							elem.innerHTML = 'ADVARSEL: Nettleseren (' + this.longName[ this.name ] + ' ' + this.major + ') er utdatert og dermed en sikkerhetsrisiko. Nettstedet kan også vises på feil måte. Du bør oppgradere til siste versjon. Det er gratis. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">KLIKK HER</a>';
							break;

						case 'UK':
							elem.innerHTML = 'WARNING: Your web browser (' + this.longName[ this.name ] + ' ' + this.major + ') is outdated and thus a security risk. The website may also appear incorrectly. You should upgrade to the latest version. It\'s free. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">CLICK HERE</a>';
							break;

						case 'DE':
							elem.innerHTML = 'WARNUNG: Ihr Web-Browser (' + this.longName[ this.name ] + ' ' + this.major + ') ist veraltet und somit ein Sicherheitsrisiko darstellen. Die Website kann auch falsch angezeigt. Sie sollten auf die neueste Version upgraden. Es ist kostenlos. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">KLICKEN SIE HIER</a>';
							break;

						case 'FR':
							elem.innerHTML = 'ATTENTION: Votre navigateur Web (' + this.longName[ this.name ] + ' ' + this.major + ') est obsolčte et donc un risque de sécurité. Le site peut également apparaître de maničre incorrecte. Vous devez mettre ā niveau vers la derničre version. C\'est gratuit. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">CLIQUEZ ICI</a>';
							break;

						case 'IT':
							elem.innerHTML = 'ATTENZIONE: Il tuo browser web (' + this.longName[ this.name ] + ' ' + this.major + ') č obsoleta e quindi un rischio per la sicurezza. Il sito web puō anche apparire in modo errato. Si consiglia di effettuare l\'aggiornamento alla versione pių recente. Č gratuito. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">CLICCA QUI</a>';
							break;

						// english is default
						default:
							elem.innerHTML = 'WARNING: Your web browser (' + this.longName[ this.name ] + ' ' + this.major + ') is outdated and thus a security risk. The website may also appear incorrectly. You should upgrade to the latest version. It\'s free. <a href="http://www.browserchoice.eu/" target="_blank" style="color:#FFFFFF;">CLICK HERE</a>';
							break;
					
						}

					document.body.appendChild( elem );
					}			
				}
			}
		}
	}



// ----- object: inertia
TECHHOUSE.inertia = function() {

	var that = this;

	// method: create
	this.create = function( steps, max ) {

		// build sine array
		var sin = [];
		for( var s = 0; s < 360; s++ ) {
			sin[ s ] = Math.sin( s / 360 * 2 * Math.PI );
			}

		// create inertia values for all steps
		var steplist = [];
		for( s = 0; s < 90; s = s + ( 90 / steps ) ) {
			steplist.push( Math.round( ( max - 1 ) * sin[ Math.round( s ) ] ) );
			}

		return steplist;

		}

	}



// ----- object: mousePosition
TECHHOUSE.mousePosition = function() {

	var that = this;

	this.x = 0;
	this.y = 0;

	// method: getPosition
	this.getPosition = function( e ) {

		e = e ? e : window.event;

		if( TECHHOUSE.browser.name == 'MSIE' ) {
			that.x = e.clientX + document.body.scrollLeft;
			that.y = e.clientY + document.body.scrollTop;
			}

		else {
			that.x = e.pageX;
			that.y = e.pageY;
			}  

		if( that.x < 0 )
			that.x = 0;

		if( that.y < 0 )
			that.y = 0;

		return true;
		}

	// set events
	if( TECHHOUSE.browser.name == 'MSIE' )
		document.attachEvent( 'onmousemove', this.getPosition );
	else
		document.addEventListener( 'mousemove', this.getPosition, false );

	}



// ----- object: mouseWheel
TECHHOUSE.mouseWheel = function( parms ) {
	this.element = document.getElementById( parms.element );

	var that = this;

	this.action = function( move ) {
		that.element.innerHTML = "Move: " + move + "<br>";
		}

	// method: handler
	this.handler = function( e ) {
		e = e ? e : window.event;
		var move = e.detail ? e.detail * -1 : e.wheelDelta / 40;
		if( move == 3 )
			move = 1;
		if( move == -3 )
			move = -1;
		that.action( move );
		return that.cancelEvent( e );
		}

	// method: cancelEvent
	this.cancelEvent = function( e ) {
		e = e ? e : window.event;

		if( e.stopPropagation )
			e.stopPropagation();

		if( e.preventDefault )
			e.preventDefault();

		e.cancelBubble = true;
		e.cancel = true;
		e.returnValue = false;

		return false;
		}

	// attach events
	if( this.element ) {

		if( TECHHOUSE.browser.name == 'MSIE' )
			this.element.attachEvent( "onmousewheel", this.handler );
		else if( TECHHOUSE.browser.name == 'FIREFOX' )
			this.element.addEventListener( 'DOMMouseScroll', this.handler, false );
		else if( TECHHOUSE.browser.name == 'SAFARI' )
			this.element.addEventListener( 'mousewheel', this.handler, false );
		else if( TECHHOUSE.browser.name == 'OPERA' )
			this.element.addEventListener( 'mousewheel', this.handler, false );
		else if( TECHHOUSE.browser.name == 'CHROME' )
			this.element.addEventListener( 'mousewheel', this.handler, false );

		}

	}



// --- function: disableSelection
TECHHOUSE.disableSelection = function( parms ) {
	var element = document.getElementById( parms.elementId );

	if( element ) {

		if( TECHHOUSE.browser.name == 'MSIE' )
			element.onselectstart = function() { return false; }

		else if( TECHHOUSE.browser.name == 'FIREFOX' )
			element.style.MozUserSelect = 'none';

		else
			element.onmousedown = function() { return false; }

		}

	}



// --- function: realPosition
TECHHOUSE.realPosition = function( parms ) {
	var elem = parms.element;
	var curLeft = curTop = 0;

	if( elem.offsetParent ) {

		do {

			if( TECHHOUSE.browser.name == 'MSIE' ) {
				curLeft += elem.offsetLeft;
				curTop += elem.offsetTop;

				// use this if DOCTYPE doesn't include "http://www.w3.org/TR/html4/loose.dtd"
				// curTop += ( elem.offsetTop / 2 );
				}
			else {
				curLeft += elem.offsetLeft;
				curTop += elem.offsetTop;
				}

			} while( elem = elem.offsetParent );

		return[ curLeft, curTop ];

		}

	}



// --- function: randomizeArray
TECHHOUSE.randomizeArray = function( parms ) {

	var i, j, tempi, tempj;

	if( ! parms.arr ) {
		return undefined;
		}

	// Fisher-Yates array randomizer
	i = parms.arr.length;

	if( i == 0 ) {
		return undefined;
		}

	while( --i ) {
		j = Math.floor( Math.random() * ( i + 1 ) );
		tempi = parms.arr[ i ];
		tempj = parms.arr[ j ];
		parms.arr[ i ] = tempj;
		parms.arr[ j ] = tempi;
		}

	return true;
	}



// ----- function: changeOpacity
TECHHOUSE.changeOpacity = function( elem, value, MSIE ) {

	if( elem ) {
		elem.style.opacity = ( value / 100 );
		elem.style.MozOpacity = ( value / 100 );
		elem.style.KhtmlOpacity = ( value / 100 );
		if( MSIE ) {
			elem.style.filter = "alpha(opacity=" + value + ")"; 
			}
		}

	}



// ----- function: fades element opacity up to 100
TECHHOUSE.opacityFadeUp = function( elem, opacity, change ) {

	opacity += change;
	if( opacity > 100 ) {
		opacity = 100;
		}

	TECHHOUSE.changeOpacity( elem, opacity, false );

	if( opacity < 100 ) {
		setTimeout( function() { TECHHOUSE.opacityFadeUp( elem, opacity, change ) }, 1 );
		}

	}




// ----- function: expands element height downwards to offsetHeight
TECHHOUSE.elementExpandDown = function( elem, height, maxHeight, change ) {

	elem.style.overflow = 'hidden';

	height += change;
	if( height > maxHeight ) {
		height = maxHeight;
		}
	elem.style.height = height + 'px';

	if( height < maxHeight ) {
		setTimeout( function() { TECHHOUSE.elementExpandDown( elem, height, maxHeight, change ) }, 10 );
		}
	else {
		elem.style.overflow = 'visible';
		}

	}



// ----- function: expands element height upwards to offsetHeight
TECHHOUSE.elementExpandUp = function( elem, height, maxHeight, startTop, change ) {

	elem.style.overflow = 'hidden';

	height += change;
	if( height > maxHeight ) {
		height = maxHeight;
		}
	elem.style.height = height + 'px';
	elem.style.top = ( ( startTop + maxHeight ) - height ) + 'px';

	if( height < maxHeight ) {
		setTimeout( function() { TECHHOUSE.elementExpandUp( elem, height, maxHeight, startTop, change ) }, 10 );
		}
	else {
		elem.style.overflow = 'visible';
		}

	}



// --- function: stopBubbling
TECHHOUSE.stopBubbling = function( e ) {

	e = e ? e : window.event;

	if( e.stopPropagation ) {

		// W3C stop bubbling
		e.stopPropagation();

		}

	else {

		// MSIE stop bubbling
		e.cancelBubble = true;

		}

	}



// --- function: stopDefault
TECHHOUSE.stopDefault = function( e ) {

	e = e ? e : window.event;

	if( e.preventDefault ) {
		e.preventDefault();
		}
		
	else {

		e.returnValue = false;

		}

	}



// --- function: getOffsetHeightWithoutPaddingAndBorder
TECHHOUSE.getOffsetHeightWithoutPaddingAndBorder = function( elem ) {

	var stripUnitRegex;
	var borderTop, borderBottom, border;
	var paddingTop, paddingBottom, padding;
	var height;



	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );



	// get border top and bottom
	try {
		borderTop = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-top-width' ) )[ 0 ];
		borderBottom = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-bottom-width' ) )[ 0 ];
		}
	catch( e ) {
		borderTop = stripUnitRegex.exec( elem.currentStyle.borderTopWidth )[ 0 ];
		borderBottom = stripUnitRegex.exec( elem.currentStyle.borderBottomWidth )[ 0 ];
		}

	// calculate total border top and bottom
	if( borderTop ) {
		border = parseInt( borderTop );
		}

	if( borderBottom ) {
		border += parseInt( borderBottom );
		}



	// get padding top and bottom
	try {
		paddingTop = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-top' ) )[ 0 ];
		paddingBottom = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-bottom' ) )[ 0 ];
		}
	catch( e ) {
		paddingTop = stripUnitRegex.exec( elem.currentStyle.paddingTop )[ 0 ];
		paddingBottom = stripUnitRegex.exec( elem.currentStyle.paddingBottom )[ 0 ];
		}

	// calculate total padding top and bottom
	if( paddingTop ) {
		padding = parseInt( paddingTop );
		}

	if( paddingBottom ) {
		padding += parseInt( paddingBottom );
		}



	// get height with border and padding
	height = parseInt( stripUnitRegex.exec( elem.offsetHeight )[ 0 ] );



	// calculate height without padding
	if( padding ) {
		height -= padding;
		}



	// calculate height without border
	if( border ) {
		height -= border;
		}



	// return height or undefined
	if( height ) {
		return height;
		}
	else {
		return undefined;
		}

	}



// --- function: getOffsetWidthWithoutPaddingAndBorder
TECHHOUSE.getOffsetWidthWithoutPaddingAndBorder = function( elem ) {

	var stripUnitRegex;
	var borderLeft, borderRight, border;
	var paddingLeft, paddingRight, padding;
	var width;



	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );



	// get border left and right
	try {
		borderLeft = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-left-width' ) )[ 0 ];
		borderRight = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-right-width' ) )[ 0 ];
		}
	catch( e ) {
		borderLeft = stripUnitRegex.exec( elem.currentStyle.borderLeftWidth )[ 0 ];
		borderRight = stripUnitRegex.exec( elem.currentStyle.borderRightWidth )[ 0 ];
		}

	// calculate total border left and right
	if( borderLeft ) {
		border = parseInt( borderLeft );
		}

	if( borderRight ) {
		border += parseInt( borderRight );
		}



	// get padding left and right
	try {
		paddingLeft = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-left' ) )[ 0 ];
		paddingRight = stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-right' ) )[ 0 ];
		}
	catch( e ) {
		paddingLeft = stripUnitRegex.exec( elem.currentStyle.paddingLeft )[ 0 ];
		paddingRight = stripUnitRegex.exec( elem.currentStyle.paddingRight )[ 0 ];
		}

	// calculate total padding left and right
	if( paddingLeft ) {
		padding = parseInt( paddingLeft );
		}

	if( paddingRight ) {
		padding += parseInt( paddingRight );
		}



	// get width with border and padding
	width = parseInt( stripUnitRegex.exec( elem.offsetWidth )[ 0 ] );



	// calculate width without padding
	if( padding ) {
		width -= padding;
		}



	// calculate width without border
	if( border ) {
		width -= border;
		}



	// return width or undefined
	if( width ) {
		return width;
		}
	else {
		return undefined;
		}

	}



// --- function: getTopBorder
TECHHOUSE.getTopBorder = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get top border
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-top-width' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.borderTopWidth )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getRightBorder
TECHHOUSE.getRightBorder = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get right border
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-right-width' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.borderRightWidth )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getBottomBorder
TECHHOUSE.getBottomBorder = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get bottom border
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-bottom-width' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.borderBottomWidth )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getLeftBorder
TECHHOUSE.getLeftBorder = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get left border
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'border-left-width' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.borderLeftWidth )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getTopPadding
TECHHOUSE.getTopPadding = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get top padding
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-top' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.paddingTop )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getRightPadding
TECHHOUSE.getRightPadding = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get right padding
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-right' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.paddingRight )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getBottomPadding
TECHHOUSE.getBottomPadding = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get bottom padding
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-bottom' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.paddingBottom )[ 0 ] );
		}

	return val || 0;
	}



// --- function: getLeftPadding
TECHHOUSE.getLeftPadding = function( elem ) {

	var stripUnitRegex;
	var val;

	// splits string (ie '10px') into value and unit
	stripUnitRegex = new RegExp( '([0-9]*).*' );

	// get left padding
	try {
		val = parseInt( stripUnitRegex.exec( getComputedStyle( elem, '' ).getPropertyValue( 'padding-left' ) )[ 0 ] );
		}
	catch( e ) {
		val = parseInt( stripUnitRegex.exec( elem.currentStyle.paddingLeft )[ 0 ] );
		}

	return val || 0;
	}



// --- function: dump
TECHHOUSE.dump = function( message, zIndex ) {

	var dumpElem;

	dumpElem = document.getElementById( 'TECHHOUSE_dump' );

	if( ! dumpElem ) {
		dumpElem = document.createElement( 'div' );
		dumpElem.setAttribute( 'id', 'TECHHOUSE_dump' );
		dumpElem.style.position = 'fixed';
		dumpElem.style.top = '0';
		dumpElem.style.left = '0';
		dumpElem.style.height = '100%';
		dumpElem.style.zIndex = zIndex || '-999';
		dumpElem.style.backgroundColor = '#000000';
		dumpElem.style.color = '#00CC00';
		dumpElem.style.fontFamily = 'Courier New';
		dumpElem.style.fontSize = '11px';
		dumpElem.style.lineHeight = '9px';
		dumpElem.style.paddingLeft = '5px';
		dumpElem.style.paddingRight = '5px';
		dumpElem.style.borderRight = '5px solid #00CC00';
		document.body.appendChild( dumpElem );
		}

	dumpElem.innerHTML += message + "<br>";

	}



// --- function: isSocSecNum
TECHHOUSE.isSocSecNum = function( value ) {

	/*
		return message:
			1 = incorrect format (DDMMYY-CCCC)
			2 = incorrect checksum
			3 = MAN
			4 = WOMAN
	*/

	var retVal, retMes, checksum;

	// correct format?
	if( value.match( /[0-9]{6}\-?[0-9]{4}/ ) ) {
		value = value.replace( /\-/g, "" );

		// correct checksum?
		checksum = 0;
		for( i = 9; i > -1 ; i-- ) {
			checksum += ( +value.charAt( i ) ) * ( ( i > 2 ) ? ( 10 - i ) : ( 4 - i ) );
			}

		if( checksum % 11 != 0 ) {
			retVal = false;
			retMes = 2;
			}
		else {
			retVal = true;
			retMes = value.match( /[13579]$/ ) ? 3 : 4;
			}

		}

	// not correct format
	else {
		retVal = false;
		retMes = 1;
		}

	return [ retVal, retMes ];
	}



// This is the place for instantiating new objects
TECHHOUSE.browser = new TECHHOUSE.browserDetect();



// --- function: init
// IMPORTANT: This is the place for instantiating new objects WHEN the document has finished loading
TECHHOUSE.init = function() {
	TECHHOUSE.mouse = new TECHHOUSE.mousePosition();
	}

if( TECHHOUSE.browser.name == 'MSIE' )
	window.attachEvent( 'onload', TECHHOUSE.init );
else
	window.addEventListener( 'load', TECHHOUSE.init, false );

