/*
  *     hm_util.js -- HM utilities  Library
/* ----------------------------------------------------------------------------------------------------- */
/*
   version 1.0 -- Jim Cory, Horizon Mapping
 
*/

/*
-- Examples of things needed in html page, like variable settings.

-- This is for the day and date

<p>Hello. Today is: <script language="JAVASCRIPT">
<!--//
document.write(todaysDate)
//-->

</script> </p>

*/

function todays_date(opt){

	var myMonths=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var myDays= new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
	
	today=new Date();
	thisDay=myDays[today.getDay()] ;
	thisMonth=myMonths[today.getMonth()] ;
	thisYear=today.getFullYear() ;
	thisDate=today.getDate() ;
	
	switch (thisDate) {
		case 1:
			dateSuffix="st" ;
			break ;
		case 21:
			dateSuffix="st" ;
			break ;
		case 31:
			dateSuffix="st" ;
			break  ;   
		case 2:  
			dateSuffix="nd"  ; 
			break  ;   
		case 22:
			dateSuffix="nd" ;
			break;   
		case 3:
			dateSuffix="rd"  ; 
			break  ;    
		case 23:
			dateSuffix="rd"  ; 
			break  ;     
		default:   
			dateSuffix="th" ;
	}

	if (opt == "std") {
		todaysDate=thisDay + ", " + thisMonth + " " + thisDate + ", " + thisYear ;
		}
	else if (opt == "fancy") {
		todaysDate=thisDay + ", " + thisDate + dateSuffix + " " + thisMonth + " " + thisYear ;
		}

}

/*
-- Examples of things needed in html page, like variable settings.

-- Need this to get the time display updated regularly (optional)

<body background="backg2.gif" onload="clockWork">

<p>And the time is now (according to your computer):</p>

<form name="formTime" method="POST" enctype="TEXT/PLAIN">
  <p><input type="TEXT" name="textTime" size="25" maxlength="25"> </p>
</form>

*/

function myClock(){
	today=new Date()
	var theHours=today.getHours()
	if (theHours>11)
	{
		theTimeSuffix="PM"
	}
	if (theHours>12)
		var theHours=theHours-12
	else
	{
		theTimeSuffix="AM"
	}
	var theMinutes=today.getMinutes()
	if (theMinutes<10)
		var theMinutes="0"+theMinutes
	var theSeconds=today.getSeconds()
	if (theSeconds<10)
		var theSeconds="0"+theSeconds
	var theTimeNow=theHours+":"+theMinutes+":"+theSeconds+" "+theTimeSuffix
	document.formTime.textTime.value=theTimeNow
}

/*
   -- Not sure how this works yet if set but not called onload, so commented out
   
   var clockWork=setInterval("myClock()",1000)

 
*/
