

//********************************** JC..STANDALONE,EXTERNAL CLOCKDASH JAVASCRIPT *******************************
//Name:         Dashclock      Orig.Ver: 1.0       Date:08-03-2004   
//Modified:     Rev: 1.2       Dated: 09-15-2004              For use as a standalone, external JavaScript.
//JC'S NOTE::::: IF THIS CODE WILL BE A STANDALONE,EXTERNAL JAVASCRIPT, COMMENT OUT ALL THE LINES THAT ARE
//             NON-JAVASCRIPT,i.e. HTML CODE. ALSO Remove these type of commands: <SCRIPT>,</SCRIPT>,<HEAD>,etc..
//             IF YOU ARE NOT USING THIS AS AN EXTERNAL JAVASCRIPT, THEN NO NEED TO COMMENT
//             OUT ANY OF THOSE LINES.
//****************************************************************************************************************




<!-- THREE STEPS TO INSTALL CLOCK DASH: -->


/*
<!--  JC ****** Is commenting out all these non-JavaScript Code,also SCRIPT commands and some comments.


  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the onLoad event handler into the BODY tag
  3.  Put the last coding into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->


<HEAD>


<SCRIPT LANGUAGE="JavaScript">
    
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  KK Chan -->
<!-- Begin 



   JC.*******....Commented all the above out     -->
 */



var jc_clocktextcolor, jc_citytextname, jc_citytime;   //  JC..08-05-04 Declare these variables, for use by function 
                                                       //  UpdateClocks()  since this external, standalone JavaScript
                                                      //  will be passed some variables, by the Caller.
                                                      //  NOTE:: Not really neccessary!!, But always a Good coding practice.


var timerID ;
function tzone(tz, os, ds, cl)
{
	this.ct = new Date(0) ;		// datetime
	this.tz = tz ;		// code
	this.os = os ;		// GMT offset
	this.ds = ds ;		// has daylight savings
	this.cl = cl ;		// font color
}




 // JC .... The array, "new Array", below contains all your desired City or Location Zones and Info, that you
 //         want to use. Each cell in the array has 4 ELEMENTS:
 //                  Element #0 stores the Text abreviation of the city or Country name.
 //                  Element #1 stores the GMT offset for that City, i.e., +/- GMT
 //                  Element #2 stores the FLAG, ds, to show if the City observes Daylight Savings time or not.
 //                  Element #3 stores the font color.
 // NOTE:: That the variable "ct" will have a count of how many entries are in the array, which means how many City zones.
 //        Variable "ct" will be used later in other functions that we call.



/* JC 08-05-2004. CHANGES ADDED TO SUPPORT THIS NEW EXTERNAL, STANDALONE CLOCKDASH JAVASCRIPT.
                    Changed the NEXT LINE from UpdateClocks()  TO UpdateClocks(jc_clocktextcolor,jc_citytextname,jc_citytime)
                    The calling routine must pass along the desired values, which will be placed in these variables.
*/


