/******************************************************************************
Java Script Functions for RCF 03-24-2008                                   
Specifically tailored for Humanists of Colorado
Updated 04-09-2008

 ******************************************************************************/

// Page Layout Functions
// official date of record for each webpage; the alpha names and descendants pages get their dates from the generating program.
var main_dor       = "12 May 2009"; // previously "13 Apr 2009"; "09 Mar 2009"; "10 Feb 2009"; "26 Jan 2009"; "12 Jan 2009";
var nwsltrs_dor    = "10 Feb 2009"; // previously "16 Dec 2008";
var aboutus_dor    = "26 Jan 2009"; // previously "16 May 2008";
var bylaws_dor     = "17 Apr 2008";
var celebrants_dor = "16 May 2008";
var definitions_dor= "17 Apr 2008";
var email_dor      = "17 Apr 2008";
var links_dor      = "18 Jan 2009"; // previously "17 Apr 2008";

// Page Layout Functions

function wrapperStyle () {
	var br = browserId();
	if (br.substring(1,2) == "ie" && integer.parseint(br.substring(3,3)) >= 6) {
		document.write("<style type='text/css'> #wrapper {margin-left: "+((screen.width-915)/2)+"} </style>");
	}
	else if (br == "nn6") {
		document.write("<style type='text/css'> #wrapper {margin: 0 auto;} </style>");
	}
	else {
		document.write("<style type='text/css'> #wrapper {margin: 0 auto;} </style>");
	} // this branch not tested
}

function contentStyle () {
	var br = browserId();
	if (br.substring(1,2) == "ie" && integer.parseint(br.substring(3,3)) >= 6) {
		document.write("<style type='text/css'> #content {margin-right: 0;} </style>");
	}
	else if (br == "nn6") {
		document.write("<style type='text/css'> #content {margin-right: -10;} </style>");
	}
	else {
		document.write("<style type='text/css'> #content {margin-right: -21;} </style>");
	} // this branch not tested
}

function showTitle() {
     document.write("<img width='483' height='80' src='../images/HOCLogo-wide.png'");
     document.write("alt='Humanists of Colorado'>");
   //document.write("<img width='22' height='68' src='../images/logo.reduced.colors.gif'");
   //document.write("alt='Happy Humanist'>");
   //document.write(" Humanists of Colorado ");
   //document.write("<img width='22' height='68' src='../images/logo.reduced.colors.gif'");
   //document.write("alt='Happy Humanist'>");
}

function showSidebar() {
   document.write("<img width='34' height='50' ");
   document.write("src='../images/rodins.thinker.right.gif' ");
   document.write("alt='Rodins Thinker'><br><br>");
   document.write("<a href='hoc.1.main.html'>Humanists Home Page</a><br><br>");
	document.write("<a href='hoc.9.nwsltrs.html'>HOC Newsletters</a><br><br>");
	document.write("<a href='hoc.2.definitions.html'>HOC Definitions</a><br><br>");
   document.write("<a href='hoc.3.bylaws.html'>HOC By-Laws</a><br><br>");
// <!--HOC Admin-->
   document.write("<a href='hoc.5.celebrants.html'>HOC Celebrants</a><br><br>");
   document.write("<a href='hoc.6.links.html'>HOC<br>Related Links</a><br><br>");
   document.write("<a href='hoc.7.aboutus.html'>About Us</a><br><br>");
	document.write("<a href='hoc.email.address.html'>Contact Us</a><br><br>");
   document.write("<img width='34' height='50' ");
   document.write("src='../images/rodins.thinker.left.gif' ");
   document.write("alt='Rodins Thinker'><br><br>");
}

function showPageName(name) {
	document.write("Today is: <span id='date'>d d m y</span>&#59;");
	document.write("the time now is: <span id='time'>00:00:00</span> ");
	document.write("at the "+name);
}

