var isNS4 = false;
var isIE4only = false;
var isIE45only = false;
var isIE4 = false;
var isIE6 = false;
var isNS6 = false;
var isNS6only = false;
var isMac = false;
var isSafari = false;
var isOpera = false;
var hidden = "hidden"
var visible = "visible"
var dhtml = true;
var linux = false;
var noScroll = false;	// for those which don't support scrollbars on divs

var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
if ((version >= 5.5) && (version < 7)) {
	isIE6 = true;
}
	
if (navigator.appVersion.indexOf("Mac") > -1) isMac = true;
if (navigator.appVersion.indexOf("Safari") > -1) isSafari = true;
if (navigator.userAgent.indexOf("Konqueror") > -1) {
	linux = true;
	dhtml = false;
}
if (navigator.userAgent.indexOf("Linux") > -1) {
	linux = true;
}
if (navigator.userAgent.indexOf("Opera") > -1) {
	isOpera = true; 
	noScroll = true;
}

if (navigator.appVersion.charAt(0) < 4) dhtml = false;
else if (document.layers) {
	isNS4 = true;
	noScroll = true;
} else if (document.all) {
	isIE4 = true
	if (navigator.appVersion.indexOf("MSIE 4") > -1) isIE4only = true
	if (navigator.appVersion.indexOf("MSIE 4.5") > -1) {
		isIE45only = true
		noScroll = true
	}
} else if (document.getElementsByTagName("*")) {
	isNS6 = true
	if (navigator.userAgent.indexOf("Netscape6/6") > -1) {
		isNS6only = true
	}
} else dhtml = false;

//********************************************************//

//********************************************************//

var tags = new Array('td'); // only need to change TD size in various sections

function fontSizer(how) 
{	 
	if (how == "+" && initSize >= 1.1) {
		alert("You have reached the maximum recommended text size.");
		return;
	}
	//showProps(document.getElementById("bodyx").style,"bodyx.style")
	//alert(document.getElementsById("bodyx").style.fontSize);
	//return;
	//document.getElementById("mainContent").style.fontSize = ".85em";
	//document.getElementById("mainContent.td").style.fontSize = ".85em";
	//document.body.style.fontSize = "21px";
	//showProps(document.getElementsByTagName("td")[0].style,"td");
	//return;
	//alert("orig: " +initSize)
	if (!document.getElementById) return;
	if (how == "+") {
		//alert("plus")
		//initSize = 14;
		initSize = roundNumber(1*initSize + 1*.1);
	} else {
		//alert("minus")
		initSize = roundNumber(1*initSize - 1*.1);
	}
	//alert("now: " + initSize)
	var divArray = new Array("body");
	
	
	for (var i=0; i<divArray.length; i++) {
		if (document.getElementById(divArray[i]) != null) {
			getBody = document.getElementById(divArray[i]);
			
			document.getElementById(divArray[i]).style.fontSize = initSize + "em";
			
			for (j = 0 ; j < tags.length ; j++ ) 
			{	
				getallTags = getBody.getElementsByTagName(tags[j]);
				for (k = 0 ; k < getallTags.length ; k++) {
					getallTags[k].style.fontSize = initSize + "em";
				//getallTags[k].style.fontSize = (unit=='px') ? pixelArray[size]+unit : emArray[size]+unit;
				}
			}
		
		}
	
	}
	
	var today = new Date();
	var expiry = new Date(today.getTime() + 365 * 2 * 24 * 60 * 60 * 1000);
	setCookie("initSize",initSize,expiry);
} 

//****************************************//

function roundNumber(num) {
	//return num;
	var rlength = 2; // The number of decimal places to round to
	return Math.round(num*Math.pow(10,rlength))/Math.pow(10,rlength);
}

/*********************************************************************************
  dw_cookies.js - cookie functions for www.dyn-web.com
  Recycled from various sources 
**********************************************************************************/

// Modified from Bill Dortch's Cookie Functions (hidaho.com) 
// (found in JavaScript Bible)
function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//****************************************//

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}

//****************************************//

// from Bill Dortch's Cookie Functions (hidaho.com) 
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

//****************************************//

var initSize;
if (getCookie("initSize") != null) {
	initSize = getCookie("initSize")
} else {
	 initSize = .6; 
}
//alert(initSize)
//****************************************//

document.write("<style type='text/css'>body, td, #body {font-size: "+ initSize +"em;}</style>");

if (isMac) {
	//document.write("<style type='text/css'>.subnavFlyoutLink {font-size:1.3em;} .loginInputUsername {width: 89px;} .loginInputPassword {width: 68px;} #subMenu p {font-size : 1em;}</style>");
}
if (isSafari) {
	//document.write("<style type='text/css'>.subnavFlyoutLink {font-size:1.8em;}</style>");
}
