

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" : "");
}


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;
}


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 ofa_changefont = {
  sizeUnit:    "px",
  defaultSize: 11,
  maxSize:     24,
  minSize:     9,
  height:	   1,

  adjustList: [],
  set: function (sel,dflt,mn,mx) {
    this.adjustList[this.adjustList.length] = arguments;
  },

  init: function() {
    var size, sizerEl, i;
    if ( !document.getElementById || !document.getElementsByTagName ) return;
    size = window.location.search? window.location.search.slice(1): getCookie("fontSize");
    size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
    
    if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
    this.curSize = this.defaultSize;  
    sizerEl = document.getElementById('sizer');
    if (sizerEl) sizerEl.style.display = "block";
    
    for (i=0; this.adjustList[i]; i++) 
      this.adjustList[i][4] = this.adjustList[i][1] / this.defaultSize;
    if ( size != this.defaultSize ) this.adjust( size - this.defaultSize );
  },

  adjust: function(n) {
    var alist, size, list, i, j;
    
    if ( n > 0 && ofa_changefont.maxSize ) {
      if ( ofa_changefont.curSize + n > ofa_changefont.maxSize )
          n = ofa_changefont.maxSize - ofa_changefont.curSize;
    } else if ( n < 0 && ofa_changefont.minSize ) {
        if ( ofa_changefont.curSize + n < ofa_changefont.minSize )
          n = ofa_changefont.minSize - ofa_changefont.curSize;
    }
    if ( n == 0 ) return false;
    ofa_changefont.curSize += n;
    
    alist = ofa_changefont.adjustList;
    for (i=0; alist[i]; i++) {
      size = ofa_changefont.curSize * alist[i][4]; 
      size = Math.max(alist[i][2], size); size = Math.min(alist[i][3], size);
      list = ofa_getElementsBySelector( alist[i][0] );
      for (j=0; list[j]; j++) { list[j].style.fontSize = size + ofa_changefont.sizeUnit; list[j].style.lineHeight = this.height + .20;

	  }
    }
    setCookie( "fontSize", ofa_changefont.curSize, 180, "/" );
  },

  
  reset: function() {
    var alist = ofa_changefont.adjustList, list, i, j;
    for (i=0; alist[i]; i++) {
      list = ofa_getElementsBySelector( alist[i][0] );
      for (j=0; list[j]; j++) { list[j].style.fontSize = alist[i][1] + ofa_changefont.sizeUnit; }
    }
    ofa_changefont.curSize = ofa_changefont.defaultSize;
    deleteCookie("fontSize", "/");
  }

}


function ofa_getElementsBySelector(selector) {
 	var nodeList = [document], tokens, bits, list, els, i, j, k;
  if (!document.getElementsByTagName) return [];
  tokens = selector.split(' ');
  for (i=0; tokens[i]; i++) {
    if ( tokens[i].indexOf('#') != -1 ) {  
      bits = tokens[i].split('#'); 
      nodeList = [ document.getElementById( bits[1] ) ];
      continue; 
    } else if ( tokens[i].indexOf('.') != -1 ) {  
      bits = tokens[i].split('.');
      for (j=0; nodeList[j]; j++) 
        list = ofa_getElementsByClassName( bits[1], bits[0], nodeList[j]);
      nodeList = [];
      for (j=0; list[j]; j++) { nodeList.push(list[j]); }
      continue; 
    } else {  
      els = []; 
      for (j = 0; nodeList[j]; j++) {
        list = nodeList[j].getElementsByTagName(tokens[i]);
        for (k = 0; list[k]; k++) { els.push(list[k]); }
      }
      nodeList = els;
    }
  }
  return nodeList;
}

function ofa_getElementsByClassName(sClass, sTag, oCont) {
  var result = [], list, i;
  oCont = oCont? oCont: document;
  if ( document.getElementsByTagName ) {
    if ( !sTag || sTag == "*" ) {
      list = oCont.all? oCont.all: oCont.getElementsByTagName("*");
    } else list = oCont.getElementsByTagName(sTag);
    
    for (i=0; list[i]; i++) 
      if ( list[i].className.match( new RegExp("\\b" + sClass + "\\b", "i") ) ) result.push( list[i] );
  }
  return result;
}

if (!Array.prototype.push) {  
	Array.prototype.push =  function() {
		for (var i=0; arguments[i]; i++) this[this.length] = arguments[i];
		return this.length;
	}
}  