function UpdateClocks(jc_clocktextcolor,jc_citytextname,jc_citytime)
{
	var ct = new Array(

		 new tzone('SFO: ', -8, 1, 'lime'),
                 new tzone('TYO: ', +9, 0, 'violet'),
		 new tzone('HKG: ', +8, 0, 'cyan'), 
		 new tzone('BKK: ', +7, 0, 'yellow'), 
		 new tzone('NYC: ', -5, 1, '#FFAA00'), 
		 new tzone('LON: ',  0, 1, 'white'),   //JC..changed it from silver to white...8-05-2004
		 new tzone('SVO: ', +3, 0, 'pink'), 
                 new tzone('KTM: ', +5.75, 0, 'red'), 
                 new tzone('ORLANDO TIME: ', -5, 1, 'blue'),
                 new tzone('DAYTONA BEACH TIME: ', -5, 1, 'blue'),
                 new tzone('GERMANY TIME: ', +1, 1, 'blue'),
                 new tzone('SINGAPORE TIME: ', +8, 0, 'blue'),
                 new tzone('PHILIPPINES TIME: ', +8, 0, 'blue'),
                 new tzone('LONDON TIME: ', 0, 1, 'blue'),
                 new tzone('MALAYSIA TIME: ', +8, 0, 'blue'),
                 new tzone('SEOUL TIME: ', +9, 0, 'blue'),
                 new tzone('PARIS TIME: ', +1, 1, 'blue'),
                 new tzone('AMSTERDAM TIME: ', +1, 1, 'blue'),
                 new tzone('NORTH CALORINA TIME: ', -5, 1, 'blue'),
                 new tzone('SALT LAKE CITY TIME: ', -7, 1, 'blue'),
                 new tzone('ALABAMA TIME: ', -6, 1, 'blue'),
                 new tzone('ALASKA TIME: ', -9, 1, 'blue'),
                 new tzone('PHOENIX TIME: ', -7, 0, 'blue'),
                 new tzone('ATLANTA TIME: ', -5, 1, 'blue'),
                 new tzone('MEMPHIS TIME: ', -6, 1, 'blue')


	) ;


 // JC...  Add as many Cities as desired in the above Array table. NOTE:: The last entry MUST NOT HAVE A COMMA.

      


 // JC ... The function new Date(), which is a standard Microsoft function, will retrive the
 //        current system time and Date, on your system. Also it will know your time zone.
 //        This will be used as the reference for calculating time for all other Zones in the world,
 //        by converting your system's time to GMT then offsetting your current system time with the 
 //        GMT time of the desired CITY, to derive the desired City's local time.
 //        We, thus use your system's Time and Zone, as the reference, to calculate the rest of any desired
 //        City zones, around the world, as long as we know the City's GMT offset.


	



	var dt = new Date() ;	                           // [GMT] time according to machine clock

                                                           // ..JC Note: The new Date (yr,month,day) command, the values are:
                                                           //            For months: 0=JAN, 1=FEB, 2=Mar, 3=April, 4=May,etc
                                                           //            For Days:   0=Sun, 1=Mon, 3=Tue, etc..
  
	var startDST = new Date(dt.getFullYear(), 3, 1) ;  // ..JC.. Use April the 1st,of the CURRENT year as the
                                                           //       start date for calculation.  NOTE:::The preiod between
                                                           //       APRIL 1st  and OCTOBER 31st will be considered
                                                           //       the DAYLIGHT SAVINGS TIME period !!!JC..
                                                           //          
                                                           //       Get the GMTmilliseconds ellapsed since
                                                           //       January 1st 1970. Remember that inorder to eliminate
                                                           //       the vaguaries of the world's time zones,
                                                           //       JavaScript(and Java) Date object stores its
                                                           //       information as GMT time, ie. the date value is
                                                           //       stored as the number of milliseconds before,i.e. +ve
                                                           //       or after, -ve, Zero hours GMT on January 1, 1970 !!!

	while (startDST.getDay() != 0)                     // ..JC..  If April 1st is not a Sunday, i.e. 0=Sunday,then
                                                           //         keep executing the next statement which INCREMENTS
               startDST.setDate(startDST.getDate() + 1) ;  //         the DATE and stores its new Date,until you get to
                                                           //         a Sunday. We are looking for the 1st Sunday in APRIL,
                                                           //         of current year !!??



	var endDST = new Date(dt.getFullYear(), 9, 31) ;   // ..JC.. Use, 9 i.e. October 31st,of the CURRENT year as the
                                                           //       End date for calculation.  NOTE:::The preiod between
                                                           //       April 1st  and October 31st will be considered
                                                           //       the DAYLIGHT SAVINGS TIME period !!!JC..
                                                           //             
	while (endDST.getDay() != 0)                       // ..JC.. If October 31st is not a Sunday, i.e. 0=Sunday,
                                                           //        then keep executing the next statement
		endDST.setDate(endDST.getDate() - 1) ;     //        which DECREMENTS the DATE and store its Date,until 
                                                           //        you get to a Sunday. WE are looking for the LAST Sunday
                                                           //        in October, of the current year!!.


	var ds_active ;		// DS currently active

	if (startDST < dt && dt < endDST)                 // ..JC..IF the current date, dt, as obtained earlier, locally on 
                                                          //       this PC,is between the new adjusted StartDST date and 
                                                          //       the new adjusted EndDst date, then set a
                                                          //       FLAG to indicate that we are in DAYLIGHT SAVINGS 
                                                          //       time period.

		ds_active = 1 ;                           

	else

		ds_active = 0 ;                          // ..JC..  Otherwise set a FLAG to indicate that we are NOT in
                                                         //         DAYLIGHT SAVINGS TIME period.





	// Adjust each clock offset if that clock has DS and in DS
                                                          // ...JC..  Perform an adjustement on each of our current region
                                                          //  or City clocks,i.e. as set earlier in the array,
                                                          //  var ct = new Array(),  ONLY IF we are currently in
                                                         //   DAYLIGHT SAVINGS TIME period  AND the regions DS flag,
                                                         //  in the Array, is also set, ie, element #2 in
                                                         //  the array is = 1, i.e. the region observes  DAYLIGHT SAVINGS. 

	 for(n=0 ; n<ct.length ; n++)
           
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;



	// compensate time zones

	gmdt = new Date() ;                             //  ...JC..   Store the new adjusted timezones Date and Time back,
                                                        //     in GMT milliseconds format !!.




 // JC ... Notice that the "ct" in here, refers to the number of entries that were already calculated as
 //        being in the  main array, i.e. "new Array"


	for (n=0 ; n<ct.length ; n++)                   // ...JC... Now update all the current defined Time regions
                                                        //          or City clocks appropriately. i.e. We have used  our
                                                        //          local PC's Date and Time, to adjust the rest of the 
                                                        //          regions!!


		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;   



    

   <!-- These are comments by jc    -->

// JC ... Notice that the"0" in "clock0" refers to the position on the line on the screen where this 
//        City's zone time will be put:       0 means the 1st on the line, 1= 2nd on line,2= 3rd on line and 4= laston line 
//        For the 2nd line, the positions are:4 means the 1st on 2nd line, 5 for 2nd on 2nd line, 6 for 3rd 
//        and 7 for last on 2nd line.
//        ALSO NOTE: The "0" in ct[0].cl means the text color to use,when displaying the Time, i.e 0,1,2,3...etc.
//                   The "0" in ct[0].tz means the Text abbreviation of the City, as entered in the "new Array"
//                                   i.e. the first entry within that Array will be 0, the 2nd will be 1,etc..
//                   The "0" in ct[0].ct Is the actual time that will be printed in this position line, on the screen.
//                           i.e. Again, as entered in "new Array", 0 = the time for the 1st entry within the Array,
//                                       1 = the time for the 2nd entry within the Array, etc..
//                 AS you can see, you can display anything at any location as desired, you could even print"NYC"
//                 above should be Singapore time, etc..  TO KEEP THINGS EASY, USE SAME VARIABLES throught the following line
//     For example: ct [0].cl, ct[0].tz and ct[0].ct  when you want San Frasisco,SFO time,i.e the 1st entry in the Array.
//              or  ct [2].cl, ct[2].tz and ct[2].ct  when you want Hong Kong time, HKG i.e. the 3rd entry in the Array. 



/* JC 08-05-2004 ... CHANGES ADDED TO SUPPORT THIS NEW EXTERNAL, STANDALONE CLOCKDASH JAVASCRIPT.
                       I am changing this external javascript's line to use my own variables, so that I can use
                     different HTML scripts that can call this same external javascript file,by just passing it
                     the desired City variables, etc..I can thus have any desired City's clock, for example,like this

                    
                     1. Because this external javascript file is now being invoked from an HTML script ,
                        the values needed for the next javascript line of code, will be in variables, passed to it 
                        by the calling HTML file, instead of being the normal FIXED values assigned, for example:

                        [  document.all.Clock0.innerHTML =
                          '<font color="' + ct[5].cl + '">' + ct[8].tz + ClockString(ct[8].ct) + '</font>' ; ]       

                     The calling routine MUST pass along the variables when it invokes the UpdateClocks() function,
                     by using the function as, for example,: UpdateClocks(5,8,8) , instead of the normal UpdateClocks().
                     

                     I have to pass along the values that will tell it  which City's time, to display.
                     Normaly, the javascript uses this FIXED value line, to display the desired City's time,
                     for example, for Orlando, by using the javascript's "new Array()" , you can see that it is:
  
                     [  document.all.Clock0.innerHTML =
                          '<font color="' + ct[6].cl + '">' + ct[8].tz + ClockString(ct[8].ct) + '</font>' ; ]
 
                     but I am changing the external javascript's line to use my own variables, so that I can use
                     different HTML scripts that can call the same external javascript file,by just passing it
                     the desired City variables, etc..I can thus have any desired City's clock, for example,like this:
    
                     [  document.all.Clock0.innerHTML =
                         '<font color="' + ct[jc_clocktextcolor].cl + '">' + ct[jc_citytextname].tz 
                                                              + ClockString(ct[jc_citytime].ct) + '</font>' ; ]

 */






	 document.all.Clock0.innerHTML =

	'<font color="' + ct[jc_clocktextcolor].cl + '">' + ct[jc_citytextname].tz + ClockString(ct[jc_citytime].ct) + '</font>' ;



  // Commnets by JC... When using only a single City or Zone time display instead of all 8, comment out
  //                   the rest of these Or if using just 2 of them, comment out which ones you dont want,
  //                   and set the ct[] variables, appropriately.... 3-4-04 


	// document.all.Clock1.innerHTML = 
		// '<font color="' + ct[1].cl + '">' + ct[1].tz + ClockString(ct[1].ct) + '</font>' ; 

	// document.all.Clock2.innerHTML =
		// '<font color="' + ct[2].cl + '">' + ct[2].tz + ClockString(ct[2].ct) + '</font>' ;

	// document.all.Clock3.innerHTML =
		// '<font color="' + ct[3].cl + '">' + ct[3].tz + ClockString(ct[3].ct) + '</font>' ;

	// document.all.Clock4.innerHTML =
		// '<font color="' + ct[4].cl + '">' + ct[4].tz + ClockString(ct[4].ct) + '</font>' ;

	// document.all.Clock5.innerHTML =
		//'<font color="' + ct[5].cl + '">' + ct[5].tz + ClockString(ct[5].ct) + '</font>' ;

	// document.all.Clock6.innerHTML =
		// '<font color="' + ct[6].cl + '">' + ct[6].tz + ClockString(ct[6].ct) + '</font>' ;

	// document.all.Clock7.innerHTML =
		// '<font color="' + ct[7].cl + '">' + ct[7].tz + ClockString(ct[7].ct) + '</font>' ;


	timerID = window.setTimeout("UpdateClocks()", 1001) ;




  // JC...08-05-2004...The following line is Just for Debug purpose only, comment out when not in use!!
/*
   alert ("JC debugging,The caller passed us these values of jc_clocktextcolor, jc_citytextname, and jc_citytime are: "
                  + jc_clocktextcolor + jc_citytextname + jc_citytime );
*/




}    //END OF THE FUNCTION UpdateClocks()



