function setClock(city, timeZone, isDST, whichClock){
	var timeNow = 'time' + whichClock;
	var time = new Date(); // get the current date and time
	var hour = time.getHours(); // get the hour portion
	var timezoneoffset = time.getTimezoneOffset()/60; // get the time zone offset
	var thisHour = hour + timezoneoffset + timeZone; // calculate the time in the desired location
	
		
	var thisMonth = time.getMonth();
	var thisDay = time.getDay();
	var thisDate = time.getDate();
	
	if ((isDST == 'Yes')&&((thisMonth > 2)&&(thisMonth < 10))){ // adjust hour for Daylight Saving Time
		if (thisMonth == 3){ // add 1 hour if date is after 1st Sunday in April
			switch (thisDay){
				case 0:
					thisHour = thisHour + 1;
					break;
				case 1:
					if (thisDate > 11){
						thisHour = thisHour + 1;}
					break;
				case 2:
					if (thisDate > 12){
						thisHour = thisHour + 1;}
					break;
				case 3:
					if (thisDate > 13){
						thisHour = thisHour + 1;}
					break;
				case 4:
					if (thisDate > 14){
						thisHour = thisHour + 1;}
					break;
				case 5:
					if (thisDate > 15){
						thisHour = thisHour + 1;}
					break;
				case 6:
					if (thisDate > 16){
						thisHour = thisHour + 1;}
					break;
			} // end switch
		} // end if
		else if (thisMonth == 9){ // add 1 hour if date is before last Sunday in October
			switch (thisDay){
				case 0:
					if (thisDate < 25){
						thisHour += 1;}
					break;
				case 1:
					if (thisDate < 26){
						thisHour += 1;}
					break;
				case 2:
					if (thisDate < 27){
						thisHour += 1;}
					break;
				case 3:
					if (thisDate < 28){
						thisHour += 1;}
					break;
				case 4:
					if (thisDate < 29){
						thisHour += 1;}
					break;
				case 5:
					if (thisDate < 30){
						thisHour += 1;}
					break;
				case 6:
					if (thisDate < 31){
						thisHour += 1;}
					break;
			} // end switch		
		} // end else if
		else{
			thisHour += 1; // add 1 hour for all days between months of April and October
		} // end else
	} 		



	var minute = time.getMinutes(); // get the minute portion

	if (city == 'Bagram'){ // adjust for Afghanistan's 0.5 Hr difference
	  if (minute < 30){
	    minute += 30;
	  } else
	  {
	    minute -= 30;
	    thisHour += 1;
	  }
	}

	if (minute < 10){ // add a 'zero' if necessary to display 2 digits
		minute = '0' + minute;}
	var second = time.getSeconds(); // get the second portion
	if (second < 10){ // add a 'zero' if necessary to display 2 digits
		second = '0' + second;}
	
	if (thisHour < 0){ // adjust hour 24 to 0
		thisHour = 0;}
	thisHour = (thisHour % 24); // adjust time to 24 hours or less
	if (thisHour == 24){ // adjust hour 24 to 0
		thisHour = 0;}
	
	if (thisHour < 10){ // add a 'zero' if necessary to display 2 digits
		thisHour = '0' + thisHour;}
	var strTime = ' ' + thisHour + ':' + minute + ':' + second + '   ' + city; // build  the time string
	document.clock.elements[timeNow].value = strTime;
}

function updateClockGMT() {
	setClock('Las Vegas', -8, 'Yes', 'GMT'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClockGMT()',500);
}



function updateClock1() {
	setClock('D.C.', -5, 'Yes', '1'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClock2()',500);
}

function updateClock2() {
	setClock('Hawaii', -10, 'No', '2'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClock3()',500);
}

function updateClock3() {
	setClock('Bagram', +4, 'No', '3'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClock1()',500);
}

function updateClock4() {
	setClock('Baghdad', 3, 'No', '4'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClock5()',500);
}

function updateClock5() {
	setClock('Iwakuni', 9, 'No', '5'); // vars are (city, time difference from GMT, adjust for DST, clock name)
	setTimeout('updateClock4()',500);
}
