/******************************************************************************
	Java Script Functions for RCF 04-30-2008                                   
	Specifically tailored for Littleton Dems
	Version 1.0
 ******************************************************************************/

// Page Layout Functions
// official date of record for each webpage;
var dor = new Array();
dor["ltn"] = "05-04-2008";
dor["hd38"]= "04-30-2008";
dor["eng"] = "04-30-2008";
dor["sp"]  = "05-05-2008";
dor["gv"]  = "05-05-2008";

function wrapperStyle () {
	var br = browserId();
	if ( br == "ie7" || br == "ie6" ) {
		document.write("<style type='text/css'> #wrapper {margin-left: "+((screen.width-915)/2)+"} </style>");
	}
	if (br == "nn6") {
		document.write("<style type='text/css'> #wrapper {margin: 0 auto;} </style>");
	}
	else {
		document.write("<style type='text/css'> #wrapper {margin-left: "+((screen.width-915)/2)+"} </style>");
	} // this branch not tested
}

function contentStyle () {
	var br = browserId();
	if (br == "ie7" || br == "ie6" ) {
		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(town) {
	var br = browserId();
	if (br == "ie7" || br == "ie6" ) {
		document.write("<style type='text/css'> #title {width: 100%;} </style>");
	}
	else if (br == "nn6" ) {
		document.write("<style type='text/css'> #title {width: 97.10%;} </style>");
	}
	document.write("<img id='left-pic' src='ldmlogov3.jpg'"); 
	document.write("width='240' height='180' alt='left'>");
	document.write("<img id='right-pic' src='ldmlogov3.jpg'");
	document.write("width='240' height='180' alt='right'>");
	document.write("<br><br><h1>Littleton Democrats Meetup</h1>");
}

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(town) {
	document.write("<div id='footer'><table><tr><td class='hits'>");
	if (town != "") { 
		document.write("<a href='http://www.easycounter.com/'>");
		document.write("<img class='noborder' src='http://www.easycounter.com/");
		if (town == "hd38") document.write("counter.php?rcfcohd38'");
		else document.write("counter.php?rcf"+town+"dms'");
		document.write("alt='stats counter'></a><br>");
		document.write("<a href='http://www.easycounter.com/FreeCounter3.html'>stats counter</a>");
	}
   document.write("</td>");
   
	document.write("<td class='address'>");
   document.write("<address>Page last updated:<br>"+dor[town]+" <br>");
   document.write("For more info contact:<br>");
	document.write("<a href='http://rcflesher.com/rcf/webmaster.html'>Ray FLESHER</a>");
	document.write("<br></address></td>");
	
   document.write("<td class='host'>prepared by rcflesher.com<br>powered by Apache2<br>");
	document.write("hosted by lunarpages.com</td>");
	
	document.write("<td class='validation'><a href='http://validator.w3.org/'>");
	document.write("<img class='noborder' src='valid-html401.png' alt='Valid 4.01 T' ");
	document.write("width='88' height='31'></a><br>validated html code</td></tr></table>");
	document.write("</div>");
}

 // Browser Identification

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;
}

// Time Functions

var month=new Array(12);
month[0]="Jan";month[1]="Feb";month[2]="Mar";month[3]="Apr";month[4]="May";month[5]="Jun";
month[6]="Jul";month[7]="Aug";month[8]="Sep";month[9]="Oct";month[10]="Nov";month[11]="Dec";

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"
   var minutes = rightnow.getMinutes(); // capture minutes "00" thru "59"
   var ampm = "am";
	if (hours == 0) {ampm = "am"; hours += 12;}
	else if (hours < 12) ampm = "am";
	else if (hours == 12) ampm = "pm";
   else { ampm = "pm"; hours -= 12; }
   if (hours == 12 && minutes < 16 && ampm == "pm") ampm = "noon";
   var hourstring = hours.toString();
   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;
}

// Cookie Functions
/*
comments go hear
*/

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

/*
function styleWrapper() {
	document.write("<style> #wrapper {margin-left: ");
   document.write(((screen.width-925)/2));
	document.write("}</style>");
}
*/
function screenResolution() {
	document.write("screen resolution is ");
	document.write(screen.width+"x"+screen.height);
   document.write("<br>");
	document.write("window size is ");
	document.write(document.width+"x"+document.height);
   document.write("<br>");
   document.write("page size 925 leaves a margin of "+((document.width-925)/2)+".<br>");
   document.write("page size 925 leaves a margin of "+((screen.width-925)/2)+".<br>");
}