function showFooter(page,lastupdate) {
	document.write("<div id='footer'><table><tr>");
	document.write("<td class='host'>");
	document.write("<a href='http://humanists.net'>"); 
	document.write("<img class='noborder' width='135' height='52' ");
	document.write("src='../images/hostedby_ani.gif' alt='Humanists.net'></a>");
	document.write("</td>"); /* end of host section */

	document.write("<td class='hits'>");
	if (page != "") { 
		document.write("<a href='http://www.easycounter.com/'>");
		document.write("<img class='noborder' src='http://www.easycounter.com/");
//		document.write("counter.php?rcflesher08,"+page+"' alt='traffic counter'></a><br>");
		document.write("counter.php?rcfhoc' alt='traffic counter'></a><br>");
		document.write("<a href='http://www.easycounter.com/FreeCounter3.html'>traffic counter</a>");
	} 
	document.write("</td>"); /* end of hits section */

	document.write("<td class='address'>");
	document.write("<address>");
	document.write("<b>Webmaster:</b> <a href='hoc.email.address.html'>");
	document.write("contact via email</a><br>");
   document.write("Page last updated: "+lastupdate+" <br>");
	document.write("</address></td>"); /* end of address section */
 	
	document.write("<td class='validation'><a href='http://validator.w3.org/'>");
	document.write("<img class='noborder' src='../images/valid-html401.png' alt='Valid 4.01 T' ");
	document.write("width='88' height='31'></a><br>validated<br>html code</td></tr></table>");
	document.write("</div>");
}

function browserId() { 
	var br = "def"; // browser code
	var bn = navigator.appName;
	var bv = parseInt(navigator.appVersion);
	var MSIE = "Microsoft Internet Explorer";
	var NN = "Netscape";
//	var FF12 = "Firefox/2.0.0.12";
	var m7 = navigator.appVersion.indexOf("MSIE 7.0")
	var m6 = navigator.appVersion.indexOf("MSIE 6.0")
	if (bn == MSIE && bv == 4 && m7 != -1) {br = "ie7";}
	else if (bn == NN && bv == 5) {br = "nn6";}
	else if (bn == MSIE && bv == 4 && m6 != -1) {br = "ie6";}
	else if (bn == NN && bv == 4) {br = "nn4";}
	return br;
}



// Cookie Functions
/*
comments go here
*/

function deleteCookie(name) {
   document.cookie = name+"=; expires=Thu, 01-Jan-70 00:00:01 GMT"+"; path=/";
}
      
function getCookie(name) {
   var cookiename = name + "=";
   var dc = document.cookie;
   var begin, end;
   if (dc.length > 0) {
      begin = dc.indexOf(cookiename);
      if (begin != -1) {
         begin += cookiename.length;
         end = dc.indexOf(";", begin);
         if (end == -1) {
            end = dc.length;
         }
      return unescape(dc.substring(begin, end));
      }
   }
   return null;
}

function setCookie(name, value, expires) {
   document.cookie = escape(name) + "=" + escape(value) + "; path=/"
      + ((expires == null) ? "" : "; expires = " + expires.toGMTString());
}

// Time Functions

var month=new Array(12);
month[0]="Jan";  // January";
month[1]="Feb";  // February";
month[2]="Mar";  // March";
month[3]="Apr";  // April";
month[4]="May";  // May";
month[5]="Jun";  // June";
month[6]="Jul";  // July";
month[7]="Aug";  // August";
month[8]="Sep";  // September";
month[9]="Oct";  // October";
month[10]="Nov"; // November";
month[11]="Dec"; // December";

var dow=new Array(7);
dow[0]="Sun";
dow[1]="Mon";
dow[2]="Tue";
dow[3]="Wed";
dow[4]="Thu";
dow[5]="Fri";
dow[6]="Sat";

function update_time() {
   var rightnow = new Date(); // the current date and time
   var hours = rightnow.getHours(); // capture hours "00" thru "23"
   if (hours < 12) var ampm = "am";
   else { var ampm = "pm"; hours -= 12; }
   var hourstring = hours.toString();
   var minutes = rightnow.getMinutes(); // capture minutes "00" thru "59"
   if (minutes < 10) var minutestring = "0" + minutes.toString();
   else var minutestring = minutes.toString();
   var seconds = rightnow.getSeconds(); // capture seconds "00" thru "59"
   if (seconds < 10) var secondstring = "0" + seconds.toString();
   else var secondstring = seconds.toString();
   var timestring = hourstring + ":" + minutestring + ":" + secondstring;
   timestring = timestring + " " + ampm;
   var timeplace = document.getElementById("time");
   timeplace.childNodes[0].nodeValue = timestring;
   setTimeout('update_time()', 1000);
   var ddd = dow[rightnow.getDay()];
   var dd = rightnow.getDate();
   var mmm = month[rightnow.getMonth()]; 
   var yyyy = rightnow.getFullYear();
   var datestring = ddd+" "+dd+" "+mmm+" "+yyyy;
   var dateplace = document.getElementById("date");
   dateplace.childNodes[0].nodeValue = datestring;
}

// Redirection Functions

function newPage() { // not used; training only
   window.location.assign("http://rcflesher.evodynamic.com/index.html")
}
