/*
DST starts on Sunday, March 11, 2007 at 2:00 AM local standard time
2nd Sunday in March at 2:00 AM

DST ends on Sunday, November 4, 2007 at 2:00 AM local daylight time
1st Sunday in November

Indianapolis - marion county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

Lafayette - tippecanoe county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

>>Evansville - vanderburgh county
Standard time zone:			UTC/GMT -6 hours
Daylight saving time:		+1 hour	// -5 hours

Fort Wayne - allen county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

Jeffersonville - clark county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

>>Merrillville - lake county
Standard time zone:			UTC/GMT -6 hours
Daylight saving time:		+1 hour	// -5 hours

Richmond - wayne county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

South Bend - st. joseph county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

Terre Haute - vigo county
Standard time zone:			UTC/GMT -5 hours
Daylight saving time:		+1 hour	// -4 hours

*/
function getZone() {
	el = document.getElementById("ctlHeader_ddlCity");
	var city = el.options[el.selectedIndex].value;

	var today = new Date();

	var m = today.getUTCMinutes();
	var h = today.getUTCHours();

	switch(city) {
		case "Indianapolis":
		case "Lafayette":
		case "Fort Wayne":
		case "Jeffersonville":
		case "Richmond":
		case "South Bend":
		case "Terre Haute":
		var dstOffset = dst_isActive(today) ? -4 : -5;
		break;

		case "Evansville":
		case "Merrillville":
		var dstOffset = dst_isActive(today) ? -5 : -6;
		break;
	}
	//alert(dstOffset);
	h += dstOffset;
	today.setHours(h);
	var ampm = (h>=12) ? "p.m." : "a.m.";
	h -= (h>12) ? 12 : 0;
	if (h<0){
		//weird. not sure why numbers go negative, but they do.
		h = h+12;
		ampm = "p.m.";
		//stop negative numbers sometime soon, so this weird fix doesn't need to be here.
	}
	if (m<10){ m = "0" + m; }
	if (h<1 || isNaN(h)) { h = "12"; }
	document.getElementById('thisThing').innerHTML = (h + ":" + m + " " + ampm + " ");
	t = setTimeout('getZone()',500);
}

function dst_isActive(dateObj){
	var year = dateObj.getFullYear();

	var sun2mar = 15 - new Date(year, 2, 1).getDay(); // the day of the 2nd Sunday in March
	var spring = new Date("Mar " + sun2mar + ", " + year + " 2:00:00");

	var sun1nov = 8 - new Date(year, 10, 1).getDay(); // the day of the 1st Sunday in November
	var fall = new Date("Nov " + sun1nov + ", " + year + " 2:00:00");

	return ((dateObj > spring) && (dateObj < fall));
}


//-------weather functions-------
function changeTemp() {
	var el = document.getElementById("thisTemp");										
	el.innerHTML = "--&#186;F";										

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 

	el = document.getElementById("ctlHeader_ddlCity");
	var city = el.options[el.selectedIndex].value;
	var zip = "46225";	//default
	switch(city) {
		case "Indianapolis":
			zip = "46225";
		break;
		case "Lafayette":
			zip = "47901";
		break;
		case "Fort Wayne":
			zip = "46802";
		break;
		case "Jeffersonville":
			zip = "47129";
		break;
		case "Richmond":
			zip = "47374";
		break;
		case "South Bend":
			zip = "46601";
		break;
		case "Terre Haute":
			zip = "47802";
		break;
		case "Evansville":
			zip = "47708";
		break;
		case "Merrillville":
			zip = "46410";
		break;
	}
	var url="/visitindiana/includes/ASP/weather.aspx?zip="+zip;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
function stateChanged(){ 
	if (xmlHttp.readyState==4){ 
		responseStr = xmlHttp.responseText + "&#186;F";
		//alert(responseStr);
		document.getElementById("thisTemp").innerHTML=responseStr;
	}
}

//--------ajax constructs--------
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}