//
// START date/time script
function projotime(year,month,day,hours,minutes,seconds) {
	var bimonths=new Array(12);
	bimonths[1]="January";
	bimonths[2]="February";
	bimonths[3]="March";
	bimonths[4]="April";
	bimonths[5]="May";
	bimonths[6]="June";
	bimonths[7]="July";
	bimonths[8]="August";
	bimonths[9]="September";
	bimonths[10]="October";
	bimonths[11]="November";
	bimonths[12]="December";

	var bidays= new Array(7);
	bidays[0]="Sunday";
	bidays[1]="Monday";
	bidays[2]="Tuesday";
	bidays[3]="Wednesday";
	bidays[4]="Thursday";
	bidays[5]="Friday";
	bidays[6]="Saturday";


	var bitimezone='';
	var bilocaltime=new Date();
	var bioffsetmills=(bilocaltime.getTimezoneOffset()*60*1000);
	var biservertimemills=(Date.UTC(year,month-1,day,hours,minutes,seconds));
	var biadjustedtime=new Date();
	biadjustedtime.setMilliseconds(-biadjustedtime);
	biadjustedtime.setMilliseconds(biservertimemills);	

	// start section to adjust for Netscape
	var biadjustedtimestring=biadjustedtime.toString();
	// check for time zone spelled out
	if (biadjustedtimestring.indexOf('Time') !=-1) {
		//remove anything after 'Time'
		biadjustedtimestring=biadjustedtimestring.substring(0,biadjustedtimestring.indexOf('Time')+4);
		//get index of space before 'Time'
		var bitemptimestring=biadjustedtimestring.substring(0,biadjustedtimestring.lastIndexOf(' '));
		//get index of space before word before 'Time'
		bitemptimestring=bitemptimestring.substring(0,bitemptimestring.lastIndexOf(' '));
		// get index of second space before 'Time' to get to start of time zone
		var bistartindex=bitemptimestring.lastIndexOf(' ');
		// we have the start, so get the time zone from the date string
		bitemptimestring=biadjustedtimestring.substring(bistartindex,biadjustedtimestring.length);
		// see if we need to remove a '('
		if (bitemptimestring.indexOf('(')==1) {
			// remove the '('
			bitemptimestring=bitemptimestring.substring(2,bitemptimestring.length);
		}
		bitimezone=bitemptimestring;
	// end section to adjust for Netscape.	
	} else {
		bitimezone=biadjustedtime.toString();
		bitimezone=bitimezone.substring(0,bitimezone.lastIndexOf(' '));
		bitimezone=bitimezone.substring(bitimezone.lastIndexOf(' ')+1,bitimezone.length);
		// make sure the time zone is 3 characters, else make it blank because it hasn't matched our cases
		if (bitimezone.length>3) {
			bitimezone='';
		}
	}
	if (navigator.userAgent.indexOf("Safari") != -1) {
		biadjustedtime=new Date();
	}

	var bimonth=bimonths[biadjustedtime.getMonth() + 1];
	var bidate=biadjustedtime.getDate();
	var biday = bidays[biadjustedtime.getDay()];
	var biyear=biadjustedtime.getFullYear();
	var bihours=biadjustedtime.getHours();
	var biminutes=biadjustedtime.getMinutes();

//  RL -040130 - Removed this section, not needed now
//	if (day==31) {
//		var lastdaybug=1;
//	}
//	
//	if (lastdaybug == 1) {
//		if (bidate == 1) {
//			bidate = 31;
//			bimonth=bimonths[biadjustedtime.getMonth()]
//		} else {
//			bidate = 31;
//		bidate = bidate - 1;
//		}
//
//		if (biadjustedtime.getDay() > 0) {
//			biday = bidays[biadjustedtime.getDay()-1];
//		} else if (biadjustedtime.getDay()==0) {
//			biday = bidays[6];
//		}
//	}	
	
	var biampm='a.m.';
	//change from 24h to 12h clock
	if (bihours==12){
		biampm='p.m.';
	} else if (bihours==0) {
		biampm='a.m.';
		bihours=12;
	} else if (bihours>12) {
		bihours=(bihours-12);
		biampm='p.m.';
	}

	//add a zero in front of the minutes if it's a single digit
	if (biminutes<10) {
		biminutes=('0' + biminutes);
	}

	//write out the date
	//document.write(biday + ' ' + bimonth + ' ' + bidate +', ' + biyear + ' ' + bihours + ':' + biminutes + ' ' + biampm + ' ' + bitimezone);	
      // change the format we display
      document.write(biday + ', ' + bimonth + ' ' + bidate +', ' + biyear + ' ' + bihours + ':' + biminutes + ' ' + biampm);	

}
// END date/time script