function ClockString(dt)
{
	var stemp, ampm ;

	var dt_year = dt.getUTCFullYear() ;
	var dt_month = dt.getUTCMonth() + 1 ;
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours() ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;
	
	dt_year = dt_year.toString() ;
	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		if (dt_hour == 0) dt_hour = 12 ;		
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
		if (dt_hour == 0) dt_hour = 12 ;		
	}
	
	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;
	
	if (dt_second < 10)
		dt_second = '0' + dt_second ;

	stemp = dt_month + '/' + dt_day + '/' + dt_year.substr(2,2) ;
	stemp = stemp + ' ' + dt_hour + ":" + dt_minute + ":" + dt_second + ' ' + ampm ;
	return stemp ;
}



/*    JC NOTE::::: IF THIS CODE WILL BE A STANDALONE,EXTERNAL JAVASCRIPT,THEN COMMENT THESE OUT< ELSE LEAVE IN.
<!--  JC ****** ....Is commenting out all these non-JavaScript Code,also SCRIPT commands, and some comments.
//  End -->
</script>
</head>

      JC *******....Commented the above 3 lines out     -->
*/



//***************************************************************************************************************
//JC NOTE::::: IF THIS CODE WILL BE A STANDALONE,EXTERNAL JAVASCRIPT, COMMENT OUT THE REST OF THIS NON-JAVASCRIPT
//             HTML CODE INTO THE BODY OF YOUR WEB's HTML CODE. YOUR HTML SCRIPT WILL HAVE TO CALL THIS
//             JAVASCRIPT. IF YOU ARE NOT USING THIS AS AN EXTERNAL JAVASCRIPT, THEN NO NEED TO COMMENT
//             THE REST OF THE CODE OUT, JUST PASTE THIS ENTIRE TEXT FILE INTO YOUR HTML PAGE>
//***************************************************************************************************************

