// JavaScript Functions for Clock
// Author Dale Hughes
//
// Set update Interval to one second. (1000 milliseconds)
//var cw_updateInterval = 1000;
// Or to one minute
var cw_updateInterval = 60000;
function cw_getDate() {

        var curDay = new Date();
        var month = curDay.getMonth();
	var year = curDay.getYear();
	if (year < 1000) {
       		year += 1900;
	}

        var mnames = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
        return (mnames[month] + "-" + curDay.getDate()+ "-" +year);
}
function cw_getTime() {
        var time = new Date();
	var lable;
	var seconds = time.getSeconds();
	seconds = (seconds < 10 ?  "0"+seconds : seconds);
	var minutes = time.getMinutes();
	minutes = (minutes < 10 ?  "0"+minutes : minutes);
	var hours = time.getHours();
	hours = (hours < 10 ?  "0"+hours : hours);
	(hours > 11 ? lable = "PM" : lable = "AM");
	if (hours > 12) hours -= 12;
	// curTime will contain the seconds only if the cw_updateInterval is 1 second or less.
	return(hours+ ":" + minutes+ (cw_updateInterval > 1000 ? " "+lable : ":"+seconds));
}
function cw_getLeft() {

	// jan 1 2006 = 36 years from 1/1/70
	// so ........
	var birthday = 9 * 1461 * 24;
        var curDay = new Date();
        var millesec = curDay.getTime();
	var seconds = millesec / 1000;
	var minutes  = seconds / 60;
	var hours = minutes / 60;
	var days = hours / 24;
	hours = Math.floor(hours);
	
	
        return (birthday - hours);
}

var cw_HeadsUpUserName = "STRANGER"; 

function cw_updateHeadsUp() {

	var updateTimer;
	
	// **************************************************
	// Build the Heads Up.
	// The actual usable resolution for the Heads Up is 820 x 24.
	// **************************************************
	var headsUpId = document.getElementById("cw_HeadsUp");
	var headsUpHTML = "";

        var today = cw_getDate();

	var curTime = cw_getTime();

	var timeLeft = cw_getLeft();

	headsUpHTML += "<table width=188 cellpadding=0 cellspacing=2><tr>";
	headsUpHTML += "    <tr>";
//	headsUpHTML += "        <td width=100 align='right'>"+today+"</td>";
//	headsUpHTML += "        <td width=68 align='left'>"+curTime+"</td>";
	headsUpHTML += "        <td width=188 align='center'>"+today+"&nbsp;&nbsp;&nbsp;"+curTime+"</td>";
	headsUpHTML += "    </tr>";
//	headsUpHTML += "    <tr>";
//	headsUpHTML += "        <td align='center'>"+timeLeft+" Hours Left to <br>Westco's 50th Birthday.</td>";
//	headsUpHTML += "    </tr>";
	headsUpHTML += "</table>";
	headsUpId.innerHTML = headsUpHTML;

	// Set a timer to make this function update itself.
        updateTimer = setTimeout("cw_updateHeadsUp()",cw_updateInterval);

}
function cw_DateBar() {
	
	var cw_time = new Date();
	var timezoneoff = cw_time.getTimezoneOffset();
	timezoneoff /= 60;
	
	document.write("<div class='cw_GreyBarDark' align='center' >");
    	document.write("    <table bgcolor='#565656' width=820 cellpadding=0 cellspacing=0>");
        document.write("        <tr>");
        document.write("            <td align='center' width=200><span class='cw_FooterText'>"+cw_getDate()+" "+cw_getTime()+"&nbsp;&nbsp;"+timezoneoff+"</span></td>");
        document.write("        </tr>");
	document.write("    </table>");
	document.write("</div>");
}

