/********************************************************************
	font size functions 
*/

//if (document.all) { 
	var fontsize = 10;
/*} else {
	var fontsize = 11;
}*/
	var fontsizedef = fontsize;


function setFontSize(i) {

	document.body.style.fontSize = i+"px";
	window.status = "Font size set to "+document.body.style.fontSize;
	// NS6 won't properly apply the changes in abs positioned divs unless we do
	// this trickery:
	if (!document.all) { 
		e = document.getElementsByTagName('body')[0];
		e.parentNode.replaceChild(e,e);
	}

	
}

function changeFontSize(i) {

	fontsize = fontsize-(-i);
	if (fontsize < 9) {
		fontsize = 9;
		alert("This is the smallest font size");
		return;
	}
	if (fontsize > 15) {
		fontsize = 12;
		alert("This is the largest font size");
		return;
	}

	setFontSize(fontsize);
	// let's stuff it in a cookie so we can remember it
	var expiration = new Date();
	var exptime = expiration.getTime() + (365 * 24 * 60 * 60 * 1000); //365 days
	expiration.setTime(exptime);
	SetCookie ('fontSize',fontsize,expiration,'/');
}

function defaultFontSize() {
	fontsize = fontsizedef;
	document.body.style.fontSize=fontsize+"px";
}



/**********************************************************************************
Popup Functions
http://www.alistapart.com/articles/popuplinks/
*********************************************************************************/
var w = 410;
var h = 400;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var _POPUP_FEATURES = 'scrollbars=1,location=0,status=1,menubar=1,toolbar=0,resizable=1,dependent=1,width='+w+',height='+h+',top='+wint+',left='+winl;

// MISC CLEANING-AFTER-MICROSOFT STUFF

function isUndefined(v) {
	var undef;
	return v===undef;
}

function popup(url, target, features) {

  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  var theWindow =
    window.open(url, target, features);
  theWindow.focus();
  return theWindow;
}

function link_popup(src, features) {
  return
    raw_popup(src.getAttribute('href'),
    src.getAttribute('target') || '_blank',
    features);
}



//  Cookie Functions -- "Night of the Living Cookie" Version (25-Jul-96)

// "Internal" function to return the decoded value of a cookie
function getCookieVal (offset) {

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

}

//  Function to correct for 2.x Mac date bug.  Call this function to
//  fix a date object prior to passing it to SetCookie.
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 to return the value of the cookie specified by "name".
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 to create or update a cookie.
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 to delete a cookie. (Sets expiration date to start of epoch)
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";
  }

}

