function getPositionString( position )
{
	var positionAsString = position + '';
	if ( positionAsString == '' )
	{
		return '';
	}
	var lastChar = positionAsString.charAt( positionAsString.length - 1 );
	if ( position > 10 && position < 20 )
	{
		return positionAsString + 'th';
	}
	if ( lastChar == '1' )
	{
		return positionAsString + 'st';
	}
	else if ( lastChar == '2' )
	{
		return positionAsString + 'nd';
	}
	else if ( lastChar == '3' )
	{
		return positionAsString + 'rd';
	}
	else 
	{
		return positionAsString + 'th';
	}
}


function padWithZero(x) 
{ 
	return ( ( x > 9 ) ? "" : "0" ) + x;
}


function fmtTime(ms) 
{
	var sec = Math.floor( ms / 1000 );
	var min = Math.floor( sec / 60 );
	sec = sec % 60;
	var hr = Math.floor( min / 60 );
	min = min % 60;
	var formattedTime = '';
	if ( hr > 0 )
	{
		formattedTime = hr + ":" + padWithZero(min) + ":" + padWithZero(sec);	
	}
	else if ( min > 0 )
	{
		formattedTime = min + ":" + padWithZero(sec);
	}
	else
	{
		formattedTime = sec + 's';
	}
	return formattedTime;
}


/**
 * Given a time in milliseconds, returns a time in the format
 * hh:mm:ss   (without the hour part if zero hours)
 */
/*function fmtTime( msec )
{
	//var time = new Date();
	//var gmtMS = msec - ( time.getTimezoneOffset() * 60000 );
	var hours = msec /
	
	
	
	var objTime = new Date( msec );
	var seconds = objTime.getSeconds().toString();
	if ( objTime.getMinutes() == 0 && objTime.getHours() == 0 )
	{
		return seconds + 's';
	}
	if ( seconds.length < 2 ) seconds = '0' + seconds;
	var strTime = '';
	var minutes = objTime.getMinutes().toString();
	if ( objTime.getHours() == 0 )
	{
		return minutes + 'm ' + seconds + 's';
	}
	if ( minutes.length < 2 ) minutes = '0' + minutes;
	strTime = minutes + ':' + seconds;
	if ( objTime.getHours() > 0 )
	{
		strTime = objTime.getHours() + ':' + strTime;
	}
	return strTime;		
} */

function createHeaderRow( columnNames )
{
	var objRow = document.createElement( 'tr' );
	for ( var i = 0; i < columnNames.length; i++ )
	{
		var objCell = document.createElement( 'th' );
		var objText = document.createTextNode( columnNames[i] );
		objCell.appendChild( objText );
		objRow.appendChild( objCell );
	}
	return objRow;
}

function debug( message )
{
	if ( window.console ) 
	{
		window.console.log( message );
	} 
}

function appendClassName( obj, className )
{
	if ( obj.className == '' )
	{
		obj.className = className;
	}
	else
	{
		obj.className += ' ' + className;
	}
}