
/*
function: setFontStyle
date: 07/23/2003
author: EMN
describe: sets a cookie specifying which style sheet to use (referenced by int value). if cookie exists, it updates
inputs: integer value to set in cookie
output: boolean true if new cookie, false if exists
*/
function setFontStyle(intStyle) {
	var expdate = new Date ();
	FixCookieDate (expdate);
	SetCookie ("fontStyle", intStyle,null,"/");
	
	window.location.reload()
    return true
} // setFontStyle(intStyle)


// display style switching links
function writeStyleSwitchLinks() {
    document.write("<a href=\"" + location.href + "\" onMouseover=\"self.status=\'Set Font Small\'; return true\" onMouseout=\"self.status=\'\'; return true\" onClick=\"return void setFontStyle(2)\">SM</a>")
    document.writeln(" | ")
	document.writeln("<a href=\"" + location.href + "\" onMouseover=\"self.status=\'Set Font Large\'\; return true\" onMouseout=\"self.status=\'\'\; return true\" onClick=\"return void setFontStyle(1)\">LG</a>")
	document.writeln(" | ")
	document.writeln("<a href=\"" + location.href + "\" onMouseover=\"self.status=\'Set Font X-Large\'\; return true\" onMouseout=\"self.status=\'\'\; return true\" onClick=\"return void setFontStyle(3)\">XL</a>")
	document.writeln("<br />")

	return true
} // writeStyleSwitchLinks


// write style sheet based on cookie value
strFontStyle = GetCookie("fontStyle")
switch (strFontStyle) {
  case "2":
      strStyleSheet = "http://www.olivetreeviews.org/library/jsFontStyleSM.css"
      break
  case "3":
      strStyleSheet = "http://www.olivetreeviews.org/library/jsFontStyleXL.css"
      break
  default: 
      strStyleSheet = "http://www.olivetreeviews.org/library/jsFontStyleLG.css"
} // switch

strStyleDeclare = "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"" + strStyleSheet + "\" />"
//alert(strStyleDeclare)
document.writeln(strStyleDeclare)

/*
Cookie functions - taken from Bill Dortch
*************************************************************************************************
*/
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}


function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
