<!-- Begin

var timerID = null;

var sb = 0 ;

var update = 0 ;

var updateDel = 0 ;




function tzone(tz, os, ds, cl)

{

	this.ct = new Date(0) ;		// datetime

	this.tz = tz ;				// Location code

	this.os = os ;				// GMT offset

	this.ds = ds ;				// has daylight savings

	this.cl = cl ;				// font color

}


function market(mz, oh, om, ch, cm, cl, st, od)

{

	this.mz = mz ;				// Market code

	this.oh = oh ;				// Open Hour

	this.om = om ;				// Open Minute

	this.ch = ch ;				// Close Hour

	this.cm = cm ;				// Close Minute

	this.cl = cl ;				// font color

	this.st = st ;				// Open - Closed status
	
	this.od = od ;				// Mon - Fri
}




var ssv = 0 ;

var nsv ;

var flag ;



function UpdateClocks() 		// main function started with load
{

	


	
	if(parent.chart)
	
	{
	
		// check if base metals to be displayed

	
		if(showBaseDisplay())
		
		{
		
			sb = 1
			
		} 
		
		else
		
		{
		
			sb = 0
		
		} ;
		
	} ;
	

//hong kong		+8 	mon 00:30	9:00
//NY			-5 	mon 13:20	5:10
//london		0 	mon 08:30	7:30
//sydney		+10	mon 00:00	6:00
//zurich		+1	mon 07:00	9:00
//globex		-5	sun 23:00	23:15

	var markets = [];				// markets array [each market] [open gmt day, open gmt hour, open gmt minute, hours open, minutes open, gmt offset, has daylight time, daylight start, daylight end, color]
		markets[0] = ['Hong Kong: ', 1, 0, 30, 9, 0, 8];
		markets[1] = ['New York: ', 1, 13, 20,5, 10, -5];
		markets[2] = ['London: ', 1, 8, 30, 7, 30, 0];
		markets[3] = ['Sydney: ', 1, 0, 0, 6, 0, 10];
		markets[4] = ['Zurich: ', 1, 7, 0, 9, 0, 1];
		markets[5] = ['NY Globex: ', 0, 23, 0, 23, 15, -5];
	
//	for (n=0; n=5; n++)
//	{
//		for (d=0; d=1; d++)
//		{
			//alert('location ' + markets[n][d] );
//		}
//	}
	
	
	
	
	var ct = new Array( 			// Location, Hour Offset, Has Daylight Savings, Color

		new tzone('Hong Kong: ', +8, 0, 'cyan'),
		new tzone('New York: ', -5, 1, '#FFAA00'),
		new tzone('London: ',  0, 2, 'yellow'),
		new tzone('Sydney: ', +10, 3, 'violet'),
		new tzone('Zurich: ', +1, 2, 'silver'),
		new tzone('NY Globex: ', -5, 1, 'pink')
	) ;




	var mt = new Array(			// Market, Open Hour, Open Minute, Close Hour, Close Minute, Color, Status, M-F

						// Hong Kong open 8:30 AM - 5:30 PM local time
						// New York open 8:20 AM - 1:30 PM local time
						// London open 8:30 AM - 4:00 PM local time
						// Sydney open 9:00 AM - 3:00 PM local time
						// Zurich open 8:00 AM - 5:00 PM local time
						// old NY Globex open 2:00 PM - 8:00 AM Mon-Thu, 7:00 PM - 8:00 AM Sun local time
						// new NY Globex open 6:00 PM - 11:59 PM Sun-Thu, 12:00 AM - 5:15 PM Mon-Fri local time

	
		new market('Hong Kong: ', '8', '30', '17', '30', 'red', 'CLOSED', '2'),
		new market('New York: ', '8', '20', '13', '30', 'red', 'CLOSED', '2'),
		new market('London: ', '8', '30', '16', '00', 'red', 'CLOSED', '2'),
		new market('Sydney: ', '9', '00', '15', '00', 'red', 'CLOSED', '2'),
		new market('Zurich: ', '8', '00', '17', '00', 'red', 'CLOSED', '2'),
		new market('NY Globex: ', '18', '00', '17', '15', 'red', 'CLOSED', '2')
	) ;
	
	var dt = new Date() ;					// [UTC] time according to machine clock
	var startDST = new Array(6) ;			// Daylight Savings Time start date for each location
	var endDST = new Array(6) ;				// Daylight Savings Time end date for each location


	for(n=0 ; n<6 ; n++) {			// determine the start date of daylight savings time


		if (ct[n].ds == 0){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 11, 31) ;  //  week Hong Kong daylight savings time starts
			
			
		} else if (ct[n].ds == 1){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 2, 15) ;  // week New York daylight savings time starts second Sun in March
			
			
		} else if (ct[n].ds == 2){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 2, 31) ;  // week London daylight savings time starts last Sun in March
			

		} else if (ct[n].ds == 3){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 9, 31) ;  // week Sydney daylight savings time starts last Sun in October
			

		} else if (ct[n].ds == 4){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 2, 31) ;  // week Zurich daylight savings time starts last Sun in March
			
			
		} else if (ct[n].ds == 5){
		
			startDST[n] = new Date(dt.getUTCFullYear(), 2, 15) ;  // week New York Globex daylight savings time starts second Sun in March
			
			
		} ;
				
		
		if (n > 0) {
		
			while (startDST[n].getDay() != 0)								// Determine the date for Sunday

				startDST[n].setDate(startDST[n].getDate() + 1) ;

		}
		
	} ;



	for(n=0 ; n<6 ; n++) {			// determine the end date of daylight savings time


		if (ct[n].ds == 0){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 0, 1) ;  //  week Hong Kong daylight savings time ends
			
		} else if (ct[n].ds == 1){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 10, 7) ;  // week New York daylight savings time ends first Sun in November
			
		} else if (ct[n].ds == 2){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 9, 31) ;  // week London daylight savings time ends last Sun in October
			
		} else if (ct[n].ds == 3){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 2, 31) ;  // week Sydney daylight savings time ends last Sun in March
			
		} else if (ct[n].ds == 4){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 9, 31) ;  // week Zurich daylight savings time ends last Sun in October
			
		} else if (ct[n].ds == 5){
		
			endDST[n] = new Date(dt.getUTCFullYear(), 10, 7) ;  // week New York Globex daylight savings time ends first Sun in November
			
		} ;
		

		if (n > 0) {
		
			while (endDST[n].getDay() != 0)								// Determine the date for Sunday

				endDST[n].setDate(endDST[n].getDate() - 1) ;
				
		}
		
	} ;
	


	var ds_active = new Array(6) ;		// check if daylight savings time is currently active
	
	ds_active[0] = 0 ;
	
	
	for(n=1 ; n<6 ; n++) {

		if (n == 3 && !(endDST[n] < dt && dt < startDST[n]))	// if Sydney and NOT between (end of DST and start of DST)

			ds_active[n] = 1 ;  // yes

		else if (n < 3 && startDST[n] < dt && dt < endDST[n])		// else if (NY, London) and between (start of DST and end of DST)

			ds_active[n] = 1 ;  // yes

		else if (n > 3 && startDST[n] < dt && dt < endDST[n])		// else if (Zurich, Globex) and between (start of DST and end of DST)

			ds_active[n] = 1 ;  // yes

		else

			ds_active[n] = 0 ;  // no
			
	}




	// Adjust each clock offset if that clock has DS and in DS.

	for(n=1 ; n<ct.length ; n++) if (ct[n].ds !== 0 && ds_active[n] == 1) ct[n].os++ ;
				


	// compensate time zones
 
	gmdt = dt ;

	for (n=0 ; n<ct.length ; n++)

		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;



	// check if market is open
	
	var mdt ;
	var mdt_dow ;
 	var mdt_hour ;
 	var mdt_minute ;
	
	for (n=0 ; n<mt.length ; n++)		// for each market
	{	
		mdt = ct[n].ct ;
		mdt_dow = mdt.getUTCDay() ;
	
 		if (0 < mdt_dow && mdt_dow < 6) 				// check id M - F
		
 		{
 			od = 1 								// yes
 			
 		}
		
 		else od = 0 ;								// no
		
		
 		mdt_hour = mdt.getUTCHours() ;
 		
 		mdt_minute = mdt.getUTCMinutes() ;
 		
 		
		// check if market open hours
		
 		if 

 		(										// open market day
 		
	 			(										// not NY Globex market
 		
 					 n<5					
 			
 				&&									// AND
 				
 					(									// day is M-F
 					
 					od == 1

 					)
 				
 				&& 										// AND
 			
					(  										// after open time
 				
 						(
 					
 							mt[n].oh < mdt_hour
 						
 						)
 				
 					||
 				
 						(
 						
 							(mt[n].oh - 1) < mdt_hour
 					
 						&& 
 				
 							(mt[n].om - 1) < mdt_minute
 						
 						)
 				
 					)  										// end after open time
 
 				
 				&& 										// AND
 			
 					( 										// before close time
 				
 						(
 					
 							mdt_hour < (mt[n].ch)
 						
 						)
 					
 					||
 					
 						(
 							
 							
 							mdt_hour -1 < mt[n].ch
 					
 						&&
 					
 							mdt_minute < mt[n].cm
 					
 						)
 					
 					) 										// end before close time

 			  
 				)										// end not NY Globex market

 			
			|| 										// OR
 		
 				(										// NY Globex market
 				
 					n == 5
 			
 				&& 
 			
					(										// day
					
						(										// day is Sunday
				
							mdt_dow == 0
					
						&&										// AND
				
							(  										// after open time
 				
 								mt[n].oh < mdt_hour
 				
 							|| 
 				
 								(
 							
 									(mt[n].oh - 1) < mdt_hour
 						
 								&& 
 					
 									(mt[n].om - 1) < mdt_minute
 						
 								)
 				
 							)  										// end after open time
 							
 						)										// end day is Sunday

 				
 					||										// OR
 					
						(										// day is Monday thru Thursday
 			
							0 < mdt_dow && mdt_dow < 5
 				
						&&										// AND
 			
 							(										// before close or after open )
 				
 					
 								( 										// before close time
 				
 									(
 					
 										mdt_hour < (mt[n].ch)
 						
 									)
 					
 								||
 					
 									(
 							
 							
 										mdt_hour -1 < mt[n].ch
 					
 									&&
 					
 										mdt_minute < mt[n].cm
 					
 									)
 					
 								) 										// end before close time
	
 							||										// OR
 							
 				
								(  										// after open time
 				
 									(
 					
 										mt[n].oh < mdt_hour
 						
 									)
 							
 								||
 				
 									(
 						
 										(mt[n].oh - 1) < mdt_hour
 					
 									&& 
 				
 										(mt[n].om - 1) < mdt_minute
 						
 									)
 				
 								)  										// end after open time
 								
 				
 							)										// end not between close and open
 							
				
 						)										// end day is Tuesday thru Thursday


		 			||										// OR
		 			
 			
 						(										// day is Friday
 			
							mdt_dow == 5
					
						&&										// AND
						
				
 							( 										// before close time
 				
 								(
 					
 									mdt_hour < (mt[n].ch)
 								
 								)
 					
 							||
 					
 								(
 							
 							
 									mdt_hour -1 < mt[n].ch
 					
 								&&
 					
 									mdt_minute < mt[n].cm
 					
 								)
 					
 							) 										// end before close time

 				
 						)										// end day is Friday
 						

 					)										// end day
 					
 					
 				)										// end NY Globex market
 				

		
		)										// end open market day
 		 		
 		{
 			mt[n].cl = 'lime'
			
 			mt[n].st = '<b>-OPEN-</b>'
 			
		} ;
		

		
 		

	} ;

		if ( (mt[0].st == 'CLOSED') && (mt[1].st == 'CLOSED') && (mt[2].st == 'CLOSED') && (mt[3].st == 'CLOSED') && (mt[4].st == 'CLOSED') && (mt[5].st == 'CLOSED') ) 
		{ 
			update = 0 
			
			if (parent.counter) 
			{

				if (update == 0)
				{
					parent.counter.document.getElementById("Status").innerHTML = 
					'<font face="Arial" color="gold" size="1"><b><span style="background-color: #000000"><font color="#FF0000">&nbsp;> </font>All markets closed <font color="#FF0000"><&nbsp;</font></span></b></font>'

				}
				
			
			}
		} 
		
		else
		
		{ 
		
			update = 1
			
			if (parent.counter) parent.counter.document.getElementById("Status").innerHTML =
			'<font face="Arial" color="lime" size="1"><b><span style="background-color: #000000">&nbsp;>&nbsp; Markets are open &nbsp;<&nbsp;</span></b></font>'
 
		} ;


	document.getElementById("Clock0").innerHTML =		// Sydney

		'&nbsp;<font color="' + ct[3].cl + '">' + ct[3].tz + '&nbsp;&nbsp;&nbsp;' + ClockString(ct[3].ct) + '</font><br><font color="' + mt[3].cl + '">' + '&nbsp;' + mt[3].st + '</font><br>&nbsp;' ;



	document.getElementById("Clock1").innerHTML =		// Hong Kong

		'&nbsp;<font color="' + ct[0].cl + '">' + ct[0].tz + ClockString(ct[0].ct) + '</font><br><font color="' + mt[0].cl + '">' + '&nbsp;' + mt[0].st + '</font><br>&nbsp;' ;



	document.getElementById("Clock2").innerHTML =		// Zurich

		'&nbsp;<font color="' + ct[4].cl + '">' + ct[4].tz + '&nbsp;&nbsp;&nbsp;' + ClockString(ct[4].ct) + '</font><br><font color="' + mt[4].cl + '">' + '&nbsp;' + mt[4].st + '</font><br>&nbsp;' ;



	document.getElementById("Clock3").innerHTML =		// London

		'&nbsp;<font color="' + ct[2].cl + '">' + ct[2].tz + '&nbsp;&nbsp;&nbsp;' + ClockString(ct[2].ct) + '</font><br><font color="' + mt[2].cl + '">' + '&nbsp;' + mt[2].st + '</font><br>&nbsp;' ;



	document.getElementById("Clock4").innerHTML =		// New York

		'&nbsp;<font color="' + ct[1].cl + '">' + ct[1].tz + '&nbsp;' + ClockString(ct[1].ct) + '</font><br><font color="' + mt[1].cl + '">' + '&nbsp;' + mt[1].st + '</font><br>&nbsp;' ;



	document.getElementById("Clock5").innerHTML =		// NY Globex

		'&nbsp;<font color="' + ct[5].cl + '">' + ct[5].tz + ClockString(ct[5].ct) + '</font><br><font color="' + mt[5].cl + '">' + '&nbsp;' + mt[5].st + '</font>' ;