// newUntil()
// By Tim Barmann
// 9/23/2009
// writes 'New' if the current time has not yet reached the expiration time
// usage:
// newUntil("9/23/2009 8:00 pm");
// expiration date and time must follow this format

function newUntil (expiresStr) {

	var expTimeStamp = Date.parse(expiresStr);
	var expiresDate = new Date(expTimeStamp);
	var rightNow = new Date();
	if (rightNow<expiresDate)
		document.write('<font color="#990000">New: </font>');
	return;


}


// updateUntil()
// By Tim Barmann
// 9/23/2009
// writes 'Update:' if the current time has not yet reached the expiration time
// usage:
// updateUntil("9/23/2009 8:00 pm");
// expiration date and time must follow this format

function updateUntil(expiresStr) {

	var expTimeStamp = Date.parse(expiresStr);
	var expiresDate = new Date(expTimeStamp);
	var rightNow = new Date();
	if (rightNow<expiresDate)
		document.write('<font color="#990000">Update: </font>');
	return;
}

// autoHide()
// By Timothy C. Barmann
// 10/14/2009
// Purpose: automatically shows or hides an element on a page, depending on 
// the date and the time of day. It does so by changing the class on the
// element to be either 'hide' or 'unhide'
// page must be reloaded for changes to take effect
// Dependencies: A style sheet on the page must contain the definitions for
// hide and unhide classes
// .hide .hide {display:none;}
// .unhide {display:block;}
// usage:
// autoHide("divID","01/01/1970 7:00 am","10/12/2010 4:24 pm");	
// where parameters 
// 1. divID is the id of the div you want to show or hide
// 2. Date and time of day the element should begin displaying
// 3. Date and time of day the element should stop displaying
// 4. Optional: the days of the week the element should be displayed:
//    "mo tu we th fr sa sun"
//    use any or all of these days
//    if none is specified, it will be shown on all days
//    date and time must follow this format

function autoHide(strId,strStart,strEnd,strDays) {
	if ((strId === undefined ) || (strStart === undefined) || (strEnd === undefined))
      return;
	if (strDays === undefined)
		var strDays="mo,tu,we,th,fr,sa,su";
	else
		strDays=strDays.toLowerCase();
	e=document.getElementById(strId);
	if (e==null) {
		alert ("Element " + strId + " not found.");
		return;
	}
	var weekDays= Array ("su","mo","tu","we","th","fr","sa");
	
	var startTime = new Date(strStart);
	var endTime = new Date(strEnd);
	var rightNow = new Date();
	
	var startMinutes = (startTime.getHours()*60) + startTime.getMinutes();
	var endMinutes =  (endTime.getHours()*60) + endTime.getMinutes();
	var rightNowMinutes = (rightNow.getHours()*60) + rightNow.getMinutes();
	var dow = weekDays[rightNow.getDay()];   // day of week
	
	if ((rightNow>startTime) && (rightNow<endTime) && (strDays.indexOf(dow)!=-1) && (rightNowMinutes>=startMinutes) && (rightNowMinutes < endMinutes)) 
		e.setAttribute("class", "unhide");
	else
		e.setAttribute("class", "hide");
} // end function