
        function endIsNearFormat( seconds )
        {
                minutes         =       Math.floor( seconds / ( 60 * 1000 ) );
                leftover        =       seconds % ( 60 * 1000 );

                seconds         =       Math.floor( leftover / 1000 );
                leftover        =       leftover % ( 1000 );

                tenths          =       Math.floor( leftover / 100 );

                if ( minutes < 10 )     minutes         =       '0' + minutes;
                if ( seconds < 10 )     seconds         =       '0' + seconds;

                return minutes + ':' + seconds + '.' + tenths;
        }

        function MakePrintableTime( milliseconds )
        {
                if ( milliseconds <= 0 )
                        return "Sold!";

                if ( milliseconds <= ( homeStretchTime * 1000 ) )
                        return endIsNearFormat( milliseconds );

                seconds         =       milliseconds / 1000;

                hours           =       Math.floor( seconds / ( 60 * 60 ) );
                leftover        =       seconds % ( 60 * 60 );

                minutes         =       Math.floor( leftover / 60 );
                leftover        =       leftover % 60;

                seconds         =       Math.floor( leftover );

                if ( hours < 10 )       hours           =       '0' + hours;
                if ( minutes < 10 )     minutes         =       '0' + minutes;
                if ( seconds < 10 )     seconds         =       '0' + seconds;

                return hours + ':' + minutes + ':' + seconds;
        }

        function updateTimers()
        {
                now     =       new Date();
                now.setTime( now.getTime() + ServerToLocalTimeOffset );

                for ( i = 0; i < auctionTimers.length; i++ )
                {
                        thisAuctionTimer        =       auctionTimers[i];

                        timeTillEnd             =       ( thisAuctionTimer.End_Time.getTime() - now.getTime() );

                        if ( timeTillEnd <= 0 )
                        {
				if ( ! auctionTimers[i].Container )
				{
					if ( auctionTimers[i].Featured )
						auctionTimers[i].Container	=	document.getElementById( 'auctionTimerSpaceFeatured:' + thisAuctionTimer.Id );
					else
						auctionTimers[i].Container	=	document.getElementById( 'auctionTimerSpace:' + thisAuctionTimer.Id );
				}

				try 
				{
					auctionTimers[i].Container.innerHTML   	=       'Sold!';
				}
				catch (e) {}
                        }       
                        else
                        {
				// for auctions that don't need an update every tenth of a second, only do one once per second.
				if ( ( timeTillEnd <= ( homeStretchTime * 1000 ) ) || ( Math.floor( timeTillEnd / 100 ) % 10 == 0 ) )
				{
					if ( ! auctionTimers[i].Time_Container )
					{
						if ( auctionTimers[i].Featured )
							auctionTimers[i].Time_Container	=	document.getElementById( 'auctionTimerFeatured:' + thisAuctionTimer.Id );
						else
							auctionTimers[i].Time_Container	=       document.getElementById( 'auctionTimer:' + thisAuctionTimer.Id );
					}

					try 
					{
						auctionTimers[i].Time_Container.innerHTML	=	MakePrintableTime( timeTillEnd );
						if ( timeTillEnd <= ( flashyTime * 1000 ) )
						{
							colindex					=	Math.floor( timeTillEnd / 100 ) % 5;
							auctionTimers[i].Time_Container.style.color	=	flashyTimerColors[ colindex ];
						}
					}
					catch (e) {}
				}
			}
                }

                setTimeout('updateTimers()', timersOnScreenUpdate);
        }

        function serverResyncProcess( server_response )
        {
                var mainparts   =       server_response.split(',');

		try 
		{
			if ( mainparts[0] > 0 )
			{
				ServerCurrentTime   =       new Date();         ServerCurrentTime.setTime( mainparts[0] );
				LocalCurrentTime    =       new Date();

				ServerToLocalTimeOffset     =       ServerCurrentTime - LocalCurrentTime;
			}
		}
		catch (e) {}

		try 
		{
			mylist          =       mainparts[1];
			var bids        =       mylist.split('#');
			for ( i = 0; i < bids.length; i++ )
			{
				bid     	=       bids[i];
				var bidparts    =       bid.split(':');

				if ( thisAuctionTimer.Featured )
					outputSpan      =       document.getElementById( 'auctionBidFeatured:' + bidparts[0] );
				else
					outputSpan      =       document.getElementById( 'auctionBid:' + bidparts[0] );
				try 
				{
					outputSpan.innerHTML = '$' + bidparts[1];
				}
				catch (e) {}    
			}
		}
		catch (e) {}

                setTimeout( 'serverResync()', timersServerResync );        
	}

        function serverResync()
        {
                var auctionList         =       '';

                for (i = 0; i < auctionTimers.length; i++)
                {
                        if ( i != 0 )   auctionList += ',';
                        auctionList     +=      auctionTimers[i].Id;
                }

                url     =       timerUpdateURL + '?AuctionList=' + auctionList;

                //ajaxFunction( timerUpdateURL, serverResyncProcess );
                ajaxFunction( url, serverResyncProcess );
        }

        setTimeout( 'updateTimers()', timersOnScreenUpdate );
        setTimeout( 'serverResync()', timersServerResync );   