// changed delay from 1.001 seconds to 10 seconds
	timerID = window.setTimeout("UpdateClocks()", 10000) ;

}



function ClockString(dt)

{

	var stemp, ampm ;
	var dow = new Array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")


	var dt_year = dt.getUTCFullYear() ;

	var dt_month = dt.getUTCMonth() + 1 ;
	
	var dt_dow = dt.getUTCDay() ;

	var dt_day = dt.getUTCDate() ;

	var dt_hour = dt.getUTCHours() ;

	var dt_minute = dt.getUTCMinutes() ;

	var dt_second = dt.getUTCSeconds() ;	
	
	var dt_sdow ;
	
	
	
	dt_sdow = dow[dt_dow] ;

	dt_year = dt_year.toString() ;
	
	if (showMilitaryTime()) {

		if (0 <= dt_hour && dt_hour < 12)		// convert to 12 hour time

		{

			ampm = 'AM' ;

			if (dt_hour == 0) dt_hour = 12 ;
			
			if (dt_hour < 10)							// add leading space if hour is less than 10

				dt_hour = '&nbsp;' + dt_hour ;

					

		} else {

			ampm = 'PM' ;

			dt_hour = dt_hour - 12 ;

			if (dt_hour == 0) dt_hour = 12 ;
			
			if (dt_hour < 10)							// add leading space if hour is less than 10

				dt_hour = '&nbsp;' + dt_hour ;

	
		}
		
		
	} else {
	
		ampm = ''
		

		if (dt_hour < 10)						// add leading 0 if hour is less than 10

			dt_hour = '0' + dt_hour ;

		
	} ;
	
			

	if (dt_minute < 10)						// add leading 0 if minutes is less than 10

		dt_minute = '0' + dt_minute ;
		

	
	if (dt_second < 10)						// add leading 0 if seconds is less than 10

		dt_second = '0' + dt_second ;



	stemp = dt_sdow ;

	stemp = stemp + '. ' + dt_hour + ":" + dt_minute + ' ' + ampm ;

	return stemp ;

}





function showMilitaryTime() {

	if (document.form.showMilitary[0].checked) {
	
		return false;

	}
		
		return true;
		
}




function showBaseDisplay() 

{

	if (document.form1.showBase[0].checked) {
	
		return true;

	} 
		
	else
		
	{
		
		return false;
			
	}
		
}





//  End -->

