// BCFFC JavaScript

var pageTracker = null;

// onLoad function for all BCFFC pages
function bcffcSetup() {
   setFontSize();
   if (typeof(gatag_setup) == 'function') {
      gatag_setup();
   }
   if (typeof(_gat) == 'object') {
      pageTracker = _gat._getTracker("UA-333730-1");
      pageTracker._setDomainName("none");
      pageTracker._setAllowLinker(true);
      pageTracker._trackPageview();
   }
   if (typeof(bcffcJumpTo) == 'function') {
      bcffcJumpTo();
   }
}

function textCounter(field, countfield, maxlimit) {
   if (field.value.length > maxlimit) {
      // if too long...trim it!
      field.value = field.value.substring(0, maxlimit);
   } else {
      // otherwise, update 'characters left' counter
      countfield.value = maxlimit - field.value.length;
   }
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
// JavaScript Document
// script by Pony Smith :: pony_smith@yahoo.com
// initialize universal variables for cookie scripts
cookie_name = "fontSize";
var index;
var num;
// create array of font sizes .. these percentages are applied to the <body> font-size
// all other font sizes are declared in 'em' and are inherited from the body
var sizes = new Array('68%','72%','76%','84%','92%','100%','108%');

// function to change the size of the text
// called from increase/decrease font size buttons
// takes one argument 'inc' which is either 1 or -1 and advances the pointer in the sizes array
function textSize(inc) {
   // take the original number 'num' which is passed from or declared in the getCookie() script (triggered onLoad)
   add = '(' + num + ') + (' + inc + ')';
   // add the 'num' and 'inc' strings and evaluate them to get an integer
   var arr = eval(add);
   // if the integer is below the array minimum or above its maximum, set 'arr' to the min or max respectively
   if(arr < 0) {
      arr = 0;
   }
   if(arr > 6) {
      arr = 6;
   }
   // redefine 'num' as 'arr'
   // ensures that the function can work again, since it won't refresh and trigger getCookie() with each click
   num = arr;
   // alert("arr = " + arr);
   // retrieve the appropriate number from the array and set the <body> font-size to that percentage
   document.getElementById('body').style.fontSize = sizes[arr];
   // run the setCookie() script to make sure that the current font-size is stored for other pages and future visits
   setFontSizeCookie(arr);
}


// set cookie function .. called from within textSize()
function setFontSizeCookie(arrNum) {
   // this checks to see if the new number matches the old one
   // if so, the function ends .. if not, it sets 'index = -1' which means that
   // 'document.cookie.indexOf(cookie_name)' has a value of -1 .. ie. it doesn't exist.
   if(document.cookie != document.cookie) {
      index = document.cookie.indexOf(cookie_name);
   }
   else {
      index = -1;
   }
   // if the cookie does not match the new number called from textSize(),
   // overwrite the cookie with the new number
   if(index == -1) {
      document.cookie = cookie_name + "=" + arrNum + "; path=/"
   }
}


// retrieve cookie function .. called in <body onLoad>
function setFontSize() {
   var splits = document.cookie.split(';');
   // run through the various cookie entries to find the font size cookie
   for(i=0; i<splits.length; i++) {
      index = document.cookie.indexOf(cookie_name);
      // check to see if cookie exists .. as long as 'index' does not equal -1, the cookie exists.
      if (index != -1) {
         // retrieve only the number
         num = splits[i].substring(splits[i].indexOf('=')+1, splits[i].length);
         // pull the corresponding value from the sizes array and set the <body> font-size to that percentage
         document.getElementById('body').style.fontSize = sizes[num];
      } else {
         // if there is no cookie present, set '2' as a default font size
         num = '2';
//         document.getElementById('body').style.fontSize = sizes[num];
      }
   }
}
