// JavaScript Functions for Chaska.net Portal
// 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));
}

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();


	headsUpHTML += "<table width=300 cellpadding=0 cellspacing=0><tr>";
	headsUpHTML += "    <td width=100><span class='personalText'>"+today+"</span></td>";
	headsUpHTML += "    <td width=68><span class='personalText'>"+curTime+"</span></td>";
	headsUpHTML += "</tr></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>");
}
function cw_ReloadWeatherImage() {
    var now = new Date();
    if (document.images) {
        document.images.currentWeather.src = 'http://banners.wunderground.com/banner/infobox_both/language/www/US/MN/Chaska.gif?' + now.getTime();
    }
    setTimeout('cw_ReloadWeatherImage()',60000);
}
//setTimeout('cw_ReloadWeatherImage()',60000);
