///////////////////////////////////////////////////////////
/////////////// CONFIGURATION /////////////////////////////

	// Set the font face
	var myfont_face = "Times New Courier, seraf";

	// Set the font size (in point)
	var myfont_size = "13";

	// Set the font color
	var myfont_color = "#000000";
	
	// Set the background color
	var myback_color = "#C6C6FF";

	// Set the text to display before the time
	var mypre_text = "In Israel it's ";

/////////////// END CONFIGURATION /////////////////////////
///////////////////////////////////////////////////////////

// Global variable definitions
//	var inNode;

// The following arrays contain date display text
	var DaysOfWeek = new Array(7);
		DaysOfWeek[0] = "Sun";
		DaysOfWeek[1] = "Mon";
		DaysOfWeek[2] = "Tue";
		DaysOfWeek[3] = "Wed";
		DaysOfWeek[4] = "Thu";
		DaysOfWeek[5] = "Fri";
		DaysOfWeek[6] = "Sat";

	var HebDaysOfWeek = new Array(7);
		HebDaysOfWeek[0] = "Yom Rishon";
		HebDaysOfWeek[1] = "Yom Sheni";
		HebDaysOfWeek[2] = "Yom Shlishi";
		HebDaysOfWeek[3] = "Yom R'vi'i";
		HebDaysOfWeek[4] = "Yom Chamishi";
		HebDaysOfWeek[5] = "Yom Shishi";
		HebDaysOfWeek[6] = "Shabbat";

	var MonthsOfYear = new Array(12);
		MonthsOfYear[0] = "Jan";
		MonthsOfYear[1] = "Feb";
		MonthsOfYear[2] = "Mar";
		MonthsOfYear[3] = "Apr";
		MonthsOfYear[4] = "May";
		MonthsOfYear[5] = "Jun";
		MonthsOfYear[6] = "Jul";
		MonthsOfYear[7] = "Aug";
		MonthsOfYear[8] = "Sep";
		MonthsOfYear[9] = "Oct";
		MonthsOfYear[10] = "Nov";
		MonthsOfYear[11] = "Dec";

	var HebMonthsOfYear = new Array(14);
		HebMonthsOfYear[0] = "";
		HebMonthsOfYear[1] = "Tishrei";
		HebMonthsOfYear[2] = "Cheshvan";
		HebMonthsOfYear[3] = "Kislev";
		HebMonthsOfYear[4] = "Tevet";
		HebMonthsOfYear[5] = "Shevat";
		HebMonthsOfYear[6] = "Adar-I"; // only valid on leap years
		HebMonthsOfYear[7] = "Adar"; // on a leap year, should be Adar-II
		HebMonthsOfYear[8] = "Nisan";
		HebMonthsOfYear[9] = "Iyar";
		HebMonthsOfYear[10] = "Sivan";
		HebMonthsOfYear[11] = "Tamuz";
		HebMonthsOfYear[12] = "Av";
		HebMonthsOfYear[13] = "Elul";

// Is Daylight Saving Time affecting this computer today?
// getTimezoneOffset returns GMT-localtime in mins
// so for GMT+2 (jerusalem), it returns -120
// dst is always further to the right (east) so
// the value for getTimezoneOffset when dst is on season
// is always strictly less than when it is off season
	function dst_offset_mins() {
	var Tday = new Date(); 		        // today's date
	var t_min = Tday.getTimezoneOffset();   // minutes from GTM today
	var NWday = new Date(2007, 0, 1, 12);   // 1 Jan 07 12 noon
	var nw_min = NWday.getTimezoneOffset(); // minutes from GTM northern mid-winter
	var SWday = new Date(2007, 6, 1, 12);	// 1 Jul 07 12 noon
	var sw_min = SWday.getTimezoneOffset(); // minutes from GTM southern mid-winter
	if (sw_min==nw_min) {
		return 0 // no dst at all - 0 except Israel summertime = 60
	} 
	if (sw_min<nw_min) {
	// northern hemisphere with dst operative
	// the "southern mid-winter" offset is a dst day in the north
	// so it is strictly less than the regular "northern mid-winter" offset
		if (t_min==nw_min) {
			return 0 // northern hemisphere && dst is off season
		} else {
			return 60 // northern hemisphere && dst is on season
		}
	// must be southern hemisphere with dst operative
	// see reasoning give above
	} else if (t_min==sw_min) {
		return 0 // southern hemisphere && dst is off season
			  // 0 except Israel summertime = 60
	} else {
		return 60 // southern hemisphere && dst is on season
	}
}

// The main part of the script
	function showtime() {
	
	// Get all our date values
		var hdif; // reserved for +/- mins from Jerusalem time
		var msdif // reserved for +/- millisecs from Jerusalem time
		var Digital = new Date(); // get the local time & date
		var jtime = Digital.getTime(); // convert to millsecs since 1 Jan 1970
		// get TimezoneOffset from GMT - time in minutes
		// east of GMT, amount is negative, west of GMT, amount is positive
		var zone_offset = Digital.getTimezoneOffset();
			// use (-) to reverse the GMT point of view
			zone_offset = -(zone_offset+dst_offset_mins()); // in minutes
		// Now convert the local time to Jerusalem time
		// GMT+120 is official geographical time for Jerusalem
		if (zone_offset!=120) {
		// west of Jerusalem - subtract the (negative) diff to make J time
		// east of Jerusalem - subtract the (positive) diff to make J time
			hdif = zone_offset-120;
			msdif = hdif*60*1000; // millisecs
			Digital.setTime(jtime-msdif);
		} 
		// at this point, Digital should contain Jerusalem time
		var day = Digital.getDay();
		var mday = Digital.getDate();
		var month = Digital.getMonth();
		var hours = Digital.getHours();
		var year = Digital.getYear();
		var minutes = Digital.getMinutes();
		var seconds = Digital.getSeconds();
		Digital.setHours(0,0,0,0); // zero out hours, mins, secs, and millisecs
		var hebdate = GregToHeb(Digital); // returns Heb M/D/Y
		var hdate = new Array();
		hdate = hebdate.split("/");
		
	// Format minutes and seconds
		if (minutes <= 9) { minutes = "0"+minutes; }
		if (seconds <= 9) { seconds = "0"+seconds; }

	// This is the actual HTML of the time. If you're going to play around
	// with this, be careful to keep all your quotations intact.
		mytime = '';
		mytime += '<font style="color:'+myfont_color+'; font-family:';
                mytime += myfont_face+'; font-size:'+myfont_size+'pt;';
		mytime += ' background:'+myback_color+'; font-weight: bold;">';
		mytime += mypre_text+hours+':'+minutes;
		if (hours<12) {
			mytime += 'AM'
		}
		mytime += ' --- ';

		mytime += HebDaysOfWeek[day]+', '+hdate[1]+' ';
		mytime += HebMonthsOfYear[Number(hdate[0])];
		if ((IsLeapYear(Number(hdate[2])))&&(hdate[0]==7)) {
			mytime += '-II'
		}
		mytime += ' '+hdate[2]+' --- ';

		mytime += DaysOfWeek[day]+', '+mday+' ';
		mytime += MonthsOfYear[month];
		// fix for newer XP machines....
		if (year>1900) {
			mytime += ' '+year;
		} else {
			mytime += ' '+(1900+year);
		}
		mytime += '</font>';

//	inNode = document.getElementById("LiveTime");
//	inNode.innerHTML = mytime; 
	document.getElementById("LiveTime").innerHTML = mytime;           

	setTimeout("showtime()", 60000);				
}
