/*************************
Show current Clock

the form and its text input fields must have the following ids "clock", "day", "time"
Note: the form must be declared before using this codes
usage: 
    1. make script link in head part of html page
			<script language="JavaScript" TYPE="text/javascript" src="clock.js"> </script>
			
	2. copy the code below and paste where you want to show clock

	<form action="" id="clock" style="text-align:center; margin:8% 0;" >
		<input type="text" size="24" id="day"  style="border:0; background:none;"/>&nbsp;
		<input type="text" size="5"  id="time" style="border:0; background:none;"/>&nbsp;
	</form>
	<script> tick(); </script>

	3. if clock is put inside a table, the structure is
		<form>
			<td>
				<input />
				<input /?
			</td>
		</form>
		
****************************/

var tic = null,
	zone = new Date().getTimezoneOffset() / 60,
	days = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
	months = [ 'January', 'February', 'March', 'April', 'May',
			  'June', 'July', 'August', 'September', 'October', 'November', 'December' ];

function lz( n ) { return n<=9 ? '0' + n : n; }

function tick() {
var f = document.forms.clock,
	h = new Date(),
	i = h.getHours() + zone,
	s = ':' + lz( h.getMinutes() ) + ':' + lz( h.getSeconds() );

	f.day.value = days[ h.getDay() ] + ' ' + h.getDate() + ' ' + 
					months[ h.getMonth() ] + ' ' + h.getFullYear() + ' ';
					
	f.time.value = lz( h.getHours() ) + s;
	
	tic = window.setTimeout( 'tick();', 400 );
}

