

	var widthoftextbox;
	var nFlag;
	
	// The browser deal with time in different manners therefore we have to compensate for this.
	if ((navigator.appVersion.indexOf('MSIE 3') == -1))
	{
		nFlag = 1;
		widthoftextbox = 53;
	}
	
	else
	{
		nFlag = -1;
		widthoftextbox = 133;
	}
    
	// Netscape and Explorer display widths of text boxes differently
	function textboxwidth()
	{	
		return widthoftextbox;
	}
		
	
	// Converts a one digit number into a two digit number by simply adding a '0' 
	// before it. 
	function padout( number ) 
	{ 
		return( (number < 10) ? '0' + number : number ); 
	}
     	
	
	
	// Returns the name of the day that is represented by the number passed to the function. 0 represents Sunday, 1
	// represents Monday, etc....
	function dayNumToName(nNum) 
	{
		switch (nNum) 
		{
			case 0: 
				return 'Sun';
			case 1: 
				return 'Mon';
			case 2: 
				return 'Tue';
			case 3: 
				return 'Wed';
			case 4: 
				return 'Thu';
			case 5: 
				return 'Fri';
			case 6: 
				return 'Sat';					
		}
	}
	
	
	
	
	
	// Returns the name of the month that is represented by the number passed to the function. 0 represents Jan, 1
	// represents February, etc....
	function monthNumToName( nNum ) 
	{
		switch (nNum) 
		{
			case 0:  
				return 'Jan';
			case 1:  
				return 'Feb';
			case 2:  
				return 'Mar';
			case 3:  
				return 'Apr';
			case 4:  
				return 'May';
			case 5:  
				return 'Jun';
			case 6:  
				return 'Jul';
			case 7:  
				return 'Aug';
			case 8:  
				return 'Sep';
			case 9:  
				return 'Oct';
			case 10: 
				return 'Nov';
			case 11: 
				return 'Dec';
		}
	}

	

	
	
	
	
	// Formats the hours.
	function formatHour( nHour ) 
	{
		var tmpStr = '';
		
		if (nHour > 12)
			nHour -= 12;

		//if (nHour < 10)
			//tmpStr = '0';
			
		return( tmpStr + nHour );
	}

	
	
	
	
	// Formats seconds
	function formatMinNSeconds( minSecs ) 
	{
		var tmpStr = '';
		
		if (minSecs < 10)
			tmpStr = '0';
			
		return( tmpStr + minSecs );
	}

	
	
	
	// Adds the relevent 'am' or 'pm letters to the time.
	function formatAmPm(nHour) 
	{
		var tmpStr = 'am';
		
		if (nHour > 11)
			tmpStr = 'pm';

		return( tmpStr );
	}
	
		
	
	
	// Formats the time, basically adds commas and a '-' to the date and time
	function formatLocalTime( strLocalTime ) 
	{	
		return( strLocalTime.substring( 0, 10 ) +', '+ strLocalTime.substring( strLocalTime.length-5, strLocalTime.length )+' - '+strLocalTime.substring( 10, strLocalTime.length-5 ));
	}
	
	
	
	
	// Gets the current date and time from the browser and adds the GMT offset time to calculate the GMT time, then adds the GMT-off-set 
	// of the city selected. This calculates the tmie of the city selected.
	function strDateTime( theDate, givenGmtOffset ) 
	{
     	with (theDate) 
		{
			return( formatDateToStr( new Date( getTime() + getTimezoneOffset() * nFlag *60*1000 + givenGmtOffset *60*1000 )));     		
     	}
	}
	

	

	
	// Turns the date passed to the function into a string.
	function formatDateToStr( cityDate ) 
	{
		with (cityDate) 
		{
			return( formatHour(getHours()) +':'+ formatMinNSeconds(getMinutes())+':'+formatMinNSeconds(getSeconds()) + ' '+
					formatAmPm( getHours())	);
		}
	}
	
	
	
	
	
	
	// Calculates the time for LA, NY, TK, GMT and the city selected by the user.
	function displayTime() 
	{
		var curDate = new Date();
		document.TimeTextBoxes.GMTTimeTextBox.value = strDateTime( curDate, "60" );
		
	}