/*  JC ****** Is Commenting OUT ALL OF THE REST of this code,i.e. non-JavaScript Code.




<!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->


<!-- JC ... 05-07-2004... Put all your Javascript functions that ARE triggered with the onLoad command in here,on same line,                           i.e.if they use the onLoad commands,
                          otherwise, the last one overwrites the rest, and some of the javascripts wont work right, if you                           don't load them, this way !!! e.g. if you only put one of them here. 
                          Currently I have 2 Javascripts, that need to be triggered, immediately after the
                          main Web page is loaded; updateClocks(), which is within this main page, and initRollovers(),
                          which is within my script, JC_rollover.js; REMEMBER to disable the onLoad.window command
                          within that jc_rollover.js because dont need it any more, we are now doing it here.
                          My third javascript that I am using, JC_RightClickDisable.js, doesnt use the onLoad command
                          so there is no need to include it here.
-->


<BODY onLoad="UpdateClocks();initRollovers()">



<!-- STEP THREE: Copy this code into the BODY of your HTML document  -->


<!--
 JC ...comments: The WIDTH %, below, refers to HOW MUCH OF AN ENTIRE DISPLAY LINE TO USE, 100% means the whole line
 will be utilized to show the clock or clocks, 4 maximum on a line i.e. clock 0 to 3 on the first line
 and clocks 4 to 7 on the 2nd line. Each of the 2 lines can have separate border, spacing or width, if desired.
-->


<table border="10" cellspacing="0" width="100%">

  <tr bgcolor="#ff6600" style="font-family: Verdana, Tahoma, Arial; font-size: x-small">

    <td ID="Clock0"  width="100%"> </td>  


<!--
 JC ...comments: Turn off the row, <tr>, if only using one City Time zone space for display.
                 You can put this after the 1st,2nd,3rd or keep it after the
                 4th Clock,as normal, to display, 1,2,3 or all 4 Time area zones of the 
                 first display line.
                 In this case I am only putting up one clock for one city, so I am using
                 only the first one, above, i.e. CLOCK0, and turning the row off i.e. /TR
                 so that the clock box spaces for clock1,clock2 and clock3 will not be displayed
                 in this 1st Clock display line. So within the top clock display line, I am
                 only using 1 of the 4 available clock display spaces, i,e, cells.
-->


 </tr>

    <td ID="Clock1" width="25%" > </td>  

    <td ID="Clock2" width="25%" > </td>

    <td ID="Clock3" width="25%" > </td>
   

  </tr>  




<!--
  JC ...Comments: Turn off the entire 2nd line of clock displays, if only using ONLY the top line.
                  Commenting out the entire 2nd, i.e. bottom, part of the display table, 
                  dont need it.. I will only use the top line to display the City Time.
                  So, the next 6 lines are commented out and will do nothing.. 03/03/2004 .


  <tr bgcolor="#000000" style="font-family: Verdana, Tahoma, Arial; font-size: x-small">
    <td ID="Clock4" width="25%" >   </td>
 
    <td ID="Clock5" width="25%" >   </td>

    <td ID="Clock6" width="25%" >   </td>

    <td ID="Clock7" width="25%" >   </td>

  </tr>

-->              <!-- JC... End of commented out code  -->      


 </tr>

</table>         <!-- JC.... Inserted this for end of table. i.e.the inner table that has the clock, not
                             the main table started by the dbd-cool-tabs-blue theme.   -->



<!--   JC ..Comment out this message ....

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

-->    <!-- JC... End of commented out code  -->
<!-- Script Size:  4.83 KB   JC.. That's how big the original javascript code was, before any additions-->


</body>
</html>
<!-- JC ... The CLOCKDASH Clock Code ENDS here.     -->


JC ****** COMMENTED ALL THE ABOVE HTML CODE, SINCE WE ARE USING THIS JAVASCRIPT AS AN EXTERNAL< STANDALONE SCRIPT.i.e. non-JavaScript Code, is commented out.
*/